From d1cb3ecf327066137fb6245b13030cde60241dd6 Mon Sep 17 00:00:00 2001 From: Russell King Date: Tue, 26 Nov 2013 19:44:18 +0000 Subject: ARM: plat-versatile: LEDs initialise to off state There really is no excuse to turn on all 8 LEDs at boot time, such that on the Versatile PB/926 we end up with 6 LEDs on continuously and forever. We're not a christmas decoration! Signed-off-by: Russell King Signed-off-by: Linus Walleij --- arch/arm/plat-versatile/leds.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/arm/plat-versatile/leds.c b/arch/arm/plat-versatile/leds.c index d2490d00b46c..2018f307f32e 100644 --- a/arch/arm/plat-versatile/leds.c +++ b/arch/arm/plat-versatile/leds.c @@ -72,8 +72,8 @@ static int __init versatile_leds_init(void) { int i; - /* All ON */ - writel(0xff, LEDREG); + /* All off */ + writel(0, LEDREG); for (i = 0; i < ARRAY_SIZE(versatile_leds); i++) { struct versatile_led *led; -- cgit v1.2.3 From e4ecf2bda239ddef5f4edd0e05d48bfdf88a475d Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Thu, 27 Feb 2014 14:29:22 +0100 Subject: ARM: plat-versatile: convert LEDs to platform device The LEDs were initialized unconditionally with an fs_initcall() which doesn't play well with multiplatform. Convert the driver to a platform device and convert all boards with these LEDs to register a platform device and pass the register as a resource instead. Tested successfully on the Versatile/AB and RealView PB1176. Cc: Bryan Wu Cc: Richard Purdie Cc: Russell King Cc: Pawel Moll Signed-off-by: Linus Walleij --- arch/arm/mach-realview/core.c | 15 ++++++++++ arch/arm/mach-realview/core.h | 1 + arch/arm/mach-realview/realview_eb.c | 1 + arch/arm/mach-realview/realview_pb1176.c | 1 + arch/arm/mach-realview/realview_pb11mp.c | 1 + arch/arm/mach-realview/realview_pba8.c | 1 + arch/arm/mach-realview/realview_pbx.c | 1 + arch/arm/mach-versatile/core.c | 16 +++++++++++ arch/arm/plat-versatile/leds.c | 49 ++++++++++++++++++-------------- 9 files changed, 65 insertions(+), 21 deletions(-) diff --git a/arch/arm/mach-realview/core.c b/arch/arm/mach-realview/core.c index 1d5ee5c9a1dc..960b8dd78c44 100644 --- a/arch/arm/mach-realview/core.c +++ b/arch/arm/mach-realview/core.c @@ -148,6 +148,21 @@ struct platform_device realview_cf_device = { }, }; +static struct resource realview_leds_resources[] = { + { + .start = REALVIEW_SYS_BASE + REALVIEW_SYS_LED_OFFSET, + .end = REALVIEW_SYS_BASE + REALVIEW_SYS_LED_OFFSET + 4, + .flags = IORESOURCE_MEM, + }, +}; + +struct platform_device realview_leds_device = { + .name = "versatile-leds", + .id = -1, + .num_resources = ARRAY_SIZE(realview_leds_resources), + .resource = realview_leds_resources, +}; + static struct resource realview_i2c_resource = { .start = REALVIEW_I2C_BASE, .end = REALVIEW_I2C_BASE + SZ_4K - 1, diff --git a/arch/arm/mach-realview/core.h b/arch/arm/mach-realview/core.h index 602ca5ec52c5..13dc830ef469 100644 --- a/arch/arm/mach-realview/core.h +++ b/arch/arm/mach-realview/core.h @@ -37,6 +37,7 @@ struct machine_desc; extern struct platform_device realview_flash_device; extern struct platform_device realview_cf_device; +extern struct platform_device realview_leds_device; extern struct platform_device realview_i2c_device; extern struct mmci_platform_data realview_mmc0_plat_data; extern struct mmci_platform_data realview_mmc1_plat_data; diff --git a/arch/arm/mach-realview/realview_eb.c b/arch/arm/mach-realview/realview_eb.c index c85ddb2a0ad0..6bb070e80128 100644 --- a/arch/arm/mach-realview/realview_eb.c +++ b/arch/arm/mach-realview/realview_eb.c @@ -452,6 +452,7 @@ static void __init realview_eb_init(void) realview_flash_register(&realview_eb_flash_resource, 1); platform_device_register(&realview_i2c_device); platform_device_register(&char_lcd_device); + platform_device_register(&realview_leds_device); eth_device_register(); realview_usb_register(realview_eb_isp1761_resources); diff --git a/arch/arm/mach-realview/realview_pb1176.c b/arch/arm/mach-realview/realview_pb1176.c index c5eade76461b..173f2c15de49 100644 --- a/arch/arm/mach-realview/realview_pb1176.c +++ b/arch/arm/mach-realview/realview_pb1176.c @@ -367,6 +367,7 @@ static void __init realview_pb1176_init(void) realview_usb_register(realview_pb1176_isp1761_resources); platform_device_register(&pmu_device); platform_device_register(&char_lcd_device); + platform_device_register(&realview_leds_device); for (i = 0; i < ARRAY_SIZE(amba_devs); i++) { struct amba_device *d = amba_devs[i]; diff --git a/arch/arm/mach-realview/realview_pb11mp.c b/arch/arm/mach-realview/realview_pb11mp.c index f4b0962578fe..bde7e6b1fd44 100644 --- a/arch/arm/mach-realview/realview_pb11mp.c +++ b/arch/arm/mach-realview/realview_pb11mp.c @@ -347,6 +347,7 @@ static void __init realview_pb11mp_init(void) realview_eth_register(NULL, realview_pb11mp_smsc911x_resources); platform_device_register(&realview_i2c_device); platform_device_register(&realview_cf_device); + platform_device_register(&realview_leds_device); realview_usb_register(realview_pb11mp_isp1761_resources); platform_device_register(&pmu_device); diff --git a/arch/arm/mach-realview/realview_pba8.c b/arch/arm/mach-realview/realview_pba8.c index 10a3e1d76891..4e57a8599265 100644 --- a/arch/arm/mach-realview/realview_pba8.c +++ b/arch/arm/mach-realview/realview_pba8.c @@ -289,6 +289,7 @@ static void __init realview_pba8_init(void) realview_eth_register(NULL, realview_pba8_smsc911x_resources); platform_device_register(&realview_i2c_device); platform_device_register(&realview_cf_device); + platform_device_register(&realview_leds_device); realview_usb_register(realview_pba8_isp1761_resources); platform_device_register(&pmu_device); diff --git a/arch/arm/mach-realview/realview_pbx.c b/arch/arm/mach-realview/realview_pbx.c index 9d75493e3f0c..72c96caebefa 100644 --- a/arch/arm/mach-realview/realview_pbx.c +++ b/arch/arm/mach-realview/realview_pbx.c @@ -385,6 +385,7 @@ static void __init realview_pbx_init(void) realview_eth_register(NULL, realview_pbx_smsc911x_resources); platform_device_register(&realview_i2c_device); platform_device_register(&realview_cf_device); + platform_device_register(&realview_leds_device); realview_usb_register(realview_pbx_isp1761_resources); for (i = 0; i < ARRAY_SIZE(amba_devs); i++) { diff --git a/arch/arm/mach-versatile/core.c b/arch/arm/mach-versatile/core.c index a335126ae18f..b31878570a00 100644 --- a/arch/arm/mach-versatile/core.c +++ b/arch/arm/mach-versatile/core.c @@ -310,6 +310,21 @@ static struct platform_device char_lcd_device = { .resource = char_lcd_resources, }; +static struct resource leds_resources[] = { + { + .start = VERSATILE_SYS_BASE + VERSATILE_SYS_LED_OFFSET, + .end = VERSATILE_SYS_BASE + VERSATILE_SYS_LED_OFFSET + 4, + .flags = IORESOURCE_MEM, + }, +}; + +static struct platform_device leds_device = { + .name = "versatile-leds", + .id = -1, + .num_resources = ARRAY_SIZE(leds_resources), + .resource = leds_resources, +}; + /* * Clock handling */ @@ -795,6 +810,7 @@ void __init versatile_init(void) platform_device_register(&versatile_i2c_device); platform_device_register(&smc91x_device); platform_device_register(&char_lcd_device); + platform_device_register(&leds_device); for (i = 0; i < ARRAY_SIZE(amba_devs); i++) { struct amba_device *d = amba_devs[i]; diff --git a/arch/arm/plat-versatile/leds.c b/arch/arm/plat-versatile/leds.c index 2018f307f32e..80553022d661 100644 --- a/arch/arm/plat-versatile/leds.c +++ b/arch/arm/plat-versatile/leds.c @@ -7,22 +7,14 @@ */ #include #include +#include #include #include #include - -#include -#include - -#ifdef VERSATILE_SYS_BASE -#define LEDREG (__io_address(VERSATILE_SYS_BASE) + VERSATILE_SYS_LED_OFFSET) -#endif - -#ifdef REALVIEW_SYS_BASE -#define LEDREG (__io_address(REALVIEW_SYS_BASE) + REALVIEW_SYS_LED_OFFSET) -#endif +#include struct versatile_led { + void __iomem *base; struct led_classdev cdev; u8 mask; }; @@ -50,30 +42,37 @@ static void versatile_led_set(struct led_classdev *cdev, { struct versatile_led *led = container_of(cdev, struct versatile_led, cdev); - u32 reg = readl(LEDREG); + u32 reg = readl(led->base); if (b != LED_OFF) reg |= led->mask; else reg &= ~led->mask; - writel(reg, LEDREG); + writel(reg, led->base); } static enum led_brightness versatile_led_get(struct led_classdev *cdev) { struct versatile_led *led = container_of(cdev, struct versatile_led, cdev); - u32 reg = readl(LEDREG); + u32 reg = readl(led->base); return (reg & led->mask) ? LED_FULL : LED_OFF; } -static int __init versatile_leds_init(void) +static int versatile_leds_probe(struct platform_device *dev) { int i; + struct resource *res; + void __iomem *base; + + res = platform_get_resource(dev, IORESOURCE_MEM, 0); + base = devm_ioremap_resource(&dev->dev, res); + if (IS_ERR(base)) + return PTR_ERR(base); /* All off */ - writel(0, LEDREG); + writel(0, base); for (i = 0; i < ARRAY_SIZE(versatile_leds); i++) { struct versatile_led *led; @@ -81,6 +80,7 @@ static int __init versatile_leds_init(void) if (!led) break; + led->base = base; led->cdev.name = versatile_leds[i].name; led->cdev.brightness_set = versatile_led_set; led->cdev.brightness_get = versatile_led_get; @@ -96,8 +96,15 @@ static int __init versatile_leds_init(void) return 0; } -/* - * Since we may have triggers on any subsystem, defer registration - * until after subsystem_init. - */ -fs_initcall(versatile_leds_init); +static struct platform_driver versatile_leds_driver = { + .driver = { + .name = "versatile-leds", + }, + .probe = versatile_leds_probe, +}; + +module_platform_driver(versatile_leds_driver); + +MODULE_AUTHOR("Linus Walleij "); +MODULE_DESCRIPTION("ARM Versatile LED driver"); +MODULE_LICENSE("GPL v2"); -- cgit v1.2.3 From 598db5816664472e1649ef94b0ba4c5cc1b9f3b4 Mon Sep 17 00:00:00 2001 From: Kees Cook Date: Thu, 13 Mar 2014 16:46:00 +0000 Subject: iio: force snprintf for PAGE_SIZE bufs This is a tiny preventative measure to make sure we can't write beyond PAGE_SIZE on the buffers being used in sysfs for iio. There is currently no way for this to happen, but the change makes this code more robust for the future. Signed-off-by: Kees Cook Signed-off-by: Jonathan Cameron --- drivers/iio/industrialio-core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c index ede16aec20fb..1375921d8261 100644 --- a/drivers/iio/industrialio-core.c +++ b/drivers/iio/industrialio-core.c @@ -340,7 +340,7 @@ ssize_t iio_enum_read(struct iio_dev *indio_dev, else if (i >= e->num_items) return -EINVAL; - return sprintf(buf, "%s\n", e->items[i]); + return snprintf(buf, PAGE_SIZE, "%s\n", e->items[i]); } EXPORT_SYMBOL_GPL(iio_enum_read); @@ -820,7 +820,7 @@ static ssize_t iio_show_dev_name(struct device *dev, char *buf) { struct iio_dev *indio_dev = dev_to_iio_dev(dev); - return sprintf(buf, "%s\n", indio_dev->name); + return snprintf(buf, PAGE_SIZE, "%s\n", indio_dev->name); } static DEVICE_ATTR(name, S_IRUGO, iio_show_dev_name, NULL); -- cgit v1.2.3 From 43c7ecb1fa6b45633747773f055b8deb1c3e52be Mon Sep 17 00:00:00 2001 From: Matt Ranostay Date: Wed, 3 Dec 2014 12:53:00 +0000 Subject: iio:as3935: Add DT binding docs for AS3935 driver Document compatible string, required and optional DT properties for AS3935 chipset driver. Signed-off-by: Matt Ranostay Acked-by: Rob Herring Signed-off-by: Jonathan Cameron --- .../devicetree/bindings/iio/proximity/as3935.txt | 28 ++++++++++++++++++++++ .../devicetree/bindings/vendor-prefixes.txt | 1 + 2 files changed, 29 insertions(+) create mode 100644 Documentation/devicetree/bindings/iio/proximity/as3935.txt diff --git a/Documentation/devicetree/bindings/iio/proximity/as3935.txt b/Documentation/devicetree/bindings/iio/proximity/as3935.txt new file mode 100644 index 000000000000..ae23dd8da736 --- /dev/null +++ b/Documentation/devicetree/bindings/iio/proximity/as3935.txt @@ -0,0 +1,28 @@ +Austrian Microsystems AS3935 Franklin lightning sensor device driver + +Required properties: + - compatible: must be "ams,as3935" + - reg: SPI chip select number for the device + - spi-cpha: SPI Mode 1. Refer to spi/spi-bus.txt for generic SPI + slave node bindings. + - interrupt-parent : should be the phandle for the interrupt controller + - 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. + +Example: + +as3935@0 { + compatible = "ams,as3935"; + reg = <0>; + spi-cpha; + interrupt-parent = <&gpio1>; + interrupts = <16 1>; + ams,tuning-capacitor-pf = <80>; +}; diff --git a/Documentation/devicetree/bindings/vendor-prefixes.txt b/Documentation/devicetree/bindings/vendor-prefixes.txt index 40ce2df0e0e9..2025cee4b6b2 100644 --- a/Documentation/devicetree/bindings/vendor-prefixes.txt +++ b/Documentation/devicetree/bindings/vendor-prefixes.txt @@ -11,6 +11,7 @@ ak Asahi Kasei Corp. allwinner Allwinner Technology Co., Ltd. altr Altera Corp. amcc Applied Micro Circuits Corporation (APM, formally AMCC) +ams AMS AG amstaos AMS-Taos Inc. apm Applied Micro Circuits Corporation (APM) arm ARM Ltd. -- cgit v1.2.3 From 24ddb0e4bba4e98d3f3a783846789520e796b164 Mon Sep 17 00:00:00 2001 From: Matt Ranostay Date: Wed, 3 Dec 2014 12:53:00 +0000 Subject: iio: Add AS3935 lightning sensor support AS3935 chipset can detect lightning strikes and reports those back as events and the estimated distance to the storm. Signed-off-by: Matt Ranostay Reviewed-by: Marek Vasut Signed-off-by: Jonathan Cameron --- .../ABI/testing/sysfs-bus-iio-proximity-as3935 | 16 + drivers/iio/Kconfig | 1 + drivers/iio/Makefile | 1 + drivers/iio/proximity/Kconfig | 19 + drivers/iio/proximity/Makefile | 6 + drivers/iio/proximity/as3935.c | 456 +++++++++++++++++++++ 6 files changed, 499 insertions(+) create mode 100644 Documentation/ABI/testing/sysfs-bus-iio-proximity-as3935 create mode 100644 drivers/iio/proximity/Kconfig create mode 100644 drivers/iio/proximity/Makefile create mode 100644 drivers/iio/proximity/as3935.c diff --git a/Documentation/ABI/testing/sysfs-bus-iio-proximity-as3935 b/Documentation/ABI/testing/sysfs-bus-iio-proximity-as3935 new file mode 100644 index 000000000000..6708c5e264aa --- /dev/null +++ b/Documentation/ABI/testing/sysfs-bus-iio-proximity-as3935 @@ -0,0 +1,16 @@ +What /sys/bus/iio/devices/iio:deviceX/in_proximity_raw +Date: March 2014 +KernelVersion: 3.15 +Contact: Matt Ranostay +Description: + Get the current distance in meters of storm (1km steps) + 1000-40000 = distance in meters + +What /sys/bus/iio/devices/iio:deviceX/sensor_sensitivity +Date: March 2014 +KernelVersion: 3.15 +Contact: Matt Ranostay +Description: + Show or set the gain boost of the amp, from 0-31 range. + 18 = indoors (default) + 14 = outdoors diff --git a/drivers/iio/Kconfig b/drivers/iio/Kconfig index 5dd0e120a504..743485e4d6f8 100644 --- a/drivers/iio/Kconfig +++ b/drivers/iio/Kconfig @@ -74,6 +74,7 @@ if IIO_TRIGGER source "drivers/iio/trigger/Kconfig" endif #IIO_TRIGGER source "drivers/iio/pressure/Kconfig" +source "drivers/iio/proximity/Kconfig" source "drivers/iio/temperature/Kconfig" endif # IIO diff --git a/drivers/iio/Makefile b/drivers/iio/Makefile index 887d39090d75..698afc2d17ce 100644 --- a/drivers/iio/Makefile +++ b/drivers/iio/Makefile @@ -24,5 +24,6 @@ obj-y += light/ obj-y += magnetometer/ obj-y += orientation/ obj-y += pressure/ +obj-y += proximity/ obj-y += temperature/ obj-y += trigger/ diff --git a/drivers/iio/proximity/Kconfig b/drivers/iio/proximity/Kconfig new file mode 100644 index 000000000000..0c8cdf58f6a1 --- /dev/null +++ b/drivers/iio/proximity/Kconfig @@ -0,0 +1,19 @@ +# +# Proximity sensors +# + +menu "Lightning sensors" + +config AS3935 + tristate "AS3935 Franklin lightning sensor" + select IIO_BUFFER + select IIO_TRIGGERED_BUFFER + depends on SPI + help + Say Y here to build SPI interface support for the Austrian + Microsystems AS3935 lightning detection sensor. + + To compile this driver as a module, choose M here: the + module will be called as3935 + +endmenu diff --git a/drivers/iio/proximity/Makefile b/drivers/iio/proximity/Makefile new file mode 100644 index 000000000000..743adee1c8bf --- /dev/null +++ b/drivers/iio/proximity/Makefile @@ -0,0 +1,6 @@ +# +# Makefile for IIO proximity sensors +# + +# When adding new entries keep the list in alphabetical order +obj-$(CONFIG_AS3935) += as3935.o diff --git a/drivers/iio/proximity/as3935.c b/drivers/iio/proximity/as3935.c new file mode 100644 index 000000000000..bf677bfe8eb2 --- /dev/null +++ b/drivers/iio/proximity/as3935.c @@ -0,0 +1,456 @@ +/* + * as3935.c - Support for AS3935 Franklin lightning sensor + * + * Copyright (C) 2014 Matt Ranostay + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +#define AS3935_AFE_GAIN 0x00 +#define AS3935_AFE_MASK 0x3F +#define AS3935_AFE_GAIN_MAX 0x1F +#define AS3935_AFE_PWR_BIT BIT(0) + +#define AS3935_INT 0x03 +#define AS3935_INT_MASK 0x07 +#define AS3935_EVENT_INT BIT(3) +#define AS3935_NOISE_INT BIT(1) + +#define AS3935_DATA 0x07 +#define AS3935_DATA_MASK 0x3F + +#define AS3935_TUNE_CAP 0x08 +#define AS3935_CALIBRATE 0x3D + +#define AS3935_WRITE_DATA BIT(15) +#define AS3935_READ_DATA BIT(14) +#define AS3935_ADDRESS(x) ((x) << 8) + +#define MAX_PF_CAP 120 +#define TUNE_CAP_DIV 8 + +struct as3935_state { + struct spi_device *spi; + struct iio_trigger *trig; + struct mutex lock; + struct delayed_work work; + + u32 tune_cap; + u8 buf[2] ____cacheline_aligned; +}; + +static const struct iio_chan_spec as3935_channels[] = { + { + .type = IIO_PROXIMITY, + .info_mask_separate = + BIT(IIO_CHAN_INFO_RAW) | + BIT(IIO_CHAN_INFO_PROCESSED), + .scan_index = 0, + .scan_type = { + .sign = 'u', + .realbits = 6, + .storagebits = 8, + }, + }, + IIO_CHAN_SOFT_TIMESTAMP(1), +}; + +static int as3935_read(struct as3935_state *st, unsigned int reg, int *val) +{ + u8 cmd; + int ret; + + cmd = (AS3935_READ_DATA | AS3935_ADDRESS(reg)) >> 8; + ret = spi_w8r8(st->spi, cmd); + if (ret < 0) + return ret; + *val = ret; + + return 0; +}; + +static int as3935_write(struct as3935_state *st, + unsigned int reg, + unsigned int val) +{ + u8 *buf = st->buf; + + buf[0] = (AS3935_WRITE_DATA | AS3935_ADDRESS(reg)) >> 8; + buf[1] = val; + + return spi_write(st->spi, buf, 2); +}; + +static ssize_t as3935_sensor_sensitivity_show(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + struct as3935_state *st = iio_priv(dev_to_iio_dev(dev)); + int val, ret; + + ret = as3935_read(st, AS3935_AFE_GAIN, &val); + if (ret) + return ret; + val = (val & AS3935_AFE_MASK) >> 1; + + return sprintf(buf, "%d\n", val); +}; + +static ssize_t as3935_sensor_sensitivity_store(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t len) +{ + struct as3935_state *st = iio_priv(dev_to_iio_dev(dev)); + unsigned long val; + int ret; + + ret = kstrtoul((const char *) buf, 10, &val); + if (ret) + return -EINVAL; + + if (val > AS3935_AFE_GAIN_MAX) + return -EINVAL; + + as3935_write(st, AS3935_AFE_GAIN, val << 1); + + return len; +}; + +static IIO_DEVICE_ATTR(sensor_sensitivity, S_IRUGO | S_IWUSR, + as3935_sensor_sensitivity_show, as3935_sensor_sensitivity_store, 0); + + +static struct attribute *as3935_attributes[] = { + &iio_dev_attr_sensor_sensitivity.dev_attr.attr, + NULL, +}; + +static struct attribute_group as3935_attribute_group = { + .attrs = as3935_attributes, +}; + +static int as3935_read_raw(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, + int *val, + int *val2, + long m) +{ + struct as3935_state *st = iio_priv(indio_dev); + int ret; + + + switch (m) { + case IIO_CHAN_INFO_PROCESSED: + case IIO_CHAN_INFO_RAW: + *val2 = 0; + ret = as3935_read(st, AS3935_DATA, val); + if (ret) + return ret; + + if (m == IIO_CHAN_INFO_RAW) + return IIO_VAL_INT; + + /* storm out of range */ + if (*val == AS3935_DATA_MASK) + return -EINVAL; + *val *= 1000; + break; + default: + return -EINVAL; + } + + return IIO_VAL_INT; +} + +static const struct iio_info as3935_info = { + .driver_module = THIS_MODULE, + .attrs = &as3935_attribute_group, + .read_raw = &as3935_read_raw, +}; + +static irqreturn_t as3935_trigger_handler(int irq, void *private) +{ + struct iio_poll_func *pf = private; + struct iio_dev *indio_dev = pf->indio_dev; + struct as3935_state *st = iio_priv(indio_dev); + int val, ret; + + ret = as3935_read(st, AS3935_DATA, &val); + if (ret) + goto err_read; + val &= AS3935_DATA_MASK; + val *= 1000; + + iio_push_to_buffers_with_timestamp(indio_dev, &val, pf->timestamp); +err_read: + iio_trigger_notify_done(indio_dev->trig); + + return IRQ_HANDLED; +}; + +static const struct iio_trigger_ops iio_interrupt_trigger_ops = { + .owner = THIS_MODULE, +}; + +static void as3935_event_work(struct work_struct *work) +{ + struct as3935_state *st; + int val; + + st = container_of(work, struct as3935_state, work.work); + + as3935_read(st, AS3935_INT, &val); + val &= AS3935_INT_MASK; + + switch (val) { + case AS3935_EVENT_INT: + iio_trigger_poll(st->trig, iio_get_time_ns()); + break; + case AS3935_NOISE_INT: + dev_warn(&st->spi->dev, "noise level is too high"); + break; + } +}; + +static irqreturn_t as3935_interrupt_handler(int irq, void *private) +{ + struct iio_dev *indio_dev = private; + struct as3935_state *st = iio_priv(indio_dev); + + /* + * Delay work for >2 milliseconds after an interrupt to allow + * estimated distance to recalculated. + */ + + schedule_delayed_work(&st->work, msecs_to_jiffies(3)); + + return IRQ_HANDLED; +} + +static void calibrate_as3935(struct as3935_state *st) +{ + mutex_lock(&st->lock); + + /* mask disturber interrupt bit */ + as3935_write(st, AS3935_INT, BIT(5)); + + as3935_write(st, AS3935_CALIBRATE, 0x96); + as3935_write(st, AS3935_TUNE_CAP, + BIT(5) | (st->tune_cap / TUNE_CAP_DIV)); + + mdelay(2); + as3935_write(st, AS3935_TUNE_CAP, (st->tune_cap / TUNE_CAP_DIV)); + + mutex_unlock(&st->lock); +} + +#ifdef CONFIG_PM_SLEEP +static int as3935_suspend(struct spi_device *spi, pm_message_t msg) +{ + struct iio_dev *indio_dev = spi_get_drvdata(spi); + struct as3935_state *st = iio_priv(indio_dev); + int val, ret; + + mutex_lock(&st->lock); + ret = as3935_read(st, AS3935_AFE_GAIN, &val); + if (ret) + goto err_suspend; + val |= AS3935_AFE_PWR_BIT; + + ret = as3935_write(st, AS3935_AFE_GAIN, val); + +err_suspend: + mutex_unlock(&st->lock); + + return ret; +} + +static int as3935_resume(struct spi_device *spi) +{ + struct iio_dev *indio_dev = spi_get_drvdata(spi); + struct as3935_state *st = iio_priv(indio_dev); + int val, ret; + + mutex_lock(&st->lock); + ret = as3935_read(st, AS3935_AFE_GAIN, &val); + if (ret) + goto err_resume; + val &= ~AS3935_AFE_PWR_BIT; + ret = as3935_write(st, AS3935_AFE_GAIN, val); + +err_resume: + mutex_unlock(&st->lock); + + return ret; +} +#else +#define as3935_suspend NULL +#define as3935_resume NULL +#endif + +static int as3935_probe(struct spi_device *spi) +{ + struct iio_dev *indio_dev; + struct iio_trigger *trig; + struct as3935_state *st; + struct device_node *np = spi->dev.of_node; + int ret; + + /* Be sure lightning event interrupt is specified */ + if (!spi->irq) { + dev_err(&spi->dev, "unable to get event interrupt\n"); + return -EINVAL; + } + + indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(st)); + if (!indio_dev) + return -ENOMEM; + + st = iio_priv(indio_dev); + st->spi = spi; + st->tune_cap = 0; + + spi_set_drvdata(spi, indio_dev); + mutex_init(&st->lock); + INIT_DELAYED_WORK(&st->work, as3935_event_work); + + ret = of_property_read_u32(np, + "ams,tuning-capacitor-pf", &st->tune_cap); + if (ret) { + st->tune_cap = 0; + dev_warn(&spi->dev, + "no tuning-capacitor-pf set, defaulting to %d", + st->tune_cap); + } + + if (st->tune_cap > MAX_PF_CAP) { + dev_err(&spi->dev, + "wrong tuning-capacitor-pf setting of %d\n", + st->tune_cap); + return -EINVAL; + } + + indio_dev->dev.parent = &spi->dev; + indio_dev->name = spi_get_device_id(spi)->name; + indio_dev->channels = as3935_channels; + indio_dev->num_channels = ARRAY_SIZE(as3935_channels); + indio_dev->modes = INDIO_DIRECT_MODE; + indio_dev->info = &as3935_info; + + trig = devm_iio_trigger_alloc(&spi->dev, "%s-dev%d", + indio_dev->name, indio_dev->id); + + if (!trig) + return -ENOMEM; + + st->trig = trig; + trig->dev.parent = indio_dev->dev.parent; + iio_trigger_set_drvdata(trig, indio_dev); + trig->ops = &iio_interrupt_trigger_ops; + + ret = iio_trigger_register(trig); + if (ret) { + dev_err(&spi->dev, "failed to register trigger\n"); + return ret; + } + + ret = iio_triggered_buffer_setup(indio_dev, NULL, + &as3935_trigger_handler, NULL); + + if (ret) { + dev_err(&spi->dev, "cannot setup iio trigger\n"); + goto unregister_trigger; + } + + calibrate_as3935(st); + + ret = devm_request_irq(&spi->dev, spi->irq, + &as3935_interrupt_handler, + IRQF_TRIGGER_RISING, + dev_name(&spi->dev), + indio_dev); + + if (ret) { + dev_err(&spi->dev, "unable to request irq\n"); + goto unregister_buffer; + } + + ret = iio_device_register(indio_dev); + if (ret < 0) { + dev_err(&spi->dev, "unable to register device\n"); + goto unregister_buffer; + } + return 0; + +unregister_buffer: + iio_triggered_buffer_cleanup(indio_dev); + +unregister_trigger: + iio_trigger_unregister(st->trig); + + return ret; +}; + +static int as3935_remove(struct spi_device *spi) +{ + struct iio_dev *indio_dev = spi_get_drvdata(spi); + struct as3935_state *st = iio_priv(indio_dev); + + iio_device_unregister(indio_dev); + iio_triggered_buffer_cleanup(indio_dev); + iio_trigger_unregister(st->trig); + + return 0; +}; + +static const struct spi_device_id as3935_id[] = { + {"as3935", 0}, + {}, +}; +MODULE_DEVICE_TABLE(spi, as3935_id); + +static struct spi_driver as3935_driver = { + .driver = { + .name = "as3935", + .owner = THIS_MODULE, + }, + .probe = as3935_probe, + .remove = as3935_remove, + .id_table = as3935_id, + .suspend = as3935_suspend, + .resume = as3935_resume, +}; +module_spi_driver(as3935_driver); + +MODULE_AUTHOR("Matt Ranostay "); +MODULE_DESCRIPTION("AS3935 lightning sensor"); +MODULE_LICENSE("GPL"); +MODULE_ALIAS("spi:as3935"); -- cgit v1.2.3 From c0a6b7ee9498269e4bf9a7e6676f2f45edca2f1a Mon Sep 17 00:00:00 2001 From: Sebastian Reichel Date: Fri, 3 Oct 2014 17:25:00 +0100 Subject: iio: documentation: Add ABI documentation for *_mean_raw Add ABI documentation for in_*_mean_raw files, which are already supported and used in the kernel for some time. Signed-off-by: Sebastian Reichel Signed-off-by: Jonathan Cameron --- Documentation/ABI/testing/sysfs-bus-iio | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Documentation/ABI/testing/sysfs-bus-iio b/Documentation/ABI/testing/sysfs-bus-iio index 6e02c5029152..58ba33300305 100644 --- a/Documentation/ABI/testing/sysfs-bus-iio +++ b/Documentation/ABI/testing/sysfs-bus-iio @@ -210,6 +210,14 @@ Contact: linux-iio@vger.kernel.org Description: Scaled humidity measurement in milli percent. +What: /sys/bus/iio/devices/iio:deviceX/in_X_mean_raw +KernelVersion: 3.5 +Contact: linux-iio@vger.kernel.org +Description: + Averaged raw measurement from channel X. The number of values + used for averaging is device specific. The converting rules for + normal raw values also applies to the averaged raw values. + What: /sys/bus/iio/devices/iio:deviceX/in_accel_offset What: /sys/bus/iio/devices/iio:deviceX/in_accel_x_offset What: /sys/bus/iio/devices/iio:deviceX/in_accel_y_offset -- cgit v1.2.3 From 476d4af22cec8a9ebc90137712e5ab7070b7379d Mon Sep 17 00:00:00 2001 From: Sebastian Reichel Date: Fri, 3 Oct 2014 17:25:00 +0100 Subject: iio: inkern: add iio_read_channel_average_raw Add iio_read_channel_average_raw to support reading averaged raw values in consumer drivers. Signed-off-by: Sebastian Reichel Signed-off-by: Jonathan Cameron --- drivers/iio/inkern.c | 18 ++++++++++++++++++ include/linux/iio/consumer.h | 13 +++++++++++++ 2 files changed, 31 insertions(+) diff --git a/drivers/iio/inkern.c b/drivers/iio/inkern.c index 0cf5f8e06cfc..adeba5a0ecf7 100644 --- a/drivers/iio/inkern.c +++ b/drivers/iio/inkern.c @@ -443,6 +443,24 @@ err_unlock: } EXPORT_SYMBOL_GPL(iio_read_channel_raw); +int iio_read_channel_average_raw(struct iio_channel *chan, int *val) +{ + int ret; + + mutex_lock(&chan->indio_dev->info_exist_lock); + if (chan->indio_dev->info == NULL) { + ret = -ENODEV; + goto err_unlock; + } + + ret = iio_channel_read(chan, val, NULL, IIO_CHAN_INFO_AVERAGE_RAW); +err_unlock: + mutex_unlock(&chan->indio_dev->info_exist_lock); + + return ret; +} +EXPORT_SYMBOL_GPL(iio_read_channel_average_raw); + static int iio_convert_raw_to_processed_unlocked(struct iio_channel *chan, int raw, int *processed, unsigned int scale) { diff --git a/include/linux/iio/consumer.h b/include/linux/iio/consumer.h index 2752b1fd12be..651f9a0e2765 100644 --- a/include/linux/iio/consumer.h +++ b/include/linux/iio/consumer.h @@ -122,6 +122,19 @@ struct iio_channel int iio_read_channel_raw(struct iio_channel *chan, int *val); +/** + * iio_read_channel_average_raw() - read from a given channel + * @chan: The channel being queried. + * @val: Value read back. + * + * Note raw reads from iio channels are in adc counts and hence + * scale will need to be applied if standard units required. + * + * In opposit to the normal iio_read_channel_raw this function + * returns the average of multiple reads. + */ +int iio_read_channel_average_raw(struct iio_channel *chan, int *val); + /** * iio_read_channel_processed() - read processed value from a given channel * @chan: The channel being queried. -- cgit v1.2.3 From 396590b3bc919800d40464559f2a9c16938a193f Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Fri, 3 Oct 2014 10:31:00 +0100 Subject: staging:iio:ad799x: Move ring functions to the main file The ad799x_ring.c file is pretty much only one function these days. No need to keep it in a separate file. Since there is then only one user of the header left also move everything from the header to the main file. Signed-off-by: Lars-Peter Clausen Acked-by: Hartmut Knaack Signed-off-by: Jonathan Cameron --- drivers/staging/iio/adc/Kconfig | 13 +-- drivers/staging/iio/adc/Makefile | 1 - drivers/staging/iio/adc/ad799x.h | 121 ---------------------------- drivers/staging/iio/adc/ad799x_core.c | 145 +++++++++++++++++++++++++++++++++- drivers/staging/iio/adc/ad799x_ring.c | 84 -------------------- 5 files changed, 143 insertions(+), 221 deletions(-) delete mode 100644 drivers/staging/iio/adc/ad799x.h delete mode 100644 drivers/staging/iio/adc/ad799x_ring.c diff --git a/drivers/staging/iio/adc/Kconfig b/drivers/staging/iio/adc/Kconfig index 363329808a4f..ed23cceba17d 100644 --- a/drivers/staging/iio/adc/Kconfig +++ b/drivers/staging/iio/adc/Kconfig @@ -40,23 +40,14 @@ config AD7606_IFACE_SPI config AD799X tristate "Analog Devices AD799x ADC driver" depends on I2C - select IIO_TRIGGER if IIO_BUFFER - select AD799X_RING_BUFFER + select IIO_BUFFER + select IIO_TRIGGERED_BUFFER help Say yes here to build support for Analog Devices: ad7991, ad7995, ad7999, ad7992, ad7993, ad7994, ad7997, ad7998 i2c analog to digital converters (ADC). Provides direct access via sysfs. -config AD799X_RING_BUFFER - bool "Analog Devices AD799x: use ring buffer" - depends on AD799X - select IIO_BUFFER - select IIO_TRIGGERED_BUFFER - help - Say yes here to include ring buffer support in the AD799X - ADC driver. - config AD7780 tristate "Analog Devices AD7780 and similar ADCs driver" depends on SPI diff --git a/drivers/staging/iio/adc/Makefile b/drivers/staging/iio/adc/Makefile index 3e9fb143d25b..b2d35f813292 100644 --- a/drivers/staging/iio/adc/Makefile +++ b/drivers/staging/iio/adc/Makefile @@ -9,7 +9,6 @@ ad7606-$(CONFIG_AD7606_IFACE_SPI) += ad7606_spi.o obj-$(CONFIG_AD7606) += ad7606.o ad799x-y := ad799x_core.o -ad799x-$(CONFIG_AD799X_RING_BUFFER) += ad799x_ring.o obj-$(CONFIG_AD799X) += ad799x.o obj-$(CONFIG_AD7291) += ad7291.o diff --git a/drivers/staging/iio/adc/ad799x.h b/drivers/staging/iio/adc/ad799x.h deleted file mode 100644 index fc8c85298feb..000000000000 --- a/drivers/staging/iio/adc/ad799x.h +++ /dev/null @@ -1,121 +0,0 @@ -/* - * Copyright (C) 2010-2011 Michael Hennerich, Analog Devices Inc. - * Copyright (C) 2008-2010 Jonathan Cameron - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - * - * ad799x.h - */ - -#ifndef _AD799X_H_ -#define _AD799X_H_ - -#define AD799X_CHANNEL_SHIFT 4 -#define AD799X_STORAGEBITS 16 -/* - * AD7991, AD7995 and AD7999 defines - */ - -#define AD7991_REF_SEL 0x08 -#define AD7991_FLTR 0x04 -#define AD7991_BIT_TRIAL_DELAY 0x02 -#define AD7991_SAMPLE_DELAY 0x01 - -/* - * AD7992, AD7993, AD7994, AD7997 and AD7998 defines - */ - -#define AD7998_FLTR 0x08 -#define AD7998_ALERT_EN 0x04 -#define AD7998_BUSY_ALERT 0x02 -#define AD7998_BUSY_ALERT_POL 0x01 - -#define AD7998_CONV_RES_REG 0x0 -#define AD7998_ALERT_STAT_REG 0x1 -#define AD7998_CONF_REG 0x2 -#define AD7998_CYCLE_TMR_REG 0x3 - -#define AD7998_DATALOW_REG(x) ((x) * 3 + 0x4) -#define AD7998_DATAHIGH_REG(x) ((x) * 3 + 0x5) -#define AD7998_HYST_REG(x) ((x) * 3 + 0x6) - -#define AD7998_CYC_MASK 0x7 -#define AD7998_CYC_DIS 0x0 -#define AD7998_CYC_TCONF_32 0x1 -#define AD7998_CYC_TCONF_64 0x2 -#define AD7998_CYC_TCONF_128 0x3 -#define AD7998_CYC_TCONF_256 0x4 -#define AD7998_CYC_TCONF_512 0x5 -#define AD7998_CYC_TCONF_1024 0x6 -#define AD7998_CYC_TCONF_2048 0x7 - -#define AD7998_ALERT_STAT_CLEAR 0xFF - -/* - * AD7997 and AD7997 defines - */ - -#define AD7997_8_READ_SINGLE 0x80 -#define AD7997_8_READ_SEQUENCE 0x70 -/* TODO: move this into a common header */ -#define RES_MASK(bits) ((1 << (bits)) - 1) - -enum { - ad7991, - ad7995, - ad7999, - ad7992, - ad7993, - ad7994, - ad7997, - ad7998 -}; - -struct ad799x_state; - -/** - * struct ad799x_chip_info - chip specifc information - * @channel: channel specification - * @num_channels: number of channels - * @monitor_mode: whether the chip supports monitor interrupts - * @default_config: device default configuration - * @event_attrs: pointer to the monitor event attribute group - */ - -struct ad799x_chip_info { - struct iio_chan_spec channel[9]; - int num_channels; - u16 default_config; - const struct iio_info *info; -}; - -struct ad799x_state { - struct i2c_client *client; - const struct ad799x_chip_info *chip_info; - struct regulator *reg; - struct regulator *vref; - unsigned id; - u16 config; - - u8 *rx_buf; - unsigned int transfer_size; -}; - -#ifdef CONFIG_AD799X_RING_BUFFER -int ad799x_register_ring_funcs_and_init(struct iio_dev *indio_dev); -void ad799x_ring_cleanup(struct iio_dev *indio_dev); -#else /* CONFIG_AD799X_RING_BUFFER */ - -static inline int -ad799x_register_ring_funcs_and_init(struct iio_dev *indio_dev) -{ - return 0; -} - -static inline void ad799x_ring_cleanup(struct iio_dev *indio_dev) -{ -} -#endif /* CONFIG_AD799X_RING_BUFFER */ -#endif /* _AD799X_H_ */ diff --git a/drivers/staging/iio/adc/ad799x_core.c b/drivers/staging/iio/adc/ad799x_core.c index 979ec77d6c2d..bcbf6102efed 100644 --- a/drivers/staging/iio/adc/ad799x_core.c +++ b/drivers/staging/iio/adc/ad799x_core.c @@ -37,8 +37,144 @@ #include #include #include +#include +#include -#include "ad799x.h" +#define AD799X_CHANNEL_SHIFT 4 +#define AD799X_STORAGEBITS 16 +/* + * AD7991, AD7995 and AD7999 defines + */ + +#define AD7991_REF_SEL 0x08 +#define AD7991_FLTR 0x04 +#define AD7991_BIT_TRIAL_DELAY 0x02 +#define AD7991_SAMPLE_DELAY 0x01 + +/* + * AD7992, AD7993, AD7994, AD7997 and AD7998 defines + */ + +#define AD7998_FLTR 0x08 +#define AD7998_ALERT_EN 0x04 +#define AD7998_BUSY_ALERT 0x02 +#define AD7998_BUSY_ALERT_POL 0x01 + +#define AD7998_CONV_RES_REG 0x0 +#define AD7998_ALERT_STAT_REG 0x1 +#define AD7998_CONF_REG 0x2 +#define AD7998_CYCLE_TMR_REG 0x3 + +#define AD7998_DATALOW_REG(x) ((x) * 3 + 0x4) +#define AD7998_DATAHIGH_REG(x) ((x) * 3 + 0x5) +#define AD7998_HYST_REG(x) ((x) * 3 + 0x6) + +#define AD7998_CYC_MASK 0x7 +#define AD7998_CYC_DIS 0x0 +#define AD7998_CYC_TCONF_32 0x1 +#define AD7998_CYC_TCONF_64 0x2 +#define AD7998_CYC_TCONF_128 0x3 +#define AD7998_CYC_TCONF_256 0x4 +#define AD7998_CYC_TCONF_512 0x5 +#define AD7998_CYC_TCONF_1024 0x6 +#define AD7998_CYC_TCONF_2048 0x7 + +#define AD7998_ALERT_STAT_CLEAR 0xFF + +/* + * AD7997 and AD7997 defines + */ + +#define AD7997_8_READ_SINGLE 0x80 +#define AD7997_8_READ_SEQUENCE 0x70 +/* TODO: move this into a common header */ +#define RES_MASK(bits) ((1 << (bits)) - 1) + +enum { + ad7991, + ad7995, + ad7999, + ad7992, + ad7993, + ad7994, + ad7997, + ad7998 +}; + +/** + * struct ad799x_chip_info - chip specifc information + * @channel: channel specification + * @num_channels: number of channels + * @monitor_mode: whether the chip supports monitor interrupts + * @default_config: device default configuration + * @event_attrs: pointer to the monitor event attribute group + */ +struct ad799x_chip_info { + struct iio_chan_spec channel[9]; + int num_channels; + u16 default_config; + const struct iio_info *info; +}; + +struct ad799x_state { + struct i2c_client *client; + const struct ad799x_chip_info *chip_info; + struct regulator *reg; + struct regulator *vref; + unsigned id; + u16 config; + + u8 *rx_buf; + unsigned int transfer_size; +}; + +/** + * ad799x_trigger_handler() bh of trigger launched polling to ring buffer + * + * Currently there is no option in this driver to disable the saving of + * timestamps within the ring. + **/ +static irqreturn_t ad799x_trigger_handler(int irq, void *p) +{ + struct iio_poll_func *pf = p; + struct iio_dev *indio_dev = pf->indio_dev; + struct ad799x_state *st = iio_priv(indio_dev); + int b_sent; + u8 cmd; + + switch (st->id) { + case ad7991: + case ad7995: + case ad7999: + cmd = st->config | + (*indio_dev->active_scan_mask << AD799X_CHANNEL_SHIFT); + break; + case ad7992: + case ad7993: + case ad7994: + cmd = (*indio_dev->active_scan_mask << AD799X_CHANNEL_SHIFT) | + AD7998_CONV_RES_REG; + break; + case ad7997: + case ad7998: + cmd = AD7997_8_READ_SEQUENCE | AD7998_CONV_RES_REG; + break; + default: + cmd = 0; + } + + b_sent = i2c_smbus_read_i2c_block_data(st->client, + cmd, st->transfer_size, st->rx_buf); + if (b_sent < 0) + goto out; + + iio_push_to_buffers_with_timestamp(indio_dev, st->rx_buf, + iio_get_time_ns()); +out: + iio_trigger_notify_done(indio_dev->trig); + + return IRQ_HANDLED; +} /* * ad799x register access by I2C @@ -578,7 +714,8 @@ static int ad799x_probe(struct i2c_client *client, indio_dev->channels = st->chip_info->channel; indio_dev->num_channels = st->chip_info->num_channels; - ret = ad799x_register_ring_funcs_and_init(indio_dev); + ret = iio_triggered_buffer_setup(indio_dev, NULL, + &ad799x_trigger_handler, NULL); if (ret) goto error_disable_reg; @@ -601,7 +738,7 @@ static int ad799x_probe(struct i2c_client *client, return 0; error_cleanup_ring: - ad799x_ring_cleanup(indio_dev); + iio_triggered_buffer_cleanup(indio_dev); error_disable_reg: if (!IS_ERR(st->vref)) regulator_disable(st->vref); @@ -618,7 +755,7 @@ static int ad799x_remove(struct i2c_client *client) iio_device_unregister(indio_dev); - ad799x_ring_cleanup(indio_dev); + iio_triggered_buffer_cleanup(indio_dev); if (!IS_ERR(st->vref)) regulator_disable(st->vref); if (!IS_ERR(st->reg)) diff --git a/drivers/staging/iio/adc/ad799x_ring.c b/drivers/staging/iio/adc/ad799x_ring.c deleted file mode 100644 index 0ff6c03a483e..000000000000 --- a/drivers/staging/iio/adc/ad799x_ring.c +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright (C) 2010-2012 Michael Hennerich, Analog Devices Inc. - * Copyright (C) 2008-2010 Jonathan Cameron - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - * - * ad799x_ring.c - */ - -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include "ad799x.h" - -/** - * ad799x_trigger_handler() bh of trigger launched polling to ring buffer - * - * Currently there is no option in this driver to disable the saving of - * timestamps within the ring. - **/ - -static irqreturn_t ad799x_trigger_handler(int irq, void *p) -{ - struct iio_poll_func *pf = p; - struct iio_dev *indio_dev = pf->indio_dev; - struct ad799x_state *st = iio_priv(indio_dev); - int b_sent; - u8 cmd; - - switch (st->id) { - case ad7991: - case ad7995: - case ad7999: - cmd = st->config | - (*indio_dev->active_scan_mask << AD799X_CHANNEL_SHIFT); - break; - case ad7992: - case ad7993: - case ad7994: - cmd = (*indio_dev->active_scan_mask << AD799X_CHANNEL_SHIFT) | - AD7998_CONV_RES_REG; - break; - case ad7997: - case ad7998: - cmd = AD7997_8_READ_SEQUENCE | AD7998_CONV_RES_REG; - break; - default: - cmd = 0; - } - - b_sent = i2c_smbus_read_i2c_block_data(st->client, - cmd, st->transfer_size, st->rx_buf); - if (b_sent < 0) - goto out; - - iio_push_to_buffers_with_timestamp(indio_dev, st->rx_buf, - iio_get_time_ns()); -out: - iio_trigger_notify_done(indio_dev->trig); - - return IRQ_HANDLED; -} - -int ad799x_register_ring_funcs_and_init(struct iio_dev *indio_dev) -{ - return iio_triggered_buffer_setup(indio_dev, NULL, - &ad799x_trigger_handler, NULL); -} - -void ad799x_ring_cleanup(struct iio_dev *indio_dev) -{ - iio_triggered_buffer_cleanup(indio_dev); -} -- cgit v1.2.3 From bd75afaa314b2743c5379df3ccc84fab03126b71 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Fri, 3 Oct 2014 10:31:00 +0100 Subject: staging:iio: Move ad799x driver out of staging The driver is now at a reasonable quality level. Move it out of staging. Signed-off-by: Lars-Peter Clausen Acked-by: Hartmut Knaack Signed-off-by: Jonathan Cameron --- drivers/iio/adc/Kconfig | 11 + drivers/iio/adc/Makefile | 1 + drivers/iio/adc/ad799x.c | 794 ++++++++++++++++++++++++++++++++++ drivers/staging/iio/adc/Kconfig | 11 - drivers/staging/iio/adc/Makefile | 3 - drivers/staging/iio/adc/ad799x_core.c | 794 ---------------------------------- 6 files changed, 806 insertions(+), 808 deletions(-) create mode 100644 drivers/iio/adc/ad799x.c delete mode 100644 drivers/staging/iio/adc/ad799x_core.c diff --git a/drivers/iio/adc/Kconfig b/drivers/iio/adc/Kconfig index 555320659c99..a0368119c275 100644 --- a/drivers/iio/adc/Kconfig +++ b/drivers/iio/adc/Kconfig @@ -96,6 +96,17 @@ config AD7923 To compile this driver as a module, choose M here: the module will be called ad7923. +config AD799X + tristate "Analog Devices AD799x ADC driver" + depends on I2C + select IIO_BUFFER + select IIO_TRIGGERED_BUFFER + help + Say yes here to build support for Analog Devices: + ad7991, ad7995, ad7999, ad7992, ad7993, ad7994, ad7997, ad7998 + i2c analog to digital converters (ADC). Provides direct access + via sysfs. + config AT91_ADC tristate "Atmel AT91 ADC" depends on ARCH_AT91 diff --git a/drivers/iio/adc/Makefile b/drivers/iio/adc/Makefile index 89f1216e636a..1e2fc8912825 100644 --- a/drivers/iio/adc/Makefile +++ b/drivers/iio/adc/Makefile @@ -11,6 +11,7 @@ obj-$(CONFIG_AD7476) += ad7476.o obj-$(CONFIG_AD7791) += ad7791.o obj-$(CONFIG_AD7793) += ad7793.o obj-$(CONFIG_AD7887) += ad7887.o +obj-$(CONFIG_AD799X) += ad799x.o obj-$(CONFIG_AT91_ADC) += at91_adc.o obj-$(CONFIG_EXYNOS_ADC) += exynos_adc.o obj-$(CONFIG_LP8788_ADC) += lp8788_adc.o diff --git a/drivers/iio/adc/ad799x.c b/drivers/iio/adc/ad799x.c new file mode 100644 index 000000000000..bcbf6102efed --- /dev/null +++ b/drivers/iio/adc/ad799x.c @@ -0,0 +1,794 @@ +/* + * iio/adc/ad799x.c + * Copyright (C) 2010-2011 Michael Hennerich, Analog Devices Inc. + * + * based on iio/adc/max1363 + * Copyright (C) 2008-2010 Jonathan Cameron + * + * based on linux/drivers/i2c/chips/max123x + * Copyright (C) 2002-2004 Stefan Eletzhofer + * + * based on linux/drivers/acron/char/pcf8583.c + * Copyright (C) 2000 Russell King + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * ad799x.c + * + * Support for ad7991, ad7995, ad7999, ad7992, ad7993, ad7994, ad7997, + * ad7998 and similar chips. + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#define AD799X_CHANNEL_SHIFT 4 +#define AD799X_STORAGEBITS 16 +/* + * AD7991, AD7995 and AD7999 defines + */ + +#define AD7991_REF_SEL 0x08 +#define AD7991_FLTR 0x04 +#define AD7991_BIT_TRIAL_DELAY 0x02 +#define AD7991_SAMPLE_DELAY 0x01 + +/* + * AD7992, AD7993, AD7994, AD7997 and AD7998 defines + */ + +#define AD7998_FLTR 0x08 +#define AD7998_ALERT_EN 0x04 +#define AD7998_BUSY_ALERT 0x02 +#define AD7998_BUSY_ALERT_POL 0x01 + +#define AD7998_CONV_RES_REG 0x0 +#define AD7998_ALERT_STAT_REG 0x1 +#define AD7998_CONF_REG 0x2 +#define AD7998_CYCLE_TMR_REG 0x3 + +#define AD7998_DATALOW_REG(x) ((x) * 3 + 0x4) +#define AD7998_DATAHIGH_REG(x) ((x) * 3 + 0x5) +#define AD7998_HYST_REG(x) ((x) * 3 + 0x6) + +#define AD7998_CYC_MASK 0x7 +#define AD7998_CYC_DIS 0x0 +#define AD7998_CYC_TCONF_32 0x1 +#define AD7998_CYC_TCONF_64 0x2 +#define AD7998_CYC_TCONF_128 0x3 +#define AD7998_CYC_TCONF_256 0x4 +#define AD7998_CYC_TCONF_512 0x5 +#define AD7998_CYC_TCONF_1024 0x6 +#define AD7998_CYC_TCONF_2048 0x7 + +#define AD7998_ALERT_STAT_CLEAR 0xFF + +/* + * AD7997 and AD7997 defines + */ + +#define AD7997_8_READ_SINGLE 0x80 +#define AD7997_8_READ_SEQUENCE 0x70 +/* TODO: move this into a common header */ +#define RES_MASK(bits) ((1 << (bits)) - 1) + +enum { + ad7991, + ad7995, + ad7999, + ad7992, + ad7993, + ad7994, + ad7997, + ad7998 +}; + +/** + * struct ad799x_chip_info - chip specifc information + * @channel: channel specification + * @num_channels: number of channels + * @monitor_mode: whether the chip supports monitor interrupts + * @default_config: device default configuration + * @event_attrs: pointer to the monitor event attribute group + */ +struct ad799x_chip_info { + struct iio_chan_spec channel[9]; + int num_channels; + u16 default_config; + const struct iio_info *info; +}; + +struct ad799x_state { + struct i2c_client *client; + const struct ad799x_chip_info *chip_info; + struct regulator *reg; + struct regulator *vref; + unsigned id; + u16 config; + + u8 *rx_buf; + unsigned int transfer_size; +}; + +/** + * ad799x_trigger_handler() bh of trigger launched polling to ring buffer + * + * Currently there is no option in this driver to disable the saving of + * timestamps within the ring. + **/ +static irqreturn_t ad799x_trigger_handler(int irq, void *p) +{ + struct iio_poll_func *pf = p; + struct iio_dev *indio_dev = pf->indio_dev; + struct ad799x_state *st = iio_priv(indio_dev); + int b_sent; + u8 cmd; + + switch (st->id) { + case ad7991: + case ad7995: + case ad7999: + cmd = st->config | + (*indio_dev->active_scan_mask << AD799X_CHANNEL_SHIFT); + break; + case ad7992: + case ad7993: + case ad7994: + cmd = (*indio_dev->active_scan_mask << AD799X_CHANNEL_SHIFT) | + AD7998_CONV_RES_REG; + break; + case ad7997: + case ad7998: + cmd = AD7997_8_READ_SEQUENCE | AD7998_CONV_RES_REG; + break; + default: + cmd = 0; + } + + b_sent = i2c_smbus_read_i2c_block_data(st->client, + cmd, st->transfer_size, st->rx_buf); + if (b_sent < 0) + goto out; + + iio_push_to_buffers_with_timestamp(indio_dev, st->rx_buf, + iio_get_time_ns()); +out: + iio_trigger_notify_done(indio_dev->trig); + + return IRQ_HANDLED; +} + +/* + * ad799x register access by I2C + */ +static int ad799x_i2c_read16(struct ad799x_state *st, u8 reg, u16 *data) +{ + struct i2c_client *client = st->client; + int ret = 0; + + ret = i2c_smbus_read_word_swapped(client, reg); + if (ret < 0) { + dev_err(&client->dev, "I2C read error\n"); + return ret; + } + + *data = (u16)ret; + + return 0; +} + +static int ad799x_i2c_read8(struct ad799x_state *st, u8 reg, u8 *data) +{ + struct i2c_client *client = st->client; + int ret = 0; + + ret = i2c_smbus_read_byte_data(client, reg); + if (ret < 0) { + dev_err(&client->dev, "I2C read error\n"); + return ret; + } + + *data = (u8)ret; + + return 0; +} + +static int ad799x_i2c_write16(struct ad799x_state *st, u8 reg, u16 data) +{ + struct i2c_client *client = st->client; + int ret = 0; + + ret = i2c_smbus_write_word_swapped(client, reg, data); + if (ret < 0) + dev_err(&client->dev, "I2C write error\n"); + + return ret; +} + +static int ad799x_i2c_write8(struct ad799x_state *st, u8 reg, u8 data) +{ + struct i2c_client *client = st->client; + int ret = 0; + + ret = i2c_smbus_write_byte_data(client, reg, data); + if (ret < 0) + dev_err(&client->dev, "I2C write error\n"); + + return ret; +} + +static int ad7997_8_update_scan_mode(struct iio_dev *indio_dev, + const unsigned long *scan_mask) +{ + struct ad799x_state *st = iio_priv(indio_dev); + + kfree(st->rx_buf); + st->rx_buf = kmalloc(indio_dev->scan_bytes, GFP_KERNEL); + if (!st->rx_buf) + return -ENOMEM; + + st->transfer_size = bitmap_weight(scan_mask, indio_dev->masklength) * 2; + + switch (st->id) { + case ad7997: + case ad7998: + return ad799x_i2c_write16(st, AD7998_CONF_REG, + st->config | (*scan_mask << AD799X_CHANNEL_SHIFT)); + default: + break; + } + + return 0; +} + +static int ad799x_scan_direct(struct ad799x_state *st, unsigned ch) +{ + u16 rxbuf; + u8 cmd; + int ret; + + switch (st->id) { + case ad7991: + case ad7995: + case ad7999: + cmd = st->config | ((1 << ch) << AD799X_CHANNEL_SHIFT); + break; + case ad7992: + case ad7993: + case ad7994: + cmd = (1 << ch) << AD799X_CHANNEL_SHIFT; + break; + case ad7997: + case ad7998: + cmd = (ch << AD799X_CHANNEL_SHIFT) | AD7997_8_READ_SINGLE; + break; + default: + return -EINVAL; + } + + ret = ad799x_i2c_read16(st, cmd, &rxbuf); + if (ret < 0) + return ret; + + return rxbuf; +} + +static int ad799x_read_raw(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, + int *val, + int *val2, + long m) +{ + int ret; + struct ad799x_state *st = iio_priv(indio_dev); + + switch (m) { + case IIO_CHAN_INFO_RAW: + mutex_lock(&indio_dev->mlock); + if (iio_buffer_enabled(indio_dev)) + ret = -EBUSY; + else + ret = ad799x_scan_direct(st, chan->scan_index); + mutex_unlock(&indio_dev->mlock); + + if (ret < 0) + return ret; + *val = (ret >> chan->scan_type.shift) & + RES_MASK(chan->scan_type.realbits); + return IIO_VAL_INT; + case IIO_CHAN_INFO_SCALE: + ret = regulator_get_voltage(st->vref); + if (ret < 0) + return ret; + *val = ret / 1000; + *val2 = chan->scan_type.realbits; + return IIO_VAL_FRACTIONAL_LOG2; + } + return -EINVAL; +} +static const unsigned int ad7998_frequencies[] = { + [AD7998_CYC_DIS] = 0, + [AD7998_CYC_TCONF_32] = 15625, + [AD7998_CYC_TCONF_64] = 7812, + [AD7998_CYC_TCONF_128] = 3906, + [AD7998_CYC_TCONF_512] = 976, + [AD7998_CYC_TCONF_1024] = 488, + [AD7998_CYC_TCONF_2048] = 244, +}; +static ssize_t ad799x_read_frequency(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + struct iio_dev *indio_dev = dev_to_iio_dev(dev); + struct ad799x_state *st = iio_priv(indio_dev); + + int ret; + u8 val; + ret = ad799x_i2c_read8(st, AD7998_CYCLE_TMR_REG, &val); + if (ret) + return ret; + + val &= AD7998_CYC_MASK; + + return sprintf(buf, "%u\n", ad7998_frequencies[val]); +} + +static ssize_t ad799x_write_frequency(struct device *dev, + struct device_attribute *attr, + const char *buf, + size_t len) +{ + struct iio_dev *indio_dev = dev_to_iio_dev(dev); + struct ad799x_state *st = iio_priv(indio_dev); + + long val; + int ret, i; + u8 t; + + ret = kstrtol(buf, 10, &val); + if (ret) + return ret; + + mutex_lock(&indio_dev->mlock); + ret = ad799x_i2c_read8(st, AD7998_CYCLE_TMR_REG, &t); + if (ret) + goto error_ret_mutex; + /* Wipe the bits clean */ + t &= ~AD7998_CYC_MASK; + + for (i = 0; i < ARRAY_SIZE(ad7998_frequencies); i++) + if (val == ad7998_frequencies[i]) + break; + if (i == ARRAY_SIZE(ad7998_frequencies)) { + ret = -EINVAL; + goto error_ret_mutex; + } + t |= i; + ret = ad799x_i2c_write8(st, AD7998_CYCLE_TMR_REG, t); + +error_ret_mutex: + mutex_unlock(&indio_dev->mlock); + + return ret ? ret : len; +} + +static int ad799x_read_event_config(struct iio_dev *indio_dev, + const struct iio_chan_spec *chan, + enum iio_event_type type, + enum iio_event_direction dir) +{ + return 1; +} + +static unsigned int ad799x_threshold_reg(const struct iio_chan_spec *chan, + enum iio_event_direction dir, + enum iio_event_info info) +{ + switch (info) { + case IIO_EV_INFO_VALUE: + if (dir == IIO_EV_DIR_FALLING) + return AD7998_DATALOW_REG(chan->channel); + else + return AD7998_DATAHIGH_REG(chan->channel); + case IIO_EV_INFO_HYSTERESIS: + return AD7998_HYST_REG(chan->channel); + default: + return -EINVAL; + } + + return 0; +} + +static int ad799x_write_event_value(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) +{ + int ret; + struct ad799x_state *st = iio_priv(indio_dev); + + mutex_lock(&indio_dev->mlock); + ret = ad799x_i2c_write16(st, ad799x_threshold_reg(chan, dir, info), + val); + mutex_unlock(&indio_dev->mlock); + + return ret; +} + +static int ad799x_read_event_value(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) +{ + int ret; + struct ad799x_state *st = iio_priv(indio_dev); + u16 valin; + + mutex_lock(&indio_dev->mlock); + ret = ad799x_i2c_read16(st, ad799x_threshold_reg(chan, dir, info), + &valin); + mutex_unlock(&indio_dev->mlock); + if (ret < 0) + return ret; + *val = valin; + + return IIO_VAL_INT; +} + +static irqreturn_t ad799x_event_handler(int irq, void *private) +{ + struct iio_dev *indio_dev = private; + struct ad799x_state *st = iio_priv(private); + u8 status; + int i, ret; + + ret = ad799x_i2c_read8(st, AD7998_ALERT_STAT_REG, &status); + if (ret) + goto done; + + if (!status) + goto done; + + ad799x_i2c_write8(st, AD7998_ALERT_STAT_REG, AD7998_ALERT_STAT_CLEAR); + + for (i = 0; i < 8; i++) { + if (status & (1 << i)) + iio_push_event(indio_dev, + i & 0x1 ? + IIO_UNMOD_EVENT_CODE(IIO_VOLTAGE, + (i >> 1), + IIO_EV_TYPE_THRESH, + IIO_EV_DIR_RISING) : + IIO_UNMOD_EVENT_CODE(IIO_VOLTAGE, + (i >> 1), + IIO_EV_TYPE_THRESH, + IIO_EV_DIR_FALLING), + iio_get_time_ns()); + } + +done: + return IRQ_HANDLED; +} + +static IIO_DEV_ATTR_SAMP_FREQ(S_IWUSR | S_IRUGO, + ad799x_read_frequency, + ad799x_write_frequency); +static IIO_CONST_ATTR_SAMP_FREQ_AVAIL("15625 7812 3906 1953 976 488 244 0"); + +static struct attribute *ad799x_event_attributes[] = { + &iio_dev_attr_sampling_frequency.dev_attr.attr, + &iio_const_attr_sampling_frequency_available.dev_attr.attr, + NULL, +}; + +static struct attribute_group ad799x_event_attrs_group = { + .attrs = ad799x_event_attributes, + .name = "events", +}; + +static const struct iio_info ad7991_info = { + .read_raw = &ad799x_read_raw, + .driver_module = THIS_MODULE, +}; + +static const struct iio_info ad7993_4_7_8_info = { + .read_raw = &ad799x_read_raw, + .event_attrs = &ad799x_event_attrs_group, + .read_event_config = &ad799x_read_event_config, + .read_event_value = &ad799x_read_event_value, + .write_event_value = &ad799x_write_event_value, + .driver_module = THIS_MODULE, + .update_scan_mode = ad7997_8_update_scan_mode, +}; + +static const struct iio_event_spec ad799x_events[] = { + { + .type = IIO_EV_TYPE_THRESH, + .dir = IIO_EV_DIR_RISING, + .mask_separate = BIT(IIO_EV_INFO_VALUE) | + BIT(IIO_EV_INFO_ENABLE), + }, { + .type = IIO_EV_TYPE_THRESH, + .dir = IIO_EV_DIR_FALLING, + .mask_separate = BIT(IIO_EV_INFO_VALUE) | + BIT(IIO_EV_INFO_ENABLE), + }, { + .type = IIO_EV_TYPE_THRESH, + .dir = IIO_EV_DIR_EITHER, + .mask_separate = BIT(IIO_EV_INFO_HYSTERESIS), + }, +}; + +#define _AD799X_CHANNEL(_index, _realbits, _ev_spec, _num_ev_spec) { \ + .type = IIO_VOLTAGE, \ + .indexed = 1, \ + .channel = (_index), \ + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \ + .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), \ + .scan_index = (_index), \ + .scan_type = { \ + .sign = 'u', \ + .realbits = (_realbits), \ + .storagebits = 16, \ + .shift = 12 - (_realbits), \ + .endianness = IIO_BE, \ + }, \ + .event_spec = _ev_spec, \ + .num_event_specs = _num_ev_spec, \ +} + +#define AD799X_CHANNEL(_index, _realbits) \ + _AD799X_CHANNEL(_index, _realbits, NULL, 0) + +#define AD799X_CHANNEL_WITH_EVENTS(_index, _realbits) \ + _AD799X_CHANNEL(_index, _realbits, ad799x_events, \ + ARRAY_SIZE(ad799x_events)) + +static const struct ad799x_chip_info ad799x_chip_info_tbl[] = { + [ad7991] = { + .channel = { + AD799X_CHANNEL(0, 12), + AD799X_CHANNEL(1, 12), + AD799X_CHANNEL(2, 12), + AD799X_CHANNEL(3, 12), + IIO_CHAN_SOFT_TIMESTAMP(4), + }, + .num_channels = 5, + .info = &ad7991_info, + }, + [ad7995] = { + .channel = { + AD799X_CHANNEL(0, 10), + AD799X_CHANNEL(1, 10), + AD799X_CHANNEL(2, 10), + AD799X_CHANNEL(3, 10), + IIO_CHAN_SOFT_TIMESTAMP(4), + }, + .num_channels = 5, + .info = &ad7991_info, + }, + [ad7999] = { + .channel = { + AD799X_CHANNEL(0, 8), + AD799X_CHANNEL(1, 8), + AD799X_CHANNEL(2, 8), + AD799X_CHANNEL(3, 8), + IIO_CHAN_SOFT_TIMESTAMP(4), + }, + .num_channels = 5, + .info = &ad7991_info, + }, + [ad7992] = { + .channel = { + AD799X_CHANNEL_WITH_EVENTS(0, 12), + AD799X_CHANNEL_WITH_EVENTS(1, 12), + IIO_CHAN_SOFT_TIMESTAMP(3), + }, + .num_channels = 3, + .default_config = AD7998_ALERT_EN, + .info = &ad7993_4_7_8_info, + }, + [ad7993] = { + .channel = { + AD799X_CHANNEL_WITH_EVENTS(0, 10), + AD799X_CHANNEL_WITH_EVENTS(1, 10), + AD799X_CHANNEL_WITH_EVENTS(2, 10), + AD799X_CHANNEL_WITH_EVENTS(3, 10), + IIO_CHAN_SOFT_TIMESTAMP(4), + }, + .num_channels = 5, + .default_config = AD7998_ALERT_EN, + .info = &ad7993_4_7_8_info, + }, + [ad7994] = { + .channel = { + AD799X_CHANNEL_WITH_EVENTS(0, 12), + AD799X_CHANNEL_WITH_EVENTS(1, 12), + AD799X_CHANNEL_WITH_EVENTS(2, 12), + AD799X_CHANNEL_WITH_EVENTS(3, 12), + IIO_CHAN_SOFT_TIMESTAMP(4), + }, + .num_channels = 5, + .default_config = AD7998_ALERT_EN, + .info = &ad7993_4_7_8_info, + }, + [ad7997] = { + .channel = { + AD799X_CHANNEL_WITH_EVENTS(0, 10), + AD799X_CHANNEL_WITH_EVENTS(1, 10), + AD799X_CHANNEL_WITH_EVENTS(2, 10), + AD799X_CHANNEL_WITH_EVENTS(3, 10), + AD799X_CHANNEL(4, 10), + AD799X_CHANNEL(5, 10), + AD799X_CHANNEL(6, 10), + AD799X_CHANNEL(7, 10), + IIO_CHAN_SOFT_TIMESTAMP(8), + }, + .num_channels = 9, + .default_config = AD7998_ALERT_EN, + .info = &ad7993_4_7_8_info, + }, + [ad7998] = { + .channel = { + AD799X_CHANNEL_WITH_EVENTS(0, 12), + AD799X_CHANNEL_WITH_EVENTS(1, 12), + AD799X_CHANNEL_WITH_EVENTS(2, 12), + AD799X_CHANNEL_WITH_EVENTS(3, 12), + AD799X_CHANNEL(4, 12), + AD799X_CHANNEL(5, 12), + AD799X_CHANNEL(6, 12), + AD799X_CHANNEL(7, 12), + IIO_CHAN_SOFT_TIMESTAMP(8), + }, + .num_channels = 9, + .default_config = AD7998_ALERT_EN, + .info = &ad7993_4_7_8_info, + }, +}; + +static int ad799x_probe(struct i2c_client *client, + const struct i2c_device_id *id) +{ + int ret; + struct ad799x_state *st; + struct iio_dev *indio_dev; + + indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*st)); + if (indio_dev == NULL) + return -ENOMEM; + + st = iio_priv(indio_dev); + /* this is only used for device removal purposes */ + i2c_set_clientdata(client, indio_dev); + + st->id = id->driver_data; + st->chip_info = &ad799x_chip_info_tbl[st->id]; + st->config = st->chip_info->default_config; + + /* TODO: Add pdata options for filtering and bit delay */ + + st->reg = devm_regulator_get(&client->dev, "vcc"); + if (IS_ERR(st->reg)) + return PTR_ERR(st->reg); + ret = regulator_enable(st->reg); + if (ret) + return ret; + st->vref = devm_regulator_get(&client->dev, "vref"); + if (IS_ERR(st->vref)) { + ret = PTR_ERR(st->vref); + goto error_disable_reg; + } + ret = regulator_enable(st->vref); + if (ret) + goto error_disable_reg; + + st->client = client; + + indio_dev->dev.parent = &client->dev; + indio_dev->name = id->name; + indio_dev->info = st->chip_info->info; + + indio_dev->modes = INDIO_DIRECT_MODE; + indio_dev->channels = st->chip_info->channel; + indio_dev->num_channels = st->chip_info->num_channels; + + ret = iio_triggered_buffer_setup(indio_dev, NULL, + &ad799x_trigger_handler, NULL); + if (ret) + goto error_disable_reg; + + if (client->irq > 0) { + ret = devm_request_threaded_irq(&client->dev, + client->irq, + NULL, + ad799x_event_handler, + IRQF_TRIGGER_FALLING | + IRQF_ONESHOT, + client->name, + indio_dev); + if (ret) + goto error_cleanup_ring; + } + ret = iio_device_register(indio_dev); + if (ret) + goto error_cleanup_ring; + + return 0; + +error_cleanup_ring: + iio_triggered_buffer_cleanup(indio_dev); +error_disable_reg: + if (!IS_ERR(st->vref)) + regulator_disable(st->vref); + if (!IS_ERR(st->reg)) + regulator_disable(st->reg); + + return ret; +} + +static int ad799x_remove(struct i2c_client *client) +{ + struct iio_dev *indio_dev = i2c_get_clientdata(client); + struct ad799x_state *st = iio_priv(indio_dev); + + iio_device_unregister(indio_dev); + + iio_triggered_buffer_cleanup(indio_dev); + if (!IS_ERR(st->vref)) + regulator_disable(st->vref); + if (!IS_ERR(st->reg)) + regulator_disable(st->reg); + kfree(st->rx_buf); + + return 0; +} + +static const struct i2c_device_id ad799x_id[] = { + { "ad7991", ad7991 }, + { "ad7995", ad7995 }, + { "ad7999", ad7999 }, + { "ad7992", ad7992 }, + { "ad7993", ad7993 }, + { "ad7994", ad7994 }, + { "ad7997", ad7997 }, + { "ad7998", ad7998 }, + {} +}; + +MODULE_DEVICE_TABLE(i2c, ad799x_id); + +static struct i2c_driver ad799x_driver = { + .driver = { + .name = "ad799x", + }, + .probe = ad799x_probe, + .remove = ad799x_remove, + .id_table = ad799x_id, +}; +module_i2c_driver(ad799x_driver); + +MODULE_AUTHOR("Michael Hennerich "); +MODULE_DESCRIPTION("Analog Devices AD799x ADC"); +MODULE_LICENSE("GPL v2"); diff --git a/drivers/staging/iio/adc/Kconfig b/drivers/staging/iio/adc/Kconfig index ed23cceba17d..b87e382ad768 100644 --- a/drivers/staging/iio/adc/Kconfig +++ b/drivers/staging/iio/adc/Kconfig @@ -37,17 +37,6 @@ config AD7606_IFACE_SPI Say yes here to include parallel interface support on the AD7606 ADC driver. -config AD799X - tristate "Analog Devices AD799x ADC driver" - depends on I2C - select IIO_BUFFER - select IIO_TRIGGERED_BUFFER - help - Say yes here to build support for Analog Devices: - ad7991, ad7995, ad7999, ad7992, ad7993, ad7994, ad7997, ad7998 - i2c analog to digital converters (ADC). Provides direct access - via sysfs. - config AD7780 tristate "Analog Devices AD7780 and similar ADCs driver" depends on SPI diff --git a/drivers/staging/iio/adc/Makefile b/drivers/staging/iio/adc/Makefile index b2d35f813292..afdcd1ff08ff 100644 --- a/drivers/staging/iio/adc/Makefile +++ b/drivers/staging/iio/adc/Makefile @@ -8,9 +8,6 @@ ad7606-$(CONFIG_AD7606_IFACE_PARALLEL) += ad7606_par.o ad7606-$(CONFIG_AD7606_IFACE_SPI) += ad7606_spi.o obj-$(CONFIG_AD7606) += ad7606.o -ad799x-y := ad799x_core.o -obj-$(CONFIG_AD799X) += ad799x.o - obj-$(CONFIG_AD7291) += ad7291.o obj-$(CONFIG_AD7780) += ad7780.o obj-$(CONFIG_AD7816) += ad7816.o diff --git a/drivers/staging/iio/adc/ad799x_core.c b/drivers/staging/iio/adc/ad799x_core.c deleted file mode 100644 index bcbf6102efed..000000000000 --- a/drivers/staging/iio/adc/ad799x_core.c +++ /dev/null @@ -1,794 +0,0 @@ -/* - * iio/adc/ad799x.c - * Copyright (C) 2010-2011 Michael Hennerich, Analog Devices Inc. - * - * based on iio/adc/max1363 - * Copyright (C) 2008-2010 Jonathan Cameron - * - * based on linux/drivers/i2c/chips/max123x - * Copyright (C) 2002-2004 Stefan Eletzhofer - * - * based on linux/drivers/acron/char/pcf8583.c - * Copyright (C) 2000 Russell King - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - * - * ad799x.c - * - * Support for ad7991, ad7995, ad7999, ad7992, ad7993, ad7994, ad7997, - * ad7998 and similar chips. - * - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#define AD799X_CHANNEL_SHIFT 4 -#define AD799X_STORAGEBITS 16 -/* - * AD7991, AD7995 and AD7999 defines - */ - -#define AD7991_REF_SEL 0x08 -#define AD7991_FLTR 0x04 -#define AD7991_BIT_TRIAL_DELAY 0x02 -#define AD7991_SAMPLE_DELAY 0x01 - -/* - * AD7992, AD7993, AD7994, AD7997 and AD7998 defines - */ - -#define AD7998_FLTR 0x08 -#define AD7998_ALERT_EN 0x04 -#define AD7998_BUSY_ALERT 0x02 -#define AD7998_BUSY_ALERT_POL 0x01 - -#define AD7998_CONV_RES_REG 0x0 -#define AD7998_ALERT_STAT_REG 0x1 -#define AD7998_CONF_REG 0x2 -#define AD7998_CYCLE_TMR_REG 0x3 - -#define AD7998_DATALOW_REG(x) ((x) * 3 + 0x4) -#define AD7998_DATAHIGH_REG(x) ((x) * 3 + 0x5) -#define AD7998_HYST_REG(x) ((x) * 3 + 0x6) - -#define AD7998_CYC_MASK 0x7 -#define AD7998_CYC_DIS 0x0 -#define AD7998_CYC_TCONF_32 0x1 -#define AD7998_CYC_TCONF_64 0x2 -#define AD7998_CYC_TCONF_128 0x3 -#define AD7998_CYC_TCONF_256 0x4 -#define AD7998_CYC_TCONF_512 0x5 -#define AD7998_CYC_TCONF_1024 0x6 -#define AD7998_CYC_TCONF_2048 0x7 - -#define AD7998_ALERT_STAT_CLEAR 0xFF - -/* - * AD7997 and AD7997 defines - */ - -#define AD7997_8_READ_SINGLE 0x80 -#define AD7997_8_READ_SEQUENCE 0x70 -/* TODO: move this into a common header */ -#define RES_MASK(bits) ((1 << (bits)) - 1) - -enum { - ad7991, - ad7995, - ad7999, - ad7992, - ad7993, - ad7994, - ad7997, - ad7998 -}; - -/** - * struct ad799x_chip_info - chip specifc information - * @channel: channel specification - * @num_channels: number of channels - * @monitor_mode: whether the chip supports monitor interrupts - * @default_config: device default configuration - * @event_attrs: pointer to the monitor event attribute group - */ -struct ad799x_chip_info { - struct iio_chan_spec channel[9]; - int num_channels; - u16 default_config; - const struct iio_info *info; -}; - -struct ad799x_state { - struct i2c_client *client; - const struct ad799x_chip_info *chip_info; - struct regulator *reg; - struct regulator *vref; - unsigned id; - u16 config; - - u8 *rx_buf; - unsigned int transfer_size; -}; - -/** - * ad799x_trigger_handler() bh of trigger launched polling to ring buffer - * - * Currently there is no option in this driver to disable the saving of - * timestamps within the ring. - **/ -static irqreturn_t ad799x_trigger_handler(int irq, void *p) -{ - struct iio_poll_func *pf = p; - struct iio_dev *indio_dev = pf->indio_dev; - struct ad799x_state *st = iio_priv(indio_dev); - int b_sent; - u8 cmd; - - switch (st->id) { - case ad7991: - case ad7995: - case ad7999: - cmd = st->config | - (*indio_dev->active_scan_mask << AD799X_CHANNEL_SHIFT); - break; - case ad7992: - case ad7993: - case ad7994: - cmd = (*indio_dev->active_scan_mask << AD799X_CHANNEL_SHIFT) | - AD7998_CONV_RES_REG; - break; - case ad7997: - case ad7998: - cmd = AD7997_8_READ_SEQUENCE | AD7998_CONV_RES_REG; - break; - default: - cmd = 0; - } - - b_sent = i2c_smbus_read_i2c_block_data(st->client, - cmd, st->transfer_size, st->rx_buf); - if (b_sent < 0) - goto out; - - iio_push_to_buffers_with_timestamp(indio_dev, st->rx_buf, - iio_get_time_ns()); -out: - iio_trigger_notify_done(indio_dev->trig); - - return IRQ_HANDLED; -} - -/* - * ad799x register access by I2C - */ -static int ad799x_i2c_read16(struct ad799x_state *st, u8 reg, u16 *data) -{ - struct i2c_client *client = st->client; - int ret = 0; - - ret = i2c_smbus_read_word_swapped(client, reg); - if (ret < 0) { - dev_err(&client->dev, "I2C read error\n"); - return ret; - } - - *data = (u16)ret; - - return 0; -} - -static int ad799x_i2c_read8(struct ad799x_state *st, u8 reg, u8 *data) -{ - struct i2c_client *client = st->client; - int ret = 0; - - ret = i2c_smbus_read_byte_data(client, reg); - if (ret < 0) { - dev_err(&client->dev, "I2C read error\n"); - return ret; - } - - *data = (u8)ret; - - return 0; -} - -static int ad799x_i2c_write16(struct ad799x_state *st, u8 reg, u16 data) -{ - struct i2c_client *client = st->client; - int ret = 0; - - ret = i2c_smbus_write_word_swapped(client, reg, data); - if (ret < 0) - dev_err(&client->dev, "I2C write error\n"); - - return ret; -} - -static int ad799x_i2c_write8(struct ad799x_state *st, u8 reg, u8 data) -{ - struct i2c_client *client = st->client; - int ret = 0; - - ret = i2c_smbus_write_byte_data(client, reg, data); - if (ret < 0) - dev_err(&client->dev, "I2C write error\n"); - - return ret; -} - -static int ad7997_8_update_scan_mode(struct iio_dev *indio_dev, - const unsigned long *scan_mask) -{ - struct ad799x_state *st = iio_priv(indio_dev); - - kfree(st->rx_buf); - st->rx_buf = kmalloc(indio_dev->scan_bytes, GFP_KERNEL); - if (!st->rx_buf) - return -ENOMEM; - - st->transfer_size = bitmap_weight(scan_mask, indio_dev->masklength) * 2; - - switch (st->id) { - case ad7997: - case ad7998: - return ad799x_i2c_write16(st, AD7998_CONF_REG, - st->config | (*scan_mask << AD799X_CHANNEL_SHIFT)); - default: - break; - } - - return 0; -} - -static int ad799x_scan_direct(struct ad799x_state *st, unsigned ch) -{ - u16 rxbuf; - u8 cmd; - int ret; - - switch (st->id) { - case ad7991: - case ad7995: - case ad7999: - cmd = st->config | ((1 << ch) << AD799X_CHANNEL_SHIFT); - break; - case ad7992: - case ad7993: - case ad7994: - cmd = (1 << ch) << AD799X_CHANNEL_SHIFT; - break; - case ad7997: - case ad7998: - cmd = (ch << AD799X_CHANNEL_SHIFT) | AD7997_8_READ_SINGLE; - break; - default: - return -EINVAL; - } - - ret = ad799x_i2c_read16(st, cmd, &rxbuf); - if (ret < 0) - return ret; - - return rxbuf; -} - -static int ad799x_read_raw(struct iio_dev *indio_dev, - struct iio_chan_spec const *chan, - int *val, - int *val2, - long m) -{ - int ret; - struct ad799x_state *st = iio_priv(indio_dev); - - switch (m) { - case IIO_CHAN_INFO_RAW: - mutex_lock(&indio_dev->mlock); - if (iio_buffer_enabled(indio_dev)) - ret = -EBUSY; - else - ret = ad799x_scan_direct(st, chan->scan_index); - mutex_unlock(&indio_dev->mlock); - - if (ret < 0) - return ret; - *val = (ret >> chan->scan_type.shift) & - RES_MASK(chan->scan_type.realbits); - return IIO_VAL_INT; - case IIO_CHAN_INFO_SCALE: - ret = regulator_get_voltage(st->vref); - if (ret < 0) - return ret; - *val = ret / 1000; - *val2 = chan->scan_type.realbits; - return IIO_VAL_FRACTIONAL_LOG2; - } - return -EINVAL; -} -static const unsigned int ad7998_frequencies[] = { - [AD7998_CYC_DIS] = 0, - [AD7998_CYC_TCONF_32] = 15625, - [AD7998_CYC_TCONF_64] = 7812, - [AD7998_CYC_TCONF_128] = 3906, - [AD7998_CYC_TCONF_512] = 976, - [AD7998_CYC_TCONF_1024] = 488, - [AD7998_CYC_TCONF_2048] = 244, -}; -static ssize_t ad799x_read_frequency(struct device *dev, - struct device_attribute *attr, - char *buf) -{ - struct iio_dev *indio_dev = dev_to_iio_dev(dev); - struct ad799x_state *st = iio_priv(indio_dev); - - int ret; - u8 val; - ret = ad799x_i2c_read8(st, AD7998_CYCLE_TMR_REG, &val); - if (ret) - return ret; - - val &= AD7998_CYC_MASK; - - return sprintf(buf, "%u\n", ad7998_frequencies[val]); -} - -static ssize_t ad799x_write_frequency(struct device *dev, - struct device_attribute *attr, - const char *buf, - size_t len) -{ - struct iio_dev *indio_dev = dev_to_iio_dev(dev); - struct ad799x_state *st = iio_priv(indio_dev); - - long val; - int ret, i; - u8 t; - - ret = kstrtol(buf, 10, &val); - if (ret) - return ret; - - mutex_lock(&indio_dev->mlock); - ret = ad799x_i2c_read8(st, AD7998_CYCLE_TMR_REG, &t); - if (ret) - goto error_ret_mutex; - /* Wipe the bits clean */ - t &= ~AD7998_CYC_MASK; - - for (i = 0; i < ARRAY_SIZE(ad7998_frequencies); i++) - if (val == ad7998_frequencies[i]) - break; - if (i == ARRAY_SIZE(ad7998_frequencies)) { - ret = -EINVAL; - goto error_ret_mutex; - } - t |= i; - ret = ad799x_i2c_write8(st, AD7998_CYCLE_TMR_REG, t); - -error_ret_mutex: - mutex_unlock(&indio_dev->mlock); - - return ret ? ret : len; -} - -static int ad799x_read_event_config(struct iio_dev *indio_dev, - const struct iio_chan_spec *chan, - enum iio_event_type type, - enum iio_event_direction dir) -{ - return 1; -} - -static unsigned int ad799x_threshold_reg(const struct iio_chan_spec *chan, - enum iio_event_direction dir, - enum iio_event_info info) -{ - switch (info) { - case IIO_EV_INFO_VALUE: - if (dir == IIO_EV_DIR_FALLING) - return AD7998_DATALOW_REG(chan->channel); - else - return AD7998_DATAHIGH_REG(chan->channel); - case IIO_EV_INFO_HYSTERESIS: - return AD7998_HYST_REG(chan->channel); - default: - return -EINVAL; - } - - return 0; -} - -static int ad799x_write_event_value(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) -{ - int ret; - struct ad799x_state *st = iio_priv(indio_dev); - - mutex_lock(&indio_dev->mlock); - ret = ad799x_i2c_write16(st, ad799x_threshold_reg(chan, dir, info), - val); - mutex_unlock(&indio_dev->mlock); - - return ret; -} - -static int ad799x_read_event_value(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) -{ - int ret; - struct ad799x_state *st = iio_priv(indio_dev); - u16 valin; - - mutex_lock(&indio_dev->mlock); - ret = ad799x_i2c_read16(st, ad799x_threshold_reg(chan, dir, info), - &valin); - mutex_unlock(&indio_dev->mlock); - if (ret < 0) - return ret; - *val = valin; - - return IIO_VAL_INT; -} - -static irqreturn_t ad799x_event_handler(int irq, void *private) -{ - struct iio_dev *indio_dev = private; - struct ad799x_state *st = iio_priv(private); - u8 status; - int i, ret; - - ret = ad799x_i2c_read8(st, AD7998_ALERT_STAT_REG, &status); - if (ret) - goto done; - - if (!status) - goto done; - - ad799x_i2c_write8(st, AD7998_ALERT_STAT_REG, AD7998_ALERT_STAT_CLEAR); - - for (i = 0; i < 8; i++) { - if (status & (1 << i)) - iio_push_event(indio_dev, - i & 0x1 ? - IIO_UNMOD_EVENT_CODE(IIO_VOLTAGE, - (i >> 1), - IIO_EV_TYPE_THRESH, - IIO_EV_DIR_RISING) : - IIO_UNMOD_EVENT_CODE(IIO_VOLTAGE, - (i >> 1), - IIO_EV_TYPE_THRESH, - IIO_EV_DIR_FALLING), - iio_get_time_ns()); - } - -done: - return IRQ_HANDLED; -} - -static IIO_DEV_ATTR_SAMP_FREQ(S_IWUSR | S_IRUGO, - ad799x_read_frequency, - ad799x_write_frequency); -static IIO_CONST_ATTR_SAMP_FREQ_AVAIL("15625 7812 3906 1953 976 488 244 0"); - -static struct attribute *ad799x_event_attributes[] = { - &iio_dev_attr_sampling_frequency.dev_attr.attr, - &iio_const_attr_sampling_frequency_available.dev_attr.attr, - NULL, -}; - -static struct attribute_group ad799x_event_attrs_group = { - .attrs = ad799x_event_attributes, - .name = "events", -}; - -static const struct iio_info ad7991_info = { - .read_raw = &ad799x_read_raw, - .driver_module = THIS_MODULE, -}; - -static const struct iio_info ad7993_4_7_8_info = { - .read_raw = &ad799x_read_raw, - .event_attrs = &ad799x_event_attrs_group, - .read_event_config = &ad799x_read_event_config, - .read_event_value = &ad799x_read_event_value, - .write_event_value = &ad799x_write_event_value, - .driver_module = THIS_MODULE, - .update_scan_mode = ad7997_8_update_scan_mode, -}; - -static const struct iio_event_spec ad799x_events[] = { - { - .type = IIO_EV_TYPE_THRESH, - .dir = IIO_EV_DIR_RISING, - .mask_separate = BIT(IIO_EV_INFO_VALUE) | - BIT(IIO_EV_INFO_ENABLE), - }, { - .type = IIO_EV_TYPE_THRESH, - .dir = IIO_EV_DIR_FALLING, - .mask_separate = BIT(IIO_EV_INFO_VALUE) | - BIT(IIO_EV_INFO_ENABLE), - }, { - .type = IIO_EV_TYPE_THRESH, - .dir = IIO_EV_DIR_EITHER, - .mask_separate = BIT(IIO_EV_INFO_HYSTERESIS), - }, -}; - -#define _AD799X_CHANNEL(_index, _realbits, _ev_spec, _num_ev_spec) { \ - .type = IIO_VOLTAGE, \ - .indexed = 1, \ - .channel = (_index), \ - .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \ - .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), \ - .scan_index = (_index), \ - .scan_type = { \ - .sign = 'u', \ - .realbits = (_realbits), \ - .storagebits = 16, \ - .shift = 12 - (_realbits), \ - .endianness = IIO_BE, \ - }, \ - .event_spec = _ev_spec, \ - .num_event_specs = _num_ev_spec, \ -} - -#define AD799X_CHANNEL(_index, _realbits) \ - _AD799X_CHANNEL(_index, _realbits, NULL, 0) - -#define AD799X_CHANNEL_WITH_EVENTS(_index, _realbits) \ - _AD799X_CHANNEL(_index, _realbits, ad799x_events, \ - ARRAY_SIZE(ad799x_events)) - -static const struct ad799x_chip_info ad799x_chip_info_tbl[] = { - [ad7991] = { - .channel = { - AD799X_CHANNEL(0, 12), - AD799X_CHANNEL(1, 12), - AD799X_CHANNEL(2, 12), - AD799X_CHANNEL(3, 12), - IIO_CHAN_SOFT_TIMESTAMP(4), - }, - .num_channels = 5, - .info = &ad7991_info, - }, - [ad7995] = { - .channel = { - AD799X_CHANNEL(0, 10), - AD799X_CHANNEL(1, 10), - AD799X_CHANNEL(2, 10), - AD799X_CHANNEL(3, 10), - IIO_CHAN_SOFT_TIMESTAMP(4), - }, - .num_channels = 5, - .info = &ad7991_info, - }, - [ad7999] = { - .channel = { - AD799X_CHANNEL(0, 8), - AD799X_CHANNEL(1, 8), - AD799X_CHANNEL(2, 8), - AD799X_CHANNEL(3, 8), - IIO_CHAN_SOFT_TIMESTAMP(4), - }, - .num_channels = 5, - .info = &ad7991_info, - }, - [ad7992] = { - .channel = { - AD799X_CHANNEL_WITH_EVENTS(0, 12), - AD799X_CHANNEL_WITH_EVENTS(1, 12), - IIO_CHAN_SOFT_TIMESTAMP(3), - }, - .num_channels = 3, - .default_config = AD7998_ALERT_EN, - .info = &ad7993_4_7_8_info, - }, - [ad7993] = { - .channel = { - AD799X_CHANNEL_WITH_EVENTS(0, 10), - AD799X_CHANNEL_WITH_EVENTS(1, 10), - AD799X_CHANNEL_WITH_EVENTS(2, 10), - AD799X_CHANNEL_WITH_EVENTS(3, 10), - IIO_CHAN_SOFT_TIMESTAMP(4), - }, - .num_channels = 5, - .default_config = AD7998_ALERT_EN, - .info = &ad7993_4_7_8_info, - }, - [ad7994] = { - .channel = { - AD799X_CHANNEL_WITH_EVENTS(0, 12), - AD799X_CHANNEL_WITH_EVENTS(1, 12), - AD799X_CHANNEL_WITH_EVENTS(2, 12), - AD799X_CHANNEL_WITH_EVENTS(3, 12), - IIO_CHAN_SOFT_TIMESTAMP(4), - }, - .num_channels = 5, - .default_config = AD7998_ALERT_EN, - .info = &ad7993_4_7_8_info, - }, - [ad7997] = { - .channel = { - AD799X_CHANNEL_WITH_EVENTS(0, 10), - AD799X_CHANNEL_WITH_EVENTS(1, 10), - AD799X_CHANNEL_WITH_EVENTS(2, 10), - AD799X_CHANNEL_WITH_EVENTS(3, 10), - AD799X_CHANNEL(4, 10), - AD799X_CHANNEL(5, 10), - AD799X_CHANNEL(6, 10), - AD799X_CHANNEL(7, 10), - IIO_CHAN_SOFT_TIMESTAMP(8), - }, - .num_channels = 9, - .default_config = AD7998_ALERT_EN, - .info = &ad7993_4_7_8_info, - }, - [ad7998] = { - .channel = { - AD799X_CHANNEL_WITH_EVENTS(0, 12), - AD799X_CHANNEL_WITH_EVENTS(1, 12), - AD799X_CHANNEL_WITH_EVENTS(2, 12), - AD799X_CHANNEL_WITH_EVENTS(3, 12), - AD799X_CHANNEL(4, 12), - AD799X_CHANNEL(5, 12), - AD799X_CHANNEL(6, 12), - AD799X_CHANNEL(7, 12), - IIO_CHAN_SOFT_TIMESTAMP(8), - }, - .num_channels = 9, - .default_config = AD7998_ALERT_EN, - .info = &ad7993_4_7_8_info, - }, -}; - -static int ad799x_probe(struct i2c_client *client, - const struct i2c_device_id *id) -{ - int ret; - struct ad799x_state *st; - struct iio_dev *indio_dev; - - indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*st)); - if (indio_dev == NULL) - return -ENOMEM; - - st = iio_priv(indio_dev); - /* this is only used for device removal purposes */ - i2c_set_clientdata(client, indio_dev); - - st->id = id->driver_data; - st->chip_info = &ad799x_chip_info_tbl[st->id]; - st->config = st->chip_info->default_config; - - /* TODO: Add pdata options for filtering and bit delay */ - - st->reg = devm_regulator_get(&client->dev, "vcc"); - if (IS_ERR(st->reg)) - return PTR_ERR(st->reg); - ret = regulator_enable(st->reg); - if (ret) - return ret; - st->vref = devm_regulator_get(&client->dev, "vref"); - if (IS_ERR(st->vref)) { - ret = PTR_ERR(st->vref); - goto error_disable_reg; - } - ret = regulator_enable(st->vref); - if (ret) - goto error_disable_reg; - - st->client = client; - - indio_dev->dev.parent = &client->dev; - indio_dev->name = id->name; - indio_dev->info = st->chip_info->info; - - indio_dev->modes = INDIO_DIRECT_MODE; - indio_dev->channels = st->chip_info->channel; - indio_dev->num_channels = st->chip_info->num_channels; - - ret = iio_triggered_buffer_setup(indio_dev, NULL, - &ad799x_trigger_handler, NULL); - if (ret) - goto error_disable_reg; - - if (client->irq > 0) { - ret = devm_request_threaded_irq(&client->dev, - client->irq, - NULL, - ad799x_event_handler, - IRQF_TRIGGER_FALLING | - IRQF_ONESHOT, - client->name, - indio_dev); - if (ret) - goto error_cleanup_ring; - } - ret = iio_device_register(indio_dev); - if (ret) - goto error_cleanup_ring; - - return 0; - -error_cleanup_ring: - iio_triggered_buffer_cleanup(indio_dev); -error_disable_reg: - if (!IS_ERR(st->vref)) - regulator_disable(st->vref); - if (!IS_ERR(st->reg)) - regulator_disable(st->reg); - - return ret; -} - -static int ad799x_remove(struct i2c_client *client) -{ - struct iio_dev *indio_dev = i2c_get_clientdata(client); - struct ad799x_state *st = iio_priv(indio_dev); - - iio_device_unregister(indio_dev); - - iio_triggered_buffer_cleanup(indio_dev); - if (!IS_ERR(st->vref)) - regulator_disable(st->vref); - if (!IS_ERR(st->reg)) - regulator_disable(st->reg); - kfree(st->rx_buf); - - return 0; -} - -static const struct i2c_device_id ad799x_id[] = { - { "ad7991", ad7991 }, - { "ad7995", ad7995 }, - { "ad7999", ad7999 }, - { "ad7992", ad7992 }, - { "ad7993", ad7993 }, - { "ad7994", ad7994 }, - { "ad7997", ad7997 }, - { "ad7998", ad7998 }, - {} -}; - -MODULE_DEVICE_TABLE(i2c, ad799x_id); - -static struct i2c_driver ad799x_driver = { - .driver = { - .name = "ad799x", - }, - .probe = ad799x_probe, - .remove = ad799x_remove, - .id_table = ad799x_id, -}; -module_i2c_driver(ad799x_driver); - -MODULE_AUTHOR("Michael Hennerich "); -MODULE_DESCRIPTION("Analog Devices AD799x ADC"); -MODULE_LICENSE("GPL v2"); -- cgit v1.2.3 From 2816ac64ac46c4017355a49331250e5c016dc2c0 Mon Sep 17 00:00:00 2001 From: Angelo Compagnucci Date: Sun, 3 Aug 2014 23:22:00 +0100 Subject: Add support for Microchip Technology's MCP3426/7/8 ADC This patch extends previous mcp3422 driver to support missing members of the family, mcp3426/7/8. Signed-off-by: Angelo Compagnucci Signed-off-by: Jonathan Cameron --- drivers/iio/adc/Kconfig | 7 ++++--- drivers/iio/adc/mcp3422.c | 33 ++++++++++++++++++++++++++++----- 2 files changed, 32 insertions(+), 8 deletions(-) diff --git a/drivers/iio/adc/Kconfig b/drivers/iio/adc/Kconfig index a0368119c275..1dffa2d56262 100644 --- a/drivers/iio/adc/Kconfig +++ b/drivers/iio/adc/Kconfig @@ -157,11 +157,12 @@ config MCP320X called mcp320x. config MCP3422 - tristate "Microchip Technology MCP3422/3/4 driver" + tristate "Microchip Technology MCP3422/3/4/6/7/8 driver" depends on I2C help - Say yes here to build support for Microchip Technology's MCP3422, - MCP3423 or MCP3424 analog to digital converters. + Say yes here to build support for Microchip Technology's + MCP3422, MCP3423, MCP3424, MCP3426, MCP3427 or MCP3428 + analog to digital converters. This driver can also be built as a module. If so, the module will be called mcp3422. diff --git a/drivers/iio/adc/mcp3422.c b/drivers/iio/adc/mcp3422.c index 47dcb34ff44c..51672256072b 100644 --- a/drivers/iio/adc/mcp3422.c +++ b/drivers/iio/adc/mcp3422.c @@ -1,10 +1,11 @@ /* - * mcp3422.c - driver for the Microchip mcp3422/3/4 chip family + * mcp3422.c - driver for the Microchip mcp3422/3/4/6/7/8 chip family * * Copyright (C) 2013, Angelo Compagnucci * Author: Angelo Compagnucci * * Datasheet: http://ww1.microchip.com/downloads/en/devicedoc/22088b.pdf + * http://ww1.microchip.com/downloads/en/DeviceDoc/22226a.pdf * * This driver exports the value of analog input voltage to sysfs, the * voltage unit is nV. @@ -96,6 +97,7 @@ static const int mcp3422_sign_extend[4] = { /* Client data (each client gets its own) */ struct mcp3422 { struct i2c_client *i2c; + u8 id; u8 config; u8 pga[4]; struct mutex lock; @@ -238,6 +240,8 @@ static int mcp3422_write_raw(struct iio_dev *iio, temp = MCP3422_SRATE_15; break; case 3: + if (adc->id > 4) + return -EINVAL; temp = MCP3422_SRATE_3; break; default: @@ -271,6 +275,17 @@ static int mcp3422_write_raw_get_fmt(struct iio_dev *indio_dev, } } +static ssize_t mcp3422_show_samp_freqs(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct mcp3422 *adc = iio_priv(dev_to_iio_dev(dev)); + + if (adc->id > 4) + return sprintf(buf, "240 60 15\n"); + + return sprintf(buf, "240 60 15 3\n"); +} + static ssize_t mcp3422_show_scales(struct device *dev, struct device_attribute *attr, char *buf) { @@ -284,12 +299,13 @@ static ssize_t mcp3422_show_scales(struct device *dev, mcp3422_scales[sample_rate][3]); } -static IIO_CONST_ATTR_SAMP_FREQ_AVAIL("240 60 15 3"); +static IIO_DEVICE_ATTR(sampling_frequency_available, S_IRUGO, + mcp3422_show_samp_freqs, NULL, 0); static IIO_DEVICE_ATTR(in_voltage_scale_available, S_IRUGO, mcp3422_show_scales, NULL, 0); static struct attribute *mcp3422_attributes[] = { - &iio_const_attr_sampling_frequency_available.dev_attr.attr, + &iio_dev_attr_sampling_frequency_available.dev_attr.attr, &iio_dev_attr_in_voltage_scale_available.dev_attr.attr, NULL, }; @@ -335,6 +351,7 @@ static int mcp3422_probe(struct i2c_client *client, adc = iio_priv(indio_dev); adc->i2c = client; + adc->id = (u8)(id->driver_data); mutex_init(&adc->lock); @@ -343,13 +360,16 @@ static int mcp3422_probe(struct i2c_client *client, indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->info = &mcp3422_info; - switch ((unsigned int)(id->driver_data)) { + switch (adc->id) { case 2: case 3: + case 6: + case 7: indio_dev->channels = mcp3422_channels; indio_dev->num_channels = ARRAY_SIZE(mcp3422_channels); break; case 4: + case 8: indio_dev->channels = mcp3424_channels; indio_dev->num_channels = ARRAY_SIZE(mcp3424_channels); break; @@ -375,6 +395,9 @@ static const struct i2c_device_id mcp3422_id[] = { { "mcp3422", 2 }, { "mcp3423", 3 }, { "mcp3424", 4 }, + { "mcp3426", 6 }, + { "mcp3427", 7 }, + { "mcp3428", 8 }, { } }; MODULE_DEVICE_TABLE(i2c, mcp3422_id); @@ -399,5 +422,5 @@ static struct i2c_driver mcp3422_driver = { module_i2c_driver(mcp3422_driver); MODULE_AUTHOR("Angelo Compagnucci "); -MODULE_DESCRIPTION("Microchip mcp3422/3/4 driver"); +MODULE_DESCRIPTION("Microchip mcp3422/3/4/6/7/8 driver"); MODULE_LICENSE("GPL v2"); -- cgit v1.2.3 From ef4b4856593fc3d9d169bededdaf7acf62f83a52 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Fri, 3 Jan 2014 22:24:00 +0000 Subject: iio:core: Fix bug in length of event info_mask and catch unhandled bits set in masks. The unhandled bits case was highlighted by smatch: CHECK drivers/iio/industrialio-core.c drivers/iio/industrialio-core.c:719 iio_device_add_info_mask_type() error: buffer overflow 'iio_chan_info_postfix' 17 <= 31 CC [M] drivers/iio/industrialio-core.o CHECK drivers/iio/industrialio-event.c drivers/iio/industrialio-event.c:327 iio_device_add_event() error: buffer overflow 'iio_ev_info_text' 3 <= 3 The incorrect limit for the for_each_set_bit loop was noticed whilst fixing this other case. Note that as we only have 3 possible entries a the moment and the value was set to 4, the bug would not have any effect currently. It will bite fairly soon though, so best fix it now. Signed-off-by: Jonathan Cameron Cc: Lars-Peter Clausen Cc: Dan Carpenter --- drivers/iio/industrialio-core.c | 2 ++ drivers/iio/industrialio-event.c | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c index 1375921d8261..184444db62ac 100644 --- a/drivers/iio/industrialio-core.c +++ b/drivers/iio/industrialio-core.c @@ -716,6 +716,8 @@ static int iio_device_add_info_mask_type(struct iio_dev *indio_dev, int i, ret, attrcount = 0; for_each_set_bit(i, infomask, sizeof(infomask)*8) { + if (i >= ARRAY_SIZE(iio_chan_info_postfix)) + return -EINVAL; ret = __iio_add_chan_devattr(iio_chan_info_postfix[i], chan, &iio_read_channel_info, diff --git a/drivers/iio/industrialio-event.c b/drivers/iio/industrialio-event.c index ea6e06b9c7d4..dddfb0f90d34 100644 --- a/drivers/iio/industrialio-event.c +++ b/drivers/iio/industrialio-event.c @@ -321,7 +321,9 @@ static int iio_device_add_event(struct iio_dev *indio_dev, char *postfix; int ret; - for_each_set_bit(i, mask, sizeof(*mask)) { + for_each_set_bit(i, mask, sizeof(*mask)*8) { + if (i >= ARRAY_SIZE(iio_ev_info_text)) + return -EINVAL; postfix = kasprintf(GFP_KERNEL, "%s_%s_%s", iio_ev_type_text[type], iio_ev_dir_text[dir], iio_ev_info_text[i]); -- cgit v1.2.3 From 239670ef48dfff9cf07675acdb3bb7deee4853e1 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Fri, 3 Jan 2014 22:08:00 +0000 Subject: iio:gyro:itg3200 - drop unreachable return ret. Highlighted by smatch CHECK drivers/iio/gyro/itg3200_core.c drivers/iio/gyro/itg3200_core.c:114 itg3200_read_raw() info: ignoring unreachable code. Signed-off-by: Jonathan Cameron Cc: Neil Brown Cc: Dan Carpenter --- drivers/iio/gyro/itg3200_core.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/iio/gyro/itg3200_core.c b/drivers/iio/gyro/itg3200_core.c index 4d3f3b92b361..8295e318399f 100644 --- a/drivers/iio/gyro/itg3200_core.c +++ b/drivers/iio/gyro/itg3200_core.c @@ -110,8 +110,6 @@ static int itg3200_read_raw(struct iio_dev *indio_dev, default: return -EINVAL; } - - return ret; } static ssize_t itg3200_read_frequency(struct device *dev, -- cgit v1.2.3 From 6027c077f62f11818a7645151119f8718862d764 Mon Sep 17 00:00:00 2001 From: Srinivas Pandruvada Date: Wed, 19 Mar 2014 16:56:00 +0000 Subject: iio: ak8975 : Add AK8963 compatibility mode support AK8963 and AK8975 use same register definitions, except the range of X,Y,Z values. Added support of 8963 based on i2c_device_id. Unfortunately there is no way to detect the type via registers, both device registers return 0x48 as id of chipset. Signed-off-by: Srinivas Pandruvada Signed-off-by: Jonathan Cameron --- drivers/iio/magnetometer/Kconfig | 3 ++- drivers/iio/magnetometer/ak8975.c | 34 +++++++++++++++++++++++++++++----- 2 files changed, 31 insertions(+), 6 deletions(-) diff --git a/drivers/iio/magnetometer/Kconfig b/drivers/iio/magnetometer/Kconfig index d86d226dcd67..05a364c543f8 100644 --- a/drivers/iio/magnetometer/Kconfig +++ b/drivers/iio/magnetometer/Kconfig @@ -11,7 +11,8 @@ config AK8975 depends on GPIOLIB help Say yes here to build support for Asahi Kasei AK8975 3-Axis - Magnetometer. + Magnetometer. This driver can also support AK8963, if i2c + device name is identified as ak8963. To compile this driver as a module, choose M here: the module will be called ak8975. diff --git a/drivers/iio/magnetometer/ak8975.c b/drivers/iio/magnetometer/ak8975.c index 74866d1efd1b..0f1ca5303139 100644 --- a/drivers/iio/magnetometer/ak8975.c +++ b/drivers/iio/magnetometer/ak8975.c @@ -85,7 +85,14 @@ #define AK8975_MAX_CONVERSION_TIMEOUT 500 #define AK8975_CONVERSION_DONE_POLL_TIME 10 #define AK8975_DATA_READY_TIMEOUT ((100*HZ)/1000) -#define RAW_TO_GAUSS(asa) ((((asa) + 128) * 3000) / 256) +#define RAW_TO_GAUSS_8975(asa) ((((asa) + 128) * 3000) / 256) +#define RAW_TO_GAUSS_8963(asa) ((((asa) + 128) * 6000) / 256) + +/* Compatible Asahi Kasei Compass parts */ +enum asahi_compass_chipset { + AK8975, + AK8963, +}; /* * Per-instance context data for the device. @@ -101,6 +108,7 @@ struct ak8975_data { int eoc_irq; wait_queue_head_t data_ready_queue; unsigned long flags; + enum asahi_compass_chipset chipset; }; static const int ak8975_index_to_reg[] = { @@ -272,9 +280,21 @@ static int ak8975_setup(struct i2c_client *client) * Since ASA doesn't change, we cache the resultant scale factor into the * device context in ak8975_setup(). */ - data->raw_to_gauss[0] = RAW_TO_GAUSS(data->asa[0]); - data->raw_to_gauss[1] = RAW_TO_GAUSS(data->asa[1]); - data->raw_to_gauss[2] = RAW_TO_GAUSS(data->asa[2]); + if (data->chipset == AK8963) { + /* + * H range is +-8190 and magnetometer range is +-4912. + * So HuT using the above explanation for 8975, + * 4912/8190 = ~ 6/10. + * So the Hadj should use 6/10 instead of 3/10. + */ + data->raw_to_gauss[0] = RAW_TO_GAUSS_8963(data->asa[0]); + data->raw_to_gauss[1] = RAW_TO_GAUSS_8963(data->asa[1]); + data->raw_to_gauss[2] = RAW_TO_GAUSS_8963(data->asa[2]); + } else { + data->raw_to_gauss[0] = RAW_TO_GAUSS_8975(data->asa[0]); + data->raw_to_gauss[1] = RAW_TO_GAUSS_8975(data->asa[1]); + data->raw_to_gauss[2] = RAW_TO_GAUSS_8975(data->asa[2]); + } return 0; } @@ -499,6 +519,9 @@ static int ak8975_probe(struct i2c_client *client, data->eoc_gpio = eoc_gpio; data->eoc_irq = 0; + data->chipset = (enum asahi_compass_chipset)(id->driver_data); + dev_dbg(&client->dev, "Asahi compass chip %s\n", id->name); + /* Perform some basic start-of-day setup of the device. */ err = ak8975_setup(client); if (err < 0) { @@ -552,7 +575,8 @@ static int ak8975_remove(struct i2c_client *client) } static const struct i2c_device_id ak8975_id[] = { - {"ak8975", 0}, + {"ak8975", AK8975}, + {"ak8963", AK8963}, {} }; -- cgit v1.2.3 From 1dc7d8374dccf2815294ceb6a1092253f45ba860 Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Thu, 27 Feb 2014 14:44:17 +0100 Subject: ARM/leds: move ARM Versatile LED driver to leds subsystem Now that we have converted this driver to a real platform device module-based thing, we move the driver down into the LEDs subsystem and rename the config option to LEDS_VERSATILE. Cc: Richard Purdie Cc: Russell King Cc: Pawel Moll Acked-by: Bryan Wu Signed-off-by: Linus Walleij --- arch/arm/plat-versatile/Kconfig | 6 --- arch/arm/plat-versatile/Makefile | 1 - arch/arm/plat-versatile/leds.c | 110 --------------------------------------- drivers/leds/Kconfig | 8 +++ drivers/leds/Makefile | 1 + drivers/leds/leds-versatile.c | 110 +++++++++++++++++++++++++++++++++++++++ 6 files changed, 119 insertions(+), 117 deletions(-) delete mode 100644 arch/arm/plat-versatile/leds.c create mode 100644 drivers/leds/leds-versatile.c diff --git a/arch/arm/plat-versatile/Kconfig b/arch/arm/plat-versatile/Kconfig index 2c4332b9f948..fce41e93b6a4 100644 --- a/arch/arm/plat-versatile/Kconfig +++ b/arch/arm/plat-versatile/Kconfig @@ -6,12 +6,6 @@ config PLAT_VERSATILE_CLOCK config PLAT_VERSATILE_CLCD bool -config PLAT_VERSATILE_LEDS - def_bool y if NEW_LEDS - depends on ARCH_REALVIEW || ARCH_VERSATILE - select LEDS_CLASS - select LEDS_TRIGGERS - config PLAT_VERSATILE_SCHED_CLOCK def_bool y diff --git a/arch/arm/plat-versatile/Makefile b/arch/arm/plat-versatile/Makefile index f88d448b629c..2e0c472958ae 100644 --- a/arch/arm/plat-versatile/Makefile +++ b/arch/arm/plat-versatile/Makefile @@ -2,6 +2,5 @@ ccflags-$(CONFIG_ARCH_MULTIPLATFORM) := -I$(srctree)/$(src)/include obj-$(CONFIG_PLAT_VERSATILE_CLOCK) += clock.o obj-$(CONFIG_PLAT_VERSATILE_CLCD) += clcd.o -obj-$(CONFIG_PLAT_VERSATILE_LEDS) += leds.o obj-$(CONFIG_PLAT_VERSATILE_SCHED_CLOCK) += sched-clock.o obj-$(CONFIG_SMP) += headsmp.o platsmp.o diff --git a/arch/arm/plat-versatile/leds.c b/arch/arm/plat-versatile/leds.c deleted file mode 100644 index 80553022d661..000000000000 --- a/arch/arm/plat-versatile/leds.c +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Driver for the 8 user LEDs found on the RealViews and Versatiles - * Based on DaVinci's DM365 board code - * - * License terms: GNU General Public License (GPL) version 2 - * Author: Linus Walleij - */ -#include -#include -#include -#include -#include -#include -#include - -struct versatile_led { - void __iomem *base; - struct led_classdev cdev; - u8 mask; -}; - -/* - * The triggers lines up below will only be used if the - * LED triggers are compiled in. - */ -static const struct { - const char *name; - const char *trigger; -} versatile_leds[] = { - { "versatile:0", "heartbeat", }, - { "versatile:1", "mmc0", }, - { "versatile:2", "cpu0" }, - { "versatile:3", "cpu1" }, - { "versatile:4", "cpu2" }, - { "versatile:5", "cpu3" }, - { "versatile:6", }, - { "versatile:7", }, -}; - -static void versatile_led_set(struct led_classdev *cdev, - enum led_brightness b) -{ - struct versatile_led *led = container_of(cdev, - struct versatile_led, cdev); - u32 reg = readl(led->base); - - if (b != LED_OFF) - reg |= led->mask; - else - reg &= ~led->mask; - writel(reg, led->base); -} - -static enum led_brightness versatile_led_get(struct led_classdev *cdev) -{ - struct versatile_led *led = container_of(cdev, - struct versatile_led, cdev); - u32 reg = readl(led->base); - - return (reg & led->mask) ? LED_FULL : LED_OFF; -} - -static int versatile_leds_probe(struct platform_device *dev) -{ - int i; - struct resource *res; - void __iomem *base; - - res = platform_get_resource(dev, IORESOURCE_MEM, 0); - base = devm_ioremap_resource(&dev->dev, res); - if (IS_ERR(base)) - return PTR_ERR(base); - - /* All off */ - writel(0, base); - for (i = 0; i < ARRAY_SIZE(versatile_leds); i++) { - struct versatile_led *led; - - led = kzalloc(sizeof(*led), GFP_KERNEL); - if (!led) - break; - - led->base = base; - led->cdev.name = versatile_leds[i].name; - led->cdev.brightness_set = versatile_led_set; - led->cdev.brightness_get = versatile_led_get; - led->cdev.default_trigger = versatile_leds[i].trigger; - led->mask = BIT(i); - - if (led_classdev_register(NULL, &led->cdev) < 0) { - kfree(led); - break; - } - } - - return 0; -} - -static struct platform_driver versatile_leds_driver = { - .driver = { - .name = "versatile-leds", - }, - .probe = versatile_leds_probe, -}; - -module_platform_driver(versatile_leds_driver); - -MODULE_AUTHOR("Linus Walleij "); -MODULE_DESCRIPTION("ARM Versatile LED driver"); -MODULE_LICENSE("GPL v2"); diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig index 72156c123033..93235f7378ba 100644 --- a/drivers/leds/Kconfig +++ b/drivers/leds/Kconfig @@ -487,6 +487,14 @@ config LEDS_BLINKM This option enables support for the BlinkM RGB LED connected through I2C. Say Y to enable support for the BlinkM LED. +config LEDS_VERSATILE + bool "LED support for the ARM Versatile and RealView" + depends on ARCH_REALVIEW || ARCH_VERSATILE + depends on LEDS_CLASS + help + This option enabled support for the LEDs on the ARM Versatile + and RealView boards. Say Y to enabled these. + comment "LED Triggers" source "drivers/leds/trigger/Kconfig" diff --git a/drivers/leds/Makefile b/drivers/leds/Makefile index 3cd76dbd9be2..8b4c956e11ba 100644 --- a/drivers/leds/Makefile +++ b/drivers/leds/Makefile @@ -54,6 +54,7 @@ obj-$(CONFIG_LEDS_ASIC3) += leds-asic3.o obj-$(CONFIG_LEDS_MAX8997) += leds-max8997.o obj-$(CONFIG_LEDS_LM355x) += leds-lm355x.o obj-$(CONFIG_LEDS_BLINKM) += leds-blinkm.o +obj-$(CONFIG_LEDS_VERSATILE) += leds-versatile.o # LED SPI Drivers obj-$(CONFIG_LEDS_DAC124S085) += leds-dac124s085.o diff --git a/drivers/leds/leds-versatile.c b/drivers/leds/leds-versatile.c new file mode 100644 index 000000000000..80553022d661 --- /dev/null +++ b/drivers/leds/leds-versatile.c @@ -0,0 +1,110 @@ +/* + * Driver for the 8 user LEDs found on the RealViews and Versatiles + * Based on DaVinci's DM365 board code + * + * License terms: GNU General Public License (GPL) version 2 + * Author: Linus Walleij + */ +#include +#include +#include +#include +#include +#include +#include + +struct versatile_led { + void __iomem *base; + struct led_classdev cdev; + u8 mask; +}; + +/* + * The triggers lines up below will only be used if the + * LED triggers are compiled in. + */ +static const struct { + const char *name; + const char *trigger; +} versatile_leds[] = { + { "versatile:0", "heartbeat", }, + { "versatile:1", "mmc0", }, + { "versatile:2", "cpu0" }, + { "versatile:3", "cpu1" }, + { "versatile:4", "cpu2" }, + { "versatile:5", "cpu3" }, + { "versatile:6", }, + { "versatile:7", }, +}; + +static void versatile_led_set(struct led_classdev *cdev, + enum led_brightness b) +{ + struct versatile_led *led = container_of(cdev, + struct versatile_led, cdev); + u32 reg = readl(led->base); + + if (b != LED_OFF) + reg |= led->mask; + else + reg &= ~led->mask; + writel(reg, led->base); +} + +static enum led_brightness versatile_led_get(struct led_classdev *cdev) +{ + struct versatile_led *led = container_of(cdev, + struct versatile_led, cdev); + u32 reg = readl(led->base); + + return (reg & led->mask) ? LED_FULL : LED_OFF; +} + +static int versatile_leds_probe(struct platform_device *dev) +{ + int i; + struct resource *res; + void __iomem *base; + + res = platform_get_resource(dev, IORESOURCE_MEM, 0); + base = devm_ioremap_resource(&dev->dev, res); + if (IS_ERR(base)) + return PTR_ERR(base); + + /* All off */ + writel(0, base); + for (i = 0; i < ARRAY_SIZE(versatile_leds); i++) { + struct versatile_led *led; + + led = kzalloc(sizeof(*led), GFP_KERNEL); + if (!led) + break; + + led->base = base; + led->cdev.name = versatile_leds[i].name; + led->cdev.brightness_set = versatile_led_set; + led->cdev.brightness_get = versatile_led_get; + led->cdev.default_trigger = versatile_leds[i].trigger; + led->mask = BIT(i); + + if (led_classdev_register(NULL, &led->cdev) < 0) { + kfree(led); + break; + } + } + + return 0; +} + +static struct platform_driver versatile_leds_driver = { + .driver = { + .name = "versatile-leds", + }, + .probe = versatile_leds_probe, +}; + +module_platform_driver(versatile_leds_driver); + +MODULE_AUTHOR("Linus Walleij "); +MODULE_DESCRIPTION("ARM Versatile LED driver"); +MODULE_LICENSE("GPL v2"); -- cgit v1.2.3 From 9b58d187fdce9df05fd331ad5790bf503d7e3dfe Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Thu, 27 Feb 2014 14:51:28 +0100 Subject: ARM: plat-versatile: update defconfigs for Versatile LEDs As we moved the Versatile LEDs to the LEDs subsystem and made it a module, the config options are no more default-selected. Make sure all users still experience LEDs properly by updating all RealView and Versatile defconfigs. Cc: Bryan Wu Cc: Richard Purdie Cc: Russell King Cc: Pawel Moll Signed-off-by: Linus Walleij --- arch/arm/configs/realview-smp_defconfig | 2 ++ arch/arm/configs/realview_defconfig | 2 ++ arch/arm/configs/versatile_defconfig | 3 +++ 3 files changed, 7 insertions(+) diff --git a/arch/arm/configs/realview-smp_defconfig b/arch/arm/configs/realview-smp_defconfig index abe61bf379d2..1da5d9e48224 100644 --- a/arch/arm/configs/realview-smp_defconfig +++ b/arch/arm/configs/realview-smp_defconfig @@ -76,8 +76,10 @@ CONFIG_MMC=y CONFIG_MMC_ARMMMCI=y CONFIG_NEW_LEDS=y CONFIG_LEDS_CLASS=y +CONFIG_LEDS_VERSATILE=y CONFIG_LEDS_TRIGGERS=y CONFIG_LEDS_TRIGGER_HEARTBEAT=y +CONFIG_LEDS_TRIGGER_CPU=y CONFIG_RTC_CLASS=y CONFIG_RTC_DRV_DS1307=y CONFIG_RTC_DRV_PL031=y diff --git a/arch/arm/configs/realview_defconfig b/arch/arm/configs/realview_defconfig index 7079cbe898a8..d02e9d911bb7 100644 --- a/arch/arm/configs/realview_defconfig +++ b/arch/arm/configs/realview_defconfig @@ -75,8 +75,10 @@ CONFIG_MMC=y CONFIG_MMC_ARMMMCI=y CONFIG_NEW_LEDS=y CONFIG_LEDS_CLASS=y +CONFIG_LEDS_VERSATILE=y CONFIG_LEDS_TRIGGERS=y CONFIG_LEDS_TRIGGER_HEARTBEAT=y +CONFIG_LEDS_TRIGGER_CPU=y CONFIG_RTC_CLASS=y CONFIG_RTC_DRV_DS1307=y CONFIG_RTC_DRV_PL031=y diff --git a/arch/arm/configs/versatile_defconfig b/arch/arm/configs/versatile_defconfig index 073541a50e23..d52b4ffe2012 100644 --- a/arch/arm/configs/versatile_defconfig +++ b/arch/arm/configs/versatile_defconfig @@ -61,6 +61,9 @@ CONFIG_SND_ARMAACI=m CONFIG_MMC=y CONFIG_MMC_ARMMMCI=m CONFIG_NEW_LEDS=y +CONFIG_LEDS_CLASS=y +CONFIG_LEDS_VERSATILE=y +CONFIG_LEDS_TRIGGERS=y CONFIG_LEDS_TRIGGER_HEARTBEAT=y CONFIG_LEDS_TRIGGER_CPU=y CONFIG_EXT2_FS=y -- cgit v1.2.3 From d913971ecaf31d7d5a6836224b669e1972469445 Mon Sep 17 00:00:00 2001 From: Srinivas Pandruvada Date: Wed, 19 Mar 2014 16:56:00 +0000 Subject: iio: ak8975: Added ACPI enumeration Added capability so that this device can be enumerated via ACPI. Signed-off-by: Srinivas Pandruvada Signed-off-by: Jonathan Cameron --- drivers/iio/magnetometer/ak8975.c | 40 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 37 insertions(+), 3 deletions(-) diff --git a/drivers/iio/magnetometer/ak8975.c b/drivers/iio/magnetometer/ak8975.c index 0f1ca5303139..f5c1d41bf39f 100644 --- a/drivers/iio/magnetometer/ak8975.c +++ b/drivers/iio/magnetometer/ak8975.c @@ -31,6 +31,7 @@ #include #include #include +#include #include #include @@ -475,6 +476,27 @@ static const struct iio_info ak8975_info = { .driver_module = THIS_MODULE, }; +static const struct acpi_device_id ak_acpi_match[] = { + {"AK8975", AK8975}, + {"AK8963", AK8963}, + {"INVN6500", AK8963}, + { }, +}; +MODULE_DEVICE_TABLE(acpi, ak_acpi_match); + +static char *ak8975_match_acpi_device(struct device *dev, + enum asahi_compass_chipset *chipset) +{ + const struct acpi_device_id *id; + + id = acpi_match_device(dev->driver->acpi_match_table, dev); + if (!id) + return NULL; + *chipset = (int)id->driver_data; + + return (char *)dev_name(dev); +} + static int ak8975_probe(struct i2c_client *client, const struct i2c_device_id *id) { @@ -482,6 +504,7 @@ static int ak8975_probe(struct i2c_client *client, struct iio_dev *indio_dev; int eoc_gpio; int err; + char *name = NULL; /* Grab and set up the supplied GPIO. */ if (client->dev.platform_data) @@ -519,8 +542,18 @@ static int ak8975_probe(struct i2c_client *client, data->eoc_gpio = eoc_gpio; data->eoc_irq = 0; - data->chipset = (enum asahi_compass_chipset)(id->driver_data); - dev_dbg(&client->dev, "Asahi compass chip %s\n", id->name); + /* id will be NULL when enumerated via ACPI */ + if (id) { + data->chipset = + (enum asahi_compass_chipset)(id->driver_data); + name = (char *) id->name; + } else if (ACPI_HANDLE(&client->dev)) + name = ak8975_match_acpi_device(&client->dev, &data->chipset); + else { + err = -ENOSYS; + goto exit_free_iio; + } + dev_dbg(&client->dev, "Asahi compass chip %s\n", name); /* Perform some basic start-of-day setup of the device. */ err = ak8975_setup(client); @@ -538,7 +571,7 @@ static int ak8975_probe(struct i2c_client *client, indio_dev->info = &ak8975_info; indio_dev->name = id->name; indio_dev->modes = INDIO_DIRECT_MODE; - + indio_dev->name = name; err = iio_device_register(indio_dev); if (err < 0) goto exit_free_iio; @@ -593,6 +626,7 @@ static struct i2c_driver ak8975_driver = { .driver = { .name = "ak8975", .of_match_table = ak8975_of_match, + .acpi_match_table = ACPI_PTR(ak_acpi_match), }, .probe = ak8975_probe, .remove = ak8975_remove, -- cgit v1.2.3 From 6f174fd312d50abf3e98c0c5f7adf0cf434ae705 Mon Sep 17 00:00:00 2001 From: Srinivas Pandruvada Date: Wed, 19 Mar 2014 16:56:00 +0000 Subject: iio: imu: inv_mpu6050: Add compatibity with MPU6500 Adding MPU6500 in target list for this driver. Description: Source Document: MPU-6500 Register Map and Descriptions Revision 2.1 Section 3: Register Map This section describes difference in terms device programmability between MPU6050 and MPU6500. These are different registers, which differs between MPU6050 and MPU6500. Addr Name --------------------- 1E LP_ACCEL_ODR 6C PWR_MGMT_2 77 XA_OFFSET_H 78 XA_OFFSET_L 7A YA_OFFSET_H 7B YA_OFFSET_L 7D ZA_OFFSET_H 7E ZA_OFFSET_L But the current MPU6050 driver doesn't use registers which are different except PWR_MGMT_2. The difference is support of "LP_WAKE_CTRL" at bit6-7 in MPU6050 mode. In MPU6500 they are not defined. In current mpu6050 driver, only values used for this register are for standby mode for gyro and accelerometer. In both case frequency of wakeups is set to default and not using bit 6-7. So this driver van as well support MPU6500. In addition MPU6500 can run MPU6050 mode by changing device trim settings. So changing config comments to allow MPU6500 to use this driver. When the driver is enhanced to support more functions, i2c driver data INV_MPU6500 or "WHO_AM_I" register can be used to add additional functionality. Signed-off-by: Srinivas Pandruvada Signed-off-by: Jonathan Cameron --- drivers/iio/imu/inv_mpu6050/Kconfig | 2 ++ drivers/iio/imu/inv_mpu6050/inv_mpu_core.c | 1 + drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h | 1 + 3 files changed, 4 insertions(+) diff --git a/drivers/iio/imu/inv_mpu6050/Kconfig b/drivers/iio/imu/inv_mpu6050/Kconfig index 361b2328453d..2d0608ba88d7 100644 --- a/drivers/iio/imu/inv_mpu6050/Kconfig +++ b/drivers/iio/imu/inv_mpu6050/Kconfig @@ -9,6 +9,8 @@ config INV_MPU6050_IIO select IIO_TRIGGERED_BUFFER help This driver supports the Invensense MPU6050 devices. + This driver can also support MPU6500 in MPU6050 compatibility mode + and also in MPU6500 mode with some limitations. It is a gyroscope/accelerometer combo device. This driver can be built as a module. The module will be called inv-mpu6050. diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c index cb9f96b446a5..af287bf71915 100644 --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c @@ -764,6 +764,7 @@ static SIMPLE_DEV_PM_OPS(inv_mpu_pmops, inv_mpu_suspend, inv_mpu_resume); */ static const struct i2c_device_id inv_mpu_id[] = { {"mpu6050", INV_MPU6050}, + {"mpu6500", INV_MPU6500}, {} }; diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h b/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h index 0ab382be1e64..e7799315d4dc 100644 --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h @@ -59,6 +59,7 @@ struct inv_mpu6050_reg_map { /*device enum */ enum inv_devices { INV_MPU6050, + INV_MPU6500, INV_NUM_PARTS }; -- cgit v1.2.3 From 5f40f7d93898a473eb222aa8064144c1d6835470 Mon Sep 17 00:00:00 2001 From: Dimitri Sivanich Date: Mon, 31 Mar 2014 09:37:00 -0500 Subject: x86/UV: Set n_lshift based on GAM_GR_CONFIG MMR for UV3 The value of n_lshift for UV is currently set based on the socket m_val. For UV3, set the n_lshift value based on the GAM_GR_CONFIG MMR. This will allow bios to control the n_lshift value independent of the socket m_val. Then n_lshift can be assigned a fixed value across a multi-partition system, allowing for a fixed common global physical address format that is independent of socket m_val. Cleanup unneeded macros. Signed-off-by: Dimitri Sivanich Link: http://lkml.kernel.org/r/20140331143700.GB29916@sgi.com Signed-off-by: Ingo Molnar --- arch/x86/include/asm/uv/uv_hub.h | 12 +---------- arch/x86/include/asm/uv/uv_mmrs.h | 42 +++++++++++++++++++++++++++++++++++++- arch/x86/kernel/apic/x2apic_uv_x.c | 26 ++++++++++++++++++----- 3 files changed, 63 insertions(+), 17 deletions(-) diff --git a/arch/x86/include/asm/uv/uv_hub.h b/arch/x86/include/asm/uv/uv_hub.h index a30836c8ac4d..c63e925fd6b7 100644 --- a/arch/x86/include/asm/uv/uv_hub.h +++ b/arch/x86/include/asm/uv/uv_hub.h @@ -5,7 +5,7 @@ * * SGI UV architectural definitions * - * Copyright (C) 2007-2013 Silicon Graphics, Inc. All rights reserved. + * Copyright (C) 2007-2014 Silicon Graphics, Inc. All rights reserved. */ #ifndef _ASM_X86_UV_UV_HUB_H @@ -204,16 +204,6 @@ static inline int is_uvx_hub(void) return uv_hub_info->hub_revision >= UV2_HUB_REVISION_BASE; } -static inline int is_uv2_1_hub(void) -{ - return uv_hub_info->hub_revision == UV2_HUB_REVISION_BASE; -} - -static inline int is_uv2_2_hub(void) -{ - return uv_hub_info->hub_revision == UV2_HUB_REVISION_BASE + 1; -} - union uvh_apicid { unsigned long v; struct uvh_apicid_s { diff --git a/arch/x86/include/asm/uv/uv_mmrs.h b/arch/x86/include/asm/uv/uv_mmrs.h index e42249bcf7e1..ddd8db6b6e70 100644 --- a/arch/x86/include/asm/uv/uv_mmrs.h +++ b/arch/x86/include/asm/uv/uv_mmrs.h @@ -5,7 +5,7 @@ * * SGI UV MMR definitions * - * Copyright (C) 2007-2013 Silicon Graphics, Inc. All rights reserved. + * Copyright (C) 2007-2014 Silicon Graphics, Inc. All rights reserved. */ #ifndef _ASM_X86_UV_UV_MMRS_H @@ -2802,6 +2802,46 @@ union uv1h_lb_target_physical_apic_id_mask_u { } s1; }; +/* ========================================================================= */ +/* UV3H_GR0_GAM_GR_CONFIG */ +/* ========================================================================= */ +#define UV3H_GR0_GAM_GR_CONFIG 0xc00028UL + +#define UV3H_GR0_GAM_GR_CONFIG_M_SKT_SHFT 0 +#define UV3H_GR0_GAM_GR_CONFIG_SUBSPACE_SHFT 10 +#define UV3H_GR0_GAM_GR_CONFIG_M_SKT_MASK 0x000000000000003fUL +#define UV3H_GR0_GAM_GR_CONFIG_SUBSPACE_MASK 0x0000000000000400UL + +union uv3h_gr0_gam_gr_config_u { + unsigned long v; + struct uv3h_gr0_gam_gr_config_s { + unsigned long m_skt:6; /* RW */ + unsigned long undef_6_9:4; /* Undefined */ + unsigned long subspace:1; /* RW */ + unsigned long reserved:53; + } s3; +}; + +/* ========================================================================= */ +/* UV3H_GR1_GAM_GR_CONFIG */ +/* ========================================================================= */ +#define UV3H_GR1_GAM_GR_CONFIG 0x1000028UL + +#define UV3H_GR1_GAM_GR_CONFIG_M_SKT_SHFT 0 +#define UV3H_GR1_GAM_GR_CONFIG_SUBSPACE_SHFT 10 +#define UV3H_GR1_GAM_GR_CONFIG_M_SKT_MASK 0x000000000000003fUL +#define UV3H_GR1_GAM_GR_CONFIG_SUBSPACE_MASK 0x0000000000000400UL + +union uv3h_gr1_gam_gr_config_u { + unsigned long v; + struct uv3h_gr1_gam_gr_config_s { + unsigned long m_skt:6; /* RW */ + unsigned long undef_6_9:4; /* Undefined */ + unsigned long subspace:1; /* RW */ + unsigned long reserved:53; + } s3; +}; + /* ========================================================================= */ /* UV3H_RH_GAM_MMIOH_OVERLAY_CONFIG0_MMR */ /* ========================================================================= */ diff --git a/arch/x86/kernel/apic/x2apic_uv_x.c b/arch/x86/kernel/apic/x2apic_uv_x.c index 7834389ba5be..293b41df54ef 100644 --- a/arch/x86/kernel/apic/x2apic_uv_x.c +++ b/arch/x86/kernel/apic/x2apic_uv_x.c @@ -5,7 +5,7 @@ * * SGI UV APIC functions (note: not an Intel compatible APIC) * - * Copyright (C) 2007-2013 Silicon Graphics, Inc. All rights reserved. + * Copyright (C) 2007-2014 Silicon Graphics, Inc. All rights reserved. */ #include #include @@ -440,6 +440,20 @@ static __initdata struct redir_addr redir_addrs[] = { {UVH_RH_GAM_ALIAS210_REDIRECT_CONFIG_2_MMR, UVH_RH_GAM_ALIAS210_OVERLAY_CONFIG_2_MMR}, }; +static unsigned char get_n_lshift(int m_val) +{ + union uv3h_gr0_gam_gr_config_u m_gr_config; + + if (is_uv1_hub()) + return m_val; + + if (is_uv2_hub()) + return m_val == 40 ? 40 : 39; + + m_gr_config.v = uv_read_local_mmr(UV3H_GR0_GAM_GR_CONFIG); + return m_gr_config.s3.m_skt; +} + static __init void get_lowmem_redirect(unsigned long *base, unsigned long *size) { union uvh_rh_gam_alias210_overlay_config_2_mmr_u alias; @@ -849,6 +863,7 @@ void __init uv_system_init(void) int gnode_extra, min_pnode = 999999, max_pnode = -1; unsigned long mmr_base, present, paddr; unsigned short pnode_mask; + unsigned char n_lshift; char *hub = (is_uv1_hub() ? "UV1" : (is_uv2_hub() ? "UV2" : "UV3")); @@ -860,6 +875,7 @@ void __init uv_system_init(void) m_val = m_n_config.s.m_skt; n_val = m_n_config.s.n_skt; pnode_mask = (1 << n_val) - 1; + n_lshift = get_n_lshift(m_val); mmr_base = uv_read_local_mmr(UVH_RH_GAM_MMR_OVERLAY_CONFIG_MMR) & ~UV_MMR_ENABLE; @@ -867,8 +883,9 @@ void __init uv_system_init(void) node_id.v = uv_read_local_mmr(UVH_NODE_ID); gnode_extra = (node_id.s.node_id & ~((1 << n_val) - 1)) >> 1; gnode_upper = ((unsigned long)gnode_extra << m_val); - pr_info("UV: N:%d M:%d pnode_mask:0x%x gnode_upper/extra:0x%lx/0x%x\n", - n_val, m_val, pnode_mask, gnode_upper, gnode_extra); + pr_info("UV: N:%d M:%d pnode_mask:0x%x gnode_upper/extra:0x%lx/0x%x n_lshift 0x%x\n", + n_val, m_val, pnode_mask, gnode_upper, gnode_extra, + n_lshift); pr_info("UV: global MMR base 0x%lx\n", mmr_base); @@ -935,8 +952,7 @@ void __init uv_system_init(void) uv_cpu_hub_info(cpu)->hub_revision = uv_hub_info->hub_revision; uv_cpu_hub_info(cpu)->m_shift = 64 - m_val; - uv_cpu_hub_info(cpu)->n_lshift = is_uv2_1_hub() ? - (m_val == 40 ? 40 : 39) : m_val; + uv_cpu_hub_info(cpu)->n_lshift = n_lshift; pnode = uv_apicid_to_pnode(apicid); blade = boot_pnode_to_blade(pnode); -- cgit v1.2.3 From fe455b17de6c881eecf4f9784c3b0483a5e3d19e Mon Sep 17 00:00:00 2001 From: Dimitri Sivanich Date: Mon, 31 Mar 2014 10:23:20 -0500 Subject: x86/UV: Fix conditional in gru_exit() Fix supported system conditional in gru_exit(), in preparation for UV3. Signed-off-by: Dimitri Sivanich Link: http://lkml.kernel.org/r/20140331152320.GA31495@sgi.com Signed-off-by: Ingo Molnar --- drivers/misc/sgi-gru/grufile.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/misc/sgi-gru/grufile.c b/drivers/misc/sgi-gru/grufile.c index 0535d1e0bc78..104a05f6b738 100644 --- a/drivers/misc/sgi-gru/grufile.c +++ b/drivers/misc/sgi-gru/grufile.c @@ -6,7 +6,7 @@ * This file supports the user system call for file open, close, mmap, etc. * This also incudes the driver initialization code. * - * Copyright (c) 2008 Silicon Graphics, Inc. All Rights Reserved. + * Copyright (c) 2008-2014 Silicon Graphics, Inc. All Rights Reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -58,6 +58,11 @@ static int max_user_cbrs, max_user_dsr_bytes; static struct miscdevice gru_miscdev; +static int gru_supported(void) +{ + return is_uv_system() && + (uv_hub_info->hub_revision < UV3_HUB_REVISION_BASE); +} /* * gru_vma_close @@ -518,7 +523,7 @@ static int __init gru_init(void) { int ret; - if (!is_uv_system() || (is_uvx_hub() && !is_uv2_hub())) + if (!gru_supported()) return 0; #if defined CONFIG_IA64 @@ -573,7 +578,7 @@ exit0: static void __exit gru_exit(void) { - if (!is_uv_system()) + if (!gru_supported()) return; gru_teardown_tlb_irqs(); -- cgit v1.2.3 From 0ea481466d1c7cbd9d8f70ddc17a443a6c6fc09b Mon Sep 17 00:00:00 2001 From: Herbert Xu Date: Fri, 4 Apr 2014 20:24:03 +0800 Subject: crypto: ghash-clmulni-intel - Use u128 instead of be128 for internal key The internal key isn't actually in big-endian format so let's switch to u128 which also happens to allow us to remove a sparse warning. Based on suggestion by Ard Biesheuvel. Signed-off-by: Herbert Xu Acked-by: Ard Biesheuvel --- arch/x86/crypto/ghash-clmulni-intel_asm.S | 4 ++-- arch/x86/crypto/ghash-clmulni-intel_glue.c | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/arch/x86/crypto/ghash-clmulni-intel_asm.S b/arch/x86/crypto/ghash-clmulni-intel_asm.S index 185fad49d86f..5d1e0075ac24 100644 --- a/arch/x86/crypto/ghash-clmulni-intel_asm.S +++ b/arch/x86/crypto/ghash-clmulni-intel_asm.S @@ -92,7 +92,7 @@ __clmul_gf128mul_ble: ret ENDPROC(__clmul_gf128mul_ble) -/* void clmul_ghash_mul(char *dst, const be128 *shash) */ +/* void clmul_ghash_mul(char *dst, const u128 *shash) */ ENTRY(clmul_ghash_mul) movups (%rdi), DATA movups (%rsi), SHASH @@ -106,7 +106,7 @@ ENDPROC(clmul_ghash_mul) /* * void clmul_ghash_update(char *dst, const char *src, unsigned int srclen, - * const be128 *shash); + * const u128 *shash); */ ENTRY(clmul_ghash_update) cmp $16, %rdx diff --git a/arch/x86/crypto/ghash-clmulni-intel_glue.c b/arch/x86/crypto/ghash-clmulni-intel_glue.c index d785cf2c529c..88bb7ba8b175 100644 --- a/arch/x86/crypto/ghash-clmulni-intel_glue.c +++ b/arch/x86/crypto/ghash-clmulni-intel_glue.c @@ -25,17 +25,17 @@ #define GHASH_BLOCK_SIZE 16 #define GHASH_DIGEST_SIZE 16 -void clmul_ghash_mul(char *dst, const be128 *shash); +void clmul_ghash_mul(char *dst, const u128 *shash); void clmul_ghash_update(char *dst, const char *src, unsigned int srclen, - const be128 *shash); + const u128 *shash); struct ghash_async_ctx { struct cryptd_ahash *cryptd_tfm; }; struct ghash_ctx { - be128 shash; + u128 shash; }; struct ghash_desc_ctx { @@ -68,11 +68,11 @@ static int ghash_setkey(struct crypto_shash *tfm, a = be64_to_cpu(x->a); b = be64_to_cpu(x->b); - ctx->shash.a = (__be64)((b << 1) | (a >> 63)); - ctx->shash.b = (__be64)((a << 1) | (b >> 63)); + ctx->shash.a = (b << 1) | (a >> 63); + ctx->shash.b = (a << 1) | (b >> 63); if (a >> 63) - ctx->shash.b ^= cpu_to_be64(0xc2); + ctx->shash.b ^= ((u64)0xc2) << 56; return 0; } -- cgit v1.2.3 From b47a22290d581277be70e8a597824a4985d39e83 Mon Sep 17 00:00:00 2001 From: Mario Kicherer Date: Fri, 4 Apr 2014 20:40:50 +0200 Subject: ALSA: MIDI driver for Behringer BCD2000 USB device This patch adds initial support for the Behringer BCD2000 USB DJ controller. At the moment, only the MIDI part of the device is working, i.e. knobs, buttons and LEDs. I also plan to add support for the audio part, but I assume that this will require more effort than the rather simple MIDI interface. Progress can be tracked at https://github.com/anyc/snd-usb-bcd2000. Signed-off-by: Mario Kicherer Reviewed-by: Daniel Mack Reviewed-by: Clemens Ladisch Signed-off-by: Takashi Iwai --- sound/usb/Kconfig | 13 ++ sound/usb/Makefile | 2 +- sound/usb/bcd2000/Makefile | 3 + sound/usb/bcd2000/bcd2000.c | 461 ++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 478 insertions(+), 1 deletion(-) create mode 100644 sound/usb/bcd2000/Makefile create mode 100644 sound/usb/bcd2000/bcd2000.c diff --git a/sound/usb/Kconfig b/sound/usb/Kconfig index e05a86b7c0da..d393153c474f 100644 --- a/sound/usb/Kconfig +++ b/sound/usb/Kconfig @@ -147,5 +147,18 @@ config SND_USB_HIFACE To compile this driver as a module, choose M here: the module will be called snd-usb-hiface. +config SND_BCD2000 + tristate "Behringer BCD2000 MIDI driver" + select SND_RAWMIDI + help + Say Y here to include MIDI support for the Behringer BCD2000 DJ + controller. + + Audio support is still work-in-progress at + https://github.com/anyc/snd-usb-bcd2000 + + To compile this driver as a module, choose M here: the module + will be called snd-bcd2000. + endif # SND_USB diff --git a/sound/usb/Makefile b/sound/usb/Makefile index abe668f660d1..2b92f0dcbc4c 100644 --- a/sound/usb/Makefile +++ b/sound/usb/Makefile @@ -23,4 +23,4 @@ obj-$(CONFIG_SND_USB_UA101) += snd-usbmidi-lib.o obj-$(CONFIG_SND_USB_USX2Y) += snd-usbmidi-lib.o obj-$(CONFIG_SND_USB_US122L) += snd-usbmidi-lib.o -obj-$(CONFIG_SND) += misc/ usx2y/ caiaq/ 6fire/ hiface/ +obj-$(CONFIG_SND) += misc/ usx2y/ caiaq/ 6fire/ hiface/ bcd2000/ diff --git a/sound/usb/bcd2000/Makefile b/sound/usb/bcd2000/Makefile new file mode 100644 index 000000000000..f09ccc0af6ff --- /dev/null +++ b/sound/usb/bcd2000/Makefile @@ -0,0 +1,3 @@ +snd-bcd2000-y := bcd2000.o + +obj-$(CONFIG_SND_BCD2000) += snd-bcd2000.o \ No newline at end of file diff --git a/sound/usb/bcd2000/bcd2000.c b/sound/usb/bcd2000/bcd2000.c new file mode 100644 index 000000000000..820d6ca8c458 --- /dev/null +++ b/sound/usb/bcd2000/bcd2000.c @@ -0,0 +1,461 @@ +/* + * Behringer BCD2000 driver + * + * Copyright (C) 2014 Mario Kicherer (dev@kicherer.org) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define PREFIX "snd-bcd2000: " +#define BUFSIZE 64 + +static struct usb_device_id id_table[] = { + { USB_DEVICE(0x1397, 0x00bd) }, + { }, +}; + +static unsigned char device_cmd_prefix[] = {0x03, 0x00}; + +static unsigned char bcd2000_init_sequence[] = { + 0x07, 0x00, 0x00, 0x00, 0x78, 0x48, 0x1c, 0x81, + 0xc4, 0x00, 0x00, 0x00, 0x5e, 0x53, 0x4a, 0xf7, + 0x18, 0xfa, 0x11, 0xff, 0x6c, 0xf3, 0x90, 0xff, + 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x18, 0xfa, 0x11, 0xff, 0x14, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0xf2, 0x34, 0x4a, 0xf7, + 0x18, 0xfa, 0x11, 0xff +}; + +struct bcd2000 { + struct usb_device *dev; + struct snd_card *card; + struct usb_interface *intf; + int card_index; + + int midi_out_active; + struct snd_rawmidi *rmidi; + struct snd_rawmidi_substream *midi_receive_substream; + struct snd_rawmidi_substream *midi_out_substream; + + unsigned char midi_in_buf[BUFSIZE]; + unsigned char midi_out_buf[BUFSIZE]; + + struct urb *midi_out_urb; + struct urb *midi_in_urb; + + struct usb_anchor anchor; +}; + +static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; +static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; + +static DEFINE_MUTEX(devices_mutex); +DECLARE_BITMAP(devices_used, SNDRV_CARDS); +static struct usb_driver bcd2000_driver; + +#ifdef CONFIG_SND_DEBUG +static void bcd2000_dump_buffer(const char *prefix, const char *buf, int len) +{ + print_hex_dump(KERN_DEBUG, prefix, + DUMP_PREFIX_NONE, 16, 1, + buf, len, false); +} +#else +static void bcd2000_dump_buffer(const char *prefix, const char *buf, int len) {} +#endif + +static int bcd2000_midi_input_open(struct snd_rawmidi_substream *substream) +{ + return 0; +} + +static int bcd2000_midi_input_close(struct snd_rawmidi_substream *substream) +{ + return 0; +} + +/* (de)register midi substream from client */ +static void bcd2000_midi_input_trigger(struct snd_rawmidi_substream *substream, + int up) +{ + struct bcd2000 *bcd2k = substream->rmidi->private_data; + bcd2k->midi_receive_substream = up ? substream : NULL; +} + +static void bcd2000_midi_handle_input(struct bcd2000 *bcd2k, + const unsigned char *buf, unsigned int buf_len) +{ + unsigned int payload_length, tocopy; + struct snd_rawmidi_substream *midi_receive_substream; + + midi_receive_substream = ACCESS_ONCE(bcd2k->midi_receive_substream); + if (!midi_receive_substream) + return; + + bcd2000_dump_buffer(PREFIX "received from device: ", buf, buf_len); + + if (buf_len < 2) + return; + + payload_length = buf[0]; + + /* ignore packets without payload */ + if (payload_length == 0) + return; + + tocopy = min(payload_length, buf_len-1); + + bcd2000_dump_buffer(PREFIX "sending to userspace: ", + &buf[1], tocopy); + + snd_rawmidi_receive(midi_receive_substream, + &buf[1], tocopy); +} + +static void bcd2000_midi_send(struct bcd2000 *bcd2k) +{ + int len, ret; + struct snd_rawmidi_substream *midi_out_substream; + + BUILD_BUG_ON(sizeof(device_cmd_prefix) >= BUFSIZE); + + midi_out_substream = ACCESS_ONCE(bcd2k->midi_out_substream); + if (!midi_out_substream) + return; + + /* copy command prefix bytes */ + memcpy(bcd2k->midi_out_buf, device_cmd_prefix, + sizeof(device_cmd_prefix)); + + /* + * get MIDI packet and leave space for command prefix + * and payload length + */ + len = snd_rawmidi_transmit(midi_out_substream, + bcd2k->midi_out_buf + 3, BUFSIZE - 3); + + if (len < 0) + dev_err(&bcd2k->dev->dev, "%s: snd_rawmidi_transmit error %d\n", + __func__, len); + + if (len <= 0) + return; + + /* set payload length */ + bcd2k->midi_out_buf[2] = len; + bcd2k->midi_out_urb->transfer_buffer_length = BUFSIZE; + + bcd2000_dump_buffer(PREFIX "sending to device: ", + bcd2k->midi_out_buf, len+3); + + /* send packet to the BCD2000 */ + ret = usb_submit_urb(bcd2k->midi_out_urb, GFP_ATOMIC); + if (ret < 0) + dev_err(&bcd2k->dev->dev, PREFIX + "%s (%p): usb_submit_urb() failed, ret=%d, len=%d\n", + __func__, midi_out_substream, ret, len); + else + bcd2k->midi_out_active = 1; +} + +static int bcd2000_midi_output_open(struct snd_rawmidi_substream *substream) +{ + return 0; +} + +static int bcd2000_midi_output_close(struct snd_rawmidi_substream *substream) +{ + struct bcd2000 *bcd2k = substream->rmidi->private_data; + + if (bcd2k->midi_out_active) { + usb_kill_urb(bcd2k->midi_out_urb); + bcd2k->midi_out_active = 0; + } + + return 0; +} + +/* (de)register midi substream from client */ +static void bcd2000_midi_output_trigger(struct snd_rawmidi_substream *substream, + int up) +{ + struct bcd2000 *bcd2k = substream->rmidi->private_data; + + if (up) { + bcd2k->midi_out_substream = substream; + /* check if there is data userspace wants to send */ + if (!bcd2k->midi_out_active) + bcd2000_midi_send(bcd2k); + } else { + bcd2k->midi_out_substream = NULL; + } +} + +static void bcd2000_output_complete(struct urb *urb) +{ + struct bcd2000 *bcd2k = urb->context; + + bcd2k->midi_out_active = 0; + + if (urb->status) + dev_warn(&urb->dev->dev, + PREFIX "output urb->status: %d\n", urb->status); + + if (urb->status == -ESHUTDOWN) + return; + + /* check if there is more data userspace wants to send */ + bcd2000_midi_send(bcd2k); +} + +static void bcd2000_input_complete(struct urb *urb) +{ + int ret; + struct bcd2000 *bcd2k = urb->context; + + if (urb->status) + dev_warn(&urb->dev->dev, + PREFIX "input urb->status: %i\n", urb->status); + + if (!bcd2k || urb->status == -ESHUTDOWN) + return; + + if (urb->actual_length > 0) + bcd2000_midi_handle_input(bcd2k, urb->transfer_buffer, + urb->actual_length); + + /* return URB to device */ + ret = usb_submit_urb(bcd2k->midi_in_urb, GFP_ATOMIC); + if (ret < 0) + dev_err(&bcd2k->dev->dev, PREFIX + "%s: usb_submit_urb() failed, ret=%d\n", + __func__, ret); +} + +static struct snd_rawmidi_ops bcd2000_midi_output = { + .open = bcd2000_midi_output_open, + .close = bcd2000_midi_output_close, + .trigger = bcd2000_midi_output_trigger, +}; + +static struct snd_rawmidi_ops bcd2000_midi_input = { + .open = bcd2000_midi_input_open, + .close = bcd2000_midi_input_close, + .trigger = bcd2000_midi_input_trigger, +}; + +static void bcd2000_init_device(struct bcd2000 *bcd2k) +{ + int ret; + + init_usb_anchor(&bcd2k->anchor); + usb_anchor_urb(bcd2k->midi_out_urb, &bcd2k->anchor); + usb_anchor_urb(bcd2k->midi_in_urb, &bcd2k->anchor); + + /* copy init sequence into buffer */ + memcpy(bcd2k->midi_out_buf, bcd2000_init_sequence, 52); + bcd2k->midi_out_urb->transfer_buffer_length = 52; + + /* submit sequence */ + ret = usb_submit_urb(bcd2k->midi_out_urb, GFP_KERNEL); + if (ret < 0) + dev_err(&bcd2k->dev->dev, PREFIX + "%s: usb_submit_urb() out failed, ret=%d: ", + __func__, ret); + else + bcd2k->midi_out_active = 1; + + /* pass URB to device to enable button and controller events */ + ret = usb_submit_urb(bcd2k->midi_in_urb, GFP_KERNEL); + if (ret < 0) + dev_err(&bcd2k->dev->dev, PREFIX + "%s: usb_submit_urb() in failed, ret=%d: ", + __func__, ret); + + /* ensure initialization is finished */ + usb_wait_anchor_empty_timeout(&bcd2k->anchor, 1000); +} + +static int bcd2000_init_midi(struct bcd2000 *bcd2k) +{ + int ret; + struct snd_rawmidi *rmidi; + + ret = snd_rawmidi_new(bcd2k->card, bcd2k->card->shortname, 0, + 1, /* output */ + 1, /* input */ + &rmidi); + + if (ret < 0) + return ret; + + strlcpy(rmidi->name, bcd2k->card->shortname, sizeof(rmidi->name)); + + rmidi->info_flags = SNDRV_RAWMIDI_INFO_DUPLEX; + rmidi->private_data = bcd2k; + + rmidi->info_flags |= SNDRV_RAWMIDI_INFO_OUTPUT; + snd_rawmidi_set_ops(rmidi, SNDRV_RAWMIDI_STREAM_OUTPUT, + &bcd2000_midi_output); + + rmidi->info_flags |= SNDRV_RAWMIDI_INFO_INPUT; + snd_rawmidi_set_ops(rmidi, SNDRV_RAWMIDI_STREAM_INPUT, + &bcd2000_midi_input); + + bcd2k->rmidi = rmidi; + + bcd2k->midi_in_urb = usb_alloc_urb(0, GFP_KERNEL); + bcd2k->midi_out_urb = usb_alloc_urb(0, GFP_KERNEL); + + if (!bcd2k->midi_in_urb || !bcd2k->midi_out_urb) { + dev_err(&bcd2k->dev->dev, PREFIX "usb_alloc_urb failed\n"); + return -ENOMEM; + } + + usb_fill_int_urb(bcd2k->midi_in_urb, bcd2k->dev, + usb_rcvintpipe(bcd2k->dev, 0x81), + bcd2k->midi_in_buf, BUFSIZE, + bcd2000_input_complete, bcd2k, 1); + + usb_fill_int_urb(bcd2k->midi_out_urb, bcd2k->dev, + usb_sndintpipe(bcd2k->dev, 0x1), + bcd2k->midi_out_buf, BUFSIZE, + bcd2000_output_complete, bcd2k, 1); + + bcd2000_init_device(bcd2k); + + return 0; +} + +static void bcd2000_free_usb_related_resources(struct bcd2000 *bcd2k, + struct usb_interface *interface) +{ + /* usb_kill_urb not necessary, urb is aborted automatically */ + + usb_free_urb(bcd2k->midi_out_urb); + usb_free_urb(bcd2k->midi_in_urb); + + if (bcd2k->intf) { + usb_set_intfdata(bcd2k->intf, NULL); + bcd2k->intf = NULL; + } +} + +static int bcd2000_probe(struct usb_interface *interface, + const struct usb_device_id *usb_id) +{ + struct snd_card *card; + struct bcd2000 *bcd2k; + unsigned int card_index; + char usb_path[32]; + int err; + + mutex_lock(&devices_mutex); + + for (card_index = 0; card_index < SNDRV_CARDS; ++card_index) + if (!test_bit(card_index, devices_used)) + break; + + if (card_index >= SNDRV_CARDS) { + mutex_unlock(&devices_mutex); + return -ENOENT; + } + + err = snd_card_new(&interface->dev, index[card_index], id[card_index], + THIS_MODULE, sizeof(*bcd2k), &card); + if (err < 0) { + mutex_unlock(&devices_mutex); + return err; + } + + bcd2k = card->private_data; + bcd2k->dev = interface_to_usbdev(interface); + bcd2k->card = card; + bcd2k->card_index = card_index; + bcd2k->intf = interface; + + snd_card_set_dev(card, &interface->dev); + + strncpy(card->driver, "snd-bcd2000", sizeof(card->driver)); + strncpy(card->shortname, "BCD2000", sizeof(card->shortname)); + usb_make_path(bcd2k->dev, usb_path, sizeof(usb_path)); + snprintf(bcd2k->card->longname, sizeof(bcd2k->card->longname), + "Behringer BCD2000 at %s", + usb_path); + + err = bcd2000_init_midi(bcd2k); + if (err < 0) + goto probe_error; + + err = snd_card_register(card); + if (err < 0) + goto probe_error; + + usb_set_intfdata(interface, bcd2k); + set_bit(card_index, devices_used); + + mutex_unlock(&devices_mutex); + return 0; + +probe_error: + dev_info(&bcd2k->dev->dev, PREFIX "error during probing"); + bcd2000_free_usb_related_resources(bcd2k, interface); + snd_card_free(card); + mutex_unlock(&devices_mutex); + return err; +} + +static void bcd2000_disconnect(struct usb_interface *interface) +{ + struct bcd2000 *bcd2k = usb_get_intfdata(interface); + + if (!bcd2k) + return; + + mutex_lock(&devices_mutex); + + /* make sure that userspace cannot create new requests */ + snd_card_disconnect(bcd2k->card); + + bcd2000_free_usb_related_resources(bcd2k, interface); + + clear_bit(bcd2k->card_index, devices_used); + + snd_card_free_when_closed(bcd2k->card); + + mutex_unlock(&devices_mutex); +} + +static struct usb_driver bcd2000_driver = { + .name = "snd-bcd2000", + .probe = bcd2000_probe, + .disconnect = bcd2000_disconnect, + .id_table = id_table, +}; + +module_usb_driver(bcd2000_driver); + +MODULE_DEVICE_TABLE(usb, id_table); +MODULE_AUTHOR("Mario Kicherer, dev@kicherer.org"); +MODULE_DESCRIPTION("Behringer BCD2000 driver"); +MODULE_LICENSE("GPL"); -- cgit v1.2.3 From b64aef7034572b1f669bf295b88332ea0b149050 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Sun, 4 May 2014 17:45:00 +0100 Subject: staging:iio:adc:spear adc - prefix defines to avoid namespace clashes. Signed-off-by: Jonathan Cameron Acked-by: Stefan Roese Acked-by: Hartmut Knaack --- drivers/staging/iio/adc/spear_adc.c | 73 ++++++++++++++++++------------------- 1 file changed, 36 insertions(+), 37 deletions(-) diff --git a/drivers/staging/iio/adc/spear_adc.c b/drivers/staging/iio/adc/spear_adc.c index 970d9edc73b6..49293f9e609f 100644 --- a/drivers/staging/iio/adc/spear_adc.c +++ b/drivers/staging/iio/adc/spear_adc.c @@ -22,39 +22,36 @@ #include #include -/* - * SPEAR registers definitions - */ - -#define SCAN_RATE_LO(x) ((x) & 0xFFFF) -#define SCAN_RATE_HI(x) (((x) >> 0x10) & 0xFFFF) -#define CLK_LOW(x) (((x) & 0xf) << 0) -#define CLK_HIGH(x) (((x) & 0xf) << 4) +/* SPEAR registers definitions */ +#define SPEAR600_ADC_SCAN_RATE_LO(x) ((x) & 0xFFFF) +#define SPEAR600_ADC_SCAN_RATE_HI(x) (((x) >> 0x10) & 0xFFFF) +#define SPEAR_ADC_CLK_LOW(x) (((x) & 0xf) << 0) +#define SPEAR_ADC_CLK_HIGH(x) (((x) & 0xf) << 4) /* Bit definitions for SPEAR_ADC_STATUS */ -#define START_CONVERSION (1 << 0) -#define CHANNEL_NUM(x) ((x) << 1) -#define ADC_ENABLE (1 << 4) -#define AVG_SAMPLE(x) ((x) << 5) -#define VREF_INTERNAL (1 << 9) +#define SPEAR_ADC_STATUS_START_CONVERSION (1 << 0) +#define SPEAR_ADC_STATUS_CHANNEL_NUM(x) ((x) << 1) +#define SPEAR_ADC_STATUS_ADC_ENABLE (1 << 4) +#define SPEAR_ADC_STATUS_AVG_SAMPLE(x) ((x) << 5) +#define SPEAR_ADC_STATUS_VREF_INTERNAL (1 << 9) -#define DATA_MASK 0x03ff -#define DATA_BITS 10 +#define SPEAR_ADC_DATA_MASK 0x03ff +#define SPEAR_ADC_DATA_BITS 10 -#define MOD_NAME "spear-adc" +#define SPEAR_ADC_MOD_NAME "spear-adc" -#define ADC_CHANNEL_NUM 8 +#define SPEAR_ADC_CHANNEL_NUM 8 -#define CLK_MIN 2500000 -#define CLK_MAX 20000000 +#define SPEAR_ADC_CLK_MIN 2500000 +#define SPEAR_ADC_CLK_MAX 20000000 struct adc_regs_spear3xx { u32 status; u32 average; u32 scan_rate; u32 clk; /* Not avail for 1340 & 1310 */ - u32 ch_ctrl[ADC_CHANNEL_NUM]; - u32 ch_data[ADC_CHANNEL_NUM]; + u32 ch_ctrl[SPEAR_ADC_CHANNEL_NUM]; + u32 ch_data[SPEAR_ADC_CHANNEL_NUM]; }; struct chan_data { @@ -66,8 +63,8 @@ struct adc_regs_spear6xx { u32 status; u32 pad[2]; u32 clk; - u32 ch_ctrl[ADC_CHANNEL_NUM]; - struct chan_data ch_data[ADC_CHANNEL_NUM]; + u32 ch_ctrl[SPEAR_ADC_CHANNEL_NUM]; + struct chan_data ch_data[SPEAR_ADC_CHANNEL_NUM]; u32 scan_rate_lo; u32 scan_rate_hi; struct chan_data average; @@ -106,7 +103,7 @@ static void spear_adc_set_clk(struct spear_adc_info *info, u32 val) clk_high = count - clk_low; info->current_clk = apb_clk / count; - __raw_writel(CLK_LOW(clk_low) | CLK_HIGH(clk_high), + __raw_writel(SPEAR_ADC_CLK_LOW(clk_low) | SPEAR_ADC_CLK_HIGH(clk_high), &info->adc_base_spear6xx->clk); } @@ -120,19 +117,19 @@ static u32 spear_adc_get_average(struct spear_adc_info *info) { if (of_device_is_compatible(info->np, "st,spear600-adc")) { return __raw_readl(&info->adc_base_spear6xx->average.msb) & - DATA_MASK; + SPEAR_ADC_DATA_MASK; } else { return __raw_readl(&info->adc_base_spear3xx->average) & - DATA_MASK; + SPEAR_ADC_DATA_MASK; } } static void spear_adc_set_scanrate(struct spear_adc_info *info, u32 rate) { if (of_device_is_compatible(info->np, "st,spear600-adc")) { - __raw_writel(SCAN_RATE_LO(rate), + __raw_writel(SPEAR600_ADC_SCAN_RATE_LO(rate), &info->adc_base_spear6xx->scan_rate_lo); - __raw_writel(SCAN_RATE_HI(rate), + __raw_writel(SPEAR600_ADC_SCAN_RATE_HI(rate), &info->adc_base_spear6xx->scan_rate_hi); } else { __raw_writel(rate, &info->adc_base_spear3xx->scan_rate); @@ -152,11 +149,12 @@ static int spear_read_raw(struct iio_dev *indio_dev, case IIO_CHAN_INFO_RAW: mutex_lock(&indio_dev->mlock); - status = CHANNEL_NUM(chan->channel) | - AVG_SAMPLE(info->avg_samples) | - START_CONVERSION | ADC_ENABLE; + status = SPEAR_ADC_STATUS_CHANNEL_NUM(chan->channel) | + SPEAR_ADC_STATUS_AVG_SAMPLE(info->avg_samples) | + SPEAR_ADC_STATUS_START_CONVERSION | + SPEAR_ADC_STATUS_ADC_ENABLE; if (info->vref_external == 0) - status |= VREF_INTERNAL; + status |= SPEAR_ADC_STATUS_VREF_INTERNAL; spear_adc_set_status(info, status); wait_for_completion(&info->completion); /* set by ISR */ @@ -168,7 +166,7 @@ static int spear_read_raw(struct iio_dev *indio_dev, case IIO_CHAN_INFO_SCALE: *val = info->vref_external; - *val2 = DATA_BITS; + *val2 = SPEAR_ADC_DATA_BITS; return IIO_VAL_FRACTIONAL_LOG2; } @@ -253,7 +251,7 @@ static ssize_t spear_adc_write_frequency(struct device *dev, mutex_lock(&indio_dev->mlock); - if ((lval < CLK_MIN) || (lval > CLK_MAX)) { + if ((lval < SPEAR_ADC_CLK_MIN) || (lval > SPEAR_ADC_CLK_MAX)) { ret = -EINVAL; goto out; } @@ -339,7 +337,8 @@ static int spear_adc_probe(struct platform_device *pdev) goto errout3; } - ret = devm_request_irq(dev, irq, spear_adc_isr, 0, MOD_NAME, info); + ret = devm_request_irq(dev, irq, spear_adc_isr, 0, SPEAR_ADC_MOD_NAME, + info); if (ret < 0) { dev_err(dev, "failed requesting interrupt\n"); goto errout3; @@ -370,7 +369,7 @@ static int spear_adc_probe(struct platform_device *pdev) init_completion(&info->completion); - iodev->name = MOD_NAME; + iodev->name = SPEAR_ADC_MOD_NAME; iodev->dev.parent = dev; iodev->info = &spear_adc_iio_info; iodev->modes = INDIO_DIRECT_MODE; @@ -419,7 +418,7 @@ static struct platform_driver spear_adc_driver = { .probe = spear_adc_probe, .remove = spear_adc_remove, .driver = { - .name = MOD_NAME, + .name = SPEAR_ADC_MOD_NAME, .owner = THIS_MODULE, .of_match_table = of_match_ptr(spear_adc_dt_ids), }, -- cgit v1.2.3 From a8375a9952c1864bea1047a8087a81747b09f3ae Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Sun, 4 May 2014 17:45:00 +0100 Subject: staging:iio:adc:spear_adc drop initialization of unused scan_type As the driver does not support the buffered interfaces of IIO this is not used. Signed-off-by: Jonathan Cameron Acked-by: Stefan Roese --- drivers/staging/iio/adc/spear_adc.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/drivers/staging/iio/adc/spear_adc.c b/drivers/staging/iio/adc/spear_adc.c index 49293f9e609f..c4e928b283f8 100644 --- a/drivers/staging/iio/adc/spear_adc.c +++ b/drivers/staging/iio/adc/spear_adc.c @@ -179,10 +179,6 @@ static int spear_read_raw(struct iio_dev *indio_dev, .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \ .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), \ .channel = idx, \ - .scan_type = { \ - .sign = 'u', \ - .storagebits = 16, \ - }, \ } static const struct iio_chan_spec spear_adc_iio_channels[] = { -- cgit v1.2.3 From 932de74ba335358e2521f951c59bbda2746c5aef Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Sun, 4 May 2014 17:45:00 +0100 Subject: staging:iio:adc:spear_adc use info_mask_shared_by_all for samp freq Using the core support makes this element available to in kernel users as well as to userspace under exactly the same interface as before. The intent is to move all sampling frequency control to this approach throughout IIO. Drop unused clk_high and clk_low whilst we are at it. Signed-off-by: Jonathan Cameron Acked-by: Stefan Roese Acked-by: Hartmut Knaack --- drivers/staging/iio/adc/spear_adc.c | 92 +++++++++++++------------------------ 1 file changed, 33 insertions(+), 59 deletions(-) diff --git a/drivers/staging/iio/adc/spear_adc.c b/drivers/staging/iio/adc/spear_adc.c index c4e928b283f8..44a129f37d9c 100644 --- a/drivers/staging/iio/adc/spear_adc.c +++ b/drivers/staging/iio/adc/spear_adc.c @@ -168,16 +168,48 @@ static int spear_read_raw(struct iio_dev *indio_dev, *val = info->vref_external; *val2 = SPEAR_ADC_DATA_BITS; return IIO_VAL_FRACTIONAL_LOG2; + case IIO_CHAN_INFO_SAMP_FREQ: + *val = info->current_clk; + return IIO_VAL_INT; } return -EINVAL; } +static int spear_adc_write_raw(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, + int val, + int val2, + long mask) +{ + struct spear_adc_info *info = iio_priv(indio_dev); + int ret = 0; + + if (mask != IIO_CHAN_INFO_SAMP_FREQ) + return -EINVAL; + + mutex_lock(&indio_dev->mlock); + + if ((val < SPEAR_ADC_CLK_MIN) || + (val > SPEAR_ADC_CLK_MAX) || + (val2 != 0)) { + ret = -EINVAL; + goto out; + } + + spear_adc_set_clk(info, val); + +out: + mutex_unlock(&indio_dev->mlock); + return ret; +} + #define SPEAR_ADC_CHAN(idx) { \ .type = IIO_VOLTAGE, \ .indexed = 1, \ .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \ .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), \ + .info_mask_shared_by_all = BIT(IIO_CHAN_INFO_SAMP_FREQ),\ .channel = idx, \ } @@ -219,67 +251,9 @@ static int spear_adc_configure(struct spear_adc_info *info) return 0; } -static ssize_t spear_adc_read_frequency(struct device *dev, - struct device_attribute *attr, - char *buf) -{ - struct iio_dev *indio_dev = dev_to_iio_dev(dev); - struct spear_adc_info *info = iio_priv(indio_dev); - - return sprintf(buf, "%d\n", info->current_clk); -} - -static ssize_t spear_adc_write_frequency(struct device *dev, - struct device_attribute *attr, - const char *buf, - size_t len) -{ - struct iio_dev *indio_dev = dev_to_iio_dev(dev); - struct spear_adc_info *info = iio_priv(indio_dev); - u32 clk_high, clk_low, count; - u32 apb_clk = clk_get_rate(info->clk); - unsigned long lval; - int ret; - - ret = kstrtoul(buf, 10, &lval); - if (ret) - return ret; - - mutex_lock(&indio_dev->mlock); - - if ((lval < SPEAR_ADC_CLK_MIN) || (lval > SPEAR_ADC_CLK_MAX)) { - ret = -EINVAL; - goto out; - } - - count = (apb_clk + lval - 1) / lval; - clk_low = count / 2; - clk_high = count - clk_low; - info->current_clk = apb_clk / count; - spear_adc_set_clk(info, lval); - -out: - mutex_unlock(&indio_dev->mlock); - - return ret ? ret : len; -} - -static IIO_DEV_ATTR_SAMP_FREQ(S_IWUSR | S_IRUGO, - spear_adc_read_frequency, - spear_adc_write_frequency); - -static struct attribute *spear_attributes[] = { - &iio_dev_attr_sampling_frequency.dev_attr.attr, - NULL -}; - -static const struct attribute_group spear_attribute_group = { - .attrs = spear_attributes, -}; - static const struct iio_info spear_adc_iio_info = { .read_raw = &spear_read_raw, - .attrs = &spear_attribute_group, + .write_raw = &spear_adc_write_raw, .driver_module = THIS_MODULE, }; -- cgit v1.2.3 From b586e5d9eee038b8ee6f846cdb6cf2fcbcb2f4ed Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Sun, 4 May 2014 17:45:00 +0100 Subject: staging:iio:adc:spear rename device specific state structure to _state Also rename instances of it to st. This brings the driver inline with the conventions of IIO and avoids some naming confusion with some IIO structures which also use the _info postfix. Signed-off-by: Jonathan Cameron Acked-by: Hartmut Knaack --- drivers/staging/iio/adc/spear_adc.c | 126 ++++++++++++++++++------------------ 1 file changed, 63 insertions(+), 63 deletions(-) diff --git a/drivers/staging/iio/adc/spear_adc.c b/drivers/staging/iio/adc/spear_adc.c index 44a129f37d9c..3003e89b5779 100644 --- a/drivers/staging/iio/adc/spear_adc.c +++ b/drivers/staging/iio/adc/spear_adc.c @@ -70,7 +70,7 @@ struct adc_regs_spear6xx { struct chan_data average; }; -struct spear_adc_info { +struct spear_adc_state { struct device_node *np; struct adc_regs_spear3xx __iomem *adc_base_spear3xx; struct adc_regs_spear6xx __iomem *adc_base_spear6xx; @@ -88,51 +88,51 @@ struct spear_adc_info { * static inline functions, because of different register offsets * on different SoC variants (SPEAr300 vs SPEAr600 etc). */ -static void spear_adc_set_status(struct spear_adc_info *info, u32 val) +static void spear_adc_set_status(struct spear_adc_state *st, u32 val) { - __raw_writel(val, &info->adc_base_spear6xx->status); + __raw_writel(val, &st->adc_base_spear6xx->status); } -static void spear_adc_set_clk(struct spear_adc_info *info, u32 val) +static void spear_adc_set_clk(struct spear_adc_state *st, u32 val) { u32 clk_high, clk_low, count; - u32 apb_clk = clk_get_rate(info->clk); + u32 apb_clk = clk_get_rate(st->clk); count = (apb_clk + val - 1) / val; clk_low = count / 2; clk_high = count - clk_low; - info->current_clk = apb_clk / count; + st->current_clk = apb_clk / count; __raw_writel(SPEAR_ADC_CLK_LOW(clk_low) | SPEAR_ADC_CLK_HIGH(clk_high), - &info->adc_base_spear6xx->clk); + &st->adc_base_spear6xx->clk); } -static void spear_adc_set_ctrl(struct spear_adc_info *info, int n, +static void spear_adc_set_ctrl(struct spear_adc_state *st, int n, u32 val) { - __raw_writel(val, &info->adc_base_spear6xx->ch_ctrl[n]); + __raw_writel(val, &st->adc_base_spear6xx->ch_ctrl[n]); } -static u32 spear_adc_get_average(struct spear_adc_info *info) +static u32 spear_adc_get_average(struct spear_adc_state *st) { - if (of_device_is_compatible(info->np, "st,spear600-adc")) { - return __raw_readl(&info->adc_base_spear6xx->average.msb) & + if (of_device_is_compatible(st->np, "st,spear600-adc")) { + return __raw_readl(&st->adc_base_spear6xx->average.msb) & SPEAR_ADC_DATA_MASK; } else { - return __raw_readl(&info->adc_base_spear3xx->average) & + return __raw_readl(&st->adc_base_spear3xx->average) & SPEAR_ADC_DATA_MASK; } } -static void spear_adc_set_scanrate(struct spear_adc_info *info, u32 rate) +static void spear_adc_set_scanrate(struct spear_adc_state *st, u32 rate) { - if (of_device_is_compatible(info->np, "st,spear600-adc")) { + if (of_device_is_compatible(st->np, "st,spear600-adc")) { __raw_writel(SPEAR600_ADC_SCAN_RATE_LO(rate), - &info->adc_base_spear6xx->scan_rate_lo); + &st->adc_base_spear6xx->scan_rate_lo); __raw_writel(SPEAR600_ADC_SCAN_RATE_HI(rate), - &info->adc_base_spear6xx->scan_rate_hi); + &st->adc_base_spear6xx->scan_rate_hi); } else { - __raw_writel(rate, &info->adc_base_spear3xx->scan_rate); + __raw_writel(rate, &st->adc_base_spear3xx->scan_rate); } } @@ -142,7 +142,7 @@ static int spear_read_raw(struct iio_dev *indio_dev, int *val2, long mask) { - struct spear_adc_info *info = iio_priv(indio_dev); + struct spear_adc_state *st = iio_priv(indio_dev); u32 status; switch (mask) { @@ -150,26 +150,26 @@ static int spear_read_raw(struct iio_dev *indio_dev, mutex_lock(&indio_dev->mlock); status = SPEAR_ADC_STATUS_CHANNEL_NUM(chan->channel) | - SPEAR_ADC_STATUS_AVG_SAMPLE(info->avg_samples) | + SPEAR_ADC_STATUS_AVG_SAMPLE(st->avg_samples) | SPEAR_ADC_STATUS_START_CONVERSION | SPEAR_ADC_STATUS_ADC_ENABLE; - if (info->vref_external == 0) + if (st->vref_external == 0) status |= SPEAR_ADC_STATUS_VREF_INTERNAL; - spear_adc_set_status(info, status); - wait_for_completion(&info->completion); /* set by ISR */ - *val = info->value; + spear_adc_set_status(st, status); + wait_for_completion(&st->completion); /* set by ISR */ + *val = st->value; mutex_unlock(&indio_dev->mlock); return IIO_VAL_INT; case IIO_CHAN_INFO_SCALE: - *val = info->vref_external; + *val = st->vref_external; *val2 = SPEAR_ADC_DATA_BITS; return IIO_VAL_FRACTIONAL_LOG2; case IIO_CHAN_INFO_SAMP_FREQ: - *val = info->current_clk; + *val = st->current_clk; return IIO_VAL_INT; } @@ -182,7 +182,7 @@ static int spear_adc_write_raw(struct iio_dev *indio_dev, int val2, long mask) { - struct spear_adc_info *info = iio_priv(indio_dev); + struct spear_adc_state *st = iio_priv(indio_dev); int ret = 0; if (mask != IIO_CHAN_INFO_SAMP_FREQ) @@ -197,7 +197,7 @@ static int spear_adc_write_raw(struct iio_dev *indio_dev, goto out; } - spear_adc_set_clk(info, val); + spear_adc_set_clk(st, val); out: mutex_unlock(&indio_dev->mlock); @@ -226,32 +226,32 @@ static const struct iio_chan_spec spear_adc_iio_channels[] = { static irqreturn_t spear_adc_isr(int irq, void *dev_id) { - struct spear_adc_info *info = (struct spear_adc_info *)dev_id; + struct spear_adc_state *st = (struct spear_adc_state *)dev_id; /* Read value to clear IRQ */ - info->value = spear_adc_get_average(info); - complete(&info->completion); + st->value = spear_adc_get_average(st); + complete(&st->completion); return IRQ_HANDLED; } -static int spear_adc_configure(struct spear_adc_info *info) +static int spear_adc_configure(struct spear_adc_state *st) { int i; /* Reset ADC core */ - spear_adc_set_status(info, 0); - __raw_writel(0, &info->adc_base_spear6xx->clk); + spear_adc_set_status(st, 0); + __raw_writel(0, &st->adc_base_spear6xx->clk); for (i = 0; i < 8; i++) - spear_adc_set_ctrl(info, i, 0); - spear_adc_set_scanrate(info, 0); + spear_adc_set_ctrl(st, i, 0); + spear_adc_set_scanrate(st, 0); - spear_adc_set_clk(info, info->sampling_freq); + spear_adc_set_clk(st, st->sampling_freq); return 0; } -static const struct iio_info spear_adc_iio_info = { +static const struct iio_info spear_adc_info = { .read_raw = &spear_read_raw, .write_raw = &spear_adc_write_raw, .driver_module = THIS_MODULE, @@ -261,40 +261,40 @@ static int spear_adc_probe(struct platform_device *pdev) { struct device_node *np = pdev->dev.of_node; struct device *dev = &pdev->dev; - struct spear_adc_info *info; + struct spear_adc_state *st; struct iio_dev *iodev = NULL; int ret = -ENODEV; int irq; - iodev = devm_iio_device_alloc(dev, sizeof(struct spear_adc_info)); + iodev = devm_iio_device_alloc(dev, sizeof(struct spear_adc_state)); if (!iodev) { dev_err(dev, "failed allocating iio device\n"); return -ENOMEM; } - info = iio_priv(iodev); - info->np = np; + st = iio_priv(iodev); + st->np = np; /* * SPEAr600 has a different register layout than other SPEAr SoC's * (e.g. SPEAr3xx). Let's provide two register base addresses * to support multi-arch kernels. */ - info->adc_base_spear6xx = of_iomap(np, 0); - if (!info->adc_base_spear6xx) { + st->adc_base_spear6xx = of_iomap(np, 0); + if (!st->adc_base_spear6xx) { dev_err(dev, "failed mapping memory\n"); return -ENOMEM; } - info->adc_base_spear3xx = - (struct adc_regs_spear3xx __iomem *)info->adc_base_spear6xx; + st->adc_base_spear3xx = + (struct adc_regs_spear3xx __iomem *)st->adc_base_spear6xx; - info->clk = clk_get(dev, NULL); - if (IS_ERR(info->clk)) { + st->clk = clk_get(dev, NULL); + if (IS_ERR(st->clk)) { dev_err(dev, "failed getting clock\n"); goto errout1; } - ret = clk_prepare_enable(info->clk); + ret = clk_prepare_enable(st->clk); if (ret) { dev_err(dev, "failed enabling clock\n"); goto errout2; @@ -308,14 +308,14 @@ static int spear_adc_probe(struct platform_device *pdev) } ret = devm_request_irq(dev, irq, spear_adc_isr, 0, SPEAR_ADC_MOD_NAME, - info); + st); if (ret < 0) { dev_err(dev, "failed requesting interrupt\n"); goto errout3; } if (of_property_read_u32(np, "sampling-frequency", - &info->sampling_freq)) { + &st->sampling_freq)) { dev_err(dev, "sampling-frequency missing in DT\n"); ret = -EINVAL; goto errout3; @@ -325,23 +325,23 @@ static int spear_adc_probe(struct platform_device *pdev) * Optional avg_samples defaults to 0, resulting in single data * conversion */ - of_property_read_u32(np, "average-samples", &info->avg_samples); + of_property_read_u32(np, "average-samples", &st->avg_samples); /* * Optional vref_external defaults to 0, resulting in internal vref * selection */ - of_property_read_u32(np, "vref-external", &info->vref_external); + of_property_read_u32(np, "vref-external", &st->vref_external); - spear_adc_configure(info); + spear_adc_configure(st); platform_set_drvdata(pdev, iodev); - init_completion(&info->completion); + init_completion(&st->completion); iodev->name = SPEAR_ADC_MOD_NAME; iodev->dev.parent = dev; - iodev->info = &spear_adc_iio_info; + iodev->info = &spear_adc_info; iodev->modes = INDIO_DIRECT_MODE; iodev->channels = spear_adc_iio_channels; iodev->num_channels = ARRAY_SIZE(spear_adc_iio_channels); @@ -355,23 +355,23 @@ static int spear_adc_probe(struct platform_device *pdev) return 0; errout3: - clk_disable_unprepare(info->clk); + clk_disable_unprepare(st->clk); errout2: - clk_put(info->clk); + clk_put(st->clk); errout1: - iounmap(info->adc_base_spear6xx); + iounmap(st->adc_base_spear6xx); return ret; } static int spear_adc_remove(struct platform_device *pdev) { struct iio_dev *iodev = platform_get_drvdata(pdev); - struct spear_adc_info *info = iio_priv(iodev); + struct spear_adc_state *st = iio_priv(iodev); iio_device_unregister(iodev); - clk_disable_unprepare(info->clk); - clk_put(info->clk); - iounmap(info->adc_base_spear6xx); + clk_disable_unprepare(st->clk); + clk_put(st->clk); + iounmap(st->adc_base_spear6xx); return 0; } -- cgit v1.2.3 From e90ba52f4dee0e8e96910efe96358b1f9ed0f9d2 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Sun, 4 May 2014 17:45:00 +0100 Subject: staging:iio:adc:spear rename iodev -> indio_dev to fit with current convention How we ended up with indio_dev is a mystery, but we have so in the interests of consistency, move this driver over to that convention. Signed-off-by: Jonathan Cameron Acked-by: Hartmut Knaack --- drivers/staging/iio/adc/spear_adc.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/drivers/staging/iio/adc/spear_adc.c b/drivers/staging/iio/adc/spear_adc.c index 3003e89b5779..52c26a6b7c1f 100644 --- a/drivers/staging/iio/adc/spear_adc.c +++ b/drivers/staging/iio/adc/spear_adc.c @@ -262,17 +262,17 @@ static int spear_adc_probe(struct platform_device *pdev) struct device_node *np = pdev->dev.of_node; struct device *dev = &pdev->dev; struct spear_adc_state *st; - struct iio_dev *iodev = NULL; + struct iio_dev *indio_dev = NULL; int ret = -ENODEV; int irq; - iodev = devm_iio_device_alloc(dev, sizeof(struct spear_adc_state)); - if (!iodev) { + indio_dev = devm_iio_device_alloc(dev, sizeof(struct spear_adc_state)); + if (!indio_dev) { dev_err(dev, "failed allocating iio device\n"); return -ENOMEM; } - st = iio_priv(iodev); + st = iio_priv(indio_dev); st->np = np; /* @@ -335,18 +335,18 @@ static int spear_adc_probe(struct platform_device *pdev) spear_adc_configure(st); - platform_set_drvdata(pdev, iodev); + platform_set_drvdata(pdev, indio_dev); init_completion(&st->completion); - iodev->name = SPEAR_ADC_MOD_NAME; - iodev->dev.parent = dev; - iodev->info = &spear_adc_info; - iodev->modes = INDIO_DIRECT_MODE; - iodev->channels = spear_adc_iio_channels; - iodev->num_channels = ARRAY_SIZE(spear_adc_iio_channels); + indio_dev->name = SPEAR_ADC_MOD_NAME; + indio_dev->dev.parent = dev; + indio_dev->info = &spear_adc_info; + indio_dev->modes = INDIO_DIRECT_MODE; + indio_dev->channels = spear_adc_iio_channels; + indio_dev->num_channels = ARRAY_SIZE(spear_adc_iio_channels); - ret = iio_device_register(iodev); + ret = iio_device_register(indio_dev); if (ret) goto errout3; @@ -365,10 +365,10 @@ errout1: static int spear_adc_remove(struct platform_device *pdev) { - struct iio_dev *iodev = platform_get_drvdata(pdev); - struct spear_adc_state *st = iio_priv(iodev); + struct iio_dev *indio_dev = platform_get_drvdata(pdev); + struct spear_adc_state *st = iio_priv(indio_dev); - iio_device_unregister(iodev); + iio_device_unregister(indio_dev); clk_disable_unprepare(st->clk); clk_put(st->clk); iounmap(st->adc_base_spear6xx); -- cgit v1.2.3 From e20d6090e314fa52f25e4a257de3672aa474122c Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Sun, 4 May 2014 17:45:00 +0100 Subject: staging:iio:adc:spear rename spear_read_raw to spear_adc_read_raw This brings it inline with all the other prefix usage in the driver. Signed-off-by: Jonathan Cameron Acked-by: Hartmut Knaack --- drivers/staging/iio/adc/spear_adc.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/staging/iio/adc/spear_adc.c b/drivers/staging/iio/adc/spear_adc.c index 52c26a6b7c1f..c5492ba50751 100644 --- a/drivers/staging/iio/adc/spear_adc.c +++ b/drivers/staging/iio/adc/spear_adc.c @@ -136,11 +136,11 @@ static void spear_adc_set_scanrate(struct spear_adc_state *st, u32 rate) } } -static int spear_read_raw(struct iio_dev *indio_dev, - struct iio_chan_spec const *chan, - int *val, - int *val2, - long mask) +static int spear_adc_read_raw(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, + int *val, + int *val2, + long mask) { struct spear_adc_state *st = iio_priv(indio_dev); u32 status; @@ -252,7 +252,7 @@ static int spear_adc_configure(struct spear_adc_state *st) } static const struct iio_info spear_adc_info = { - .read_raw = &spear_read_raw, + .read_raw = &spear_adc_read_raw, .write_raw = &spear_adc_write_raw, .driver_module = THIS_MODULE, }; -- cgit v1.2.3 From 9fb6bf02e3ad04c20edb8e46536ce3eeda32c736 Mon Sep 17 00:00:00 2001 From: Benjamin Tissoires Date: Mon, 7 Apr 2014 13:39:33 -0400 Subject: HID: rmi: introduce RMI driver for Synaptics touchpads This driver add support for RMI4 over USB or I2C. The current state is that it uses its own RMI4 implementation, but once RMI4 is merged upstream, the driver will be a transport driver for the RMI4 library. Part of this driver should be considered as temporary. Most of the RMI4 processing and input handling will be deleted at some point. I based my work on Andrew's regarding its port of RMI4 over HID (see https://github.com/mightybigcar/synaptics-rmi4/tree/rmihid ) This repo presents how the driver may looks like at the end: https://github.com/mightybigcar/synaptics-rmi4/blob/rmihid/drivers/input/rmi4/rmi_hid.c Without this temporary solution, the workaround we gave to users is to disable i2c-hid, which leads to disabling the touchscreen on the XPS 11 and 12 (Haswell generation). Related bugs: https://bugzilla.redhat.com/show_bug.cgi?id=1048314 https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1218973 Signed-off-by: Andrew Duggan Signed-off-by: Benjamin Tissoires Signed-off-by: Jiri Kosina --- drivers/hid/Kconfig | 8 + drivers/hid/Makefile | 1 + drivers/hid/hid-core.c | 2 + drivers/hid/hid-rmi.c | 889 +++++++++++++++++++++++++++++++++++++++++++++++++ include/linux/hid.h | 2 + 5 files changed, 902 insertions(+) create mode 100644 drivers/hid/hid-rmi.c diff --git a/drivers/hid/Kconfig b/drivers/hid/Kconfig index 7af9d0b5dea1..762f15d6ed88 100644 --- a/drivers/hid/Kconfig +++ b/drivers/hid/Kconfig @@ -657,6 +657,14 @@ config HID_SUNPLUS ---help--- Support for Sunplus wireless desktop. +config HID_RMI + tristate "Synaptics RMI4 device support" + depends on HID + ---help--- + Support for Synaptics RMI4 touchpads. + Say Y here if you have a Synaptics RMI4 touchpads over i2c-hid or usbhid + and want support for its special functionalities. + config HID_GREENASIA tristate "GreenAsia (Product ID 0x12) game controller support" depends on HID diff --git a/drivers/hid/Makefile b/drivers/hid/Makefile index fc712dde02a4..a6fa6baf368e 100644 --- a/drivers/hid/Makefile +++ b/drivers/hid/Makefile @@ -97,6 +97,7 @@ obj-$(CONFIG_HID_ROCCAT) += hid-roccat.o hid-roccat-common.o \ hid-roccat-arvo.o hid-roccat-isku.o hid-roccat-kone.o \ hid-roccat-koneplus.o hid-roccat-konepure.o hid-roccat-kovaplus.o \ hid-roccat-lua.o hid-roccat-pyra.o hid-roccat-ryos.o hid-roccat-savu.o +obj-$(CONFIG_HID_RMI) += hid-rmi.o obj-$(CONFIG_HID_SAITEK) += hid-saitek.o obj-$(CONFIG_HID_SAMSUNG) += hid-samsung.o obj-$(CONFIG_HID_SMARTJOYPLUS) += hid-sjoy.o diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c index 9e8064205bc7..f05255d92de7 100644 --- a/drivers/hid/hid-core.c +++ b/drivers/hid/hid-core.c @@ -1882,6 +1882,8 @@ static const struct hid_device_id hid_have_special_driver[] = { { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_VAIO_VGP_MOUSE) }, { HID_USB_DEVICE(USB_VENDOR_ID_STEELSERIES, USB_DEVICE_ID_STEELSERIES_SRWS1) }, { HID_USB_DEVICE(USB_VENDOR_ID_SUNPLUS, USB_DEVICE_ID_SUNPLUS_WDESKTOP) }, + { HID_USB_DEVICE(USB_VENDOR_ID_SYNAPTICS, HID_ANY_ID) }, + { HID_I2C_DEVICE(USB_VENDOR_ID_SYNAPTICS, HID_ANY_ID) }, { HID_USB_DEVICE(USB_VENDOR_ID_THINGM, USB_DEVICE_ID_BLINK1) }, { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb300) }, { HID_USB_DEVICE(USB_VENDOR_ID_THRUSTMASTER, 0xb304) }, diff --git a/drivers/hid/hid-rmi.c b/drivers/hid/hid-rmi.c new file mode 100644 index 000000000000..699d631c6920 --- /dev/null +++ b/drivers/hid/hid-rmi.c @@ -0,0 +1,889 @@ +/* + * Copyright (c) 2013 Andrew Duggan + * Copyright (c) 2013 Synaptics Incorporated + * Copyright (c) 2014 Benjamin Tissoires + * Copyright (c) 2014 Red Hat, Inc + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "hid-ids.h" + +#define RMI_MOUSE_REPORT_ID 0x01 /* Mouse emulation Report */ +#define RMI_WRITE_REPORT_ID 0x09 /* Output Report */ +#define RMI_READ_ADDR_REPORT_ID 0x0a /* Output Report */ +#define RMI_READ_DATA_REPORT_ID 0x0b /* Input Report */ +#define RMI_ATTN_REPORT_ID 0x0c /* Input Report */ +#define RMI_SET_RMI_MODE_REPORT_ID 0x0f /* Feature Report */ + +/* flags */ +#define RMI_READ_REQUEST_PENDING BIT(0) +#define RMI_READ_DATA_PENDING BIT(1) +#define RMI_STARTED BIT(2) + +enum rmi_mode_type { + RMI_MODE_OFF = 0, + RMI_MODE_ATTN_REPORTS = 1, + RMI_MODE_NO_PACKED_ATTN_REPORTS = 2, +}; + +struct rmi_function { + unsigned page; /* page of the function */ + u16 query_base_addr; /* base address for queries */ + u16 command_base_addr; /* base address for commands */ + u16 control_base_addr; /* base address for controls */ + u16 data_base_addr; /* base address for datas */ + unsigned int interrupt_base; /* cross-function interrupt number + * (uniq in the device)*/ + unsigned int interrupt_count; /* number of interrupts */ + unsigned int report_size; /* size of a report */ + unsigned long irq_mask; /* mask of the interrupts + * (to be applied against ATTN IRQ) */ +}; + +/** + * struct rmi_data - stores information for hid communication + * + * @page_mutex: Locks current page to avoid changing pages in unexpected ways. + * @page: Keeps track of the current virtual page + * + * @wait: Used for waiting for read data + * + * @writeReport: output buffer when writing RMI registers + * @readReport: input buffer when reading RMI registers + * + * @input_report_size: size of an input report (advertised by HID) + * @output_report_size: size of an output report (advertised by HID) + * + * @flags: flags for the current device (started, reading, etc...) + * + * @f11: placeholder of internal RMI function F11 description + * @f30: placeholder of internal RMI function F30 description + * + * @max_fingers: maximum finger count reported by the device + * @max_x: maximum x value reported by the device + * @max_y: maximum y value reported by the device + * + * @gpio_led_count: count of GPIOs + LEDs reported by F30 + * @button_count: actual physical buttons count + * @button_mask: button mask used to decode GPIO ATTN reports + * @button_state_mask: pull state of the buttons + * + * @input: pointer to the kernel input device + * + * @reset_work: worker which will be called in case of a mouse report + * @hdev: pointer to the struct hid_device + */ +struct rmi_data { + struct mutex page_mutex; + int page; + + wait_queue_head_t wait; + + u8 *writeReport; + u8 *readReport; + + int input_report_size; + int output_report_size; + + unsigned long flags; + + struct rmi_function f11; + struct rmi_function f30; + + unsigned int max_fingers; + unsigned int max_x; + unsigned int max_y; + unsigned int x_size_mm; + unsigned int y_size_mm; + + unsigned int gpio_led_count; + unsigned int button_count; + unsigned long button_mask; + unsigned long button_state_mask; + + struct input_dev *input; + + struct work_struct reset_work; + struct hid_device *hdev; +}; + +#define RMI_PAGE(addr) (((addr) >> 8) & 0xff) + +static int rmi_write_report(struct hid_device *hdev, u8 *report, int len); + +/** + * rmi_set_page - Set RMI page + * @hdev: The pointer to the hid_device struct + * @page: The new page address. + * + * RMI devices have 16-bit addressing, but some of the physical + * implementations (like SMBus) only have 8-bit addressing. So RMI implements + * a page address at 0xff of every page so we can reliable page addresses + * every 256 registers. + * + * The page_mutex lock must be held when this function is entered. + * + * Returns zero on success, non-zero on failure. + */ +static int rmi_set_page(struct hid_device *hdev, u8 page) +{ + struct rmi_data *data = hid_get_drvdata(hdev); + int retval; + + data->writeReport[0] = RMI_WRITE_REPORT_ID; + data->writeReport[1] = 1; + data->writeReport[2] = 0xFF; + data->writeReport[4] = page; + + retval = rmi_write_report(hdev, data->writeReport, + data->output_report_size); + if (retval != data->output_report_size) { + dev_err(&hdev->dev, + "%s: set page failed: %d.", __func__, retval); + return retval; + } + + data->page = page; + return 0; +} + +static int rmi_set_mode(struct hid_device *hdev, u8 mode) +{ + int ret; + u8 txbuf[2] = {RMI_SET_RMI_MODE_REPORT_ID, mode}; + + ret = hid_hw_raw_request(hdev, RMI_SET_RMI_MODE_REPORT_ID, txbuf, + sizeof(txbuf), HID_FEATURE_REPORT, HID_REQ_SET_REPORT); + if (ret < 0) { + dev_err(&hdev->dev, "unable to set rmi mode to %d (%d)\n", mode, + ret); + return ret; + } + + return 0; +} + +static int rmi_write_report(struct hid_device *hdev, u8 *report, int len) +{ + int ret; + + ret = hid_hw_output_report(hdev, (void *)report, len); + if (ret < 0) { + dev_err(&hdev->dev, "failed to write hid report (%d)\n", ret); + return ret; + } + + return ret; +} + +static int rmi_read_block(struct hid_device *hdev, u16 addr, void *buf, + const int len) +{ + struct rmi_data *data = hid_get_drvdata(hdev); + int ret; + int bytes_read; + int bytes_needed; + int retries; + int read_input_count; + + mutex_lock(&data->page_mutex); + + if (RMI_PAGE(addr) != data->page) { + ret = rmi_set_page(hdev, RMI_PAGE(addr)); + if (ret < 0) + goto exit; + } + + for (retries = 5; retries > 0; retries--) { + data->writeReport[0] = RMI_READ_ADDR_REPORT_ID; + data->writeReport[1] = 0; /* old 1 byte read count */ + data->writeReport[2] = addr & 0xFF; + data->writeReport[3] = (addr >> 8) & 0xFF; + data->writeReport[4] = len & 0xFF; + data->writeReport[5] = (len >> 8) & 0xFF; + + set_bit(RMI_READ_REQUEST_PENDING, &data->flags); + + ret = rmi_write_report(hdev, data->writeReport, + data->output_report_size); + if (ret != data->output_report_size) { + clear_bit(RMI_READ_REQUEST_PENDING, &data->flags); + dev_err(&hdev->dev, + "failed to write request output report (%d)\n", + ret); + goto exit; + } + + bytes_read = 0; + bytes_needed = len; + while (bytes_read < len) { + if (!wait_event_timeout(data->wait, + test_bit(RMI_READ_DATA_PENDING, &data->flags), + msecs_to_jiffies(1000))) { + hid_warn(hdev, "%s: timeout elapsed\n", + __func__); + ret = -EAGAIN; + break; + } + + read_input_count = data->readReport[1]; + memcpy(buf + bytes_read, &data->readReport[2], + read_input_count < bytes_needed ? + read_input_count : bytes_needed); + + bytes_read += read_input_count; + bytes_needed -= read_input_count; + clear_bit(RMI_READ_DATA_PENDING, &data->flags); + } + + if (ret >= 0) { + ret = 0; + break; + } + } + +exit: + clear_bit(RMI_READ_REQUEST_PENDING, &data->flags); + mutex_unlock(&data->page_mutex); + return ret; +} + +static inline int rmi_read(struct hid_device *hdev, u16 addr, void *buf) +{ + return rmi_read_block(hdev, addr, buf, 1); +} + +static void rmi_f11_process_touch(struct rmi_data *hdata, int slot, + u8 finger_state, u8 *touch_data) +{ + int x, y, wx, wy; + int wide, major, minor; + int z; + + input_mt_slot(hdata->input, slot); + input_mt_report_slot_state(hdata->input, MT_TOOL_FINGER, + finger_state == 0x01); + if (finger_state == 0x01) { + x = (touch_data[0] << 4) | (touch_data[2] & 0x07); + y = (touch_data[1] << 4) | (touch_data[2] >> 4); + wx = touch_data[3] & 0x07; + wy = touch_data[3] >> 4; + wide = (wx > wy); + major = max(wx, wy); + minor = min(wx, wy); + z = touch_data[4]; + + /* y is inverted */ + y = hdata->max_y - y; + + input_event(hdata->input, EV_ABS, ABS_MT_POSITION_X, x); + input_event(hdata->input, EV_ABS, ABS_MT_POSITION_Y, y); + input_event(hdata->input, EV_ABS, ABS_MT_ORIENTATION, wide); + input_event(hdata->input, EV_ABS, ABS_MT_PRESSURE, z); + input_event(hdata->input, EV_ABS, ABS_MT_TOUCH_MAJOR, major); + input_event(hdata->input, EV_ABS, ABS_MT_TOUCH_MINOR, minor); + } +} + +static void rmi_reset_work(struct work_struct *work) +{ + struct rmi_data *hdata = container_of(work, struct rmi_data, + reset_work); + + /* switch the device to RMI if we receive a generic mouse report */ + rmi_set_mode(hdata->hdev, RMI_MODE_ATTN_REPORTS); +} + +static inline int rmi_schedule_reset(struct hid_device *hdev) +{ + struct rmi_data *hdata = hid_get_drvdata(hdev); + return schedule_work(&hdata->reset_work); +} + +static int rmi_f11_input_event(struct hid_device *hdev, u8 irq, u8 *data, + int size) +{ + struct rmi_data *hdata = hid_get_drvdata(hdev); + int offset; + int i; + + if (size < hdata->f11.report_size) + return 0; + + if (!(irq & hdata->f11.irq_mask)) + return 0; + + offset = (hdata->max_fingers >> 2) + 1; + for (i = 0; i < hdata->max_fingers; i++) { + int fs_byte_position = i >> 2; + int fs_bit_position = (i & 0x3) << 1; + int finger_state = (data[fs_byte_position] >> fs_bit_position) & + 0x03; + + rmi_f11_process_touch(hdata, i, finger_state, + &data[offset + 5 * i]); + } + input_mt_sync_frame(hdata->input); + input_sync(hdata->input); + return hdata->f11.report_size; +} + +static int rmi_f30_input_event(struct hid_device *hdev, u8 irq, u8 *data, + int size) +{ + struct rmi_data *hdata = hid_get_drvdata(hdev); + int i; + int button = 0; + bool value; + + if (!(irq & hdata->f30.irq_mask)) + return 0; + + for (i = 0; i < hdata->gpio_led_count; i++) { + if (test_bit(i, &hdata->button_mask)) { + value = (data[i / 8] >> (i & 0x07)) & BIT(0); + if (test_bit(i, &hdata->button_state_mask)) + value = !value; + input_event(hdata->input, EV_KEY, BTN_LEFT + button++, + value); + } + } + return hdata->f30.report_size; +} + +static int rmi_input_event(struct hid_device *hdev, u8 *data, int size) +{ + struct rmi_data *hdata = hid_get_drvdata(hdev); + unsigned long irq_mask = 0; + unsigned index = 2; + + if (!(test_bit(RMI_STARTED, &hdata->flags))) + return 0; + + irq_mask |= hdata->f11.irq_mask; + irq_mask |= hdata->f30.irq_mask; + + if (data[1] & ~irq_mask) + hid_warn(hdev, "unknown intr source:%02lx %s:%d\n", + data[1] & ~irq_mask, __FILE__, __LINE__); + + if (hdata->f11.interrupt_base < hdata->f30.interrupt_base) { + index += rmi_f11_input_event(hdev, data[1], &data[index], + size - index); + index += rmi_f30_input_event(hdev, data[1], &data[index], + size - index); + } else { + index += rmi_f30_input_event(hdev, data[1], &data[index], + size - index); + index += rmi_f11_input_event(hdev, data[1], &data[index], + size - index); + } + + return 1; +} + +static int rmi_read_data_event(struct hid_device *hdev, u8 *data, int size) +{ + struct rmi_data *hdata = hid_get_drvdata(hdev); + + if (!test_bit(RMI_READ_REQUEST_PENDING, &hdata->flags)) { + hid_err(hdev, "no read request pending\n"); + return 0; + } + + memcpy(hdata->readReport, data, size < hdata->input_report_size ? + size : hdata->input_report_size); + set_bit(RMI_READ_DATA_PENDING, &hdata->flags); + wake_up(&hdata->wait); + + return 1; +} + +static int rmi_raw_event(struct hid_device *hdev, + struct hid_report *report, u8 *data, int size) +{ + switch (data[0]) { + case RMI_READ_DATA_REPORT_ID: + return rmi_read_data_event(hdev, data, size); + case RMI_ATTN_REPORT_ID: + return rmi_input_event(hdev, data, size); + case RMI_MOUSE_REPORT_ID: + rmi_schedule_reset(hdev); + break; + } + + return 0; +} + +static int rmi_post_reset(struct hid_device *hdev) +{ + return rmi_set_mode(hdev, RMI_MODE_ATTN_REPORTS); +} + +static int rmi_post_resume(struct hid_device *hdev) +{ + return rmi_set_mode(hdev, RMI_MODE_ATTN_REPORTS); +} + +#define RMI4_MAX_PAGE 0xff +#define RMI4_PAGE_SIZE 0x0100 + +#define PDT_START_SCAN_LOCATION 0x00e9 +#define PDT_END_SCAN_LOCATION 0x0005 +#define RMI4_END_OF_PDT(id) ((id) == 0x00 || (id) == 0xff) + +struct pdt_entry { + u8 query_base_addr:8; + u8 command_base_addr:8; + u8 control_base_addr:8; + u8 data_base_addr:8; + u8 interrupt_source_count:3; + u8 bits3and4:2; + u8 function_version:2; + u8 bit7:1; + u8 function_number:8; +} __attribute__((__packed__)); + +static inline unsigned long rmi_gen_mask(unsigned irq_base, unsigned irq_count) +{ + return GENMASK(irq_count + irq_base - 1, irq_base); +} + +static void rmi_register_function(struct rmi_data *data, + struct pdt_entry *pdt_entry, int page, unsigned interrupt_count) +{ + struct rmi_function *f = NULL; + u16 page_base = page << 8; + + switch (pdt_entry->function_number) { + case 0x11: + f = &data->f11; + break; + case 0x30: + f = &data->f30; + break; + } + + if (f) { + f->page = page; + f->query_base_addr = page_base | pdt_entry->query_base_addr; + f->command_base_addr = page_base | pdt_entry->command_base_addr; + f->control_base_addr = page_base | pdt_entry->control_base_addr; + f->data_base_addr = page_base | pdt_entry->data_base_addr; + f->interrupt_base = interrupt_count; + f->interrupt_count = pdt_entry->interrupt_source_count; + f->irq_mask = rmi_gen_mask(f->interrupt_base, + f->interrupt_count); + } +} + +static int rmi_scan_pdt(struct hid_device *hdev) +{ + struct rmi_data *data = hid_get_drvdata(hdev); + struct pdt_entry entry; + int page; + bool page_has_function; + int i; + int retval; + int interrupt = 0; + u16 page_start, pdt_start , pdt_end; + + hid_info(hdev, "Scanning PDT...\n"); + + for (page = 0; (page <= RMI4_MAX_PAGE); page++) { + page_start = RMI4_PAGE_SIZE * page; + pdt_start = page_start + PDT_START_SCAN_LOCATION; + pdt_end = page_start + PDT_END_SCAN_LOCATION; + + page_has_function = false; + for (i = pdt_start; i >= pdt_end; i -= sizeof(entry)) { + retval = rmi_read_block(hdev, i, &entry, sizeof(entry)); + if (retval) { + hid_err(hdev, + "Read of PDT entry at %#06x failed.\n", + i); + goto error_exit; + } + + if (RMI4_END_OF_PDT(entry.function_number)) + break; + + page_has_function = true; + + hid_info(hdev, "Found F%02X on page %#04x\n", + entry.function_number, page); + + rmi_register_function(data, &entry, page, interrupt); + interrupt += entry.interrupt_source_count; + } + + if (!page_has_function) + break; + } + + hid_info(hdev, "%s: Done with PDT scan.\n", __func__); + retval = 0; + +error_exit: + return retval; +} + +static int rmi_populate_f11(struct hid_device *hdev) +{ + struct rmi_data *data = hid_get_drvdata(hdev); + u8 buf[20]; + int ret; + bool has_query12; + bool has_physical_props; + unsigned x_size, y_size; + + if (!data->f11.query_base_addr) { + hid_err(hdev, "No 2D sensor found, giving up.\n"); + return -ENODEV; + } + + /* query 0 contains some useful information */ + ret = rmi_read(hdev, data->f11.query_base_addr, buf); + if (ret) { + hid_err(hdev, "can not get query 0: %d.\n", ret); + return ret; + } + has_query12 = !!(buf[0] & BIT(5)); + + /* query 1 to get the max number of fingers */ + ret = rmi_read(hdev, data->f11.query_base_addr + 1, buf); + if (ret) { + hid_err(hdev, "can not get NumberOfFingers: %d.\n", ret); + return ret; + } + data->max_fingers = (buf[0] & 0x07) + 1; + if (data->max_fingers > 5) + data->max_fingers = 10; + + data->f11.report_size = data->max_fingers * 5 + + DIV_ROUND_UP(data->max_fingers, 4); + + if (!(buf[0] & BIT(4))) { + hid_err(hdev, "No absolute events, giving up.\n"); + return -ENODEV; + } + + /* + * query 12 to know if the physical properties are reported + * (query 12 is at offset 10 for HID devices) + */ + if (has_query12) { + ret = rmi_read(hdev, data->f11.query_base_addr + 10, buf); + if (ret) { + hid_err(hdev, "can not get query 12: %d.\n", ret); + return ret; + } + has_physical_props = !!(buf[0] & BIT(5)); + + if (has_physical_props) { + ret = rmi_read_block(hdev, + data->f11.query_base_addr + 11, buf, 4); + if (ret) { + hid_err(hdev, "can not read query 15-18: %d.\n", + ret); + return ret; + } + + x_size = buf[0] | (buf[1] << 8); + y_size = buf[2] | (buf[3] << 8); + + data->x_size_mm = DIV_ROUND_CLOSEST(x_size, 10); + data->y_size_mm = DIV_ROUND_CLOSEST(y_size, 10); + + hid_info(hdev, "%s: size in mm: %d x %d\n", + __func__, data->x_size_mm, data->y_size_mm); + } + } + + /* retrieve the ctrl registers */ + ret = rmi_read_block(hdev, data->f11.control_base_addr, buf, 20); + if (ret) { + hid_err(hdev, "can not read ctrl block of size 20: %d.\n", ret); + return ret; + } + + data->max_x = buf[6] | (buf[7] << 8); + data->max_y = buf[8] | (buf[9] << 8); + + return 0; +} + +static int rmi_populate_f30(struct hid_device *hdev) +{ + struct rmi_data *data = hid_get_drvdata(hdev); + u8 buf[20]; + int ret; + bool has_gpio, has_led; + unsigned bytes_per_ctrl; + u8 ctrl2_addr; + int ctrl2_3_length; + int i; + + /* function F30 is for physical buttons */ + if (!data->f30.query_base_addr) { + hid_err(hdev, "No GPIO/LEDs found, giving up.\n"); + return -ENODEV; + } + + ret = rmi_read_block(hdev, data->f30.query_base_addr, buf, 2); + if (ret) { + hid_err(hdev, "can not get F30 query registers: %d.\n", ret); + return ret; + } + + has_gpio = !!(buf[0] & BIT(3)); + has_led = !!(buf[0] & BIT(2)); + data->gpio_led_count = buf[1] & 0x1f; + + /* retrieve ctrl 2 & 3 registers */ + bytes_per_ctrl = (data->gpio_led_count + 7) / 8; + /* Ctrl0 is present only if both has_gpio and has_led are set*/ + ctrl2_addr = (has_gpio && has_led) ? bytes_per_ctrl : 0; + /* Ctrl1 is always be present */ + ctrl2_addr += bytes_per_ctrl; + ctrl2_3_length = 2 * bytes_per_ctrl; + + data->f30.report_size = bytes_per_ctrl; + + ret = rmi_read_block(hdev, data->f30.control_base_addr + ctrl2_addr, + buf, ctrl2_3_length); + if (ret) { + hid_err(hdev, "can not read ctrl 2&3 block of size %d: %d.\n", + ctrl2_3_length, ret); + return ret; + } + + for (i = 0; i < data->gpio_led_count; i++) { + int byte_position = i >> 3; + int bit_position = i & 0x07; + u8 dir_byte = buf[byte_position]; + u8 data_byte = buf[byte_position + bytes_per_ctrl]; + bool dir = (dir_byte >> bit_position) & BIT(0); + bool dat = (data_byte >> bit_position) & BIT(0); + + if (dir == 0) { + /* input mode */ + if (dat) { + /* actual buttons have pull up resistor */ + data->button_count++; + set_bit(i, &data->button_mask); + set_bit(i, &data->button_state_mask); + } + } + + } + + return 0; +} + +static int rmi_populate(struct hid_device *hdev) +{ + int ret; + + ret = rmi_scan_pdt(hdev); + if (ret) { + hid_err(hdev, "PDT scan failed with code %d.\n", ret); + return ret; + } + + ret = rmi_populate_f11(hdev); + if (ret) { + hid_err(hdev, "Error while initializing F11 (%d).\n", ret); + return ret; + } + + ret = rmi_populate_f30(hdev); + if (ret) + hid_warn(hdev, "Error while initializing F30 (%d).\n", ret); + + return 0; +} + +static void rmi_input_configured(struct hid_device *hdev, struct hid_input *hi) +{ + struct rmi_data *data = hid_get_drvdata(hdev); + struct input_dev *input = hi->input; + int ret; + int res_x, res_y, i; + + data->input = input; + + hid_dbg(hdev, "Opening low level driver\n"); + ret = hid_hw_open(hdev); + if (ret) + return; + + /* Allow incoming hid reports */ + hid_device_io_start(hdev); + + ret = rmi_set_mode(hdev, RMI_MODE_ATTN_REPORTS); + if (ret < 0) { + dev_err(&hdev->dev, "failed to set rmi mode\n"); + goto exit; + } + + ret = rmi_set_page(hdev, 0); + if (ret < 0) { + dev_err(&hdev->dev, "failed to set page select to 0.\n"); + goto exit; + } + + ret = rmi_populate(hdev); + if (ret) + goto exit; + + __set_bit(EV_ABS, input->evbit); + input_set_abs_params(input, ABS_MT_POSITION_X, 1, data->max_x, 0, 0); + input_set_abs_params(input, ABS_MT_POSITION_Y, 1, data->max_y, 0, 0); + + if (data->x_size_mm && data->x_size_mm) { + res_x = (data->max_x - 1) / data->x_size_mm; + res_y = (data->max_y - 1) / data->x_size_mm; + + input_abs_set_res(input, ABS_MT_POSITION_X, res_x); + input_abs_set_res(input, ABS_MT_POSITION_Y, res_y); + } + + input_set_abs_params(input, ABS_MT_ORIENTATION, 0, 1, 0, 0); + input_set_abs_params(input, ABS_MT_PRESSURE, 0, 0xff, 0, 0); + input_set_abs_params(input, ABS_MT_TOUCH_MAJOR, 0, 0x0f, 0, 0); + input_set_abs_params(input, ABS_MT_TOUCH_MINOR, 0, 0x0f, 0, 0); + + input_mt_init_slots(input, data->max_fingers, INPUT_MT_POINTER); + + if (data->button_count) { + __set_bit(EV_KEY, input->evbit); + for (i = 0; i < data->button_count; i++) + __set_bit(BTN_LEFT + i, input->keybit); + + if (data->button_count == 1) + __set_bit(INPUT_PROP_BUTTONPAD, input->propbit); + } + + set_bit(RMI_STARTED, &data->flags); + +exit: + hid_device_io_stop(hdev); + hid_hw_close(hdev); +} + +static int rmi_input_mapping(struct hid_device *hdev, + struct hid_input *hi, struct hid_field *field, + struct hid_usage *usage, unsigned long **bit, int *max) +{ + /* we want to make HID ignore the advertised HID collection */ + return -1; +} + +static int rmi_probe(struct hid_device *hdev, const struct hid_device_id *id) +{ + struct rmi_data *data = NULL; + int ret; + size_t alloc_size; + + data = devm_kzalloc(&hdev->dev, sizeof(struct rmi_data), GFP_KERNEL); + if (!data) + return -ENOMEM; + + INIT_WORK(&data->reset_work, rmi_reset_work); + data->hdev = hdev; + + hid_set_drvdata(hdev, data); + + hdev->quirks |= HID_QUIRK_NO_INIT_REPORTS; + + ret = hid_parse(hdev); + if (ret) { + hid_err(hdev, "parse failed\n"); + return ret; + } + + data->input_report_size = (hdev->report_enum[HID_INPUT_REPORT] + .report_id_hash[RMI_ATTN_REPORT_ID]->size >> 3) + + 1 /* report id */; + data->output_report_size = (hdev->report_enum[HID_OUTPUT_REPORT] + .report_id_hash[RMI_WRITE_REPORT_ID]->size >> 3) + + 1 /* report id */; + + alloc_size = data->output_report_size + data->input_report_size; + + data->writeReport = devm_kzalloc(&hdev->dev, alloc_size, GFP_KERNEL); + if (!data->writeReport) { + ret = -ENOMEM; + return ret; + } + + data->readReport = data->writeReport + data->output_report_size; + + init_waitqueue_head(&data->wait); + + mutex_init(&data->page_mutex); + + ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT); + if (ret) { + hid_err(hdev, "hw start failed\n"); + return ret; + } + + if (!test_bit(RMI_STARTED, &data->flags)) { + hid_hw_stop(hdev); + return -EIO; + } + + hid_hw_stop(hdev); + return 0; +} + +static void rmi_remove(struct hid_device *hdev) +{ + struct rmi_data *hdata = hid_get_drvdata(hdev); + + clear_bit(RMI_STARTED, &hdata->flags); + + hid_hw_stop(hdev); +} + +static const struct hid_device_id rmi_id[] = { + { HID_I2C_DEVICE(USB_VENDOR_ID_SYNAPTICS, HID_ANY_ID) }, + { HID_USB_DEVICE(USB_VENDOR_ID_SYNAPTICS, HID_ANY_ID) }, + { } +}; +MODULE_DEVICE_TABLE(hid, rmi_id); + +static struct hid_driver rmi_driver = { + .name = "hid-rmi", + .id_table = rmi_id, + .probe = rmi_probe, + .remove = rmi_remove, + .raw_event = rmi_raw_event, + .input_mapping = rmi_input_mapping, + .input_configured = rmi_input_configured, +#ifdef CONFIG_PM + .resume = rmi_post_resume, + .reset_resume = rmi_post_reset, +#endif +}; + +module_hid_driver(rmi_driver); + +MODULE_AUTHOR("Andrew Duggan "); +MODULE_DESCRIPTION("RMI HID driver"); +MODULE_LICENSE("GPL"); diff --git a/include/linux/hid.h b/include/linux/hid.h index 720e3a10608c..54f855b2c902 100644 --- a/include/linux/hid.h +++ b/include/linux/hid.h @@ -570,6 +570,8 @@ struct hid_descriptor { .bus = BUS_USB, .vendor = (ven), .product = (prod) #define HID_BLUETOOTH_DEVICE(ven, prod) \ .bus = BUS_BLUETOOTH, .vendor = (ven), .product = (prod) +#define HID_I2C_DEVICE(ven, prod) \ + .bus = BUS_I2C, .vendor = (ven), .product = (prod) #define HID_REPORT_ID(rep) \ .report_type = (rep) -- cgit v1.2.3 From b89f991af08244121e69a3ee90cfa397598cf3ab Mon Sep 17 00:00:00 2001 From: Benjamin Tissoires Date: Wed, 9 Apr 2014 11:01:34 -0400 Subject: HID: rmi: do not stop the device at the end of probe Well, this is embarrassing, if the device is stopped at the end of probe, we get into big trouble. This was a leftover of an attempt to be smart when sending the patch, I deeply apologies. Signed-off-by: Benjamin Tissoires Signed-off-by: Jiri Kosina --- drivers/hid/hid-rmi.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/hid/hid-rmi.c b/drivers/hid/hid-rmi.c index 699d631c6920..7da9509894de 100644 --- a/drivers/hid/hid-rmi.c +++ b/drivers/hid/hid-rmi.c @@ -848,7 +848,6 @@ static int rmi_probe(struct hid_device *hdev, const struct hid_device_id *id) return -EIO; } - hid_hw_stop(hdev); return 0; } -- cgit v1.2.3 From 59c3d45e487315e6e05a3f2310b61109f8e503e7 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Tue, 8 Apr 2014 09:15:35 -0600 Subject: block: remove 'q' parameter from kblockd_schedule_*_work() The queue parameter is never used, just get rid of it. Signed-off-by: Jens Axboe --- block/blk-core.c | 6 +++--- block/blk-flush.c | 2 +- block/blk-mq.c | 7 ++----- block/cfq-iosched.c | 2 +- drivers/scsi/scsi_lib.c | 2 +- include/linux/blkdev.h | 4 ++-- 6 files changed, 10 insertions(+), 13 deletions(-) diff --git a/block/blk-core.c b/block/blk-core.c index 34d7c196338b..f7d2c3335dfa 100644 --- a/block/blk-core.c +++ b/block/blk-core.c @@ -2904,14 +2904,14 @@ free_and_out: } EXPORT_SYMBOL_GPL(blk_rq_prep_clone); -int kblockd_schedule_work(struct request_queue *q, struct work_struct *work) +int kblockd_schedule_work(struct work_struct *work) { return queue_work(kblockd_workqueue, work); } EXPORT_SYMBOL(kblockd_schedule_work); -int kblockd_schedule_delayed_work(struct request_queue *q, - struct delayed_work *dwork, unsigned long delay) +int kblockd_schedule_delayed_work(struct delayed_work *dwork, + unsigned long delay) { return queue_delayed_work(kblockd_workqueue, dwork, delay); } diff --git a/block/blk-flush.c b/block/blk-flush.c index 43e6b4755e9a..77f20458910c 100644 --- a/block/blk-flush.c +++ b/block/blk-flush.c @@ -144,7 +144,7 @@ static bool blk_flush_queue_rq(struct request *rq, bool add_front) { if (rq->q->mq_ops) { INIT_WORK(&rq->mq_flush_work, mq_flush_run); - kblockd_schedule_work(rq->q, &rq->mq_flush_work); + kblockd_schedule_work(&rq->mq_flush_work); return false; } else { if (add_front) diff --git a/block/blk-mq.c b/block/blk-mq.c index 1d2a9bdbee57..9c8f1f4ada7f 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -608,11 +608,8 @@ void blk_mq_run_hw_queue(struct blk_mq_hw_ctx *hctx, bool async) if (!async) __blk_mq_run_hw_queue(hctx); - else { - struct request_queue *q = hctx->queue; - - kblockd_schedule_delayed_work(q, &hctx->delayed_work, 0); - } + else + kblockd_schedule_delayed_work(&hctx->delayed_work, 0); } void blk_mq_run_queues(struct request_queue *q, bool async) diff --git a/block/cfq-iosched.c b/block/cfq-iosched.c index e0985f1955e7..5063a0bd831a 100644 --- a/block/cfq-iosched.c +++ b/block/cfq-iosched.c @@ -908,7 +908,7 @@ static inline void cfq_schedule_dispatch(struct cfq_data *cfqd) { if (cfqd->busy_queues) { cfq_log(cfqd, "schedule dispatch"); - kblockd_schedule_work(cfqd->queue, &cfqd->unplug_work); + kblockd_schedule_work(&cfqd->unplug_work); } } diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index 5681c05ac506..91f99f4ce2e8 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -139,7 +139,7 @@ static void __scsi_queue_insert(struct scsi_cmnd *cmd, int reason, int unbusy) */ spin_lock_irqsave(q->queue_lock, flags); blk_requeue_request(q, cmd->request); - kblockd_schedule_work(q, &device->requeue_work); + kblockd_schedule_work(&device->requeue_work); spin_unlock_irqrestore(q->queue_lock, flags); } diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index 1e1fa3f93d5f..2425945d36ab 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -1359,8 +1359,8 @@ static inline void put_dev_sector(Sector p) } struct work_struct; -int kblockd_schedule_work(struct request_queue *q, struct work_struct *work); -int kblockd_schedule_delayed_work(struct request_queue *q, struct delayed_work *dwork, unsigned long delay); +int kblockd_schedule_work(struct work_struct *work); +int kblockd_schedule_delayed_work(struct delayed_work *dwork, unsigned long delay); #ifdef CONFIG_BLK_CGROUP /* -- cgit v1.2.3 From 8ab14595b6dffecea264dcca2d6d9eea7c59273a Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Tue, 8 Apr 2014 09:17:40 -0600 Subject: block: add kblockd_schedule_delayed_work_on() Same function as kblockd_schedule_delayed_work(), but allow the caller to pass in a CPU that the work should be executed on. This just directly extends and maps into the workqueue API, and will be used to make the blk-mq mappings more strict. Signed-off-by: Jens Axboe --- block/blk-core.c | 7 +++++++ include/linux/blkdev.h | 1 + 2 files changed, 8 insertions(+) diff --git a/block/blk-core.c b/block/blk-core.c index f7d2c3335dfa..7af4a4898dcb 100644 --- a/block/blk-core.c +++ b/block/blk-core.c @@ -2917,6 +2917,13 @@ int kblockd_schedule_delayed_work(struct delayed_work *dwork, } EXPORT_SYMBOL(kblockd_schedule_delayed_work); +int kblockd_schedule_delayed_work_on(int cpu, struct delayed_work *dwork, + unsigned long delay) +{ + return queue_delayed_work_on(cpu, kblockd_workqueue, dwork, delay); +} +EXPORT_SYMBOL(kblockd_schedule_delayed_work_on); + #define PLUG_MAGIC 0x91827364 /** diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index 2425945d36ab..5a31307c5ded 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -1361,6 +1361,7 @@ static inline void put_dev_sector(Sector p) struct work_struct; int kblockd_schedule_work(struct work_struct *work); int kblockd_schedule_delayed_work(struct delayed_work *dwork, unsigned long delay); +int kblockd_schedule_delayed_work_on(int cpu, struct delayed_work *dwork, unsigned long delay); #ifdef CONFIG_BLK_CGROUP /* -- cgit v1.2.3 From e4043dcf30811f5db15181168e2aac172514302a Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Wed, 9 Apr 2014 10:18:23 -0600 Subject: blk-mq: ensure that hardware queues are always run on the mapped CPUs Instead of providing soft mappings with no guarantees on hardware queues always being run on the right CPU, switch to a hard mapping guarantee that ensure that we always run the hardware queue on (one of, if more) the mapped CPU. Signed-off-by: Jens Axboe --- block/blk-mq.c | 66 ++++++++++++++++++++++++++++++++++++++------------ include/linux/blk-mq.h | 1 + 2 files changed, 52 insertions(+), 15 deletions(-) diff --git a/block/blk-mq.c b/block/blk-mq.c index 9c8f1f4ada7f..5455ed19de1c 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -209,11 +209,14 @@ static struct request *blk_mq_alloc_request_pinned(struct request_queue *q, break; } - blk_mq_put_ctx(ctx); - if (!(gfp & __GFP_WAIT)) + if (gfp & __GFP_WAIT) { + __blk_mq_run_hw_queue(hctx); + blk_mq_put_ctx(ctx); + } else { + blk_mq_put_ctx(ctx); break; + } - __blk_mq_run_hw_queue(hctx); blk_mq_wait_for_tags(hctx->tags); } while (1); @@ -514,6 +517,8 @@ static void __blk_mq_run_hw_queue(struct blk_mq_hw_ctx *hctx) LIST_HEAD(rq_list); int bit, queued; + WARN_ON(!preempt_count()); + if (unlikely(test_bit(BLK_MQ_S_STOPPED, &hctx->state))) return; @@ -606,10 +611,22 @@ void blk_mq_run_hw_queue(struct blk_mq_hw_ctx *hctx, bool async) if (unlikely(test_bit(BLK_MQ_S_STOPPED, &hctx->state))) return; - if (!async) + if (!async && cpumask_test_cpu(smp_processor_id(), hctx->cpumask)) __blk_mq_run_hw_queue(hctx); - else + else if (hctx->queue->nr_hw_queues == 1) kblockd_schedule_delayed_work(&hctx->delayed_work, 0); + else { + unsigned int cpu; + + /* + * It'd be great if the workqueue API had a way to pass + * in a mask and had some smarts for more clever placement + * than the first CPU. Or we could round-robin here. For now, + * just queue on the first CPU. + */ + cpu = cpumask_first(hctx->cpumask); + kblockd_schedule_delayed_work_on(cpu, &hctx->delayed_work, 0); + } } void blk_mq_run_queues(struct request_queue *q, bool async) @@ -623,7 +640,9 @@ void blk_mq_run_queues(struct request_queue *q, bool async) test_bit(BLK_MQ_S_STOPPED, &hctx->state)) continue; + preempt_disable(); blk_mq_run_hw_queue(hctx, async); + preempt_enable(); } } EXPORT_SYMBOL(blk_mq_run_queues); @@ -648,7 +667,10 @@ EXPORT_SYMBOL(blk_mq_stop_hw_queues); void blk_mq_start_hw_queue(struct blk_mq_hw_ctx *hctx) { clear_bit(BLK_MQ_S_STOPPED, &hctx->state); + + preempt_disable(); __blk_mq_run_hw_queue(hctx); + preempt_enable(); } EXPORT_SYMBOL(blk_mq_start_hw_queue); @@ -662,7 +684,9 @@ void blk_mq_start_stopped_hw_queues(struct request_queue *q) continue; clear_bit(BLK_MQ_S_STOPPED, &hctx->state); + preempt_disable(); blk_mq_run_hw_queue(hctx, true); + preempt_enable(); } } EXPORT_SYMBOL(blk_mq_start_stopped_hw_queues); @@ -672,7 +696,10 @@ static void blk_mq_work_fn(struct work_struct *work) struct blk_mq_hw_ctx *hctx; hctx = container_of(work, struct blk_mq_hw_ctx, delayed_work.work); + + preempt_disable(); __blk_mq_run_hw_queue(hctx); + preempt_enable(); } static void __blk_mq_insert_request(struct blk_mq_hw_ctx *hctx, @@ -716,10 +743,10 @@ void blk_mq_insert_request(struct request *rq, bool at_head, bool run_queue, spin_unlock(&ctx->lock); } - blk_mq_put_ctx(current_ctx); - if (run_queue) blk_mq_run_hw_queue(hctx, async); + + blk_mq_put_ctx(current_ctx); } static void blk_mq_insert_requests(struct request_queue *q, @@ -755,9 +782,8 @@ static void blk_mq_insert_requests(struct request_queue *q, } spin_unlock(&ctx->lock); - blk_mq_put_ctx(current_ctx); - blk_mq_run_hw_queue(hctx, from_schedule); + blk_mq_put_ctx(current_ctx); } static int plug_ctx_cmp(void *priv, struct list_head *a, struct list_head *b) @@ -876,7 +902,6 @@ static void blk_mq_make_request(struct request_queue *q, struct bio *bio) if (unlikely(is_flush_fua)) { blk_mq_bio_to_request(rq, bio); - blk_mq_put_ctx(ctx); blk_insert_flush(rq); goto run_queue; } @@ -914,7 +939,6 @@ static void blk_mq_make_request(struct request_queue *q, struct bio *bio) } spin_unlock(&ctx->lock); - blk_mq_put_ctx(ctx); /* * For a SYNC request, send it to the hardware immediately. For an @@ -923,6 +947,7 @@ static void blk_mq_make_request(struct request_queue *q, struct bio *bio) */ run_queue: blk_mq_run_hw_queue(hctx, !is_sync || is_flush_fua); + blk_mq_put_ctx(ctx); } /* @@ -990,9 +1015,9 @@ static void blk_mq_hctx_notify(void *data, unsigned long action, blk_mq_hctx_mark_pending(hctx, ctx); spin_unlock(&ctx->lock); - blk_mq_put_ctx(ctx); blk_mq_run_hw_queue(hctx, true); + blk_mq_put_ctx(ctx); } static int blk_mq_init_hw_commands(struct blk_mq_hw_ctx *hctx, @@ -1255,12 +1280,13 @@ static void blk_mq_init_cpu_queues(struct request_queue *q, __ctx->queue = q; /* If the cpu isn't online, the cpu is mapped to first hctx */ - hctx = q->mq_ops->map_queue(q, i); - hctx->nr_ctx++; - if (!cpu_online(i)) continue; + hctx = q->mq_ops->map_queue(q, i); + cpumask_set_cpu(i, hctx->cpumask); + hctx->nr_ctx++; + /* * Set local node, IFF we have more than one hw queue. If * not, we remain on the home node of the device @@ -1277,6 +1303,7 @@ static void blk_mq_map_swqueue(struct request_queue *q) struct blk_mq_ctx *ctx; queue_for_each_hw_ctx(q, hctx, i) { + cpumask_clear(hctx->cpumask); hctx->nr_ctx = 0; } @@ -1285,7 +1312,11 @@ static void blk_mq_map_swqueue(struct request_queue *q) */ queue_for_each_ctx(q, ctx, i) { /* If the cpu isn't online, the cpu is mapped to first hctx */ + if (!cpu_online(i)) + continue; + hctx = q->mq_ops->map_queue(q, i); + cpumask_set_cpu(i, hctx->cpumask); ctx->index_hw = hctx->nr_ctx; hctx->ctxs[hctx->nr_ctx++] = ctx; } @@ -1329,6 +1360,9 @@ struct request_queue *blk_mq_init_queue(struct blk_mq_reg *reg, if (!hctxs[i]) goto err_hctxs; + if (!zalloc_cpumask_var(&hctxs[i]->cpumask, GFP_KERNEL)) + goto err_hctxs; + hctxs[i]->numa_node = NUMA_NO_NODE; hctxs[i]->queue_num = i; } @@ -1392,6 +1426,7 @@ err_hctxs: for (i = 0; i < reg->nr_hw_queues; i++) { if (!hctxs[i]) break; + free_cpumask_var(hctxs[i]->cpumask); reg->ops->free_hctx(hctxs[i], i); } kfree(hctxs); @@ -1413,6 +1448,7 @@ void blk_mq_free_queue(struct request_queue *q) blk_mq_unregister_cpu_notifier(&hctx->cpu_notifier); if (q->mq_ops->exit_hctx) q->mq_ops->exit_hctx(hctx, i); + free_cpumask_var(hctx->cpumask); q->mq_ops->free_hctx(hctx, i); } diff --git a/include/linux/blk-mq.h b/include/linux/blk-mq.h index 0120451545d8..b6ee48740458 100644 --- a/include/linux/blk-mq.h +++ b/include/linux/blk-mq.h @@ -19,6 +19,7 @@ struct blk_mq_hw_ctx { unsigned long state; /* BLK_MQ_S_* flags */ struct delayed_work delayed_work; + cpumask_var_t cpumask; unsigned long flags; /* BLK_MQ_F_* flags */ -- cgit v1.2.3 From cb2da43e3d02b745408252fe4c447b23b1f4fc7b Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Wed, 9 Apr 2014 10:53:21 -0600 Subject: blk-mq: simplify blk_mq_hw_sysfs_cpus_show() Now that we have a cpu mask of CPUs that are mapped to a specific hardware queue, we can just iterate that to display the sysfs num-hw-queue/cpu_list file. Signed-off-by: Jens Axboe --- block/blk-mq-sysfs.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/block/blk-mq-sysfs.c b/block/blk-mq-sysfs.c index b0ba264b0522..9176a6984857 100644 --- a/block/blk-mq-sysfs.c +++ b/block/blk-mq-sysfs.c @@ -246,16 +246,12 @@ static ssize_t blk_mq_hw_sysfs_tags_show(struct blk_mq_hw_ctx *hctx, char *page) static ssize_t blk_mq_hw_sysfs_cpus_show(struct blk_mq_hw_ctx *hctx, char *page) { - unsigned int i, queue_num, first = 1; + unsigned int i, first = 1; ssize_t ret = 0; blk_mq_disable_hotplug(); - for_each_online_cpu(i) { - queue_num = hctx->queue->mq_map[i]; - if (queue_num != hctx->queue_num) - continue; - + for_each_cpu(i, hctx->cpumask) { if (first) ret += sprintf(ret + page, "%u", i); else -- cgit v1.2.3 From 21f9fcd81593e201172160853b8647336fb81f4f Mon Sep 17 00:00:00 2001 From: Duan Jiong Date: Fri, 11 Apr 2014 15:58:56 +0800 Subject: block: replace IS_ERR and PTR_ERR with PTR_ERR_OR_ZERO This patch fixes coccinelle error regarding usage of IS_ERR and PTR_ERR instead of PTR_ERR_OR_ZERO. Signed-off-by: Duan Jiong Signed-off-by: Jens Axboe --- block/blk-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/blk-core.c b/block/blk-core.c index 7af4a4898dcb..c320def0fe81 100644 --- a/block/blk-core.c +++ b/block/blk-core.c @@ -1654,7 +1654,7 @@ static int __init fail_make_request_debugfs(void) struct dentry *dir = fault_create_debugfs_attr("fail_make_request", NULL, &fail_make_request); - return IS_ERR(dir) ? PTR_ERR(dir) : 0; + return PTR_ERR_OR_ZERO(dir); } late_initcall(fail_make_request_debugfs); -- cgit v1.2.3 From 9ef080ec0c5e9cddf68e73a70438a2a7916b595a Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Mon, 4 Aug 2014 14:24:00 +0100 Subject: iio: adc: Fix exynos_adc dependencies EXYNOS_ADC shouldn't only depend on OF. It is useless on architectures other than Exynos so it should depend on ARCH_EXYNOS (which implies OF.) Signed-off-by: Jean Delvare Cc: Jonathan Cameron Cc: Kukjin Kim Signed-off-by: Jonathan Cameron --- drivers/iio/adc/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iio/adc/Kconfig b/drivers/iio/adc/Kconfig index 1dffa2d56262..5572c5067c3c 100644 --- a/drivers/iio/adc/Kconfig +++ b/drivers/iio/adc/Kconfig @@ -118,7 +118,7 @@ config AT91_ADC config EXYNOS_ADC bool "Exynos ADC driver support" - depends on OF + depends on ARCH_EXYNOS || (OF && COMPILE_TEST) help Core support for the ADC block found in the Samsung EXYNOS series of SoCs for drivers such as the touchscreen and hwmon to use to share -- cgit v1.2.3 From 913423409df02fe6706ee81d9ac5c31f166c3d6c Mon Sep 17 00:00:00 2001 From: Michael Welling Date: Sat, 4 Oct 2014 03:26:00 +0100 Subject: Staging:iio:tsl2583 Removes unwanted space before semicolon Signed-off-by: Michael Welling Signed-off-by: Jonathan Cameron --- drivers/staging/iio/light/tsl2583.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/iio/light/tsl2583.c b/drivers/staging/iio/light/tsl2583.c index f8c659568c38..9d39387b47b9 100644 --- a/drivers/staging/iio/light/tsl2583.c +++ b/drivers/staging/iio/light/tsl2583.c @@ -211,7 +211,7 @@ static int taos_get_lux(struct iio_dev *indio_dev) if (chip->taos_chip_status != TSL258X_CHIP_WORKING) { /* device is not enabled */ dev_err(&chip->client->dev, "taos_get_lux device is not enabled\n"); - ret = -EBUSY ; + ret = -EBUSY; goto out_unlock; } -- cgit v1.2.3 From cf0d0739c0d1f1ae6178c187db6550b96dfa2019 Mon Sep 17 00:00:00 2001 From: Michael Welling Date: Sat, 4 Oct 2014 03:26:00 +0100 Subject: Staging:iio:tsl2583 Remove quoted string split across lines warnings Signed-off-by: Michael Welling Signed-off-by: Jonathan Cameron --- drivers/staging/iio/light/tsl2583.c | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/drivers/staging/iio/light/tsl2583.c b/drivers/staging/iio/light/tsl2583.c index 9d39387b47b9..8d46c92f6f64 100644 --- a/drivers/staging/iio/light/tsl2583.c +++ b/drivers/staging/iio/light/tsl2583.c @@ -165,8 +165,9 @@ taos_i2c_read(struct i2c_client *client, u8 reg, u8 *val, unsigned int len) /* select register to write */ ret = i2c_smbus_write_byte(client, (TSL258X_CMD_REG | reg)); if (ret < 0) { - dev_err(&client->dev, "taos_i2c_read failed to write" - " register %x\n", reg); + dev_err(&client->dev, + "taos_i2c_read failed to write register %x\n", + reg); return ret; } /* read the data */ @@ -231,8 +232,9 @@ static int taos_get_lux(struct iio_dev *indio_dev) int reg = TSL258X_CMD_REG | (TSL258X_ALS_CHAN0LO + i); ret = taos_i2c_read(chip->client, reg, &buf[i], 1); if (ret < 0) { - dev_err(&chip->client->dev, "taos_get_lux failed to read" - " register %x\n", reg); + dev_err(&chip->client->dev, + "taos_get_lux failed to read register %x\n", + reg); goto out_unlock; } } @@ -809,9 +811,7 @@ static int taos_probe(struct i2c_client *clientp, if (!i2c_check_functionality(clientp->adapter, I2C_FUNC_SMBUS_BYTE_DATA)) { - dev_err(&clientp->dev, - "taos_probe() - i2c smbus byte data " - "functions unsupported\n"); + dev_err(&clientp->dev, "taos_probe() - i2c smbus byte data func unsupported\n"); return -EOPNOTSUPP; } @@ -830,30 +830,32 @@ static int taos_probe(struct i2c_client *clientp, ret = i2c_smbus_write_byte(clientp, (TSL258X_CMD_REG | (TSL258X_CNTRL + i))); if (ret < 0) { - dev_err(&clientp->dev, "i2c_smbus_write_bytes() to cmd " - "reg failed in taos_probe(), err = %d\n", ret); + dev_err(&clientp->dev, + "i2c_smbus_write_byte to cmd reg failed in taos_probe(), err = %d\n", + ret); return ret; } ret = i2c_smbus_read_byte(clientp); if (ret < 0) { - dev_err(&clientp->dev, "i2c_smbus_read_byte from " - "reg failed in taos_probe(), err = %d\n", ret); - + dev_err(&clientp->dev, + "i2c_smbus_read_byte from reg failed in taos_probe(), err = %d\n", + ret); return ret; } buf[i] = ret; } if (!taos_tsl258x_device(buf)) { - dev_info(&clientp->dev, "i2c device found but does not match " - "expected id in taos_probe()\n"); + dev_info(&clientp->dev, + "i2c device found but does not match expected id in taos_probe()\n"); return -EINVAL; } ret = i2c_smbus_write_byte(clientp, (TSL258X_CMD_REG | TSL258X_CNTRL)); if (ret < 0) { - dev_err(&clientp->dev, "i2c_smbus_write_byte() to cmd reg " - "failed in taos_probe(), err = %d\n", ret); + dev_err(&clientp->dev, + "i2c_smbus_write_byte() to cmd reg failed in taos_probe(), err = %d\n", + ret); return ret; } -- cgit v1.2.3 From e193385bf4fa1bdbafcc12eaea4f0e718aeae858 Mon Sep 17 00:00:00 2001 From: Michael Welling Date: Sat, 4 Oct 2014 03:26:00 +0100 Subject: Staging:iio:tsl2583 Switch from msleep to usleep range per timers-howto.txt Signed-off-by: Michael Welling Signed-off-by: Jonathan Cameron --- drivers/staging/iio/light/tsl2583.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/iio/light/tsl2583.c b/drivers/staging/iio/light/tsl2583.c index 8d46c92f6f64..de3c9d8e7722 100644 --- a/drivers/staging/iio/light/tsl2583.c +++ b/drivers/staging/iio/light/tsl2583.c @@ -451,7 +451,7 @@ static int taos_chip_on(struct iio_dev *indio_dev) } } - msleep(3); + usleep_range(3000, 3500); /* NOW enable the ADC * initialize the desired mode of operation */ utmp = TSL258X_CNTL_PWR_ON | TSL258X_CNTL_ADC_ENBL; -- cgit v1.2.3 From 1668a7a699f8c96bc99a50e94aadfe328adf9b76 Mon Sep 17 00:00:00 2001 From: Geert Uytterhoeven Date: Tue, 18 Mar 2014 10:39:23 +0100 Subject: ARM: shmobile: armadillo800eva: Spelling and grammar Signed-off-by: Geert Uytterhoeven Signed-off-by: Simon Horman --- arch/arm/mach-shmobile/Kconfig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/arm/mach-shmobile/Kconfig b/arch/arm/mach-shmobile/Kconfig index 0f92ba8e7884..edb1a914deb3 100644 --- a/arch/arm/mach-shmobile/Kconfig +++ b/arch/arm/mach-shmobile/Kconfig @@ -205,8 +205,8 @@ config MACH_ARMADILLO800EVA_REFERENCE select SND_SOC_WM8978 if SND_SIMPLE_CARD select USE_OF ---help--- - Use reference implementation of Aramdillo800 EVA board support - which makes a greater use of device tree at the expense + Use reference implementation of Armadillo800 EVA board support + which makes greater use of device tree at the expense of not supporting a number of devices. This is intended to aid developers -- cgit v1.2.3 From d477a4a2fcbf59feb617de9502ae8b862e1578ed Mon Sep 17 00:00:00 2001 From: Geert Uytterhoeven Date: Tue, 25 Feb 2014 11:30:19 +0100 Subject: ARM: shmobile: multiplatform: Enable MSIOF in defconfig Signed-off-by: Geert Uytterhoeven Acked-by: Magnus Damm Signed-off-by: Simon Horman --- arch/arm/configs/shmobile_defconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/arm/configs/shmobile_defconfig b/arch/arm/configs/shmobile_defconfig index 83b07258a385..2a27d4622cc9 100644 --- a/arch/arm/configs/shmobile_defconfig +++ b/arch/arm/configs/shmobile_defconfig @@ -78,6 +78,7 @@ CONFIG_I2C_GPIO=y CONFIG_I2C_RCAR=y CONFIG_SPI=y CONFIG_SPI_RSPI=y +CONFIG_SPI_SH_MSIOF=y CONFIG_GPIO_EM=y CONFIG_GPIO_RCAR=y # CONFIG_HWMON is not set -- cgit v1.2.3 From c2e90c4b7c15fbb2215b47a23b446ba53e6dbf59 Mon Sep 17 00:00:00 2001 From: Magnus Damm Date: Wed, 26 Mar 2014 14:16:19 +0900 Subject: ARM: shmobile: Include i2c-shmobile.c in shmobile_defconfig Many SoCs include I2C controller instances compatible with the i2c-shmobile.c driver. To increase hardware support enable the driver in the shmobile_defconfig multiplatform configuration. Signed-off-by: Magnus Damm Acked-by: Wolfram Sang Signed-off-by: Simon Horman --- arch/arm/configs/shmobile_defconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/arm/configs/shmobile_defconfig b/arch/arm/configs/shmobile_defconfig index 2a27d4622cc9..d96133a686e5 100644 --- a/arch/arm/configs/shmobile_defconfig +++ b/arch/arm/configs/shmobile_defconfig @@ -75,6 +75,7 @@ CONFIG_SERIAL_SH_SCI=y CONFIG_SERIAL_SH_SCI_NR_UARTS=20 CONFIG_SERIAL_SH_SCI_CONSOLE=y CONFIG_I2C_GPIO=y +CONFIG_I2C_SH_MOBILE=y CONFIG_I2C_RCAR=y CONFIG_SPI=y CONFIG_SPI_RSPI=y -- cgit v1.2.3 From f5e1367f8f94293f098cab3e906934e535df1a94 Mon Sep 17 00:00:00 2001 From: Magnus Damm Date: Wed, 26 Mar 2014 14:19:11 +0900 Subject: ARM: shmobile: Include at24.c in shmobile_defconfig The Koelsch board includes an at24-compatible EEPROM hooked up via I2C. To increase hardware support enable the driver in the shmobile_defconfig multiplatform configuration. Signed-off-by: Magnus Damm Acked-by: Wolfram Sang Signed-off-by: Simon Horman --- arch/arm/configs/shmobile_defconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/arm/configs/shmobile_defconfig b/arch/arm/configs/shmobile_defconfig index d96133a686e5..146ee70dd459 100644 --- a/arch/arm/configs/shmobile_defconfig +++ b/arch/arm/configs/shmobile_defconfig @@ -43,6 +43,7 @@ CONFIG_DEVTMPFS=y CONFIG_DEVTMPFS_MOUNT=y CONFIG_MTD=y CONFIG_MTD_M25P80=y +CONFIG_EEPROM_AT24=y CONFIG_BLK_DEV_SD=y CONFIG_ATA=y CONFIG_SATA_RCAR=y -- cgit v1.2.3 From 41551f3d7d9a37b55a6f84d77200bfe29d42c466 Mon Sep 17 00:00:00 2001 From: Ulrich Hecht Date: Fri, 28 Mar 2014 17:54:01 +0100 Subject: ARM: shmobile: Enable USBHS gadget support in shmobile_defconfig The renesas_usbhs driver provides USB gadget support for most Renesas platforms. To increase hardware support enable the driver in the shmobile_defconfig multiplatform configuration. Signed-off-by: Ulrich Hecht Signed-off-by: Simon Horman --- arch/arm/configs/shmobile_defconfig | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/arch/arm/configs/shmobile_defconfig b/arch/arm/configs/shmobile_defconfig index 146ee70dd459..c10e626e8510 100644 --- a/arch/arm/configs/shmobile_defconfig +++ b/arch/arm/configs/shmobile_defconfig @@ -103,7 +103,11 @@ CONFIG_SOUND=y CONFIG_SND=y CONFIG_SND_SOC=y CONFIG_SND_SOC_RCAR=y +CONFIG_USB=y CONFIG_USB_RCAR_GEN2_PHY=y +CONFIG_USB_RENESAS_USBHS=y +CONFIG_USB_GADGET=y +CONFIG_USB_RENESAS_USBHS_UDC=y CONFIG_MMC=y CONFIG_MMC_SDHI=y CONFIG_MMC_SH_MMCIF=y -- cgit v1.2.3 From 667d0f7b0e940bf36e8d12bd7d64aa0f9217b3ac Mon Sep 17 00:00:00 2001 From: Magnus Damm Date: Wed, 2 Apr 2014 18:06:24 +0900 Subject: ARM: shmobile: Enable HIGHMEM in shmobile_defconfig Many mach-shmobile hardware platforms include support for more than 1GiB of RAM. Enable HIGHMEM by default to allow use of larger amounts of memory. Signed-off-by: Magnus Damm Signed-off-by: Simon Horman --- arch/arm/configs/shmobile_defconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/arm/configs/shmobile_defconfig b/arch/arm/configs/shmobile_defconfig index c10e626e8510..b73a0380bb03 100644 --- a/arch/arm/configs/shmobile_defconfig +++ b/arch/arm/configs/shmobile_defconfig @@ -25,6 +25,7 @@ CONFIG_SCHED_MC=y CONFIG_HAVE_ARM_ARCH_TIMER=y CONFIG_NR_CPUS=8 CONFIG_AEABI=y +CONFIG_HIGHMEM=y CONFIG_ZBOOT_ROM_TEXT=0x0 CONFIG_ZBOOT_ROM_BSS=0x0 CONFIG_ARM_APPENDED_DTB=y -- cgit v1.2.3 From e4224fe8bfd955d1aea5f89f2f3ac38dc4a590fc Mon Sep 17 00:00:00 2001 From: Magnus Damm Date: Tue, 8 Apr 2014 21:37:58 +0900 Subject: ARM: shmobile: Enable VSP1 in shmobile_defconfig Both r8a7790 and r8a7791 have multiple on-chip VSP1 devices, so enable the VSP1 driver by default in the shmobile_defconfig. Signed-off-by: Magnus Damm Signed-off-by: Simon Horman --- arch/arm/configs/shmobile_defconfig | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/arch/arm/configs/shmobile_defconfig b/arch/arm/configs/shmobile_defconfig index b73a0380bb03..8fb30b09f960 100644 --- a/arch/arm/configs/shmobile_defconfig +++ b/arch/arm/configs/shmobile_defconfig @@ -92,10 +92,14 @@ CONFIG_REGULATOR_FIXED_VOLTAGE=y CONFIG_REGULATOR_GPIO=y CONFIG_MEDIA_SUPPORT=y CONFIG_MEDIA_CAMERA_SUPPORT=y +CONFIG_MEDIA_CONTROLLER=y +CONFIG_VIDEO_V4L2_SUBDEV_API=y CONFIG_V4L_PLATFORM_DRIVERS=y CONFIG_SOC_CAMERA=y CONFIG_SOC_CAMERA_PLATFORM=y CONFIG_VIDEO_RCAR_VIN=y +CONFIG_V4L_MEM2MEM_DRIVERS=y +CONFIG_VIDEO_RENESAS_VSP1=y # CONFIG_MEDIA_SUBDRV_AUTOSELECT is not set CONFIG_VIDEO_ADV7180=y CONFIG_DRM=y -- cgit v1.2.3 From 1d59eb190e3dc575c7bbee4a163c3facd0de2ed9 Mon Sep 17 00:00:00 2001 From: Simon Horman Date: Thu, 10 Apr 2014 16:12:45 +0900 Subject: ARM: shmobile: Enable USB [EO]HCI HCD support in shmobile_defconfig The USB [EO]HCI HCD drivers provide USB host support for Renesas R-Car Gen2 platforms. To increase hardware support enable the driver in the shmobile_defconfig multiplatform configuration. Acked-by: Magnus Damm Signed-off-by: Simon Horman --- arch/arm/configs/shmobile_defconfig | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/arm/configs/shmobile_defconfig b/arch/arm/configs/shmobile_defconfig index 8fb30b09f960..6d6437cbbc52 100644 --- a/arch/arm/configs/shmobile_defconfig +++ b/arch/arm/configs/shmobile_defconfig @@ -110,6 +110,8 @@ CONFIG_SND_SOC=y CONFIG_SND_SOC_RCAR=y CONFIG_USB=y CONFIG_USB_RCAR_GEN2_PHY=y +CONFIG_USB_EHCI_HCD=y +CONFIG_USB_OHCI_HCD=y CONFIG_USB_RENESAS_USBHS=y CONFIG_USB_GADGET=y CONFIG_USB_RENESAS_USBHS_UDC=y -- cgit v1.2.3 From ce4b6a04c49b0b414d537b45ededd9dfd4e48336 Mon Sep 17 00:00:00 2001 From: Magnus Damm Date: Thu, 6 Mar 2014 12:16:58 +0900 Subject: ARM: shmobile: Update r8a7791 CPU freq to 1500MHz in C The correct maximum CPU frequency for r8a7791 is 1500 MHz so update the r8a7791 SoC C code to reflect this. Signed-off-by: Magnus Damm Signed-off-by: Simon Horman --- arch/arm/mach-shmobile/setup-r8a7791.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm/mach-shmobile/setup-r8a7791.c b/arch/arm/mach-shmobile/setup-r8a7791.c index e28404e43860..a7e4966f5e18 100644 --- a/arch/arm/mach-shmobile/setup-r8a7791.c +++ b/arch/arm/mach-shmobile/setup-r8a7791.c @@ -213,7 +213,7 @@ void __init r8a7791_add_standard_devices(void) void __init r8a7791_init_early(void) { #ifndef CONFIG_ARM_ARCH_TIMER - shmobile_setup_delay(1300, 2, 4); /* Cortex-A15 @ 1300MHz */ + shmobile_setup_delay(1500, 2, 4); /* Cortex-A15 @ 1500MHz */ #endif } -- cgit v1.2.3 From c39dae380b4a11f1050a2ef6607598dcbe0541be Mon Sep 17 00:00:00 2001 From: Magnus Damm Date: Thu, 6 Mar 2014 12:28:24 +0900 Subject: ARM: shmobile: Add shared shmobile_init_delay() Introduce shmobile_init_delay() that gets CPU specific parameters from DT and sets up the early delay from there. This allows us to both remove frequency information from the C code and consolidate existing code. Signed-off-by: Magnus Damm Signed-off-by: Simon Horman --- arch/arm/mach-shmobile/include/mach/common.h | 1 + arch/arm/mach-shmobile/timer.c | 28 ++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/arch/arm/mach-shmobile/include/mach/common.h b/arch/arm/mach-shmobile/include/mach/common.h index cb8e32deb2a3..f7a360edcc35 100644 --- a/arch/arm/mach-shmobile/include/mach/common.h +++ b/arch/arm/mach-shmobile/include/mach/common.h @@ -4,6 +4,7 @@ extern void shmobile_earlytimer_init(void); extern void shmobile_setup_delay(unsigned int max_cpu_core_mhz, unsigned int mult, unsigned int div); +extern void shmobile_init_delay(void); struct twd_local_timer; extern void shmobile_setup_console(void); extern void shmobile_boot_vector(void); diff --git a/arch/arm/mach-shmobile/timer.c b/arch/arm/mach-shmobile/timer.c index 62d7052d6f21..ccecde9a3362 100644 --- a/arch/arm/mach-shmobile/timer.c +++ b/arch/arm/mach-shmobile/timer.c @@ -21,6 +21,7 @@ #include #include #include +#include void __init shmobile_setup_delay(unsigned int max_cpu_core_mhz, unsigned int mult, unsigned int div) @@ -39,6 +40,33 @@ void __init shmobile_setup_delay(unsigned int max_cpu_core_mhz, preset_lpj = max_cpu_core_mhz * value; } +void __init shmobile_init_delay(void) +{ + struct device_node *np, *parent; + u32 max_freq, freq; + + max_freq = 0; + + parent = of_find_node_by_path("/cpus"); + if (parent) { + for_each_child_of_node(parent, np) { + if (!of_property_read_u32(np, "clock-frequency", &freq)) + max_freq = max(max_freq, freq); + } + of_node_put(parent); + } + + if (max_freq) { + if (of_find_compatible_node(NULL, NULL, "arm,cortex-a8")) + shmobile_setup_delay(max_freq, 1, 3); + else if (of_find_compatible_node(NULL, NULL, "arm,cortex-a9")) + shmobile_setup_delay(max_freq, 1, 3); + else if (of_find_compatible_node(NULL, NULL, "arm,cortex-a15")) + if (!IS_ENABLED(CONFIG_ARM_ARCH_TIMER)) + shmobile_setup_delay(max_freq, 2, 4); + } +} + static void __init shmobile_late_time_init(void) { /* -- cgit v1.2.3 From 094c62c3313e1a1c7929a2f69c07ba3382c358e4 Mon Sep 17 00:00:00 2001 From: Magnus Damm Date: Thu, 13 Feb 2014 17:26:08 +0900 Subject: ARM: shmobile: Remove legacy EMEV2 SoC support Get rid of legacy EMEV2 SoC code including the legacy clock framework implementation. The multiplatform implementation together with DT board support shall be used instead. Signed-off-by: Magnus Damm Signed-off-by: Simon Horman --- arch/arm/boot/dts/Makefile | 3 +- arch/arm/mach-shmobile/Kconfig | 10 -- arch/arm/mach-shmobile/Makefile | 1 - arch/arm/mach-shmobile/clock-emev2.c | 231 ---------------------------- arch/arm/mach-shmobile/include/mach/emev2.h | 1 - arch/arm/mach-shmobile/setup-emev2.c | 4 - 6 files changed, 1 insertion(+), 249 deletions(-) delete mode 100644 arch/arm/mach-shmobile/clock-emev2.c diff --git a/arch/arm/boot/dts/Makefile b/arch/arm/boot/dts/Makefile index 35c146f31e46..178aa089b6c4 100644 --- a/arch/arm/boot/dts/Makefile +++ b/arch/arm/boot/dts/Makefile @@ -304,8 +304,7 @@ dtb-$(CONFIG_ARCH_U8500) += ste-snowball.dtb \ dtb-$(CONFIG_ARCH_S3C24XX) += s3c2416-smdk2416.dtb dtb-$(CONFIG_ARCH_S3C64XX) += s3c6410-mini6410.dtb \ s3c6410-smdk6410.dtb -dtb-$(CONFIG_ARCH_SHMOBILE_LEGACY) += emev2-kzm9d.dtb \ - r7s72100-genmai.dtb \ +dtb-$(CONFIG_ARCH_SHMOBILE_LEGACY) += r7s72100-genmai.dtb \ r7s72100-genmai-reference.dtb \ r8a7740-armadillo800eva.dtb \ r8a7778-bockw.dtb \ diff --git a/arch/arm/mach-shmobile/Kconfig b/arch/arm/mach-shmobile/Kconfig index 0f92ba8e7884..ad0c6bc2747d 100644 --- a/arch/arm/mach-shmobile/Kconfig +++ b/arch/arm/mach-shmobile/Kconfig @@ -140,16 +140,6 @@ config ARCH_R8A7791 select SYS_SUPPORTS_SH_CMT select ARCH_DMA_ADDR_T_64BIT if ARM_LPAE -config ARCH_EMEV2 - bool "Emma Mobile EV2" - select ARCH_WANT_OPTIONAL_GPIOLIB - select ARM_GIC - select CPU_V7 - select MIGHT_HAVE_PCI - select USE_OF - select AUTO_ZRELADDR - select SYS_SUPPORTS_EM_STI - config ARCH_R7S72100 bool "RZ/A1H (R7S72100)" select ARCH_WANT_OPTIONAL_GPIOLIB diff --git a/arch/arm/mach-shmobile/Makefile b/arch/arm/mach-shmobile/Makefile index 4caffc912a81..76053770aa04 100644 --- a/arch/arm/mach-shmobile/Makefile +++ b/arch/arm/mach-shmobile/Makefile @@ -31,7 +31,6 @@ obj-$(CONFIG_ARCH_R8A7778) += clock-r8a7778.o obj-$(CONFIG_ARCH_R8A7779) += clock-r8a7779.o obj-$(CONFIG_ARCH_R8A7790) += clock-r8a7790.o obj-$(CONFIG_ARCH_R8A7791) += clock-r8a7791.o -obj-$(CONFIG_ARCH_EMEV2) += clock-emev2.o obj-$(CONFIG_ARCH_R7S72100) += clock-r7s72100.o endif diff --git a/arch/arm/mach-shmobile/clock-emev2.c b/arch/arm/mach-shmobile/clock-emev2.c deleted file mode 100644 index 5ac13ba71d54..000000000000 --- a/arch/arm/mach-shmobile/clock-emev2.c +++ /dev/null @@ -1,231 +0,0 @@ -/* - * Emma Mobile EV2 clock framework support - * - * Copyright (C) 2012 Magnus Damm - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ -#include -#include -#include -#include -#include -#include - -#define EMEV2_SMU_BASE 0xe0110000 - -/* EMEV2 SMU registers */ -#define USIAU0_RSTCTRL 0x094 -#define USIBU1_RSTCTRL 0x0ac -#define USIBU2_RSTCTRL 0x0b0 -#define USIBU3_RSTCTRL 0x0b4 -#define STI_RSTCTRL 0x124 -#define USIAU0GCLKCTRL 0x4a0 -#define USIBU1GCLKCTRL 0x4b8 -#define USIBU2GCLKCTRL 0x4bc -#define USIBU3GCLKCTRL 0x04c0 -#define STIGCLKCTRL 0x528 -#define USIAU0SCLKDIV 0x61c -#define USIB2SCLKDIV 0x65c -#define USIB3SCLKDIV 0x660 -#define STI_CLKSEL 0x688 - -/* not pretty, but hey */ -static void __iomem *smu_base; - -static void emev2_smu_write(unsigned long value, int offs) -{ - BUG_ON(!smu_base || (offs >= PAGE_SIZE)); - iowrite32(value, smu_base + offs); -} - -static struct clk_mapping smu_mapping = { - .phys = EMEV2_SMU_BASE, - .len = PAGE_SIZE, -}; - -/* Fixed 32 KHz root clock from C32K pin */ -static struct clk c32k_clk = { - .rate = 32768, - .mapping = &smu_mapping, -}; - -/* PLL3 multiplies C32K with 7000 */ -static unsigned long pll3_recalc(struct clk *clk) -{ - return clk->parent->rate * 7000; -} - -static struct sh_clk_ops pll3_clk_ops = { - .recalc = pll3_recalc, -}; - -static struct clk pll3_clk = { - .ops = &pll3_clk_ops, - .parent = &c32k_clk, -}; - -static struct clk *main_clks[] = { - &c32k_clk, - &pll3_clk, -}; - -enum { SCLKDIV_USIAU0, SCLKDIV_USIBU2, SCLKDIV_USIBU1, SCLKDIV_USIBU3, - SCLKDIV_NR }; - -#define SCLKDIV(_reg, _shift) \ -{ \ - .parent = &pll3_clk, \ - .enable_reg = IOMEM(EMEV2_SMU_BASE + (_reg)), \ - .enable_bit = _shift, \ -} - -static struct clk sclkdiv_clks[SCLKDIV_NR] = { - [SCLKDIV_USIAU0] = SCLKDIV(USIAU0SCLKDIV, 0), - [SCLKDIV_USIBU2] = SCLKDIV(USIB2SCLKDIV, 16), - [SCLKDIV_USIBU1] = SCLKDIV(USIB2SCLKDIV, 0), - [SCLKDIV_USIBU3] = SCLKDIV(USIB3SCLKDIV, 0), -}; - -enum { GCLK_USIAU0_SCLK, GCLK_USIBU1_SCLK, GCLK_USIBU2_SCLK, GCLK_USIBU3_SCLK, - GCLK_STI_SCLK, - GCLK_NR }; - -#define GCLK_SCLK(_parent, _reg) \ -{ \ - .parent = _parent, \ - .enable_reg = IOMEM(EMEV2_SMU_BASE + (_reg)), \ - .enable_bit = 1, /* SCLK_GCC */ \ -} - -static struct clk gclk_clks[GCLK_NR] = { - [GCLK_USIAU0_SCLK] = GCLK_SCLK(&sclkdiv_clks[SCLKDIV_USIAU0], - USIAU0GCLKCTRL), - [GCLK_USIBU1_SCLK] = GCLK_SCLK(&sclkdiv_clks[SCLKDIV_USIBU1], - USIBU1GCLKCTRL), - [GCLK_USIBU2_SCLK] = GCLK_SCLK(&sclkdiv_clks[SCLKDIV_USIBU2], - USIBU2GCLKCTRL), - [GCLK_USIBU3_SCLK] = GCLK_SCLK(&sclkdiv_clks[SCLKDIV_USIBU3], - USIBU3GCLKCTRL), - [GCLK_STI_SCLK] = GCLK_SCLK(&c32k_clk, STIGCLKCTRL), -}; - -static int emev2_gclk_enable(struct clk *clk) -{ - iowrite32(ioread32(clk->mapped_reg) | (1 << clk->enable_bit), - clk->mapped_reg); - return 0; -} - -static void emev2_gclk_disable(struct clk *clk) -{ - iowrite32(ioread32(clk->mapped_reg) & ~(1 << clk->enable_bit), - clk->mapped_reg); -} - -static struct sh_clk_ops emev2_gclk_clk_ops = { - .enable = emev2_gclk_enable, - .disable = emev2_gclk_disable, - .recalc = followparent_recalc, -}; - -static int __init emev2_gclk_register(struct clk *clks, int nr) -{ - struct clk *clkp; - int ret = 0; - int k; - - for (k = 0; !ret && (k < nr); k++) { - clkp = clks + k; - clkp->ops = &emev2_gclk_clk_ops; - ret |= clk_register(clkp); - } - - return ret; -} - -static unsigned long emev2_sclkdiv_recalc(struct clk *clk) -{ - unsigned int sclk_div; - - sclk_div = (ioread32(clk->mapped_reg) >> clk->enable_bit) & 0xff; - - return clk->parent->rate / (sclk_div + 1); -} - -static struct sh_clk_ops emev2_sclkdiv_clk_ops = { - .recalc = emev2_sclkdiv_recalc, -}; - -static int __init emev2_sclkdiv_register(struct clk *clks, int nr) -{ - struct clk *clkp; - int ret = 0; - int k; - - for (k = 0; !ret && (k < nr); k++) { - clkp = clks + k; - clkp->ops = &emev2_sclkdiv_clk_ops; - ret |= clk_register(clkp); - } - - return ret; -} - -static struct clk_lookup lookups[] = { - CLKDEV_DEV_ID("serial8250-em.0", &gclk_clks[GCLK_USIAU0_SCLK]), - CLKDEV_DEV_ID("e1020000.uart", &gclk_clks[GCLK_USIAU0_SCLK]), - CLKDEV_DEV_ID("serial8250-em.1", &gclk_clks[GCLK_USIBU1_SCLK]), - CLKDEV_DEV_ID("e1030000.uart", &gclk_clks[GCLK_USIBU1_SCLK]), - CLKDEV_DEV_ID("serial8250-em.2", &gclk_clks[GCLK_USIBU2_SCLK]), - CLKDEV_DEV_ID("e1040000.uart", &gclk_clks[GCLK_USIBU2_SCLK]), - CLKDEV_DEV_ID("serial8250-em.3", &gclk_clks[GCLK_USIBU3_SCLK]), - CLKDEV_DEV_ID("e1050000.uart", &gclk_clks[GCLK_USIBU3_SCLK]), - CLKDEV_DEV_ID("em_sti.0", &gclk_clks[GCLK_STI_SCLK]), - CLKDEV_DEV_ID("e0180000.sti", &gclk_clks[GCLK_STI_SCLK]), -}; - -void __init emev2_clock_init(void) -{ - int k, ret = 0; - - smu_base = ioremap(EMEV2_SMU_BASE, PAGE_SIZE); - BUG_ON(!smu_base); - - /* setup STI timer to run on 32.768 kHz and deassert reset */ - emev2_smu_write(0, STI_CLKSEL); - emev2_smu_write(1, STI_RSTCTRL); - - /* deassert reset for UART0->UART3 */ - emev2_smu_write(2, USIAU0_RSTCTRL); - emev2_smu_write(2, USIBU1_RSTCTRL); - emev2_smu_write(2, USIBU2_RSTCTRL); - emev2_smu_write(2, USIBU3_RSTCTRL); - - for (k = 0; !ret && (k < ARRAY_SIZE(main_clks)); k++) - ret = clk_register(main_clks[k]); - - if (!ret) - ret = emev2_sclkdiv_register(sclkdiv_clks, SCLKDIV_NR); - - if (!ret) - ret = emev2_gclk_register(gclk_clks, GCLK_NR); - - clkdev_add_table(lookups, ARRAY_SIZE(lookups)); - - if (!ret) - shmobile_clk_init(); - else - panic("failed to setup emev2 clocks\n"); -} diff --git a/arch/arm/mach-shmobile/include/mach/emev2.h b/arch/arm/mach-shmobile/include/mach/emev2.h index fcb142a14e07..d64e188a9755 100644 --- a/arch/arm/mach-shmobile/include/mach/emev2.h +++ b/arch/arm/mach-shmobile/include/mach/emev2.h @@ -3,7 +3,6 @@ extern void emev2_map_io(void); extern void emev2_init_delay(void); -extern void emev2_clock_init(void); extern struct smp_operations emev2_smp_ops; #endif /* __ASM_EMEV2_H__ */ diff --git a/arch/arm/mach-shmobile/setup-emev2.c b/arch/arm/mach-shmobile/setup-emev2.c index c71d667007b8..b15a0ed769fe 100644 --- a/arch/arm/mach-shmobile/setup-emev2.c +++ b/arch/arm/mach-shmobile/setup-emev2.c @@ -50,11 +50,7 @@ void __init emev2_init_delay(void) static void __init emev2_add_standard_devices_dt(void) { -#ifdef CONFIG_COMMON_CLK of_clk_init(NULL); -#else - emev2_clock_init(); -#endif of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL); } -- cgit v1.2.3 From 505891ec2558771cd84fe00fc1646275b4c069ed Mon Sep 17 00:00:00 2001 From: Magnus Damm Date: Mon, 17 Feb 2014 16:35:08 +0900 Subject: ARM: shmobile: Remove EMEV2 header file There is no C board code left for the EMEV2 SoC, so get rid of the emev2.h include file to save some lines. While at it make functions static. Signed-off-by: Magnus Damm [horms+renesas@verge.net.au: Resolved conflict] Signed-off-by: Simon Horman --- arch/arm/mach-shmobile/include/mach/emev2.h | 8 -------- arch/arm/mach-shmobile/setup-emev2.c | 7 ++++--- arch/arm/mach-shmobile/smp-emev2.c | 1 - 3 files changed, 4 insertions(+), 12 deletions(-) delete mode 100644 arch/arm/mach-shmobile/include/mach/emev2.h diff --git a/arch/arm/mach-shmobile/include/mach/emev2.h b/arch/arm/mach-shmobile/include/mach/emev2.h deleted file mode 100644 index d64e188a9755..000000000000 --- a/arch/arm/mach-shmobile/include/mach/emev2.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef __ASM_EMEV2_H__ -#define __ASM_EMEV2_H__ - -extern void emev2_map_io(void); -extern void emev2_init_delay(void); -extern struct smp_operations emev2_smp_ops; - -#endif /* __ASM_EMEV2_H__ */ diff --git a/arch/arm/mach-shmobile/setup-emev2.c b/arch/arm/mach-shmobile/setup-emev2.c index b15a0ed769fe..d953ff6e78a2 100644 --- a/arch/arm/mach-shmobile/setup-emev2.c +++ b/arch/arm/mach-shmobile/setup-emev2.c @@ -21,7 +21,6 @@ #include #include #include -#include #include #include #include @@ -38,12 +37,12 @@ static struct map_desc emev2_io_desc[] __initdata = { #endif }; -void __init emev2_map_io(void) +static void __init emev2_map_io(void) { iotable_init(emev2_io_desc, ARRAY_SIZE(emev2_io_desc)); } -void __init emev2_init_delay(void) +static void __init emev2_init_delay(void) { shmobile_setup_delay(533, 1, 3); /* Cortex-A9 @ 533MHz */ } @@ -59,6 +58,8 @@ static const char *emev2_boards_compat_dt[] __initconst = { NULL, }; +extern struct smp_operations emev2_smp_ops; + DT_MACHINE_START(EMEV2_DT, "Generic Emma Mobile EV2 (Flattened Device Tree)") .smp = smp_ops(emev2_smp_ops), .map_io = emev2_map_io, diff --git a/arch/arm/mach-shmobile/smp-emev2.c b/arch/arm/mach-shmobile/smp-emev2.c index f2ca92308f75..2dfd748da7f3 100644 --- a/arch/arm/mach-shmobile/smp-emev2.c +++ b/arch/arm/mach-shmobile/smp-emev2.c @@ -24,7 +24,6 @@ #include #include #include -#include #include #include -- cgit v1.2.3 From f05b4b52845a18e833644eb3a820a55e3278d2b4 Mon Sep 17 00:00:00 2001 From: Magnus Damm Date: Mon, 24 Feb 2014 14:49:07 +0900 Subject: ARM: shmobile: Make use of r8a7790_add_standard_devices() Move non-PFC and non-GPIO devices off from r8a7790_pinmux_init() and into r8a7790_add_standard_devices() which is the normal place to keep regular devices in the legacy case. Signed-off-by: Magnus Damm Signed-off-by: Simon Horman --- arch/arm/mach-shmobile/setup-r8a7790.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/arch/arm/mach-shmobile/setup-r8a7790.c b/arch/arm/mach-shmobile/setup-r8a7790.c index c4616f0698c6..a901d9ef53f6 100644 --- a/arch/arm/mach-shmobile/setup-r8a7790.c +++ b/arch/arm/mach-shmobile/setup-r8a7790.c @@ -185,12 +185,6 @@ void __init r8a7790_pinmux_init(void) r8a7790_register_gpio(3); r8a7790_register_gpio(4); r8a7790_register_gpio(5); - r8a7790_register_i2c(0); - r8a7790_register_i2c(1); - r8a7790_register_i2c(2); - r8a7790_register_i2c(3); - r8a7790_register_audio_dmac(0); - r8a7790_register_audio_dmac(1); } #define __R8A7790_SCIF(scif_type, _scscr, index, baseaddr, irq) \ @@ -308,6 +302,12 @@ void __init r8a7790_add_standard_devices(void) r8a7790_add_dt_devices(); r8a7790_register_irqc(0); r8a7790_register_thermal(); + r8a7790_register_i2c(0); + r8a7790_register_i2c(1); + r8a7790_register_i2c(2); + r8a7790_register_i2c(3); + r8a7790_register_audio_dmac(0); + r8a7790_register_audio_dmac(1); } void __init r8a7790_init_early(void) -- cgit v1.2.3 From 835d737d664650d7f164a5b688271a424db4434c Mon Sep 17 00:00:00 2001 From: Geert Uytterhoeven Date: Wed, 12 Mar 2014 19:44:49 +0100 Subject: ARM: shmobile: rcar-gen2: Cache Mode Monitor Register Value The MD pins are sampled at reset time, hence the read value will always be the same, and we can avoid the overhead of ioremapping the register on every read. Signed-off-by: Geert Uytterhoeven Signed-off-by: Simon Horman --- arch/arm/mach-shmobile/setup-rcar-gen2.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/arch/arm/mach-shmobile/setup-rcar-gen2.c b/arch/arm/mach-shmobile/setup-rcar-gen2.c index 10604480f325..542c5a47173f 100644 --- a/arch/arm/mach-shmobile/setup-rcar-gen2.c +++ b/arch/arm/mach-shmobile/setup-rcar-gen2.c @@ -30,12 +30,16 @@ u32 rcar_gen2_read_mode_pins(void) { - void __iomem *modemr = ioremap_nocache(MODEMR, 4); - u32 mode; - - BUG_ON(!modemr); - mode = ioread32(modemr); - iounmap(modemr); + static u32 mode; + static bool mode_valid; + + if (!mode_valid) { + void __iomem *modemr = ioremap_nocache(MODEMR, 4); + BUG_ON(!modemr); + mode = ioread32(modemr); + iounmap(modemr); + mode_valid = true; + } return mode; } -- cgit v1.2.3 From 277efd30cfc72ec2f44a9bc95d93807b867bd9e9 Mon Sep 17 00:00:00 2001 From: Magnus Damm Date: Wed, 26 Feb 2014 18:59:16 +0900 Subject: ARM: shmobile: Check r8a7791 MD21 at SMP boot On r8a7791 the hardware boot mode bit MD21 indicates if hardware debug mode is enabled or not. In case hardware debug mode is enabled print a warning and refrain from booting secondary CPU cores. Without this patch Koelsch with SW8-4 set to OFF will hang at SMP boot. Signed-off-by: Magnus Damm Tested-by: Geert Uytterhoeven Signed-off-by: Simon Horman --- arch/arm/mach-shmobile/smp-r8a7791.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/arch/arm/mach-shmobile/smp-r8a7791.c b/arch/arm/mach-shmobile/smp-r8a7791.c index 2df5bd190fe4..ec979529f30f 100644 --- a/arch/arm/mach-shmobile/smp-r8a7791.c +++ b/arch/arm/mach-shmobile/smp-r8a7791.c @@ -20,6 +20,7 @@ #include #include #include +#include #define RST 0xe6160000 #define CA15BAR 0x0020 @@ -51,9 +52,21 @@ static void __init r8a7791_smp_prepare_cpus(unsigned int max_cpus) iounmap(p); } +static int r8a7791_smp_boot_secondary(unsigned int cpu, + struct task_struct *idle) +{ + /* Error out when hardware debug mode is enabled */ + if (rcar_gen2_read_mode_pins() & BIT(21)) { + pr_warn("Unable to boot CPU%u when MD21 is set\n", cpu); + return -ENOTSUPP; + } + + return shmobile_smp_apmu_boot_secondary(cpu, idle); +} + struct smp_operations r8a7791_smp_ops __initdata = { .smp_prepare_cpus = r8a7791_smp_prepare_cpus, - .smp_boot_secondary = shmobile_smp_apmu_boot_secondary, + .smp_boot_secondary = r8a7791_smp_boot_secondary, #ifdef CONFIG_HOTPLUG_CPU .cpu_disable = shmobile_smp_cpu_disable, .cpu_die = shmobile_smp_apmu_cpu_die, -- cgit v1.2.3 From e35db38d66d1e4007cfc1bb90a05e11b4aaee2a8 Mon Sep 17 00:00:00 2001 From: Geert Uytterhoeven Date: Sun, 23 Mar 2014 20:36:18 +0100 Subject: ARM: shmobile: r8a7778/bockw: Move "select RENESAS_INTC_IRQPIN" under SoC Move the "select RENESAS_INTC_IRQPIN" from the two bockw-specific sections to the one r8a7778-specific section, like is done for the other SoCs. Signed-off-by: Geert Uytterhoeven [horms+renesas@verge.net.au: Resolved conflict] Signed-off-by: Simon Horman --- arch/arm/mach-shmobile/Kconfig | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/arch/arm/mach-shmobile/Kconfig b/arch/arm/mach-shmobile/Kconfig index ad0c6bc2747d..58bc6db6e79d 100644 --- a/arch/arm/mach-shmobile/Kconfig +++ b/arch/arm/mach-shmobile/Kconfig @@ -108,6 +108,7 @@ config ARCH_R8A7778 select SH_CLK_CPG select ARM_GIC select SYS_SUPPORTS_SH_TMU + select RENESAS_INTC_IRQPIN config ARCH_R8A7779 bool "R-Car H1 (R8A77790)" @@ -206,7 +207,6 @@ config MACH_BOCKW depends on ARCH_R8A7778 select ARCH_REQUIRE_GPIOLIB select REGULATOR_FIXED_VOLTAGE if REGULATOR - select RENESAS_INTC_IRQPIN select SND_SOC_AK4554 if SND_SIMPLE_CARD select SND_SOC_AK4642 if SND_SIMPLE_CARD select USE_OF @@ -215,7 +215,6 @@ config MACH_BOCKW_REFERENCE bool "BOCK-W - Reference Device Tree Implementation" depends on ARCH_R8A7778 select ARCH_REQUIRE_GPIOLIB - select RENESAS_INTC_IRQPIN select REGULATOR_FIXED_VOLTAGE if REGULATOR select USE_OF ---help--- -- cgit v1.2.3 From edcf139081f501b1468ae6665217e8320d4c75e8 Mon Sep 17 00:00:00 2001 From: Geert Uytterhoeven Date: Wed, 12 Mar 2014 19:44:50 +0100 Subject: ARM: shmobile: r8a7791: Use rcar_gen2_read_mode_pins() helper Signed-off-by: Geert Uytterhoeven Signed-off-by: Simon Horman --- arch/arm/mach-shmobile/clock-r8a7791.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/arch/arm/mach-shmobile/clock-r8a7791.c b/arch/arm/mach-shmobile/clock-r8a7791.c index 701383fe3267..36e57508d879 100644 --- a/arch/arm/mach-shmobile/clock-r8a7791.c +++ b/arch/arm/mach-shmobile/clock-r8a7791.c @@ -25,6 +25,7 @@ #include #include #include +#include /* * MD EXTAL PLL0 PLL1 PLL3 @@ -43,8 +44,6 @@ * see "p1 / 2" on R8A7791_CLOCK_ROOT() below */ -#define MD(nr) (1 << nr) - #define CPG_BASE 0xe6150000 #define CPG_LEN 0x1000 @@ -68,7 +67,6 @@ #define MSTPSR9 IOMEM(0xe61509a4) #define MSTPSR11 IOMEM(0xe61509ac) -#define MODEMR 0xE6160060 #define SDCKCR 0xE6150074 #define SD1CKCR 0xE6150078 #define SD2CKCR 0xE615026c @@ -295,14 +293,9 @@ static struct clk_lookup lookups[] = { void __init r8a7791_clock_init(void) { - void __iomem *modemr = ioremap_nocache(MODEMR, PAGE_SIZE); - u32 mode; + u32 mode = rcar_gen2_read_mode_pins(); int k, ret = 0; - BUG_ON(!modemr); - mode = ioread32(modemr); - iounmap(modemr); - switch (mode & (MD(14) | MD(13))) { case 0: R8A7791_CLOCK_ROOT(15, &extal_clk, 172, 208, 106, 88); -- cgit v1.2.3 From 25f5550f5a4b18fd77a2e719ba63cb34931ab66a Mon Sep 17 00:00:00 2001 From: Magnus Damm Date: Thu, 13 Mar 2014 08:36:17 +0900 Subject: ARM: shmobile: Introduce shmobile_clk_workaround() Introduce a new clock workaround function used by DT reference code on the mach-shmobile subarchitecture. The new function shmobile_clk_workaround() is used to configure clkdev to allow DT and platform devices to coexist. It is possible for the DT reference board code to also request enabling of the clock in case the driver does not implement clock control. Signed-off-by: Magnus Damm [horms+renesas@verge.net.au: Removed trailing blank line] Reviewed-by: Wolfram Sang Tested-by: Wolfram Sang Signed-off-by: Simon Horman --- arch/arm/mach-shmobile/Makefile | 2 +- arch/arm/mach-shmobile/clock.c | 28 ++++++++++++++++++++++++++++ arch/arm/mach-shmobile/include/mach/clock.h | 16 ++++++++++++++++ 3 files changed, 45 insertions(+), 1 deletion(-) diff --git a/arch/arm/mach-shmobile/Makefile b/arch/arm/mach-shmobile/Makefile index 4caffc912a81..c12a1c50e9d2 100644 --- a/arch/arm/mach-shmobile/Makefile +++ b/arch/arm/mach-shmobile/Makefile @@ -21,8 +21,8 @@ obj-$(CONFIG_ARCH_EMEV2) += setup-emev2.o obj-$(CONFIG_ARCH_R7S72100) += setup-r7s72100.o # Clock objects -ifndef CONFIG_COMMON_CLK obj-y += clock.o +ifndef CONFIG_COMMON_CLK obj-$(CONFIG_ARCH_SH7372) += clock-sh7372.o obj-$(CONFIG_ARCH_SH73A0) += clock-sh73a0.o obj-$(CONFIG_ARCH_R8A73A4) += clock-r8a73a4.o diff --git a/arch/arm/mach-shmobile/clock.c b/arch/arm/mach-shmobile/clock.c index ad7df629d995..e7232a0373b9 100644 --- a/arch/arm/mach-shmobile/clock.c +++ b/arch/arm/mach-shmobile/clock.c @@ -21,6 +21,32 @@ */ #include #include + +#ifdef CONFIG_COMMON_CLK +#include +#include +#include + +void __init shmobile_clk_workaround(const struct clk_name *clks, + int nr_clks, bool enable) +{ + const struct clk_name *clkn; + struct clk *clk; + unsigned int i; + + for (i = 0; i < nr_clks; ++i) { + clkn = clks + i; + clk = clk_get(NULL, clkn->clk); + if (!IS_ERR(clk)) { + clk_register_clkdev(clk, clkn->con_id, clkn->dev_id); + if (enable) + clk_prepare_enable(clk); + clk_put(clk); + } + } +} + +#else /* CONFIG_COMMON_CLK */ #include #include #include @@ -58,3 +84,5 @@ void __clk_put(struct clk *clk) { } EXPORT_SYMBOL(__clk_put); + +#endif /* CONFIG_COMMON_CLK */ diff --git a/arch/arm/mach-shmobile/include/mach/clock.h b/arch/arm/mach-shmobile/include/mach/clock.h index 03e56074928c..9a93cf924b9c 100644 --- a/arch/arm/mach-shmobile/include/mach/clock.h +++ b/arch/arm/mach-shmobile/include/mach/clock.h @@ -1,6 +1,21 @@ #ifndef CLOCK_H #define CLOCK_H +#ifdef CONFIG_COMMON_CLK +/* temporary clock configuration helper for platform devices */ + +struct clk_name { + const char *clk; + const char *con_id; + const char *dev_id; +}; + +void shmobile_clk_workaround(const struct clk_name *clks, int nr_clks, + bool enable); + +#else /* CONFIG_COMMON_CLK */ +/* legacy clock implementation */ + unsigned long shmobile_fixed_ratio_clk_recalc(struct clk *clk); extern struct sh_clk_ops shmobile_fixed_ratio_clk_ops; @@ -36,4 +51,5 @@ do { \ (p)->div = d; \ } while (0) +#endif /* CONFIG_COMMON_CLK */ #endif -- cgit v1.2.3 From ab077bfdc4eaffa5328a9843d4d7970718ac0b8a Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Tue, 1 Apr 2014 13:02:15 +0200 Subject: ARM: shmobile: r8a7790: Fix the I2C clocks parents in legacy code All I2C clocks derive from the HP clock, not from the P clock. Fix them. Signed-off-by: Laurent Pinchart Acked-by: Geert Uytterhoeven Reviewed-by: Wolfram Sang Signed-off-by: Simon Horman --- arch/arm/mach-shmobile/clock-r8a7790.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/arch/arm/mach-shmobile/clock-r8a7790.c b/arch/arm/mach-shmobile/clock-r8a7790.c index 3f93503f5b96..331013995fe3 100644 --- a/arch/arm/mach-shmobile/clock-r8a7790.c +++ b/arch/arm/mach-shmobile/clock-r8a7790.c @@ -249,10 +249,10 @@ static struct clk mstp_clks[MSTP_NR] = { [MSTP1007] = SH_CLK_MSTP32_STS(&p_clk, SMSTPCR10, 7, MSTPSR10, 0), /* SSI8 */ [MSTP1006] = SH_CLK_MSTP32_STS(&p_clk, SMSTPCR10, 6, MSTPSR10, 0), /* SSI9 */ [MSTP1005] = SH_CLK_MSTP32_STS(&p_clk, SMSTPCR10, 5, MSTPSR10, 0), /* SSI ALL */ - [MSTP931] = SH_CLK_MSTP32_STS(&p_clk, SMSTPCR9, 31, MSTPSR9, 0), /* I2C0 */ - [MSTP930] = SH_CLK_MSTP32_STS(&p_clk, SMSTPCR9, 30, MSTPSR9, 0), /* I2C1 */ - [MSTP929] = SH_CLK_MSTP32_STS(&p_clk, SMSTPCR9, 29, MSTPSR9, 0), /* I2C2 */ - [MSTP928] = SH_CLK_MSTP32_STS(&p_clk, SMSTPCR9, 28, MSTPSR9, 0), /* I2C3 */ + [MSTP931] = SH_CLK_MSTP32_STS(&hp_clk, SMSTPCR9, 31, MSTPSR9, 0), /* I2C0 */ + [MSTP930] = SH_CLK_MSTP32_STS(&hp_clk, SMSTPCR9, 30, MSTPSR9, 0), /* I2C1 */ + [MSTP929] = SH_CLK_MSTP32_STS(&hp_clk, SMSTPCR9, 29, MSTPSR9, 0), /* I2C2 */ + [MSTP928] = SH_CLK_MSTP32_STS(&hp_clk, SMSTPCR9, 28, MSTPSR9, 0), /* I2C3 */ [MSTP917] = SH_CLK_MSTP32_STS(&qspi_clk, SMSTPCR9, 17, MSTPSR9, 0), /* QSPI */ [MSTP815] = SH_CLK_MSTP32_STS(&zs_clk, SMSTPCR8, 15, MSTPSR8, 0), /* SATA0 */ [MSTP814] = SH_CLK_MSTP32_STS(&zs_clk, SMSTPCR8, 14, MSTPSR8, 0), /* SATA1 */ -- cgit v1.2.3 From 2b1b6e6865aeb236f759ad3f91db27b514e29023 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Tue, 1 Apr 2014 13:02:16 +0200 Subject: ARM: shmobile: r8a7791: Fix the I2C clocks parents in legacy code All I2C clocks derive from the HP clock, not from the P clock. Fix them. Signed-off-by: Laurent Pinchart Acked-by: Geert Uytterhoeven Reviewed-by: Wolfram Sang Signed-off-by: Simon Horman --- arch/arm/mach-shmobile/clock-r8a7791.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/arch/arm/mach-shmobile/clock-r8a7791.c b/arch/arm/mach-shmobile/clock-r8a7791.c index 36e57508d879..3b26c7eee873 100644 --- a/arch/arm/mach-shmobile/clock-r8a7791.c +++ b/arch/arm/mach-shmobile/clock-r8a7791.c @@ -188,12 +188,12 @@ static struct clk mstp_clks[MSTP_NR] = { [MSTP1108] = SH_CLK_MSTP32_STS(&mp_clk, SMSTPCR11, 8, MSTPSR11, 0), /* SCIFA5 */ [MSTP1107] = SH_CLK_MSTP32_STS(&mp_clk, SMSTPCR11, 7, MSTPSR11, 0), /* SCIFA4 */ [MSTP1106] = SH_CLK_MSTP32_STS(&mp_clk, SMSTPCR11, 6, MSTPSR11, 0), /* SCIFA3 */ - [MSTP931] = SH_CLK_MSTP32_STS(&p_clk, SMSTPCR9, 31, MSTPSR9, 0), /* I2C0 */ - [MSTP930] = SH_CLK_MSTP32_STS(&p_clk, SMSTPCR9, 30, MSTPSR9, 0), /* I2C1 */ - [MSTP929] = SH_CLK_MSTP32_STS(&p_clk, SMSTPCR9, 29, MSTPSR9, 0), /* I2C2 */ - [MSTP928] = SH_CLK_MSTP32_STS(&p_clk, SMSTPCR9, 28, MSTPSR9, 0), /* I2C3 */ - [MSTP927] = SH_CLK_MSTP32_STS(&p_clk, SMSTPCR9, 27, MSTPSR9, 0), /* I2C4 */ - [MSTP925] = SH_CLK_MSTP32_STS(&p_clk, SMSTPCR9, 25, MSTPSR9, 0), /* I2C5 */ + [MSTP931] = SH_CLK_MSTP32_STS(&hp_clk, SMSTPCR9, 31, MSTPSR9, 0), /* I2C0 */ + [MSTP930] = SH_CLK_MSTP32_STS(&hp_clk, SMSTPCR9, 30, MSTPSR9, 0), /* I2C1 */ + [MSTP929] = SH_CLK_MSTP32_STS(&hp_clk, SMSTPCR9, 29, MSTPSR9, 0), /* I2C2 */ + [MSTP928] = SH_CLK_MSTP32_STS(&hp_clk, SMSTPCR9, 28, MSTPSR9, 0), /* I2C3 */ + [MSTP927] = SH_CLK_MSTP32_STS(&hp_clk, SMSTPCR9, 27, MSTPSR9, 0), /* I2C4 */ + [MSTP925] = SH_CLK_MSTP32_STS(&hp_clk, SMSTPCR9, 25, MSTPSR9, 0), /* I2C5 */ [MSTP917] = SH_CLK_MSTP32_STS(&qspi_clk, SMSTPCR9, 17, MSTPSR9, 0), /* QSPI */ [MSTP815] = SH_CLK_MSTP32_STS(&zs_clk, SMSTPCR8, 15, MSTPSR8, 0), /* SATA0 */ [MSTP814] = SH_CLK_MSTP32_STS(&zs_clk, SMSTPCR8, 14, MSTPSR8, 0), /* SATA1 */ -- cgit v1.2.3 From 79ea9934b8df700fa306c8ced2d3bbf94ff276a8 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Wed, 2 Apr 2014 16:31:46 +0200 Subject: ARM: shmobile: r8a7790: Rename VSP1_(SY|RT) clocks to VSP1_(S|R) The r8a7790 has four VSP1 instances, two of them being named VSPS (which stands for "VSP Standard") and VSPR (which stands for "VSP for Resizing"). The clock section in the SoC datasheet misunderstood the abbreviations as meaning VSP System and VSP Realtime, and named the corresponding clocks VSP1(SY) and VSP1(RT). This mistake has been carried over to the kernel code. Fix this by renaming the VSP1_SY and VSP1_RT clocks to VSP1_S and VSP1_R. Signed-off-by: Laurent Pinchart Acked-by: Magnus Damm Signed-off-by: Simon Horman --- arch/arm/boot/dts/r8a7790.dtsi | 2 +- include/dt-bindings/clock/r8a7790-clock.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/arm/boot/dts/r8a7790.dtsi b/arch/arm/boot/dts/r8a7790.dtsi index 618e5b537eaf..10b326bdf831 100644 --- a/arch/arm/boot/dts/r8a7790.dtsi +++ b/arch/arm/boot/dts/r8a7790.dtsi @@ -673,7 +673,7 @@ renesas,clock-indices = < R8A7790_CLK_TMU1 R8A7790_CLK_TMU3 R8A7790_CLK_TMU2 R8A7790_CLK_CMT0 R8A7790_CLK_TMU0 R8A7790_CLK_VSP1_DU1 - R8A7790_CLK_VSP1_DU0 R8A7790_CLK_VSP1_RT R8A7790_CLK_VSP1_SY + R8A7790_CLK_VSP1_DU0 R8A7790_CLK_VSP1_R R8A7790_CLK_VSP1_S >; clock-output-names = "tmu1", "tmu3", "tmu2", "cmt0", "tmu0", "vsp1-du1", diff --git a/include/dt-bindings/clock/r8a7790-clock.h b/include/dt-bindings/clock/r8a7790-clock.h index 6548a5fbcf4a..9a7c4c5a35d1 100644 --- a/include/dt-bindings/clock/r8a7790-clock.h +++ b/include/dt-bindings/clock/r8a7790-clock.h @@ -33,8 +33,8 @@ #define R8A7790_CLK_TMU0 25 #define R8A7790_CLK_VSP1_DU1 27 #define R8A7790_CLK_VSP1_DU0 28 -#define R8A7790_CLK_VSP1_RT 30 -#define R8A7790_CLK_VSP1_SY 31 +#define R8A7790_CLK_VSP1_R 30 +#define R8A7790_CLK_VSP1_S 31 /* MSTP2 */ #define R8A7790_CLK_SCIFA2 2 -- cgit v1.2.3 From 58ea1d53ba93620ac50fef9d9720b2323971f243 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Wed, 2 Apr 2014 16:31:47 +0200 Subject: ARM: shmobile: r8a7791: Rename VSP1_SY clocks to VSP1_S The r8a7791 has three VSP1 instances, one of them being named VSPS (which stands for "VSP Standard"). The clock section in the SoC datasheet misunderstood the abbreviation as meaning VSP System, and named the corresponding clock VSP1(SY). This mistake has been carried over to the kernel code. Fix this by renaming the VSP1_SY clock to VSP1_S. Signed-off-by: Laurent Pinchart Acked-by: Magnus Damm Signed-off-by: Simon Horman --- arch/arm/boot/dts/r8a7791.dtsi | 2 +- include/dt-bindings/clock/r8a7791-clock.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/arm/boot/dts/r8a7791.dtsi b/arch/arm/boot/dts/r8a7791.dtsi index 46181708e59c..aa1cba94196c 100644 --- a/arch/arm/boot/dts/r8a7791.dtsi +++ b/arch/arm/boot/dts/r8a7791.dtsi @@ -688,7 +688,7 @@ renesas,clock-indices = < R8A7791_CLK_TMU1 R8A7791_CLK_TMU3 R8A7791_CLK_TMU2 R8A7791_CLK_CMT0 R8A7791_CLK_TMU0 R8A7791_CLK_VSP1_DU1 - R8A7791_CLK_VSP1_DU0 R8A7791_CLK_VSP1_SY + R8A7791_CLK_VSP1_DU0 R8A7791_CLK_VSP1_S >; clock-output-names = "tmu1", "tmu3", "tmu2", "cmt0", "tmu0", "vsp1-du1", diff --git a/include/dt-bindings/clock/r8a7791-clock.h b/include/dt-bindings/clock/r8a7791-clock.h index 30f82f286e29..f069bc6627cb 100644 --- a/include/dt-bindings/clock/r8a7791-clock.h +++ b/include/dt-bindings/clock/r8a7791-clock.h @@ -32,7 +32,7 @@ #define R8A7791_CLK_TMU0 25 #define R8A7791_CLK_VSP1_DU1 27 #define R8A7791_CLK_VSP1_DU0 28 -#define R8A7791_CLK_VSP1_SY 31 +#define R8A7791_CLK_VSP1_S 31 /* MSTP2 */ #define R8A7791_CLK_SCIFA2 2 -- cgit v1.2.3 From e6597e0e19bbabfdd1983dbe79892d8ba210a180 Mon Sep 17 00:00:00 2001 From: Magnus Damm Date: Thu, 13 Mar 2014 08:36:26 +0900 Subject: ARM: shmobile: Use shmobile_clk_workaround() on Lager Convert the Lager DT reference code to use the newly introduced function shmobile_clk_workaround(). Signed-off-by: Magnus Damm Signed-off-by: Simon Horman --- arch/arm/mach-shmobile/board-lager-reference.c | 65 ++++++++++---------------- 1 file changed, 25 insertions(+), 40 deletions(-) diff --git a/arch/arm/mach-shmobile/board-lager-reference.c b/arch/arm/mach-shmobile/board-lager-reference.c index 440aac36d693..c76248b9a5e7 100644 --- a/arch/arm/mach-shmobile/board-lager-reference.c +++ b/arch/arm/mach-shmobile/board-lager-reference.c @@ -18,12 +18,11 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include -#include #include #include #include #include +#include #include #include #include @@ -86,46 +85,32 @@ static void __init lager_add_du_device(void) platform_device_register_full(&info); } +/* + * This is a really crude hack to provide clkdev support to platform + * devices until they get moved to DT. + */ +static const struct clk_name clk_names[] = { + { "cmt0", NULL, "sh_cmt.0" }, + { "scifa0", NULL, "sh-sci.0" }, + { "scifa1", NULL, "sh-sci.1" }, + { "scifb0", NULL, "sh-sci.2" }, + { "scifb1", NULL, "sh-sci.3" }, + { "scifb2", NULL, "sh-sci.4" }, + { "scifa2", NULL, "sh-sci.5" }, + { "scif0", NULL, "sh-sci.6" }, + { "scif1", NULL, "sh-sci.7" }, + { "hscif0", NULL, "sh-sci.8" }, + { "hscif1", NULL, "sh-sci.9" }, + { "du0", "du.0", "rcar-du-r8a7790" }, + { "du1", "du.1", "rcar-du-r8a7790" }, + { "du2", "du.2", "rcar-du-r8a7790" }, + { "lvds0", "lvds.0", "rcar-du-r8a7790" }, + { "lvds1", "lvds.1", "rcar-du-r8a7790" }, +}; + static void __init lager_add_standard_devices(void) { - /* - * This is a really crude hack to provide clkdev support to platform - * devices until they get moved to DT. - */ - static const struct clk_name { - const char *clk; - const char *con_id; - const char *dev_id; - } clk_names[] = { - { "cmt0", NULL, "sh_cmt.0" }, - { "scifa0", NULL, "sh-sci.0" }, - { "scifa1", NULL, "sh-sci.1" }, - { "scifb0", NULL, "sh-sci.2" }, - { "scifb1", NULL, "sh-sci.3" }, - { "scifb2", NULL, "sh-sci.4" }, - { "scifa2", NULL, "sh-sci.5" }, - { "scif0", NULL, "sh-sci.6" }, - { "scif1", NULL, "sh-sci.7" }, - { "hscif0", NULL, "sh-sci.8" }, - { "hscif1", NULL, "sh-sci.9" }, - { "du0", "du.0", "rcar-du-r8a7790" }, - { "du1", "du.1", "rcar-du-r8a7790" }, - { "du2", "du.2", "rcar-du-r8a7790" }, - { "lvds0", "lvds.0", "rcar-du-r8a7790" }, - { "lvds1", "lvds.1", "rcar-du-r8a7790" }, - }; - struct clk *clk; - unsigned int i; - - for (i = 0; i < ARRAY_SIZE(clk_names); ++i) { - clk = clk_get(NULL, clk_names[i].clk); - if (!IS_ERR(clk)) { - clk_register_clkdev(clk, clk_names[i].con_id, - clk_names[i].dev_id); - clk_put(clk); - } - } - + shmobile_clk_workaround(clk_names, ARRAY_SIZE(clk_names), false); r8a7790_add_dt_devices(); of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL); -- cgit v1.2.3 From 89aff406dbc3ea3dfc008e8472181532c0c0f4ea Mon Sep 17 00:00:00 2001 From: Magnus Damm Date: Thu, 13 Mar 2014 08:36:35 +0900 Subject: ARM: shmobile: Use shmobile_clk_workaround() on Koelsch Convert the Koelsch DT reference code to use the newly introduced function shmobile_clk_workaround(). Signed-off-by: Magnus Damm Signed-off-by: Simon Horman --- arch/arm/mach-shmobile/board-koelsch-reference.c | 71 ++++++++++-------------- 1 file changed, 28 insertions(+), 43 deletions(-) diff --git a/arch/arm/mach-shmobile/board-koelsch-reference.c b/arch/arm/mach-shmobile/board-koelsch-reference.c index a3fd30242bd8..a760f7f19bc9 100644 --- a/arch/arm/mach-shmobile/board-koelsch-reference.c +++ b/arch/arm/mach-shmobile/board-koelsch-reference.c @@ -19,12 +19,11 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include -#include #include #include #include #include +#include #include #include #include @@ -82,49 +81,35 @@ static void __init koelsch_add_du_device(void) platform_device_register_full(&info); } +/* + * This is a really crude hack to provide clkdev support to platform + * devices until they get moved to DT. + */ +static const struct clk_name clk_names[] = { + { "cmt0", NULL, "sh_cmt.0" }, + { "scifa0", NULL, "sh-sci.0" }, + { "scifa1", NULL, "sh-sci.1" }, + { "scifb0", NULL, "sh-sci.2" }, + { "scifb1", NULL, "sh-sci.3" }, + { "scifb2", NULL, "sh-sci.4" }, + { "scifa2", NULL, "sh-sci.5" }, + { "scif0", NULL, "sh-sci.6" }, + { "scif1", NULL, "sh-sci.7" }, + { "scif2", NULL, "sh-sci.8" }, + { "scif3", NULL, "sh-sci.9" }, + { "scif4", NULL, "sh-sci.10" }, + { "scif5", NULL, "sh-sci.11" }, + { "scifa3", NULL, "sh-sci.12" }, + { "scifa4", NULL, "sh-sci.13" }, + { "scifa5", NULL, "sh-sci.14" }, + { "du0", "du.0", "rcar-du-r8a7791" }, + { "du1", "du.1", "rcar-du-r8a7791" }, + { "lvds0", "lvds.0", "rcar-du-r8a7791" }, +}; + static void __init koelsch_add_standard_devices(void) { - /* - * This is a really crude hack to provide clkdev support to the CMT and - * DU devices until they get moved to DT. - */ - static const struct clk_name { - const char *clk; - const char *con_id; - const char *dev_id; - } clk_names[] = { - { "cmt0", NULL, "sh_cmt.0" }, - { "scifa0", NULL, "sh-sci.0" }, - { "scifa1", NULL, "sh-sci.1" }, - { "scifb0", NULL, "sh-sci.2" }, - { "scifb1", NULL, "sh-sci.3" }, - { "scifb2", NULL, "sh-sci.4" }, - { "scifa2", NULL, "sh-sci.5" }, - { "scif0", NULL, "sh-sci.6" }, - { "scif1", NULL, "sh-sci.7" }, - { "scif2", NULL, "sh-sci.8" }, - { "scif3", NULL, "sh-sci.9" }, - { "scif4", NULL, "sh-sci.10" }, - { "scif5", NULL, "sh-sci.11" }, - { "scifa3", NULL, "sh-sci.12" }, - { "scifa4", NULL, "sh-sci.13" }, - { "scifa5", NULL, "sh-sci.14" }, - { "du0", "du.0", "rcar-du-r8a7791" }, - { "du1", "du.1", "rcar-du-r8a7791" }, - { "lvds0", "lvds.0", "rcar-du-r8a7791" }, - }; - struct clk *clk; - unsigned int i; - - for (i = 0; i < ARRAY_SIZE(clk_names); ++i) { - clk = clk_get(NULL, clk_names[i].clk); - if (!IS_ERR(clk)) { - clk_register_clkdev(clk, clk_names[i].con_id, - clk_names[i].dev_id); - clk_put(clk); - } - } - + shmobile_clk_workaround(clk_names, ARRAY_SIZE(clk_names), false); r8a7791_add_dt_devices(); of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL); -- cgit v1.2.3 From f6f98b3e44ea408e33eb4d695a4225cc11210cdb Mon Sep 17 00:00:00 2001 From: Simon Horman Date: Thu, 13 Mar 2014 15:29:57 +0900 Subject: ARM: shmobile: koelsch: Annotate clk_names with __initconst Signed-off-by: Simon Horman Acked-by: Geert Uytterhoeven --- arch/arm/mach-shmobile/board-koelsch-reference.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm/mach-shmobile/board-koelsch-reference.c b/arch/arm/mach-shmobile/board-koelsch-reference.c index a760f7f19bc9..1e6a4361c0eb 100644 --- a/arch/arm/mach-shmobile/board-koelsch-reference.c +++ b/arch/arm/mach-shmobile/board-koelsch-reference.c @@ -85,7 +85,7 @@ static void __init koelsch_add_du_device(void) * This is a really crude hack to provide clkdev support to platform * devices until they get moved to DT. */ -static const struct clk_name clk_names[] = { +static const struct clk_name clk_names[] __initconst = { { "cmt0", NULL, "sh_cmt.0" }, { "scifa0", NULL, "sh-sci.0" }, { "scifa1", NULL, "sh-sci.1" }, -- cgit v1.2.3 From f71c77286b2c1f809a85e8e42df88eb2ec132e5f Mon Sep 17 00:00:00 2001 From: Simon Horman Date: Thu, 13 Mar 2014 15:29:58 +0900 Subject: ARM: shmobile: lager: Annotate clk_names with __initconst Signed-off-by: Simon Horman Acked-by: Geert Uytterhoeven --- arch/arm/mach-shmobile/board-lager-reference.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm/mach-shmobile/board-lager-reference.c b/arch/arm/mach-shmobile/board-lager-reference.c index c76248b9a5e7..7ff395efa9fe 100644 --- a/arch/arm/mach-shmobile/board-lager-reference.c +++ b/arch/arm/mach-shmobile/board-lager-reference.c @@ -89,7 +89,7 @@ static void __init lager_add_du_device(void) * This is a really crude hack to provide clkdev support to platform * devices until they get moved to DT. */ -static const struct clk_name clk_names[] = { +static const struct clk_name clk_names[] __initconst = { { "cmt0", NULL, "sh_cmt.0" }, { "scifa0", NULL, "sh-sci.0" }, { "scifa1", NULL, "sh-sci.1" }, -- cgit v1.2.3 From 53cf0cf7ba2ef785b339826a0765bb6b1756adeb Mon Sep 17 00:00:00 2001 From: Geert Uytterhoeven Date: Thu, 13 Mar 2014 15:29:30 +0100 Subject: ARM: shmobile: koelsch-reference: Work around core clock issues Due to issues with runtime PM clock management, clocks not explicitly managed by their drivers may not be enabled at all, or be inadvertently disabled by the clk_disable_unused() late initcall. Until this is fixed, add a temporary workaround, calling shmobile_clk_workaround() with enable == true. For now this enables the clocks for: ether, i2c2, msiof0, qspi_mod, and thermal. More clocks can be added if needed. Signed-off-by: Geert Uytterhoeven Signed-off-by: Simon Horman --- arch/arm/mach-shmobile/board-koelsch-reference.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/arch/arm/mach-shmobile/board-koelsch-reference.c b/arch/arm/mach-shmobile/board-koelsch-reference.c index 1e6a4361c0eb..a39114a1fe1b 100644 --- a/arch/arm/mach-shmobile/board-koelsch-reference.c +++ b/arch/arm/mach-shmobile/board-koelsch-reference.c @@ -107,9 +107,21 @@ static const struct clk_name clk_names[] __initconst = { { "lvds0", "lvds.0", "rcar-du-r8a7791" }, }; +/* + * This is a really crude hack to work around core platform clock issues + */ +static const struct clk_name clk_enables[] = { + { "ether", NULL, "ee700000.ethernet" }, + { "i2c2", NULL, "e6530000.i2c" }, + { "msiof0", NULL, "e6e20000.spi" }, + { "qspi_mod", NULL, "e6b10000.spi" }, + { "thermal", NULL, "e61f0000.thermal" }, +}; + static void __init koelsch_add_standard_devices(void) { shmobile_clk_workaround(clk_names, ARRAY_SIZE(clk_names), false); + shmobile_clk_workaround(clk_enables, ARRAY_SIZE(clk_enables), true); r8a7791_add_dt_devices(); of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL); -- cgit v1.2.3 From 9e7b83c221cc257f4dc37acc82bbcb80627c0ab9 Mon Sep 17 00:00:00 2001 From: Simon Horman Date: Mon, 17 Mar 2014 11:19:56 +0900 Subject: ARM: shmobile: koelsch-reference: Annotate clk_enables as __initconst Signed-off-by: Simon Horman Acked-by: Geert Uytterhoeven --- arch/arm/mach-shmobile/board-koelsch-reference.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm/mach-shmobile/board-koelsch-reference.c b/arch/arm/mach-shmobile/board-koelsch-reference.c index a39114a1fe1b..63117d52db9e 100644 --- a/arch/arm/mach-shmobile/board-koelsch-reference.c +++ b/arch/arm/mach-shmobile/board-koelsch-reference.c @@ -110,7 +110,7 @@ static const struct clk_name clk_names[] __initconst = { /* * This is a really crude hack to work around core platform clock issues */ -static const struct clk_name clk_enables[] = { +static const struct clk_name clk_enables[] __initconst = { { "ether", NULL, "ee700000.ethernet" }, { "i2c2", NULL, "e6530000.i2c" }, { "msiof0", NULL, "e6e20000.spi" }, -- cgit v1.2.3 From aa5de826afe747c353162bbc116c63ab5335f91c Mon Sep 17 00:00:00 2001 From: Simon Horman Date: Mon, 17 Mar 2014 11:18:56 +0900 Subject: ARM: shmobile: lager-reference: Work around core clock issues Due to issues with runtime PM clock management, clocks not explicitly managed by their drivers may not be enabled at all, or be inadvertently disabled by the clk_disable_unused() late initcall. Until this is fixed, add a temporary workaround, calling shmobile_clk_workaround() with enable == true. For now this enables the clocks for: ether, msiof1, qspi_mod, and thermal. More clocks can be added if needed. Based on work for the koelsch board by Geert Uytterhoeven. Signed-off-by: Simon Horman Acked-by: Geert Uytterhoeven --- arch/arm/mach-shmobile/board-lager-reference.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/arch/arm/mach-shmobile/board-lager-reference.c b/arch/arm/mach-shmobile/board-lager-reference.c index 7ff395efa9fe..313118c5f365 100644 --- a/arch/arm/mach-shmobile/board-lager-reference.c +++ b/arch/arm/mach-shmobile/board-lager-reference.c @@ -108,9 +108,20 @@ static const struct clk_name clk_names[] __initconst = { { "lvds1", "lvds.1", "rcar-du-r8a7790" }, }; +/* + * This is a really crude hack to work around core platform clock issues + */ +static const struct clk_name clk_enables[] __initconst = { + { "ether", NULL, "ee700000.ethernet" }, + { "msiof1", NULL, "e6e10000.spi" }, + { "qspi_mod", NULL, "e6b10000.spi" }, + { "thermal", NULL, "e61f0000.thermal" }, +}; + static void __init lager_add_standard_devices(void) { shmobile_clk_workaround(clk_names, ARRAY_SIZE(clk_names), false); + shmobile_clk_workaround(clk_enables, ARRAY_SIZE(clk_enables), true); r8a7790_add_dt_devices(); of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL); -- cgit v1.2.3 From f98b55d730492e664fb2649bd7054fec0fe81acd Mon Sep 17 00:00:00 2001 From: Magnus Damm Date: Tue, 18 Mar 2014 21:52:47 +0900 Subject: ARM: shmobile: Add Lager clock workarounds for SDHI and MMCIF Add MMCIF1, SDHI0 and SDHI2 to the clock workaround list for Lager multiplatform. Without these additional lines wakeup from Suspend-to-RAM never happens. Signed-off-by: Magnus Damm Signed-off-by: Simon Horman --- arch/arm/mach-shmobile/board-lager-reference.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/arch/arm/mach-shmobile/board-lager-reference.c b/arch/arm/mach-shmobile/board-lager-reference.c index 313118c5f365..1eb48cffb4c5 100644 --- a/arch/arm/mach-shmobile/board-lager-reference.c +++ b/arch/arm/mach-shmobile/board-lager-reference.c @@ -114,7 +114,10 @@ static const struct clk_name clk_names[] __initconst = { static const struct clk_name clk_enables[] __initconst = { { "ether", NULL, "ee700000.ethernet" }, { "msiof1", NULL, "e6e10000.spi" }, + { "mmcif1", NULL, "ee220000.mmc" }, { "qspi_mod", NULL, "e6b10000.spi" }, + { "sdhi0", NULL, "ee100000.sd" }, + { "sdhi2", NULL, "ee140000.sd" }, { "thermal", NULL, "e61f0000.thermal" }, }; -- cgit v1.2.3 From f278ea78beeb17ea07d11fc3372d4f98c94dcf46 Mon Sep 17 00:00:00 2001 From: Magnus Damm Date: Tue, 18 Mar 2014 21:54:34 +0900 Subject: ARM: shmobile: Add Koelsch clock workarounds for SDHI Add SDHI0, SDHI1 and SDHI2 to the clock workaround list for Koelsch multiplatform. Without these additional lines wakeup from Suspend-to-RAM never happens. Signed-off-by: Magnus Damm Signed-off-by: Simon Horman --- arch/arm/mach-shmobile/board-koelsch-reference.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/arch/arm/mach-shmobile/board-koelsch-reference.c b/arch/arm/mach-shmobile/board-koelsch-reference.c index 63117d52db9e..941f8b394e84 100644 --- a/arch/arm/mach-shmobile/board-koelsch-reference.c +++ b/arch/arm/mach-shmobile/board-koelsch-reference.c @@ -115,6 +115,9 @@ static const struct clk_name clk_enables[] __initconst = { { "i2c2", NULL, "e6530000.i2c" }, { "msiof0", NULL, "e6e20000.spi" }, { "qspi_mod", NULL, "e6b10000.spi" }, + { "sdhi0", NULL, "ee100000.sd" }, + { "sdhi1", NULL, "ee140000.sd" }, + { "sdhi2", NULL, "ee160000.sd" }, { "thermal", NULL, "e61f0000.thermal" }, }; -- cgit v1.2.3 From 896b79df8d60c01d46be23c10cc0f1a6691cc588 Mon Sep 17 00:00:00 2001 From: Magnus Damm Date: Thu, 6 Mar 2014 12:15:36 +0900 Subject: ARM: shmobile: Update r8a7791 CPU freq to 1500MHz in DTS The correct maximum CPU frequency for r8a7791 is 1500 MHz so update the r8a7791 SoC DTS to reflect this. Signed-off-by: Magnus Damm Signed-off-by: Simon Horman --- arch/arm/boot/dts/r8a7791.dtsi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/arm/boot/dts/r8a7791.dtsi b/arch/arm/boot/dts/r8a7791.dtsi index 46181708e59c..23ae96ee3dde 100644 --- a/arch/arm/boot/dts/r8a7791.dtsi +++ b/arch/arm/boot/dts/r8a7791.dtsi @@ -37,14 +37,14 @@ device_type = "cpu"; compatible = "arm,cortex-a15"; reg = <0>; - clock-frequency = <1300000000>; + clock-frequency = <1500000000>; }; cpu1: cpu@1 { device_type = "cpu"; compatible = "arm,cortex-a15"; reg = <1>; - clock-frequency = <1300000000>; + clock-frequency = <1500000000>; }; }; -- cgit v1.2.3 From fad6d45cdf8269d6d1c6784792c74c53e2304b32 Mon Sep 17 00:00:00 2001 From: Geert Uytterhoeven Date: Tue, 25 Feb 2014 11:30:13 +0100 Subject: ARM: shmobile: r8a7790/lager dts: Rename label spi to qspi, add spi0 alias Prepare for the advent of MSIOF SPI, which will be spi1 to spi4. Signed-off-by: Geert Uytterhoeven Acked-by: Magnus Damm Signed-off-by: Simon Horman --- arch/arm/boot/dts/r8a7790-lager.dts | 4 ++-- arch/arm/boot/dts/r8a7790.dtsi | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/arch/arm/boot/dts/r8a7790-lager.dts b/arch/arm/boot/dts/r8a7790-lager.dts index 6e99eb2df076..86dbdc10fe9c 100644 --- a/arch/arm/boot/dts/r8a7790-lager.dts +++ b/arch/arm/boot/dts/r8a7790-lager.dts @@ -155,7 +155,7 @@ renesas,function = "mmc1"; }; - qspi_pins: spi { + qspi_pins: spi0 { renesas,groups = "qspi_ctrl", "qspi_data4"; renesas,function = "qspi"; }; @@ -190,7 +190,7 @@ status = "okay"; }; -&spi { +&qspi { pinctrl-0 = <&qspi_pins>; pinctrl-names = "default"; diff --git a/arch/arm/boot/dts/r8a7790.dtsi b/arch/arm/boot/dts/r8a7790.dtsi index 618e5b537eaf..9383b8436111 100644 --- a/arch/arm/boot/dts/r8a7790.dtsi +++ b/arch/arm/boot/dts/r8a7790.dtsi @@ -24,6 +24,7 @@ i2c1 = &i2c1; i2c2 = &i2c2; i2c3 = &i2c3; + spi0 = &qspi; }; cpus { @@ -765,7 +766,7 @@ }; }; - spi: spi@e6b10000 { + qspi: spi@e6b10000 { compatible = "renesas,qspi-r8a7790", "renesas,qspi"; reg = <0 0xe6b10000 0 0x2c>; interrupts = <0 184 IRQ_TYPE_LEVEL_HIGH>; -- cgit v1.2.3 From 6f3e4ee340ea11d9aba39c5beaa80f0d3f368428 Mon Sep 17 00:00:00 2001 From: Geert Uytterhoeven Date: Tue, 25 Feb 2014 11:30:14 +0100 Subject: ARM: shmobile: r8a7791/koelsch dts: Rename label spi to qspi, add spi0 alias Prepare for the advent of MSIOF SPI, which will be spi1 to spi3. Signed-off-by: Geert Uytterhoeven Acked-by: Magnus Damm Signed-off-by: Simon Horman --- arch/arm/boot/dts/r8a7791-koelsch.dts | 4 ++-- arch/arm/boot/dts/r8a7791.dtsi | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/arch/arm/boot/dts/r8a7791-koelsch.dts b/arch/arm/boot/dts/r8a7791-koelsch.dts index bdd73e6657b2..bf9555bf08de 100644 --- a/arch/arm/boot/dts/r8a7791-koelsch.dts +++ b/arch/arm/boot/dts/r8a7791-koelsch.dts @@ -244,7 +244,7 @@ renesas,function = "sdhi2"; }; - qspi_pins: spi { + qspi_pins: spi0 { renesas,groups = "qspi_ctrl", "qspi_data4"; renesas,function = "qspi"; }; @@ -301,7 +301,7 @@ status = "okay"; }; -&spi { +&qspi { pinctrl-0 = <&qspi_pins>; pinctrl-names = "default"; diff --git a/arch/arm/boot/dts/r8a7791.dtsi b/arch/arm/boot/dts/r8a7791.dtsi index 23ae96ee3dde..6cda1886650b 100644 --- a/arch/arm/boot/dts/r8a7791.dtsi +++ b/arch/arm/boot/dts/r8a7791.dtsi @@ -27,6 +27,7 @@ i2c3 = &i2c3; i2c4 = &i2c4; i2c5 = &i2c5; + spi0 = &qspi; }; cpus { @@ -789,7 +790,7 @@ }; }; - spi: spi@e6b10000 { + qspi: spi@e6b10000 { compatible = "renesas,qspi-r8a7791", "renesas,qspi"; reg = <0 0xe6b10000 0 0x2c>; interrupts = <0 184 IRQ_TYPE_LEVEL_HIGH>; -- cgit v1.2.3 From ae8a6146afc9dddbbf342b3a77b9bf44618511dd Mon Sep 17 00:00:00 2001 From: Geert Uytterhoeven Date: Tue, 25 Feb 2014 11:30:15 +0100 Subject: ARM: shmobile: r8a7790 dtsi: Add MSIOF nodes and aliases Signed-off-by: Geert Uytterhoeven Acked-by: Magnus Damm Signed-off-by: Simon Horman --- arch/arm/boot/dts/r8a7790.dtsi | 44 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/arch/arm/boot/dts/r8a7790.dtsi b/arch/arm/boot/dts/r8a7790.dtsi index 9383b8436111..da69afc9e5cb 100644 --- a/arch/arm/boot/dts/r8a7790.dtsi +++ b/arch/arm/boot/dts/r8a7790.dtsi @@ -25,6 +25,10 @@ i2c2 = &i2c2; i2c3 = &i2c3; spi0 = &qspi; + spi1 = &msiof0; + spi2 = &msiof1; + spi3 = &msiof2; + spi4 = &msiof3; }; cpus { @@ -776,4 +780,44 @@ #size-cells = <0>; status = "disabled"; }; + + msiof0: spi@e6e20000 { + compatible = "renesas,msiof-r8a7790"; + reg = <0 0xe6e20000 0 0x0064>; + interrupts = <0 156 IRQ_TYPE_LEVEL_HIGH>; + clocks = <&mstp0_clks R8A7790_CLK_MSIOF0>; + #address-cells = <1>; + #size-cells = <0>; + status = "disabled"; + }; + + msiof1: spi@e6e10000 { + compatible = "renesas,msiof-r8a7790"; + reg = <0 0xe6e10000 0 0x0064>; + interrupts = <0 157 IRQ_TYPE_LEVEL_HIGH>; + clocks = <&mstp2_clks R8A7790_CLK_MSIOF1>; + #address-cells = <1>; + #size-cells = <0>; + status = "disabled"; + }; + + msiof2: spi@e6e00000 { + compatible = "renesas,msiof-r8a7790"; + reg = <0 0xe6e00000 0 0x0064>; + interrupts = <0 158 IRQ_TYPE_LEVEL_HIGH>; + clocks = <&mstp2_clks R8A7790_CLK_MSIOF2>; + #address-cells = <1>; + #size-cells = <0>; + status = "disabled"; + }; + + msiof3: spi@e6c90000 { + compatible = "renesas,msiof-r8a7790"; + reg = <0 0xe6c90000 0 0x0064>; + interrupts = <0 159 IRQ_TYPE_LEVEL_HIGH>; + clocks = <&mstp2_clks R8A7790_CLK_MSIOF3>; + #address-cells = <1>; + #size-cells = <0>; + status = "disabled"; + }; }; -- cgit v1.2.3 From 7713d3abe220c7d578768c07d183f6efbfa8895b Mon Sep 17 00:00:00 2001 From: Geert Uytterhoeven Date: Tue, 25 Feb 2014 11:30:16 +0100 Subject: ARM: shmobile: r8a7791 dtsi: Add MSIOF nodes and aliases Signed-off-by: Geert Uytterhoeven Acked-by: Magnus Damm Signed-off-by: Simon Horman --- arch/arm/boot/dts/r8a7791.dtsi | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/arch/arm/boot/dts/r8a7791.dtsi b/arch/arm/boot/dts/r8a7791.dtsi index 6cda1886650b..a70fb8069ef9 100644 --- a/arch/arm/boot/dts/r8a7791.dtsi +++ b/arch/arm/boot/dts/r8a7791.dtsi @@ -28,6 +28,9 @@ i2c4 = &i2c4; i2c5 = &i2c5; spi0 = &qspi; + spi1 = &msiof0; + spi2 = &msiof1; + spi3 = &msiof2; }; cpus { @@ -800,4 +803,34 @@ #size-cells = <0>; status = "disabled"; }; + + msiof0: spi@e6e20000 { + compatible = "renesas,msiof-r8a7791"; + reg = <0 0xe6e20000 0 0x0064>; + interrupts = <0 156 IRQ_TYPE_LEVEL_HIGH>; + clocks = <&mstp0_clks R8A7791_CLK_MSIOF0>; + #address-cells = <1>; + #size-cells = <0>; + status = "disabled"; + }; + + msiof1: spi@e6e10000 { + compatible = "renesas,msiof-r8a7791"; + reg = <0 0xe6e10000 0 0x0064>; + interrupts = <0 157 IRQ_TYPE_LEVEL_HIGH>; + clocks = <&mstp2_clks R8A7791_CLK_MSIOF1>; + #address-cells = <1>; + #size-cells = <0>; + status = "disabled"; + }; + + msiof2: spi@e6e00000 { + compatible = "renesas,msiof-r8a7791"; + reg = <0 0xe6e00000 0 0x0064>; + interrupts = <0 158 IRQ_TYPE_LEVEL_HIGH>; + clocks = <&mstp2_clks R8A7791_CLK_MSIOF2>; + #address-cells = <1>; + #size-cells = <0>; + status = "disabled"; + }; }; -- cgit v1.2.3 From b0403b91e18c567fe68976253ed5759c50fb3eae Mon Sep 17 00:00:00 2001 From: Geert Uytterhoeven Date: Tue, 25 Feb 2014 11:30:17 +0100 Subject: ARM: shmobile: lager dts: Add MSIOF nodes Add pinctrl and SPI device for MSIOF on Lager. On this board, only MSIOF1 is in use. Its bus contains a single device (a Renesas R2A11302FT PMIC), for which no bindings are defined yet. Signed-off-by: Geert Uytterhoeven Acked-by: Magnus Damm Signed-off-by: Simon Horman --- arch/arm/boot/dts/r8a7790-lager.dts | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/arch/arm/boot/dts/r8a7790-lager.dts b/arch/arm/boot/dts/r8a7790-lager.dts index 86dbdc10fe9c..cdec1af99be1 100644 --- a/arch/arm/boot/dts/r8a7790-lager.dts +++ b/arch/arm/boot/dts/r8a7790-lager.dts @@ -159,6 +159,12 @@ renesas,groups = "qspi_ctrl", "qspi_data4"; renesas,function = "qspi"; }; + + msiof1_pins: spi2 { + renesas,groups = "msiof1_clk", "msiof1_sync", "msiof1_rx", + "msiof1_tx"; + renesas,function = "msiof1"; + }; }; ðer { @@ -221,6 +227,22 @@ }; }; +&msiof1 { + pinctrl-0 = <&msiof1_pins>; + pinctrl-names = "default"; + + status = "okay"; + + pmic: pmic@0 { + compatible = "renesas,r2a11302ft"; + reg = <0>; + spi-max-frequency = <6000000>; + spi-cpol; + spi-cpha; + }; + +}; + &sdhi0 { pinctrl-0 = <&sdhi0_pins>; pinctrl-names = "default"; -- cgit v1.2.3 From b16f05ab75571ec360f5b7298888fd6cdf06f586 Mon Sep 17 00:00:00 2001 From: Geert Uytterhoeven Date: Tue, 25 Feb 2014 11:30:18 +0100 Subject: ARM: shmobile: koelsch dts: Add MSIOF nodes Add pinctrl and SPI device for MSIOF on Koelsch. On this board, only MSIOF0 is in use. Its bus contains a single device (a Renesas R2A11302FT PMIC), for which no bindings are defined yet. Signed-off-by: Geert Uytterhoeven Acked-by: Magnus Damm Signed-off-by: Simon Horman --- arch/arm/boot/dts/r8a7791-koelsch.dts | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/arch/arm/boot/dts/r8a7791-koelsch.dts b/arch/arm/boot/dts/r8a7791-koelsch.dts index bf9555bf08de..e24fed9c0462 100644 --- a/arch/arm/boot/dts/r8a7791-koelsch.dts +++ b/arch/arm/boot/dts/r8a7791-koelsch.dts @@ -248,6 +248,12 @@ renesas,groups = "qspi_ctrl", "qspi_data4"; renesas,function = "qspi"; }; + + msiof0_pins: spi1 { + renesas,groups = "msiof0_clk", "msiof0_sync", "msiof0_rx", + "msiof0_tx"; + renesas,function = "msiof0"; + }; }; ðer { @@ -331,3 +337,18 @@ }; }; }; + +&msiof0 { + pinctrl-0 = <&msiof0_pins>; + pinctrl-names = "default"; + + status = "okay"; + + pmic: pmic@0 { + compatible = "renesas,r2a11302ft"; + reg = <0>; + spi-max-frequency = <6000000>; + spi-cpol; + spi-cpha; + }; +}; -- cgit v1.2.3 From a34c50d53dc7779b404baab61b290827cb898562 Mon Sep 17 00:00:00 2001 From: Geert Uytterhoeven Date: Fri, 14 Mar 2014 11:06:40 +0100 Subject: ARM: shmobile: r8a7778 dtsi: Improve and correct HSPI nodes - Add "renesas,hspi-r8a7778" compatible value, - Correct reference to parent interrupt controller (use "interrupt-parent" instead of "interrupt-controller"), - Add missing "#address-cells" and "#size-cells" properties, which are needed when populating the SPI buses. Signed-off-by: Geert Uytterhoeven Tested-by: Kuninori Morimoto Signed-off-by: Simon Horman --- arch/arm/boot/dts/r8a7778.dtsi | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/arch/arm/boot/dts/r8a7778.dtsi b/arch/arm/boot/dts/r8a7778.dtsi index 85c5b3b99f5e..3c6fab5c9702 100644 --- a/arch/arm/boot/dts/r8a7778.dtsi +++ b/arch/arm/boot/dts/r8a7778.dtsi @@ -204,26 +204,32 @@ }; hspi0: spi@fffc7000 { - compatible = "renesas,hspi"; + compatible = "renesas,hspi-r8a7778", "renesas,hspi"; reg = <0xfffc7000 0x18>; - interrupt-controller = <&gic>; + interrupt-parent = <&gic>; interrupts = <0 63 IRQ_TYPE_LEVEL_HIGH>; + #address-cells = <1>; + #size-cells = <0>; status = "disabled"; }; hspi1: spi@fffc8000 { - compatible = "renesas,hspi"; + compatible = "renesas,hspi-r8a7778", "renesas,hspi"; reg = <0xfffc8000 0x18>; - interrupt-controller = <&gic>; + interrupt-parent = <&gic>; interrupts = <0 84 IRQ_TYPE_LEVEL_HIGH>; + #address-cells = <1>; + #size-cells = <0>; status = "disabled"; }; hspi2: spi@fffc6000 { - compatible = "renesas,hspi"; + compatible = "renesas,hspi-r8a7778", "renesas,hspi"; reg = <0xfffc6000 0x18>; - interrupt-controller = <&gic>; + interrupt-parent = <&gic>; interrupts = <0 85 IRQ_TYPE_LEVEL_HIGH>; + #address-cells = <1>; + #size-cells = <0>; status = "disabled"; }; }; -- cgit v1.2.3 From 7709c33b391e217d73b38853a7914a3a3e285cbc Mon Sep 17 00:00:00 2001 From: Geert Uytterhoeven Date: Fri, 14 Mar 2014 11:06:40 +0100 Subject: ARM: shmobile: r8a7779 dtsi: Improve and correct HSPI nodes - Add "renesas,hspi-r8a7779" compatible value, - Correct reference to parent interrupt controller (use "interrupt-parent" instead of "interrupt-controller"), - Add missing "#address-cells" and "#size-cells" properties, which are needed when populating the SPI buses. Signed-off-by: Geert Uytterhoeven Tested-by: Kuninori Morimoto Signed-off-by: Simon Horman --- arch/arm/boot/dts/r8a7779.dtsi | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/arch/arm/boot/dts/r8a7779.dtsi b/arch/arm/boot/dts/r8a7779.dtsi index d0561d4c7c46..8b1a336ee401 100644 --- a/arch/arm/boot/dts/r8a7779.dtsi +++ b/arch/arm/boot/dts/r8a7779.dtsi @@ -256,26 +256,32 @@ }; hspi0: spi@fffc7000 { - compatible = "renesas,hspi"; + compatible = "renesas,hspi-r8a7779", "renesas,hspi"; reg = <0xfffc7000 0x18>; - interrupt-controller = <&gic>; + interrupt-parent = <&gic>; interrupts = <0 73 IRQ_TYPE_LEVEL_HIGH>; + #address-cells = <1>; + #size-cells = <0>; status = "disabled"; }; hspi1: spi@fffc8000 { - compatible = "renesas,hspi"; + compatible = "renesas,hspi-r8a7779", "renesas,hspi"; reg = <0xfffc8000 0x18>; - interrupt-controller = <&gic>; + interrupt-parent = <&gic>; interrupts = <0 74 IRQ_TYPE_LEVEL_HIGH>; + #address-cells = <1>; + #size-cells = <0>; status = "disabled"; }; hspi2: spi@fffc6000 { - compatible = "renesas,hspi"; + compatible = "renesas,hspi-r8a7779", "renesas,hspi"; reg = <0xfffc6000 0x18>; - interrupt-controller = <&gic>; + interrupt-parent = <&gic>; interrupts = <0 75 IRQ_TYPE_LEVEL_HIGH>; + #address-cells = <1>; + #size-cells = <0>; status = "disabled"; }; }; -- cgit v1.2.3 From 6d879a097acaeaa9deba6d4949b466886b18652e Mon Sep 17 00:00:00 2001 From: Geert Uytterhoeven Date: Fri, 14 Mar 2014 11:06:41 +0100 Subject: ARM: shmobile: bockw reference dts: Add SPI FLASH Add Spansion s25fl008k SPI FLASH and MTD partition, based on bockw legacy board code. Signed-off-by: Geert Uytterhoeven Tested-by: Kuninori Morimoto Signed-off-by: Simon Horman --- arch/arm/boot/dts/r8a7778-bockw-reference.dts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/arch/arm/boot/dts/r8a7778-bockw-reference.dts b/arch/arm/boot/dts/r8a7778-bockw-reference.dts index 06cda19dac6a..f76f6ec01e19 100644 --- a/arch/arm/boot/dts/r8a7778-bockw-reference.dts +++ b/arch/arm/boot/dts/r8a7778-bockw-reference.dts @@ -109,4 +109,18 @@ pinctrl-0 = <&hspi0_pins>; pinctrl-names = "default"; status = "okay"; + + flash: flash@0 { + #address-cells = <1>; + #size-cells = <1>; + compatible = "spansion,s25fl008k"; + reg = <0>; + spi-max-frequency = <104000000>; + m25p,fast-read; + + partition@0 { + label = "data(spi)"; + reg = <0x00000000 0x00100000>; + }; + }; }; -- cgit v1.2.3 From f7dcd382a8d6ce8c6da12786c8311e71e214290d Mon Sep 17 00:00:00 2001 From: Magnus Damm Date: Tue, 18 Mar 2014 21:57:48 +0900 Subject: ARM: shmobile: Add DTS gpio-keys support for SW2 on Lager Add DTS gpio-keys support for SW2 on the Lager board. This makes the DT code match the legacy board code. Signed-off-by: Magnus Damm Signed-off-by: Simon Horman --- arch/arm/boot/dts/r8a7790-lager.dts | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/arch/arm/boot/dts/r8a7790-lager.dts b/arch/arm/boot/dts/r8a7790-lager.dts index cdec1af99be1..c3d8b17c5e3c 100644 --- a/arch/arm/boot/dts/r8a7790-lager.dts +++ b/arch/arm/boot/dts/r8a7790-lager.dts @@ -12,6 +12,7 @@ /dts-v1/; #include "r8a7790.dtsi" #include +#include / { model = "Lager"; @@ -36,6 +37,39 @@ #size-cells = <1>; }; + gpio_keys { + compatible = "gpio-keys"; + + button@1 { + linux,code = ; + label = "SW2-1"; + gpio-key,wakeup; + debounce-interval = <20>; + gpios = <&gpio1 14 GPIO_ACTIVE_LOW>; + }; + button@2 { + linux,code = ; + label = "SW2-2"; + gpio-key,wakeup; + debounce-interval = <20>; + gpios = <&gpio1 24 GPIO_ACTIVE_LOW>; + }; + button@3 { + linux,code = ; + label = "SW2-3"; + gpio-key,wakeup; + debounce-interval = <20>; + gpios = <&gpio1 26 GPIO_ACTIVE_LOW>; + }; + button@4 { + linux,code = ; + label = "SW2-4"; + gpio-key,wakeup; + debounce-interval = <20>; + gpios = <&gpio1 28 GPIO_ACTIVE_LOW>; + }; + }; + leds { compatible = "gpio-leds"; led6 { -- cgit v1.2.3 From 7f168b1e921f137db4f323428819f4c86ede4320 Mon Sep 17 00:00:00 2001 From: Magnus Damm Date: Tue, 18 Mar 2014 22:01:17 +0900 Subject: ARM: shmobile: Add DTS gpio-keys support for SW2 on Koelsch Add DTS gpio-keys support for SW2 on the Koelsch board. This makes the DT code match the legacy board code. Also update the existing gpio-keys nodes to make use of KEY_n. Signed-off-by: Magnus Damm Acked-by: Geert Uytterhoeven Signed-off-by: Simon Horman --- arch/arm/boot/dts/r8a7791-koelsch.dts | 43 +++++++++++++++++++++++++++++------ 1 file changed, 36 insertions(+), 7 deletions(-) diff --git a/arch/arm/boot/dts/r8a7791-koelsch.dts b/arch/arm/boot/dts/r8a7791-koelsch.dts index e24fed9c0462..fd1d6ee48a28 100644 --- a/arch/arm/boot/dts/r8a7791-koelsch.dts +++ b/arch/arm/boot/dts/r8a7791-koelsch.dts @@ -13,6 +13,7 @@ /dts-v1/; #include "r8a7791.dtsi" #include +#include / { model = "Koelsch"; @@ -40,51 +41,79 @@ gpio-keys { compatible = "gpio-keys"; + key-1 { + gpios = <&gpio5 0 GPIO_ACTIVE_LOW>; + linux,code = ; + label = "SW2-1"; + gpio-key,wakeup; + debounce-interval = <20>; + }; + key-2 { + gpios = <&gpio5 1 GPIO_ACTIVE_LOW>; + linux,code = ; + label = "SW2-2"; + gpio-key,wakeup; + debounce-interval = <20>; + }; + key-3 { + gpios = <&gpio5 2 GPIO_ACTIVE_LOW>; + linux,code = ; + label = "SW2-3"; + gpio-key,wakeup; + debounce-interval = <20>; + }; + key-4 { + gpios = <&gpio5 3 GPIO_ACTIVE_LOW>; + linux,code = ; + label = "SW2-4"; + gpio-key,wakeup; + debounce-interval = <20>; + }; key-a { gpios = <&gpio7 0 GPIO_ACTIVE_LOW>; - linux,code = <30>; + linux,code = ; label = "SW30"; gpio-key,wakeup; debounce-interval = <20>; }; key-b { gpios = <&gpio7 1 GPIO_ACTIVE_LOW>; - linux,code = <48>; + linux,code = ; label = "SW31"; gpio-key,wakeup; debounce-interval = <20>; }; key-c { gpios = <&gpio7 2 GPIO_ACTIVE_LOW>; - linux,code = <46>; + linux,code = ; label = "SW32"; gpio-key,wakeup; debounce-interval = <20>; }; key-d { gpios = <&gpio7 3 GPIO_ACTIVE_LOW>; - linux,code = <32>; + linux,code = ; label = "SW33"; gpio-key,wakeup; debounce-interval = <20>; }; key-e { gpios = <&gpio7 4 GPIO_ACTIVE_LOW>; - linux,code = <18>; + linux,code = ; label = "SW34"; gpio-key,wakeup; debounce-interval = <20>; }; key-f { gpios = <&gpio7 5 GPIO_ACTIVE_LOW>; - linux,code = <33>; + linux,code = ; label = "SW35"; gpio-key,wakeup; debounce-interval = <20>; }; key-g { gpios = <&gpio7 6 GPIO_ACTIVE_LOW>; - linux,code = <34>; + linux,code = ; label = "SW36"; gpio-key,wakeup; debounce-interval = <20>; -- cgit v1.2.3 From f17dd09d5133bc0705c8319df77169cb8491eaad Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Tue, 18 Mar 2014 19:04:47 +0100 Subject: ARM: shmobile: lager: Set ethernet PHY LED mode The Lager board uses the ethernet PHY LED0 as a link signal connected to the ethernet controller. Specify the corresponding LED mode for the PHY. Signed-off-by: Laurent Pinchart Signed-off-by: Simon Horman --- arch/arm/boot/dts/r8a7790-lager.dts | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/arm/boot/dts/r8a7790-lager.dts b/arch/arm/boot/dts/r8a7790-lager.dts index c3d8b17c5e3c..a55c5f838b9a 100644 --- a/arch/arm/boot/dts/r8a7790-lager.dts +++ b/arch/arm/boot/dts/r8a7790-lager.dts @@ -213,6 +213,7 @@ reg = <1>; interrupt-parent = <&irqc0>; interrupts = <0 IRQ_TYPE_LEVEL_LOW>; + led-mode = <1>; }; }; -- cgit v1.2.3 From 19f647cbd432eff181777bbe0f302c62af4a180d Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Tue, 18 Mar 2014 19:04:48 +0100 Subject: ARM: shmobile: koelsch: Set ethernet PHY LED mode The Koelsch board uses the ethernet PHY LED0 as a link signal connected to the ethernet controller. Specify the corresponding LED mode for the PHY. Signed-off-by: Laurent Pinchart Signed-off-by: Simon Horman --- arch/arm/boot/dts/r8a7791-koelsch.dts | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/arm/boot/dts/r8a7791-koelsch.dts b/arch/arm/boot/dts/r8a7791-koelsch.dts index fd1d6ee48a28..ee23b7b99ec9 100644 --- a/arch/arm/boot/dts/r8a7791-koelsch.dts +++ b/arch/arm/boot/dts/r8a7791-koelsch.dts @@ -297,6 +297,7 @@ reg = <1>; interrupt-parent = <&irqc0>; interrupts = <0 IRQ_TYPE_LEVEL_LOW>; + micrel,led-mode = <1>; }; }; -- cgit v1.2.3 From c9b60e922c7551ff1c477a121ad09f3790c1a575 Mon Sep 17 00:00:00 2001 From: Geert Uytterhoeven Date: Sun, 23 Mar 2014 20:35:01 +0100 Subject: ARM: shmobile: armadillo-reference dts: Use KEY_* macros for gpio-keys Signed-off-by: Geert Uytterhoeven Signed-off-by: Simon Horman --- arch/arm/boot/dts/r8a7740-armadillo800eva-reference.dts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/arch/arm/boot/dts/r8a7740-armadillo800eva-reference.dts b/arch/arm/boot/dts/r8a7740-armadillo800eva-reference.dts index 95a849bf921f..97342a4820cf 100644 --- a/arch/arm/boot/dts/r8a7740-armadillo800eva-reference.dts +++ b/arch/arm/boot/dts/r8a7740-armadillo800eva-reference.dts @@ -11,6 +11,7 @@ /dts-v1/; #include "r8a7740.dtsi" #include +#include #include #include @@ -77,26 +78,26 @@ power-key { gpios = <&pfc 99 GPIO_ACTIVE_LOW>; - linux,code = <116>; + linux,code = ; label = "SW3"; gpio-key,wakeup; }; back-key { gpios = <&pfc 100 GPIO_ACTIVE_LOW>; - linux,code = <158>; + linux,code = ; label = "SW4"; }; menu-key { gpios = <&pfc 97 GPIO_ACTIVE_LOW>; - linux,code = <139>; + linux,code = ; label = "SW5"; }; home-key { gpios = <&pfc 98 GPIO_ACTIVE_LOW>; - linux,code = <102>; + linux,code = ; label = "SW6"; }; }; -- cgit v1.2.3 From 39f0163098d136411538060fd53c8b8c255cda05 Mon Sep 17 00:00:00 2001 From: Geert Uytterhoeven Date: Sun, 23 Mar 2014 20:35:02 +0100 Subject: ARM: shmobile: kzm9g-reference dts: Use KEY_* macros for gpio-keys Signed-off-by: Geert Uytterhoeven Signed-off-by: Simon Horman --- arch/arm/boot/dts/sh73a0-kzm9g-reference.dts | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/arch/arm/boot/dts/sh73a0-kzm9g-reference.dts b/arch/arm/boot/dts/sh73a0-kzm9g-reference.dts index eb8886b535e4..a99171c8a782 100644 --- a/arch/arm/boot/dts/sh73a0-kzm9g-reference.dts +++ b/arch/arm/boot/dts/sh73a0-kzm9g-reference.dts @@ -14,6 +14,7 @@ /dts-v1/; #include "sh73a0.dtsi" #include +#include #include / { @@ -112,43 +113,43 @@ back-key { gpios = <&pcf8575 8 GPIO_ACTIVE_LOW>; - linux,code = <158>; + linux,code = ; label = "SW3"; }; right-key { gpios = <&pcf8575 9 GPIO_ACTIVE_LOW>; - linux,code = <106>; + linux,code = ; label = "SW2-R"; }; left-key { gpios = <&pcf8575 10 GPIO_ACTIVE_LOW>; - linux,code = <105>; + linux,code = ; label = "SW2-L"; }; enter-key { gpios = <&pcf8575 11 GPIO_ACTIVE_LOW>; - linux,code = <28>; + linux,code = ; label = "SW2-P"; }; up-key { gpios = <&pcf8575 12 GPIO_ACTIVE_LOW>; - linux,code = <103>; + linux,code = ; label = "SW2-U"; }; down-key { gpios = <&pcf8575 13 GPIO_ACTIVE_LOW>; - linux,code = <108>; + linux,code = ; label = "SW2-D"; }; home-key { gpios = <&pcf8575 14 GPIO_ACTIVE_LOW>; - linux,code = <102>; + linux,code = ; label = "SW1"; }; }; -- cgit v1.2.3 From c6e8f325e769aabd059f8ff7d29e406345f83929 Mon Sep 17 00:00:00 2001 From: Wolfram Sang Date: Mon, 10 Mar 2014 12:26:56 +0100 Subject: ARM: shmobile: r8a7791: add IIC0/1 clock macros Signed-off-by: Wolfram Sang Acked-by: Laurent Pinchart Acked-by: Magnus Damm Signed-off-by: Simon Horman --- include/dt-bindings/clock/r8a7791-clock.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/dt-bindings/clock/r8a7791-clock.h b/include/dt-bindings/clock/r8a7791-clock.h index 30f82f286e29..2df1a11faeb3 100644 --- a/include/dt-bindings/clock/r8a7791-clock.h +++ b/include/dt-bindings/clock/r8a7791-clock.h @@ -51,6 +51,8 @@ #define R8A7791_CLK_SDHI1 12 #define R8A7791_CLK_SDHI0 14 #define R8A7791_CLK_MMCIF0 15 +#define R8A7791_CLK_IIC0 18 +#define R8A7791_CLK_IIC1 23 #define R8A7791_CLK_SSUSB 28 #define R8A7791_CLK_CMT1 29 #define R8A7791_CLK_USBDMAC0 30 -- cgit v1.2.3 From c08691b578338004ee467cfe51850e7ffb523647 Mon Sep 17 00:00:00 2001 From: Wolfram Sang Date: Mon, 10 Mar 2014 12:26:57 +0100 Subject: ARM: shmobile: r8a7791: add IIC(B) clocks to dtsi Signed-off-by: Wolfram Sang Acked-by: Laurent Pinchart Acked-by: Magnus Damm Signed-off-by: Simon Horman --- arch/arm/boot/dts/r8a7791.dtsi | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/arch/arm/boot/dts/r8a7791.dtsi b/arch/arm/boot/dts/r8a7791.dtsi index a70fb8069ef9..dd45e0197baa 100644 --- a/arch/arm/boot/dts/r8a7791.dtsi +++ b/arch/arm/boot/dts/r8a7791.dtsi @@ -716,15 +716,16 @@ mstp3_clks: mstp3_clks@e615013c { compatible = "renesas,r8a7791-mstp-clocks", "renesas,cpg-mstp-clocks"; reg = <0 0xe615013c 0 4>, <0 0xe6150048 0 4>; - clocks = <&cp_clk>, <&sd2_clk>, <&sd1_clk>, - <&cpg_clocks R8A7791_CLK_SD0>, <&mmc0_clk>, <&rclk_clk>; + clocks = <&cp_clk>, <&sd2_clk>, <&sd1_clk>, <&cpg_clocks R8A7791_CLK_SD0>, + <&mmc0_clk>, <&hp_clk>, <&hp_clk>, <&rclk_clk>; #clock-cells = <1>; renesas,clock-indices = < - R8A7791_CLK_TPU0 R8A7791_CLK_SDHI2 R8A7791_CLK_SDHI1 - R8A7791_CLK_SDHI0 R8A7791_CLK_MMCIF0 R8A7791_CLK_CMT1 + R8A7791_CLK_TPU0 R8A7791_CLK_SDHI2 R8A7791_CLK_SDHI1 R8A7791_CLK_SDHI0 + R8A7791_CLK_MMCIF0 R8A7791_CLK_IIC0 R8A7791_CLK_IIC1 R8A7791_CLK_CMT1 >; clock-output-names = - "tpu0", "sdhi2", "sdhi1", "sdhi0", "mmcif0", "cmt1"; + "tpu0", "sdhi2", "sdhi1", "sdhi0", + "mmcif0", "i2c7", "i2c8", "cmt1"; }; mstp5_clks: mstp5_clks@e6150144 { compatible = "renesas,r8a7791-mstp-clocks", "renesas,cpg-mstp-clocks"; @@ -768,17 +769,17 @@ mstp9_clks: mstp9_clks@e6150994 { compatible = "renesas,r8a7791-mstp-clocks", "renesas,cpg-mstp-clocks"; reg = <0 0xe6150994 0 4>, <0 0xe61509a4 0 4>; - clocks = <&p_clk>, <&p_clk>, <&cpg_clocks R8A7791_CLK_QSPI>, - <&p_clk>, <&p_clk>, <&p_clk>, <&p_clk>, <&p_clk>, - <&p_clk>; + clocks = <&p_clk>, <&p_clk>, <&cpg_clocks R8A7791_CLK_QSPI>, <&p_clk>, + <&cp_clk>, <&p_clk>, <&p_clk>, <&p_clk>, + <&p_clk>, <&p_clk>; #clock-cells = <1>; renesas,clock-indices = < - R8A7791_CLK_RCAN1 R8A7791_CLK_RCAN0 R8A7791_CLK_QSPI_MOD - R8A7791_CLK_I2C5 R8A7791_CLK_I2C4 R8A7791_CLK_I2C3 - R8A7791_CLK_I2C2 R8A7791_CLK_I2C1 R8A7791_CLK_I2C0 + R8A7791_CLK_RCAN1 R8A7791_CLK_RCAN0 R8A7791_CLK_QSPI_MOD R8A7791_CLK_I2C5 + R8A7791_CLK_IICDVFS R8A7791_CLK_I2C4 R8A7791_CLK_I2C3 R8A7791_CLK_I2C2 + R8A7791_CLK_I2C1 R8A7791_CLK_I2C0 >; clock-output-names = - "rcan1", "rcan0", "qspi_mod", "i2c5", "i2c4", "i2c3", + "rcan1", "rcan0", "qspi_mod", "i2c5", "i2c6", "i2c4", "i2c3", "i2c2", "i2c1", "i2c0"; }; mstp11_clks: mstp11_clks@e615099c { -- cgit v1.2.3 From 36408d9dd0c398fc3efe87231a4c847601878c97 Mon Sep 17 00:00:00 2001 From: Wolfram Sang Date: Mon, 10 Mar 2014 12:26:58 +0100 Subject: ARM: shmobile: r8a7791: add IIC(B) cores to dtsi Signed-off-by: Wolfram Sang Acked-by: Laurent Pinchart Acked-by: Magnus Damm Signed-off-by: Simon Horman --- arch/arm/boot/dts/r8a7791.dtsi | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/arch/arm/boot/dts/r8a7791.dtsi b/arch/arm/boot/dts/r8a7791.dtsi index dd45e0197baa..1004355496f2 100644 --- a/arch/arm/boot/dts/r8a7791.dtsi +++ b/arch/arm/boot/dts/r8a7791.dtsi @@ -27,6 +27,9 @@ i2c3 = &i2c3; i2c4 = &i2c4; i2c5 = &i2c5; + i2c6 = &i2c6; + i2c7 = &i2c7; + i2c8 = &i2c8; spi0 = &qspi; spi1 = &msiof0; spi2 = &msiof1; @@ -184,6 +187,7 @@ <0 17 IRQ_TYPE_LEVEL_HIGH>; }; + /* The memory map in the User's Manual maps the cores to bus numbers */ i2c0: i2c@e6508000 { #address-cells = <1>; #size-cells = <0>; @@ -235,6 +239,7 @@ }; i2c5: i2c@e6528000 { + /* doesn't need pinmux */ #address-cells = <1>; #size-cells = <0>; compatible = "renesas,i2c-r8a7791"; @@ -244,6 +249,37 @@ status = "disabled"; }; + i2c6: i2c@e60b0000 { + /* doesn't need pinmux */ + #address-cells = <1>; + #size-cells = <0>; + compatible = "renesas,iic-r8a7791", "renesas,rmobile-iic"; + reg = <0 0xe60b0000 0 0x425>; + interrupts = <0 173 IRQ_TYPE_LEVEL_HIGH>; + clocks = <&mstp9_clks R8A7791_CLK_IICDVFS>; + status = "disabled"; + }; + + i2c7: i2c@e6500000 { + #address-cells = <1>; + #size-cells = <0>; + compatible = "renesas,iic-r8a7791", "renesas,rmobile-iic"; + reg = <0 0xe6500000 0 0x425>; + interrupts = <0 174 IRQ_TYPE_LEVEL_HIGH>; + clocks = <&mstp3_clks R8A7791_CLK_IIC0>; + status = "disabled"; + }; + + i2c8: i2c@e6510000 { + #address-cells = <1>; + #size-cells = <0>; + compatible = "renesas,iic-r8a7791", "renesas,rmobile-iic"; + reg = <0 0xe6510000 0 0x425>; + interrupts = <0 175 IRQ_TYPE_LEVEL_HIGH>; + clocks = <&mstp3_clks R8A7791_CLK_IIC1>; + status = "disabled"; + }; + pfc: pfc@e6060000 { compatible = "renesas,pfc-r8a7791"; reg = <0 0xe6060000 0 0x250>; -- cgit v1.2.3 From e6a4c001116ca28a3c5698168a2a1fe274fa6d2c Mon Sep 17 00:00:00 2001 From: Wolfram Sang Date: Mon, 10 Mar 2014 12:26:59 +0100 Subject: ARM: shmobile: koelsch: make i2c2-pfc node unique This node should have a unique name so it can be distinguished when other i2c busses are added later. Signed-off-by: Wolfram Sang Acked-by: Laurent Pinchart Acked-by: Magnus Damm Signed-off-by: Simon Horman --- arch/arm/boot/dts/r8a7791-koelsch.dts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm/boot/dts/r8a7791-koelsch.dts b/arch/arm/boot/dts/r8a7791-koelsch.dts index ee23b7b99ec9..fc6c94a1fb49 100644 --- a/arch/arm/boot/dts/r8a7791-koelsch.dts +++ b/arch/arm/boot/dts/r8a7791-koelsch.dts @@ -228,7 +228,7 @@ pinctrl-0 = <&du_pins &scif0_pins &scif1_pins>; pinctrl-names = "default"; - i2c2_pins: i2c { + i2c2_pins: i2c2 { renesas,groups = "i2c2"; renesas,function = "i2c2"; }; -- cgit v1.2.3 From aa28e55dd9b6832a56b1a37fbe65c34ddcd32bdf Mon Sep 17 00:00:00 2001 From: Wolfram Sang Date: Mon, 10 Mar 2014 12:27:00 +0100 Subject: ARM: shmobile: koelsch: activate i2c6 bus Signed-off-by: Wolfram Sang Acked-by: Laurent Pinchart Acked-by: Magnus Damm Signed-off-by: Simon Horman --- arch/arm/boot/dts/r8a7791-koelsch.dts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/arch/arm/boot/dts/r8a7791-koelsch.dts b/arch/arm/boot/dts/r8a7791-koelsch.dts index fc6c94a1fb49..2a0569d93b6e 100644 --- a/arch/arm/boot/dts/r8a7791-koelsch.dts +++ b/arch/arm/boot/dts/r8a7791-koelsch.dts @@ -224,6 +224,11 @@ }; }; +&i2c6 { + status = "okay"; + clock-frequency = <100000>; +}; + &pfc { pinctrl-0 = <&du_pins &scif0_pins &scif1_pins>; pinctrl-names = "default"; -- cgit v1.2.3 From 5c53f50c50badff499568a703467c3c9f23f9bfd Mon Sep 17 00:00:00 2001 From: Ulrich Hecht Date: Thu, 27 Mar 2014 11:45:44 +0100 Subject: ARM: shmobile: Use r8a7740 suffix for i2c, mmcif, fsi2 compat strings Add "renesas,*-r8a7740" to the compatible strings for consistency with other devices. Signed-off-by: Ulrich Hecht Acked-by: Wolfram Sang Signed-off-by: Simon Horman --- arch/arm/boot/dts/r8a7740.dtsi | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/arch/arm/boot/dts/r8a7740.dtsi b/arch/arm/boot/dts/r8a7740.dtsi index 8280884bfa59..9f659861f262 100644 --- a/arch/arm/boot/dts/r8a7740.dtsi +++ b/arch/arm/boot/dts/r8a7740.dtsi @@ -126,7 +126,7 @@ i2c0: i2c@fff20000 { #address-cells = <1>; #size-cells = <0>; - compatible = "renesas,rmobile-iic"; + compatible = "renesas,iic-r8a7740", "renesas,rmobile-iic"; reg = <0xfff20000 0x425>; interrupt-parent = <&gic>; interrupts = <0 201 IRQ_TYPE_LEVEL_HIGH @@ -139,7 +139,7 @@ i2c1: i2c@e6c20000 { #address-cells = <1>; #size-cells = <0>; - compatible = "renesas,rmobile-iic"; + compatible = "renesas,iic-r8a7740", "renesas,rmobile-iic"; reg = <0xe6c20000 0x425>; interrupt-parent = <&gic>; interrupts = <0 70 IRQ_TYPE_LEVEL_HIGH @@ -174,7 +174,7 @@ }; mmcif0: mmc@e6bd0000 { - compatible = "renesas,sh-mmcif"; + compatible = "renesas,mmcif-r8a7740", "renesas,sh-mmcif"; reg = <0xe6bd0000 0x100>; interrupt-parent = <&gic>; interrupts = <0 56 IRQ_TYPE_LEVEL_HIGH @@ -220,7 +220,7 @@ sh_fsi2: sound@fe1f0000 { #sound-dai-cells = <1>; - compatible = "renesas,sh_fsi2"; + compatible = "renesas,fsi2-r8a7740", "renesas,sh_fsi2"; reg = <0xfe1f0000 0x400>; interrupt-parent = <&gic>; interrupts = <0 9 0x4>; -- cgit v1.2.3 From 6225b99aa620d6e260228a30cc5d24cde60cb1e7 Mon Sep 17 00:00:00 2001 From: Magnus Damm Date: Mon, 7 Apr 2014 15:04:21 +0900 Subject: ARM: shmobile: r8a7791: Add EHCI MSTP clock Add support for EHCI clock gating via the MSTP703 bit on r8a7791. Signed-off-by: Magnus Damm Acked-by: Laurent Pinchart Signed-off-by: Simon Horman --- arch/arm/boot/dts/r8a7791.dtsi | 6 +++--- include/dt-bindings/clock/r8a7791-clock.h | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/arch/arm/boot/dts/r8a7791.dtsi b/arch/arm/boot/dts/r8a7791.dtsi index 1004355496f2..3b28c8f41fdc 100644 --- a/arch/arm/boot/dts/r8a7791.dtsi +++ b/arch/arm/boot/dts/r8a7791.dtsi @@ -774,19 +774,19 @@ mstp7_clks: mstp7_clks@e615014c { compatible = "renesas,r8a7791-mstp-clocks", "renesas,cpg-mstp-clocks"; reg = <0 0xe615014c 0 4>, <0 0xe61501c4 0 4>; - clocks = <&mp_clk>, <&zs_clk>, <&p_clk>, <&p_clk>, <&zs_clk>, + clocks = <&mp_clk>, <&mp_clk>, <&zs_clk>, <&p_clk>, <&p_clk>, <&zs_clk>, <&zs_clk>, <&p_clk>, <&p_clk>, <&p_clk>, <&p_clk>, <&zx_clk>, <&zx_clk>, <&zx_clk>; #clock-cells = <1>; renesas,clock-indices = < - R8A7791_CLK_HSUSB R8A7791_CLK_HSCIF2 R8A7791_CLK_SCIF5 + R8A7791_CLK_EHCI R8A7791_CLK_HSUSB R8A7791_CLK_HSCIF2 R8A7791_CLK_SCIF5 R8A7791_CLK_SCIF4 R8A7791_CLK_HSCIF1 R8A7791_CLK_HSCIF0 R8A7791_CLK_SCIF3 R8A7791_CLK_SCIF2 R8A7791_CLK_SCIF1 R8A7791_CLK_SCIF0 R8A7791_CLK_DU1 R8A7791_CLK_DU0 R8A7791_CLK_LVDS0 >; clock-output-names = - "hsusb", "hscif2", "scif5", "scif4", "hscif1", "hscif0", + "ehci", "hsusb", "hscif2", "scif5", "scif4", "hscif1", "hscif0", "scif3", "scif2", "scif1", "scif0", "du1", "du0", "lvds0"; }; mstp8_clks: mstp8_clks@e6150990 { diff --git a/include/dt-bindings/clock/r8a7791-clock.h b/include/dt-bindings/clock/r8a7791-clock.h index 2df1a11faeb3..602354365819 100644 --- a/include/dt-bindings/clock/r8a7791-clock.h +++ b/include/dt-bindings/clock/r8a7791-clock.h @@ -63,6 +63,7 @@ #define R8A7791_CLK_PWM 23 /* MSTP7 */ +#define R8A7791_CLK_EHCI 3 #define R8A7791_CLK_HSUSB 4 #define R8A7791_CLK_HSCIF2 13 #define R8A7791_CLK_SCIF5 14 -- cgit v1.2.3 From 584b23db5beb3bd3a3c0767248a4843cac848a58 Mon Sep 17 00:00:00 2001 From: Ulrich Hecht Date: Mon, 31 Mar 2014 17:38:20 +0200 Subject: ARM: shmobile: armadillo-reference dts: enable RTC This enables the Seiko real-time clock that is attached to a couple of GPIO pins. Signed-off-by: Ulrich Hecht Signed-off-by: Simon Horman --- .../arm/boot/dts/r8a7740-armadillo800eva-reference.dts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/arch/arm/boot/dts/r8a7740-armadillo800eva-reference.dts b/arch/arm/boot/dts/r8a7740-armadillo800eva-reference.dts index 97342a4820cf..0cb235a450b9 100644 --- a/arch/arm/boot/dts/r8a7740-armadillo800eva-reference.dts +++ b/arch/arm/boot/dts/r8a7740-armadillo800eva-reference.dts @@ -118,6 +118,16 @@ }; }; + i2c2: i2c@2 { + #address-cells = <1>; + #size-cells = <0>; + compatible = "i2c-gpio"; + gpios = <&pfc 208 GPIO_ACTIVE_HIGH /* sda */ + &pfc 91 GPIO_ACTIVE_HIGH /* scl */ + >; + i2c-gpio,delay-us = <5>; + }; + backlight { compatible = "pwm-backlight"; pwms = <&tpu 2 33333 PWM_POLARITY_INVERTED>; @@ -167,6 +177,14 @@ }; }; +&i2c2 { + status = "okay"; + rtc@30 { + compatible = "seiko,s35390a"; + reg = <0x30>; + }; +}; + &pfc { pinctrl-0 = <&scifa1_pins>; pinctrl-names = "default"; -- cgit v1.2.3 From 1c47a6aae8bc6113463c47e9b8d35e35e97411b2 Mon Sep 17 00:00:00 2001 From: Simon Horman Date: Tue, 8 Apr 2014 09:21:35 +0900 Subject: ARM: shmobile: lager: Correct setting of ethernet PHY LED mode The correct binding is "micrel,led-mode", not "led-mode". This corrects an error which was introduced when setting of ethernet PHY LED mode was added by 82e62182d59bd1d0 ("ARM: shmobile: lager: Set ethernet PHY LED mode"). This makes the lager code consistent with the koelsch code which was added by ae00d12a032490b3 ("ARM: shmobile: koelsch: Set ethernet PHY LED mode"). Acked-by: Laurent Pinchart Signed-off-by: Simon Horman --- arch/arm/boot/dts/r8a7790-lager.dts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm/boot/dts/r8a7790-lager.dts b/arch/arm/boot/dts/r8a7790-lager.dts index a55c5f838b9a..265cba1d53dc 100644 --- a/arch/arm/boot/dts/r8a7790-lager.dts +++ b/arch/arm/boot/dts/r8a7790-lager.dts @@ -213,7 +213,7 @@ reg = <1>; interrupt-parent = <&irqc0>; interrupts = <0 IRQ_TYPE_LEVEL_LOW>; - led-mode = <1>; + micrel,led-mode = <1>; }; }; -- cgit v1.2.3 From 3672b059e3a8582171863e1c588059a37aa56b75 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Tue, 1 Apr 2014 13:02:17 +0200 Subject: ARM: shmobile: r8a7790: Fix the I2C clocks parents in DT All I2C clocks derive from the HP clock, not from the P clock. Fix them. Signed-off-by: Laurent Pinchart Acked-by: Geert Uytterhoeven Reviewed-by: Wolfram Sang Signed-off-by: Simon Horman --- arch/arm/boot/dts/r8a7790.dtsi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm/boot/dts/r8a7790.dtsi b/arch/arm/boot/dts/r8a7790.dtsi index da69afc9e5cb..c4b9ff731f72 100644 --- a/arch/arm/boot/dts/r8a7790.dtsi +++ b/arch/arm/boot/dts/r8a7790.dtsi @@ -758,7 +758,7 @@ compatible = "renesas,r8a7790-mstp-clocks", "renesas,cpg-mstp-clocks"; reg = <0 0xe6150994 0 4>, <0 0xe61509a4 0 4>; clocks = <&p_clk>, <&p_clk>, <&cpg_clocks R8A7790_CLK_QSPI>, - <&p_clk>, <&p_clk>, <&p_clk>, <&p_clk>; + <&hp_clk>, <&hp_clk>, <&hp_clk>, <&hp_clk>; #clock-cells = <1>; renesas,clock-indices = < R8A7790_CLK_RCAN1 R8A7790_CLK_RCAN0 R8A7790_CLK_QSPI_MOD -- cgit v1.2.3 From 11b48db9321d11c623155a1c82544988508f9aca Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Tue, 1 Apr 2014 13:02:18 +0200 Subject: ARM: shmobile: r8a7791: Fix the I2C clocks parents in DT All I2C clocks derive from the HP clock, not from the P clock. Fix them. Signed-off-by: Laurent Pinchart Acked-by: Geert Uytterhoeven Reviewed-by: Wolfram Sang Signed-off-by: Simon Horman --- arch/arm/boot/dts/r8a7791.dtsi | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/arm/boot/dts/r8a7791.dtsi b/arch/arm/boot/dts/r8a7791.dtsi index 3b28c8f41fdc..98baff48e6ce 100644 --- a/arch/arm/boot/dts/r8a7791.dtsi +++ b/arch/arm/boot/dts/r8a7791.dtsi @@ -805,9 +805,9 @@ mstp9_clks: mstp9_clks@e6150994 { compatible = "renesas,r8a7791-mstp-clocks", "renesas,cpg-mstp-clocks"; reg = <0 0xe6150994 0 4>, <0 0xe61509a4 0 4>; - clocks = <&p_clk>, <&p_clk>, <&cpg_clocks R8A7791_CLK_QSPI>, <&p_clk>, - <&cp_clk>, <&p_clk>, <&p_clk>, <&p_clk>, - <&p_clk>, <&p_clk>; + clocks = <&p_clk>, <&p_clk>, <&cpg_clocks R8A7791_CLK_QSPI>, <&hp_clk>, + <&cp_clk>, <&hp_clk>, <&hp_clk>, <&hp_clk>, + <&hp_clk>, <&hp_clk>; #clock-cells = <1>; renesas,clock-indices = < R8A7791_CLK_RCAN1 R8A7791_CLK_RCAN0 R8A7791_CLK_QSPI_MOD R8A7791_CLK_I2C5 -- cgit v1.2.3 From 01d968e905968602c4958c416cfed7ad84b7489f Mon Sep 17 00:00:00 2001 From: Wolfram Sang Date: Tue, 11 Mar 2014 22:24:36 +0100 Subject: ARM: shmobile: r8a7790: add IIC0-2 clock macros Signed-off-by: Wolfram Sang Acked-by: Laurent Pinchart Signed-off-by: Simon Horman --- include/dt-bindings/clock/r8a7790-clock.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/dt-bindings/clock/r8a7790-clock.h b/include/dt-bindings/clock/r8a7790-clock.h index 6548a5fbcf4a..4d3e935b3f1b 100644 --- a/include/dt-bindings/clock/r8a7790-clock.h +++ b/include/dt-bindings/clock/r8a7790-clock.h @@ -50,6 +50,7 @@ #define R8A7790_CLK_SYS_DMAC0 19 /* MSTP3 */ +#define R8A7790_CLK_IIC2 0 #define R8A7790_CLK_TPU0 4 #define R8A7790_CLK_MMCIF1 5 #define R8A7790_CLK_SDHI3 11 @@ -57,6 +58,8 @@ #define R8A7790_CLK_SDHI1 13 #define R8A7790_CLK_SDHI0 14 #define R8A7790_CLK_MMCIF0 15 +#define R8A7790_CLK_IIC0 18 +#define R8A7790_CLK_IIC1 23 #define R8A7790_CLK_SSUSB 28 #define R8A7790_CLK_CMT1 29 #define R8A7790_CLK_USBDMAC0 30 -- cgit v1.2.3 From 17465149d8a1a3b7a00f02796d7d364522d0383b Mon Sep 17 00:00:00 2001 From: Wolfram Sang Date: Tue, 11 Mar 2014 22:24:37 +0100 Subject: ARM: shmobile: r8a7790: add IIC(B) clocks to dtsi Signed-off-by: Wolfram Sang [horms+renesas@verge.net.au resolved conflicts] [horms+renesas@verge.net.au consistently use space as separator] Signed-off-by: Simon Horman --- arch/arm/boot/dts/r8a7790.dtsi | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/arch/arm/boot/dts/r8a7790.dtsi b/arch/arm/boot/dts/r8a7790.dtsi index c4b9ff731f72..79855e39469c 100644 --- a/arch/arm/boot/dts/r8a7790.dtsi +++ b/arch/arm/boot/dts/r8a7790.dtsi @@ -702,18 +702,19 @@ mstp3_clks: mstp3_clks@e615013c { compatible = "renesas,r8a7790-mstp-clocks", "renesas,cpg-mstp-clocks"; reg = <0 0xe615013c 0 4>, <0 0xe6150048 0 4>; - clocks = <&cp_clk>, <&mmc1_clk>, <&sd3_clk>, <&sd2_clk>, - <&cpg_clocks R8A7790_CLK_SD1>, <&cpg_clocks R8A7790_CLK_SD0>, - <&mmc0_clk>, <&rclk_clk>; + clocks = <&hp_clk>, <&cp_clk>, <&mmc1_clk>, <&sd3_clk>, + <&sd2_clk>, <&cpg_clocks R8A7790_CLK_SD1>, <&cpg_clocks R8A7790_CLK_SD0>, <&mmc0_clk>, + <&hp_clk>, <&hp_clk>, <&rclk_clk>; #clock-cells = <1>; renesas,clock-indices = < - R8A7790_CLK_TPU0 R8A7790_CLK_MMCIF1 R8A7790_CLK_SDHI3 - R8A7790_CLK_SDHI2 R8A7790_CLK_SDHI1 R8A7790_CLK_SDHI0 - R8A7790_CLK_MMCIF0 R8A7790_CLK_CMT1 + R8A7790_CLK_IIC2 R8A7790_CLK_TPU0 R8A7790_CLK_MMCIF1 R8A7790_CLK_SDHI3 + R8A7790_CLK_SDHI2 R8A7790_CLK_SDHI1 R8A7790_CLK_SDHI0 R8A7790_CLK_MMCIF0 + R8A7790_CLK_IIC0 R8A7790_CLK_IIC1 R8A7790_CLK_CMT1 >; clock-output-names = - "tpu0", "mmcif1", "sdhi3", "sdhi2", - "sdhi1", "sdhi0", "mmcif0", "cmt1"; + "iic2", "tpu0", "mmcif1", "sdhi3", + "sdhi2", "sdhi1", "sdhi0", "mmcif0", + "iic0", "iic1", "cmt1"; }; mstp5_clks: mstp5_clks@e6150144 { compatible = "renesas,r8a7790-mstp-clocks", "renesas,cpg-mstp-clocks"; @@ -757,16 +758,16 @@ mstp9_clks: mstp9_clks@e6150994 { compatible = "renesas,r8a7790-mstp-clocks", "renesas,cpg-mstp-clocks"; reg = <0 0xe6150994 0 4>, <0 0xe61509a4 0 4>; - clocks = <&p_clk>, <&p_clk>, <&cpg_clocks R8A7790_CLK_QSPI>, + clocks = <&p_clk>, <&p_clk>, <&cpg_clocks R8A7790_CLK_QSPI>, <&cp_clk>, <&hp_clk>, <&hp_clk>, <&hp_clk>, <&hp_clk>; #clock-cells = <1>; renesas,clock-indices = < - R8A7790_CLK_RCAN1 R8A7790_CLK_RCAN0 R8A7790_CLK_QSPI_MOD - R8A7790_CLK_I2C3 R8A7790_CLK_I2C2 R8A7790_CLK_I2C1 - R8A7790_CLK_I2C0 + R8A7790_CLK_RCAN1 R8A7790_CLK_RCAN0 R8A7790_CLK_QSPI_MOD R8A7790_CLK_IICDVFS + R8A7790_CLK_I2C3 R8A7790_CLK_I2C2 R8A7790_CLK_I2C1 R8A7790_CLK_I2C0 >; clock-output-names = - "rcan1", "rcan0", "qspi_mod", "i2c3", "i2c2", "i2c1", "i2c0"; + "rcan1", "rcan0", "qspi_mod", "iic3", + "i2c3", "i2c2", "i2c1", "i2c0"; }; }; -- cgit v1.2.3 From 05f3991622013692b8ef428a6703663331544248 Mon Sep 17 00:00:00 2001 From: Wolfram Sang Date: Tue, 25 Mar 2014 19:56:29 +0100 Subject: ARM: shmobile: r8a7790: add IIC(B) cores to dtsi Signed-off-by: Wolfram Sang Acked-by: Laurent Pinchart Signed-off-by: Simon Horman --- arch/arm/boot/dts/r8a7790.dtsi | 44 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/arch/arm/boot/dts/r8a7790.dtsi b/arch/arm/boot/dts/r8a7790.dtsi index 79855e39469c..bf2db38eade1 100644 --- a/arch/arm/boot/dts/r8a7790.dtsi +++ b/arch/arm/boot/dts/r8a7790.dtsi @@ -24,6 +24,10 @@ i2c1 = &i2c1; i2c2 = &i2c2; i2c3 = &i2c3; + i2c4 = &iic0; + i2c5 = &iic1; + i2c6 = &iic2; + i2c7 = &iic3; spi0 = &qspi; spi1 = &msiof0; spi2 = &msiof1; @@ -236,6 +240,46 @@ status = "disabled"; }; + iic0: i2c@e6500000 { + #address-cells = <1>; + #size-cells = <0>; + compatible = "renesas,iic-r8a7790", "renesas,rmobile-iic"; + reg = <0 0xe6500000 0 0x425>; + interrupts = <0 174 IRQ_TYPE_LEVEL_HIGH>; + clocks = <&mstp3_clks R8A7790_CLK_IIC0>; + status = "disabled"; + }; + + iic1: i2c@e6510000 { + #address-cells = <1>; + #size-cells = <0>; + compatible = "renesas,iic-r8a7790", "renesas,rmobile-iic"; + reg = <0 0xe6510000 0 0x425>; + interrupts = <0 175 IRQ_TYPE_LEVEL_HIGH>; + clocks = <&mstp3_clks R8A7790_CLK_IIC1>; + status = "disabled"; + }; + + iic2: i2c@e6520000 { + #address-cells = <1>; + #size-cells = <0>; + compatible = "renesas,iic-r8a7790", "renesas,rmobile-iic"; + reg = <0 0xe6520000 0 0x425>; + interrupts = <0 176 IRQ_TYPE_LEVEL_HIGH>; + clocks = <&mstp3_clks R8A7790_CLK_IIC2>; + status = "disabled"; + }; + + iic3: i2c@e60b0000 { + #address-cells = <1>; + #size-cells = <0>; + compatible = "renesas,iic-r8a7790", "renesas,rmobile-iic"; + reg = <0 0xe60b0000 0 0x425>; + interrupts = <0 173 IRQ_TYPE_LEVEL_HIGH>; + clocks = <&mstp9_clks R8A7790_CLK_IICDVFS>; + status = "disabled"; + }; + mmcif0: mmcif@ee200000 { compatible = "renesas,mmcif-r8a7790", "renesas,sh-mmcif"; reg = <0 0xee200000 0 0x80>; -- cgit v1.2.3 From a9d83bd6abc00e14e2db1660e2c7d889745bb3aa Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Sun, 13 Apr 2014 17:56:42 -0700 Subject: ARM: shmobile: r8a7778: remove old style audio clock Current sound driver moves to new style clock, but is keeping compatiblity at this point. Move to new style on r8a7778 Signed-off-by: Kuninori Morimoto Signed-off-by: Simon Horman --- arch/arm/mach-shmobile/clock-r8a7778.c | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/arch/arm/mach-shmobile/clock-r8a7778.c b/arch/arm/mach-shmobile/clock-r8a7778.c index 2009a9bc6356..201fc487e4e1 100644 --- a/arch/arm/mach-shmobile/clock-r8a7778.c +++ b/arch/arm/mach-shmobile/clock-r8a7778.c @@ -175,10 +175,6 @@ static struct clk mstp_clks[MSTP_NR] = { static struct clk_lookup lookups[] = { /* main */ - CLKDEV_CON_ID("audio_clk_a", &audio_clk_a), - CLKDEV_CON_ID("audio_clk_b", &audio_clk_b), - CLKDEV_CON_ID("audio_clk_c", &audio_clk_c), - CLKDEV_CON_ID("audio_clk_internal", &s1_clk), CLKDEV_CON_ID("shyway_clk", &s_clk), CLKDEV_CON_ID("peripheral_clk", &p_clk), @@ -234,15 +230,15 @@ static struct clk_lookup lookups[] = { CLKDEV_ICK_ID("ssi.6", "rcar_sound", &mstp_clks[MSTP309]), CLKDEV_ICK_ID("ssi.7", "rcar_sound", &mstp_clks[MSTP308]), CLKDEV_ICK_ID("ssi.8", "rcar_sound", &mstp_clks[MSTP307]), - CLKDEV_ICK_ID("scu.0", "rcar_sound", &mstp_clks[MSTP531]), - CLKDEV_ICK_ID("scu.1", "rcar_sound", &mstp_clks[MSTP530]), - CLKDEV_ICK_ID("scu.2", "rcar_sound", &mstp_clks[MSTP529]), - CLKDEV_ICK_ID("scu.3", "rcar_sound", &mstp_clks[MSTP528]), - CLKDEV_ICK_ID("scu.4", "rcar_sound", &mstp_clks[MSTP527]), - CLKDEV_ICK_ID("scu.5", "rcar_sound", &mstp_clks[MSTP526]), - CLKDEV_ICK_ID("scu.6", "rcar_sound", &mstp_clks[MSTP525]), - CLKDEV_ICK_ID("scu.7", "rcar_sound", &mstp_clks[MSTP524]), - CLKDEV_ICK_ID("scu.8", "rcar_sound", &mstp_clks[MSTP523]), + CLKDEV_ICK_ID("src.0", "rcar_sound", &mstp_clks[MSTP531]), + CLKDEV_ICK_ID("src.1", "rcar_sound", &mstp_clks[MSTP530]), + CLKDEV_ICK_ID("src.2", "rcar_sound", &mstp_clks[MSTP529]), + CLKDEV_ICK_ID("src.3", "rcar_sound", &mstp_clks[MSTP528]), + CLKDEV_ICK_ID("src.4", "rcar_sound", &mstp_clks[MSTP527]), + CLKDEV_ICK_ID("src.5", "rcar_sound", &mstp_clks[MSTP526]), + CLKDEV_ICK_ID("src.6", "rcar_sound", &mstp_clks[MSTP525]), + CLKDEV_ICK_ID("src.7", "rcar_sound", &mstp_clks[MSTP524]), + CLKDEV_ICK_ID("src.8", "rcar_sound", &mstp_clks[MSTP523]), }; void __init r8a7778_clock_init(void) -- cgit v1.2.3 From 932616eed0308cbebbb20a079e4bed3674bf1117 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Sun, 13 Apr 2014 17:56:50 -0700 Subject: ARM: shmobile: r8a7790: remove old style audio clock Current sound driver moves to new style clock, but is keeping compatiblity at this point. Move to new style on r8a7790 Signed-off-by: Kuninori Morimoto Signed-off-by: Simon Horman --- arch/arm/mach-shmobile/clock-r8a7790.c | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/arch/arm/mach-shmobile/clock-r8a7790.c b/arch/arm/mach-shmobile/clock-r8a7790.c index 331013995fe3..a936ae7de083 100644 --- a/arch/arm/mach-shmobile/clock-r8a7790.c +++ b/arch/arm/mach-shmobile/clock-r8a7790.c @@ -294,10 +294,6 @@ static struct clk mstp_clks[MSTP_NR] = { static struct clk_lookup lookups[] = { /* main clocks */ - CLKDEV_CON_ID("audio_clk_a", &audio_clk_a), - CLKDEV_CON_ID("audio_clk_b", &audio_clk_b), - CLKDEV_CON_ID("audio_clk_c", &audio_clk_c), - CLKDEV_CON_ID("audio_clk_internal", &m2_clk), CLKDEV_CON_ID("extal", &extal_clk), CLKDEV_CON_ID("extal_div2", &extal_div2_clk), CLKDEV_CON_ID("main", &main_clk), @@ -381,16 +377,16 @@ static struct clk_lookup lookups[] = { CLKDEV_ICK_ID("clk_b", "rcar_sound", &audio_clk_b), CLKDEV_ICK_ID("clk_c", "rcar_sound", &audio_clk_c), CLKDEV_ICK_ID("clk_i", "rcar_sound", &m2_clk), - CLKDEV_ICK_ID("scu.0", "rcar_sound", &mstp_clks[MSTP1031]), - CLKDEV_ICK_ID("scu.1", "rcar_sound", &mstp_clks[MSTP1030]), - CLKDEV_ICK_ID("scu.2", "rcar_sound", &mstp_clks[MSTP1029]), - CLKDEV_ICK_ID("scu.3", "rcar_sound", &mstp_clks[MSTP1028]), - CLKDEV_ICK_ID("scu.4", "rcar_sound", &mstp_clks[MSTP1027]), - CLKDEV_ICK_ID("scu.5", "rcar_sound", &mstp_clks[MSTP1026]), - CLKDEV_ICK_ID("scu.6", "rcar_sound", &mstp_clks[MSTP1025]), - CLKDEV_ICK_ID("scu.7", "rcar_sound", &mstp_clks[MSTP1024]), - CLKDEV_ICK_ID("scu.8", "rcar_sound", &mstp_clks[MSTP1023]), - CLKDEV_ICK_ID("scu.9", "rcar_sound", &mstp_clks[MSTP1022]), + CLKDEV_ICK_ID("src.0", "rcar_sound", &mstp_clks[MSTP1031]), + CLKDEV_ICK_ID("src.1", "rcar_sound", &mstp_clks[MSTP1030]), + CLKDEV_ICK_ID("src.2", "rcar_sound", &mstp_clks[MSTP1029]), + CLKDEV_ICK_ID("src.3", "rcar_sound", &mstp_clks[MSTP1028]), + CLKDEV_ICK_ID("src.4", "rcar_sound", &mstp_clks[MSTP1027]), + CLKDEV_ICK_ID("src.5", "rcar_sound", &mstp_clks[MSTP1026]), + CLKDEV_ICK_ID("src.6", "rcar_sound", &mstp_clks[MSTP1025]), + CLKDEV_ICK_ID("src.7", "rcar_sound", &mstp_clks[MSTP1024]), + CLKDEV_ICK_ID("src.8", "rcar_sound", &mstp_clks[MSTP1023]), + CLKDEV_ICK_ID("src.9", "rcar_sound", &mstp_clks[MSTP1022]), CLKDEV_ICK_ID("ssi.0", "rcar_sound", &mstp_clks[MSTP1015]), CLKDEV_ICK_ID("ssi.1", "rcar_sound", &mstp_clks[MSTP1014]), CLKDEV_ICK_ID("ssi.2", "rcar_sound", &mstp_clks[MSTP1013]), -- cgit v1.2.3 From 115897dab004f580fc8b4c6bab057940ccb64989 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Sun, 13 Apr 2014 17:56:57 -0700 Subject: ARM: shmobile: bockw: remove old style audio clock Current audio clock didn't have dependency to device/driver, but, it was not good design for DT support. To avoid branch merge conflict issue, it is using this load map, and this patch is 3) part. 1) add new style clock in platform 2) add new style clock method in driver 3) remove old tyle clock from platform Signed-off-by: Kuninori Morimoto Signed-off-by: Simon Horman --- arch/arm/mach-shmobile/board-bockw.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/arch/arm/mach-shmobile/board-bockw.c b/arch/arm/mach-shmobile/board-bockw.c index b4122f8cb8d9..1aca107f959f 100644 --- a/arch/arm/mach-shmobile/board-bockw.c +++ b/arch/arm/mach-shmobile/board-bockw.c @@ -591,6 +591,7 @@ static void __init bockw_init(void) { void __iomem *base; struct clk *clk; + struct platform_device *pdev; int i; r8a7778_clock_init(); @@ -673,9 +674,6 @@ static void __init bockw_init(void) } /* for Audio */ - clk = clk_get(NULL, "audio_clk_b"); - clk_set_rate(clk, 24576000); - clk_put(clk); rsnd_codec_power(5, 1); /* enable ak4642 */ platform_device_register_simple( @@ -684,11 +682,15 @@ static void __init bockw_init(void) platform_device_register_simple( "ak4554-adc-dac", 1, NULL, 0); - platform_device_register_resndata( + pdev = platform_device_register_resndata( &platform_bus, "rcar_sound", -1, rsnd_resources, ARRAY_SIZE(rsnd_resources), &rsnd_info, sizeof(rsnd_info)); + clk = clk_get(&pdev->dev, "clk_b"); + clk_set_rate(clk, 24576000); + clk_put(clk); + for (i = 0; i < ARRAY_SIZE(rsnd_card_info); i++) { struct platform_device_info cardinfo = { .parent = &platform_bus, -- cgit v1.2.3 From a3f50d1bdd47dfa07cb42f7d954739389664f166 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Sun, 13 Apr 2014 17:57:05 -0700 Subject: ARM: shmobile: bockw: switch to use dai info for R-Car sound Now, R-Car sound driver supports dai info settings. switch to use it Signed-off-by: Kuninori Morimoto Signed-off-by: Simon Horman --- arch/arm/mach-shmobile/board-bockw.c | 53 ++++++++++++++++++++++++------------ 1 file changed, 35 insertions(+), 18 deletions(-) diff --git a/arch/arm/mach-shmobile/board-bockw.c b/arch/arm/mach-shmobile/board-bockw.c index 1aca107f959f..f444be2f241e 100644 --- a/arch/arm/mach-shmobile/board-bockw.c +++ b/arch/arm/mach-shmobile/board-bockw.c @@ -345,24 +345,39 @@ static struct rsnd_ssi_platform_info rsnd_ssi[] = { RSND_SSI_UNUSED, /* SSI 0 */ RSND_SSI_UNUSED, /* SSI 1 */ RSND_SSI_UNUSED, /* SSI 2 */ - RSND_SSI_SET(1, HPBDMA_SLAVE_HPBIF3_TX, gic_iid(0x85), RSND_SSI_PLAY), - RSND_SSI_SET(2, HPBDMA_SLAVE_HPBIF4_RX, gic_iid(0x85), RSND_SSI_CLK_PIN_SHARE), - RSND_SSI_SET(0, HPBDMA_SLAVE_HPBIF5_TX, gic_iid(0x86), RSND_SSI_PLAY), - RSND_SSI_SET(0, HPBDMA_SLAVE_HPBIF6_RX, gic_iid(0x86), 0), - RSND_SSI_SET(3, HPBDMA_SLAVE_HPBIF7_TX, gic_iid(0x86), RSND_SSI_PLAY), - RSND_SSI_SET(4, HPBDMA_SLAVE_HPBIF8_RX, gic_iid(0x86), RSND_SSI_CLK_PIN_SHARE), + RSND_SSI(HPBDMA_SLAVE_HPBIF3_TX, gic_iid(0x85), 0), + RSND_SSI(HPBDMA_SLAVE_HPBIF4_RX, gic_iid(0x85), RSND_SSI_CLK_PIN_SHARE), + RSND_SSI(HPBDMA_SLAVE_HPBIF5_TX, gic_iid(0x86), 0), + RSND_SSI(HPBDMA_SLAVE_HPBIF6_RX, gic_iid(0x86), 0), + RSND_SSI(HPBDMA_SLAVE_HPBIF7_TX, gic_iid(0x86), 0), + RSND_SSI(HPBDMA_SLAVE_HPBIF8_RX, gic_iid(0x86), RSND_SSI_CLK_PIN_SHARE), }; -static struct rsnd_scu_platform_info rsnd_scu[9] = { - { .flags = 0, }, /* SRU 0 */ - { .flags = 0, }, /* SRU 1 */ - { .flags = 0, }, /* SRU 2 */ - { .flags = RSND_SCU_USE_HPBIF, }, - { .flags = RSND_SCU_USE_HPBIF, }, - { .flags = RSND_SCU_USE_HPBIF, }, - { .flags = RSND_SCU_USE_HPBIF, }, - { .flags = RSND_SCU_USE_HPBIF, }, - { .flags = RSND_SCU_USE_HPBIF, }, +static struct rsnd_src_platform_info rsnd_src[9] = { + RSND_SRC_UNUSED, /* SRU 0 */ + RSND_SRC_UNUSED, /* SRU 1 */ + RSND_SRC_UNUSED, /* SRU 2 */ + RSND_SRC(0, 0), + RSND_SRC(0, 0), + RSND_SRC(0, 0), + RSND_SRC(0, 0), + RSND_SRC(0, 0), + RSND_SRC(0, 0), +}; + +static struct rsnd_dai_platform_info rsnd_dai[] = { + { + .playback = { .ssi = &rsnd_ssi[5], .src = &rsnd_src[5] }, + .capture = { .ssi = &rsnd_ssi[6], .src = &rsnd_src[6] }, + }, { + .playback = { .ssi = &rsnd_ssi[3], .src = &rsnd_src[3] }, + }, { + .capture = { .ssi = &rsnd_ssi[4], .src = &rsnd_src[4] }, + }, { + .playback = { .ssi = &rsnd_ssi[7], .src = &rsnd_src[7] }, + }, { + .capture = { .ssi = &rsnd_ssi[8], .src = &rsnd_src[8] }, + }, }; enum { @@ -437,8 +452,10 @@ static struct rcar_snd_info rsnd_info = { .flags = RSND_GEN1, .ssi_info = rsnd_ssi, .ssi_info_nr = ARRAY_SIZE(rsnd_ssi), - .scu_info = rsnd_scu, - .scu_info_nr = ARRAY_SIZE(rsnd_scu), + .src_info = rsnd_src, + .src_info_nr = ARRAY_SIZE(rsnd_src), + .dai_info = rsnd_dai, + .dai_info_nr = ARRAY_SIZE(rsnd_dai), .start = rsnd_start, .stop = rsnd_stop, }; -- cgit v1.2.3 From 50f359d7389be354b46d781f3b234d3008d20f2f Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Sun, 13 Apr 2014 17:57:12 -0700 Subject: ARM: shmobile: lager: switch to use dai info for R-Car sound Now, R-Car sound driver supports dai info settings. switch to use it Signed-off-by: Kuninori Morimoto Signed-off-by: Simon Horman --- arch/arm/mach-shmobile/board-lager.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/arch/arm/mach-shmobile/board-lager.c b/arch/arm/mach-shmobile/board-lager.c index f0104bfe544e..6af09e1e0841 100644 --- a/arch/arm/mach-shmobile/board-lager.c +++ b/arch/arm/mach-shmobile/board-lager.c @@ -567,20 +567,27 @@ static struct resource rsnd_resources[] __initdata = { }; static struct rsnd_ssi_platform_info rsnd_ssi[] = { - RSND_SSI_SET(0, 0, gic_spi(370), RSND_SSI_PLAY), - RSND_SSI_SET(0, 0, gic_spi(371), RSND_SSI_CLK_PIN_SHARE), + RSND_SSI(0, gic_spi(370), 0), + RSND_SSI(0, gic_spi(371), RSND_SSI_CLK_PIN_SHARE), }; -static struct rsnd_scu_platform_info rsnd_scu[2] = { +static struct rsnd_src_platform_info rsnd_src[2] = { /* no member at this point */ }; +static struct rsnd_dai_platform_info rsnd_dai = { + .playback = { .ssi = &rsnd_ssi[0], }, + .capture = { .ssi = &rsnd_ssi[1], }, +}; + static struct rcar_snd_info rsnd_info = { .flags = RSND_GEN2, .ssi_info = rsnd_ssi, .ssi_info_nr = ARRAY_SIZE(rsnd_ssi), - .scu_info = rsnd_scu, - .scu_info_nr = ARRAY_SIZE(rsnd_scu), + .src_info = rsnd_src, + .src_info_nr = ARRAY_SIZE(rsnd_src), + .dai_info = &rsnd_dai, + .dai_info_nr = 1, }; static struct asoc_simple_card_info rsnd_card_info = { -- cgit v1.2.3 From a42ea603594c1d236a9770c5334edb0defeeada5 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Sun, 13 Apr 2014 13:41:02 +0200 Subject: ARM: sun6i: dt: Fixup prcm node name The prcm lives at address 0x01f01400 as the reg entry in its node already correctly indicates, rename the node to match this. Signed-off-by: Hans de Goede Signed-off-by: Maxime Ripard --- arch/arm/boot/dts/sun6i-a31.dtsi | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/arch/arm/boot/dts/sun6i-a31.dtsi b/arch/arm/boot/dts/sun6i-a31.dtsi index d45efa74827c..bc46814d2ff0 100644 --- a/arch/arm/boot/dts/sun6i-a31.dtsi +++ b/arch/arm/boot/dts/sun6i-a31.dtsi @@ -479,14 +479,14 @@ interrupts = <1 9 0xf04>; }; + prcm@01f01400 { + compatible = "allwinner,sun6i-a31-prcm"; + reg = <0x01f01400 0x200>; + }; + cpucfg@01f01c00 { compatible = "allwinner,sun6i-a31-cpuconfig"; reg = <0x01f01c00 0x300>; }; - - prcm@01f01c00 { - compatible = "allwinner,sun6i-a31-prcm"; - reg = <0x01f01400 0x200>; - }; }; }; -- cgit v1.2.3 From 60bbe31649ed65643f0b2b910a2d3191d10e7d4e Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Sun, 13 Apr 2014 13:41:03 +0200 Subject: ARM: sun4i: dt: Add address- and size-cells info to i2c controller nodes Signed-off-by: Hans de Goede Signed-off-by: Maxime Ripard --- arch/arm/boot/dts/sun4i-a10.dtsi | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/arch/arm/boot/dts/sun4i-a10.dtsi b/arch/arm/boot/dts/sun4i-a10.dtsi index 9174724571e2..fe845ebc27be 100644 --- a/arch/arm/boot/dts/sun4i-a10.dtsi +++ b/arch/arm/boot/dts/sun4i-a10.dtsi @@ -647,6 +647,8 @@ clocks = <&apb1_gates 0>; clock-frequency = <100000>; status = "disabled"; + #address-cells = <1>; + #size-cells = <0>; }; i2c1: i2c@01c2b000 { @@ -656,6 +658,8 @@ clocks = <&apb1_gates 1>; clock-frequency = <100000>; status = "disabled"; + #address-cells = <1>; + #size-cells = <0>; }; i2c2: i2c@01c2b400 { @@ -665,6 +669,8 @@ clocks = <&apb1_gates 2>; clock-frequency = <100000>; status = "disabled"; + #address-cells = <1>; + #size-cells = <0>; }; }; }; -- cgit v1.2.3 From a470342e645400e4d05eb52e4488b9d2ca48b19c Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Sun, 13 Apr 2014 13:41:04 +0200 Subject: ARM: sun5i: dt: Add address- and size-cells info to i2c controller nodes Signed-off-by: Hans de Goede Signed-off-by: Maxime Ripard --- arch/arm/boot/dts/sun5i-a13.dtsi | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/arch/arm/boot/dts/sun5i-a13.dtsi b/arch/arm/boot/dts/sun5i-a13.dtsi index f01c315bdc4b..d0836d43c28d 100644 --- a/arch/arm/boot/dts/sun5i-a13.dtsi +++ b/arch/arm/boot/dts/sun5i-a13.dtsi @@ -467,6 +467,8 @@ clocks = <&apb1_gates 0>; clock-frequency = <100000>; status = "disabled"; + #address-cells = <1>; + #size-cells = <0>; }; i2c1: i2c@01c2b000 { @@ -476,6 +478,8 @@ clocks = <&apb1_gates 1>; clock-frequency = <100000>; status = "disabled"; + #address-cells = <1>; + #size-cells = <0>; }; i2c2: i2c@01c2b400 { @@ -485,6 +489,8 @@ clocks = <&apb1_gates 2>; clock-frequency = <100000>; status = "disabled"; + #address-cells = <1>; + #size-cells = <0>; }; timer@01c60000 { -- cgit v1.2.3 From d1412aed95ad80758a3dc532b368890dd846d39d Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Sun, 13 Apr 2014 13:41:05 +0200 Subject: ARM: sun7i: dt: Add address- and size-cells info to i2c controller nodes Signed-off-by: Hans de Goede Signed-off-by: Maxime Ripard --- arch/arm/boot/dts/sun7i-a20.dtsi | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/arch/arm/boot/dts/sun7i-a20.dtsi b/arch/arm/boot/dts/sun7i-a20.dtsi index 32efc105df83..88171f419e35 100644 --- a/arch/arm/boot/dts/sun7i-a20.dtsi +++ b/arch/arm/boot/dts/sun7i-a20.dtsi @@ -776,6 +776,8 @@ clocks = <&apb1_gates 0>; clock-frequency = <100000>; status = "disabled"; + #address-cells = <1>; + #size-cells = <0>; }; i2c1: i2c@01c2b000 { @@ -785,6 +787,8 @@ clocks = <&apb1_gates 1>; clock-frequency = <100000>; status = "disabled"; + #address-cells = <1>; + #size-cells = <0>; }; i2c2: i2c@01c2b400 { @@ -794,6 +798,8 @@ clocks = <&apb1_gates 2>; clock-frequency = <100000>; status = "disabled"; + #address-cells = <1>; + #size-cells = <0>; }; i2c3: i2c@01c2b800 { @@ -803,6 +809,8 @@ clocks = <&apb1_gates 3>; clock-frequency = <100000>; status = "disabled"; + #address-cells = <1>; + #size-cells = <0>; }; i2c4: i2c@01c2bc00 { @@ -812,6 +820,8 @@ clocks = <&apb1_gates 15>; clock-frequency = <100000>; status = "disabled"; + #address-cells = <1>; + #size-cells = <0>; }; gmac: ethernet@01c50000 { -- cgit v1.2.3 From 79a51b25badae79d2da6f7b54530adf56697f669 Mon Sep 17 00:00:00 2001 From: Prarit Bhargava Date: Wed, 2 Apr 2014 08:13:47 -0400 Subject: x86/irq: Clean up VECTOR_UNDEFINED and VECTOR_RETRIGGERED definition During another patch review, David Rientjes noted that VECTOR_UNDEFINED and VECTOR_RETRIGGERED should be defined with ()s so that they are not erroneously used in an arithmetic operation. Suggested-by: David Rientjes Signed-off-by: Prarit Bhargava Cc: Seiji Aguchi Cc: Yang Zhang Link: http://lkml.kernel.org/r/1396440827-18352-1-git-send-email-prarit@redhat.com Signed-off-by: Ingo Molnar --- arch/x86/include/asm/hw_irq.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/x86/include/asm/hw_irq.h b/arch/x86/include/asm/hw_irq.h index a307b7530e54..4615906d83df 100644 --- a/arch/x86/include/asm/hw_irq.h +++ b/arch/x86/include/asm/hw_irq.h @@ -190,8 +190,8 @@ extern void (*__initconst interrupt[NR_VECTORS-FIRST_EXTERNAL_VECTOR])(void); #define trace_interrupt interrupt #endif -#define VECTOR_UNDEFINED -1 -#define VECTOR_RETRIGGERED -2 +#define VECTOR_UNDEFINED (-1) +#define VECTOR_RETRIGGERED (-2) typedef int vector_irq_t[NR_VECTORS]; DECLARE_PER_CPU(vector_irq_t, vector_irq); -- cgit v1.2.3 From e3ec0a8c6eea4f22d5468f01c065caca4dd1ecca Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Sun, 13 Apr 2014 14:09:15 +0200 Subject: reset: Add of_reset_control_get to reset.h of_reset_control_get is not declared static in drivers/reset/core.c, which is correct as we want to use it elsewhere too. But it does not have a protype declared anywhere under include/linux. Add a prototype / stub for it to linux/reset.h to fix this. Reviewed-by: Josh Triplett Signed-off-by: Hans de Goede Signed-off-by: Philipp Zabel --- include/linux/reset.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/include/linux/reset.h b/include/linux/reset.h index c0eda5023d74..349f150ae12c 100644 --- a/include/linux/reset.h +++ b/include/linux/reset.h @@ -2,6 +2,7 @@ #define _LINUX_RESET_H_ struct device; +struct device_node; struct reset_control; #ifdef CONFIG_RESET_CONTROLLER @@ -33,6 +34,9 @@ static inline struct reset_control *devm_reset_control_get_optional( return devm_reset_control_get(dev, id); } +struct reset_control *of_reset_control_get(struct device_node *node, + const char *id); + #else static inline int reset_control_reset(struct reset_control *rstc) @@ -75,6 +79,12 @@ static inline struct reset_control *devm_reset_control_get_optional( return ERR_PTR(-ENOSYS); } +static inline struct reset_control *of_reset_control_get( + struct device_node *node, const char *id) +{ + return ERR_PTR(-ENOSYS); +} + #endif /* CONFIG_RESET_CONTROLLER */ #endif -- cgit v1.2.3 From 763b4247cafdb978630d4da7ff48c8113c7d961e Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 9 Apr 2014 23:20:14 +0200 Subject: staging: rtl8723au: Remove a bunch of calls via indirect HAL interface and call functions directly The 'HW' variable interface is confusing and simply obfuscates the code, so this is the first patch in a series to remove it and make direct calls to the functions in place. Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 10 ++++---- drivers/staging/rtl8723au/core/rtw_wlan_util.c | 9 ++++--- drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c | 30 ++--------------------- drivers/staging/rtl8723au/include/hal_intf.h | 8 ++---- drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c | 3 +-- drivers/staging/rtl8723au/os_dep/os_intfs.c | 2 +- 6 files changed, 16 insertions(+), 46 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index 4c753639ea5a..7be834f996ab 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -7561,7 +7561,7 @@ unsigned int send_beacon23a(struct rtw_adapter *padapter) unsigned long start = jiffies; unsigned int passing_time; - rtw_hal_set_hwreg23a(padapter, HW_VAR_BCN_VALID, NULL); + rtl8723a_bcn_valid(padapter); do { issue_beacon23a(padapter, 100); issue++; @@ -8832,7 +8832,7 @@ void mlmeext_sta_del_event_callback23a(struct rtw_adapter *padapter) { /* set_opmode_cmd(padapter, infra_client_with_mlme); */ - rtw_hal_set_hwreg23a(padapter, HW_VAR_MLME_DISCONNECT, NULL); + hw_var_set_mlme_disconnect(padapter); rtw_hal_set_hwreg23a(padapter, HW_VAR_BSSID, null_addr); /* restore to initial setting. */ @@ -9305,7 +9305,7 @@ u8 join_cmd_hdl23a(struct rtw_adapter *padapter, u8 *pbuf) /* Set_MSR23a(padapter, _HW_STATE_NOLINK_); */ Set_MSR23a(padapter, _HW_STATE_STATION_); - rtw_hal_set_hwreg23a(padapter, HW_VAR_MLME_DISCONNECT, NULL); + hw_var_set_mlme_disconnect(padapter); } rtw_joinbss_reset23a(padapter); @@ -9424,7 +9424,7 @@ u8 disconnect_hdl23a(struct rtw_adapter *padapter, unsigned char *pbuf) /* pmlmeinfo->state = WIFI_FW_NULL_STATE; */ - rtw_hal_set_hwreg23a(padapter, HW_VAR_MLME_DISCONNECT, NULL); + hw_var_set_mlme_disconnect(padapter); rtw_hal_set_hwreg23a(padapter, HW_VAR_BSSID, null_addr); /* restore to initial setting. */ @@ -9644,7 +9644,7 @@ u8 setkey_hdl23a(struct rtw_adapter *padapter, u8 *pbuf) write_cam23a(padapter, pparm->keyid, ctrl, null_sta, pparm->key); /* allow multicast packets to driver */ - padapter->HalFunc.SetHwRegHandler(padapter, HW_VAR_ON_RCR_AM, null_addr); + rtl8723a_on_rcr_am(padapter); return H2C_SUCCESS; } diff --git a/drivers/staging/rtl8723au/core/rtw_wlan_util.c b/drivers/staging/rtl8723au/core/rtw_wlan_util.c index 0dfcfbce3b52..3ed3beb2e6d3 100644 --- a/drivers/staging/rtl8723au/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8723au/core/rtw_wlan_util.c @@ -490,7 +490,7 @@ void CAM_empty_entry23a(struct rtw_adapter *Adapter, u8 ucIndex) void invalidate_cam_all23a(struct rtw_adapter *padapter) { - rtw_hal_set_hwreg23a(padapter, HW_VAR_CAM_INVALID_ALL, NULL); + rtl8723a_cam_invalid_all(padapter); } void write_cam23a(struct rtw_adapter *padapter, u8 entry, u16 ctrl, u8 *mac, u8 *key) @@ -561,7 +561,7 @@ void flush_all_cam_entry23a(struct rtw_adapter *padapter) struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; - rtw_hal_set_hwreg23a(padapter, HW_VAR_CAM_INVALID_ALL, NULL); + rtl8723a_cam_invalid_all(padapter); memset((u8 *)(pmlmeinfo->FW_sta_info), 0, sizeof(pmlmeinfo->FW_sta_info)); } @@ -1726,9 +1726,10 @@ void update_TSF23a(struct mlme_ext_priv *pmlmeext, u8 *pframe, uint len) pmlmeext->TSFValue |= le32_to_cpu(*pbuf); } -void correct_TSF23a(struct rtw_adapter *padapter, struct mlme_ext_priv *pmlmeext) +void correct_TSF23a(struct rtw_adapter *padapter, + struct mlme_ext_priv *pmlmeext) { - rtw_hal_set_hwreg23a(padapter, HW_VAR_CORRECT_TSF, NULL); + hw_var_set_correct_tsf(padapter); } void beacon_timing_control23a(struct rtw_adapter *padapter) diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c index 0982b0a4ab9b..a09716907569 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c @@ -3018,7 +3018,7 @@ static void hw_var_set_bssid(struct rtw_adapter *padapter, u8 *val) rtw_write8(padapter, (reg_bssid + idx), val[idx]); } -static void hw_var_set_correct_tsf(struct rtw_adapter *padapter) +void hw_var_set_correct_tsf(struct rtw_adapter *padapter) { u64 tsf; u32 reg_tsftr; @@ -3055,7 +3055,7 @@ static void hw_var_set_correct_tsf(struct rtw_adapter *padapter) ResumeTxBeacon(padapter); } -static void hw_var_set_mlme_disconnect(struct rtw_adapter *padapter) +void hw_var_set_mlme_disconnect(struct rtw_adapter *padapter) { /* reject all data frames */ rtw_write16(padapter, REG_RXFLTMAP2, 0); @@ -3167,18 +3167,10 @@ void SetHwReg8723A(struct rtw_adapter *padapter, u8 variable, u8 *val) rtl8723a_set_bcn_func(padapter, *val); break; - case HW_VAR_CORRECT_TSF: - hw_var_set_correct_tsf(padapter); - break; - case HW_VAR_CHECK_BSSID: rtl8723a_check_bssid(padapter, *val); break; - case HW_VAR_MLME_DISCONNECT: - hw_var_set_mlme_disconnect(padapter); - break; - case HW_VAR_MLME_SITESURVEY: rtl8723a_mlme_sitesurvey(padapter, *val); break; @@ -3187,14 +3179,6 @@ void SetHwReg8723A(struct rtw_adapter *padapter, u8 variable, u8 *val) hw_var_set_mlme_join(padapter, *val); break; - case HW_VAR_ON_RCR_AM: - rtl8723a_on_rcr_am(padapter); - break; - - case HW_VAR_OFF_RCR_AM: - rtl8723a_off_rcr_am(padapter); - break; - case HW_VAR_BEACON_INTERVAL: rtl8723a_set_beacon_interval(padapter, *((u16 *) val)); break; @@ -3234,10 +3218,6 @@ void SetHwReg8723A(struct rtw_adapter *padapter, u8 variable, u8 *val) rtl8723a_cam_empty_entry(padapter, *val); break; - case HW_VAR_CAM_INVALID_ALL: - rtl8723a_cam_invalid_all(padapter); - break; - case HW_VAR_CAM_WRITE: rtl8723a_cam_write(padapter, val32[0], val32[1]); break; @@ -3297,9 +3277,6 @@ void SetHwReg8723A(struct rtw_adapter *padapter, u8 variable, u8 *val) case HW_VAR_EFUSE_BT_BYTES: pHalData->BTEfuseUsedBytes = *((u16 *) val); break; - case HW_VAR_FIFO_CLEARN_UP: - rtl8723a_fifo_cleanup(padapter); - break; case HW_VAR_CHECK_TXBUF: break; case HW_VAR_APFM_ON_MAC: @@ -3309,9 +3286,6 @@ void SetHwReg8723A(struct rtw_adapter *padapter, u8 variable, u8 *val) case HW_VAR_NAV_UPPER: rtl8723a_set_nav_upper(padapter, *val32); break; - case HW_VAR_BCN_VALID: - rtl8723a_bcn_valid(padapter); - break; default: break; } diff --git a/drivers/staging/rtl8723au/include/hal_intf.h b/drivers/staging/rtl8723au/include/hal_intf.h index d183f4ba1ecb..5bd47136def7 100644 --- a/drivers/staging/rtl8723au/include/hal_intf.h +++ b/drivers/staging/rtl8723au/include/hal_intf.h @@ -45,13 +45,9 @@ enum HW_VARIABLES { HW_VAR_BASIC_RATE, HW_VAR_TXPAUSE, HW_VAR_BCN_FUNC, - HW_VAR_CORRECT_TSF, HW_VAR_CHECK_BSSID, - HW_VAR_MLME_DISCONNECT, HW_VAR_MLME_SITESURVEY, HW_VAR_MLME_JOIN, - HW_VAR_ON_RCR_AM, - HW_VAR_OFF_RCR_AM, HW_VAR_BEACON_INTERVAL, HW_VAR_SLOT_TIME, HW_VAR_RESP_SIFS, @@ -64,7 +60,6 @@ enum HW_VARIABLES { HW_VAR_DM_FUNC_SET, HW_VAR_DM_FUNC_CLR, HW_VAR_CAM_EMPTY_ENTRY, - HW_VAR_CAM_INVALID_ALL, HW_VAR_CAM_WRITE, HW_VAR_CAM_READ, HW_VAR_AC_PARAM_VO, @@ -94,7 +89,6 @@ enum HW_VARIABLES { HW_VAR_SWITCH_EPHY_WoWLAN, HW_VAR_EFUSE_BYTES, HW_VAR_EFUSE_BT_BYTES, - HW_VAR_FIFO_CLEARN_UP, HW_VAR_CHECK_TXBUF, HW_VAR_APFM_ON_MAC, /* Auto FSM to Turn On, include clock, isolation, power control for MAC only */ /* The valid upper nav range for the HW updating, if the true value is larger than the upper range, the HW won't update it. */ @@ -388,5 +382,7 @@ void rtw_hal_reset_security_engine23a(struct rtw_adapter *adapter); s32 rtw_hal_c2h_handler23a(struct rtw_adapter *adapter, struct c2h_evt_hdr *c2h_evt); c2h_id_filter rtw_hal_c2h_id_filter_ccx23a(struct rtw_adapter *adapter); +void hw_var_set_correct_tsf(struct rtw_adapter *padapter); +void hw_var_set_mlme_disconnect(struct rtw_adapter *padapter); #endif /* __HAL_INTF_H__ */ diff --git a/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c b/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c index 50840b9a11fa..58366236777f 100644 --- a/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c +++ b/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c @@ -1883,7 +1883,6 @@ static int rtw_cfg80211_set_wpa_ie(struct rtw_adapter *padapter, const u8 *pie, int wpa_ielen = 0; int wpa2_ielen = 0; u8 *pwpa, *pwpa2; - u8 null_addr[] = { 0, 0, 0, 0, 0, 0 }; int i; if (!pie || !ielen) { @@ -2097,7 +2096,7 @@ static int rtw_cfg80211_set_wpa_ie(struct rtw_adapter *padapter, const u8 *pie, padapter->securitypriv.dot11PrivacyAlgrthm == _AES_) /* WPS open need to enable multicast */ /* check_fwstate(&padapter->mlmepriv, WIFI_UNDER_WPS) == true)*/ - rtw_hal_set_hwreg23a(padapter, HW_VAR_OFF_RCR_AM, null_addr); + rtl8723a_off_rcr_am(padapter); RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_info_, ("rtw_set_wpa_ie: pairwise_cipher = 0x%08x padapter->" diff --git a/drivers/staging/rtl8723au/os_dep/os_intfs.c b/drivers/staging/rtl8723au/os_dep/os_intfs.c index 57eca7a45672..eab40d21fb3d 100644 --- a/drivers/staging/rtl8723au/os_dep/os_intfs.c +++ b/drivers/staging/rtl8723au/os_dep/os_intfs.c @@ -887,7 +887,7 @@ void rtw_ips_pwr_down23a(struct rtw_adapter *padapter) void rtw_ips_dev_unload23a(struct rtw_adapter *padapter) { - rtw_hal_set_hwreg23a(padapter, HW_VAR_FIFO_CLEARN_UP, NULL); + rtl8723a_fifo_cleanup(padapter); if (padapter->intf_stop) padapter->intf_stop(padapter); -- cgit v1.2.3 From ff5d82e45740bbaa47e15147f705dae42ab9524d Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 9 Apr 2014 23:20:15 +0200 Subject: staging: rtl8723au: This gets rid of the last HW_VAR_BCN_VALID usage Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 6 +++--- drivers/staging/rtl8723au/hal/hal_com.c | 9 +++++++++ drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c | 6 ------ drivers/staging/rtl8723au/include/hal_com.h | 1 + drivers/staging/rtl8723au/include/hal_intf.h | 1 - 5 files changed, 13 insertions(+), 10 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index 7be834f996ab..28750eb4169e 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -7555,7 +7555,7 @@ unsigned int send_delba23a(struct rtw_adapter *padapter, u8 initiator, u8 *addr) unsigned int send_beacon23a(struct rtw_adapter *padapter) { - u8 bxmitok = false; + bool bxmitok; int issue = 0; int poll = 0; unsigned long start = jiffies; @@ -7567,9 +7567,9 @@ unsigned int send_beacon23a(struct rtw_adapter *padapter) issue++; do { yield(); - rtw23a_hal_get_hwreg(padapter, HW_VAR_BCN_VALID, (u8 *)(&bxmitok)); + bxmitok = rtl8723a_get_bcn_valid(padapter); poll++; - } while ((poll%10)!= 0 && false == bxmitok && + } while ((poll % 10) != 0 && bxmitok == false && !padapter->bSurpriseRemoved && !padapter->bDriverStopped); diff --git a/drivers/staging/rtl8723au/hal/hal_com.c b/drivers/staging/rtl8723au/hal/hal_com.c index 0640f3522136..5f20117e4e4f 100644 --- a/drivers/staging/rtl8723au/hal/hal_com.c +++ b/drivers/staging/rtl8723au/hal/hal_com.c @@ -752,6 +752,15 @@ void rtl8723a_bcn_valid(struct rtw_adapter *padapter) rtw_read8(padapter, REG_TDECTRL + 2) | BIT0); } +bool rtl8723a_get_bcn_valid(struct rtw_adapter *padapter) +{ + bool retval; + + retval = (rtw_read8(padapter, REG_TDECTRL + 2) & BIT0) ? true : false; + + return retval; +} + void rtl8723a_set_tx_pause(struct rtw_adapter *padapter, u8 pause) { rtw_write8(padapter, REG_TXPAUSE, pause); diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c index a09716907569..26efc7069977 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c @@ -3305,12 +3305,6 @@ void GetHwReg8723A(struct rtw_adapter *padapter, u8 variable, u8 *val) *val = rtw_read8(padapter, REG_TXPAUSE); break; - case HW_VAR_BCN_VALID: - /* BCN_VALID, BIT16 of REG_TDECTRL = BIT0 of REG_TDECTRL+2 */ - val[0] = (BIT0 & rtw_read8(padapter, REG_TDECTRL + 2)) ? true : - false; - break; - case HW_VAR_RF_TYPE: *val = pHalData->rf_type; break; diff --git a/drivers/staging/rtl8723au/include/hal_com.h b/drivers/staging/rtl8723au/include/hal_com.h index 20f983cfc2b7..8e94d2e3ecef 100644 --- a/drivers/staging/rtl8723au/include/hal_com.h +++ b/drivers/staging/rtl8723au/include/hal_com.h @@ -189,6 +189,7 @@ void rtl8723a_cam_write(struct rtw_adapter *padapter, u32 val1, u32 val2); void rtl8723a_fifo_cleanup(struct rtw_adapter *padapter); void rtl8723a_set_apfm_on_mac(struct rtw_adapter *padapter, u8 val); void rtl8723a_bcn_valid(struct rtw_adapter *padapter); +bool rtl8723a_get_bcn_valid(struct rtw_adapter *padapter); void rtl8723a_set_tx_pause(struct rtw_adapter *padapter, u8 pause); void rtl8723a_set_beacon_interval(struct rtw_adapter *padapter, u16 interval); void rtl8723a_set_resp_sifs(struct rtw_adapter *padapter, diff --git a/drivers/staging/rtl8723au/include/hal_intf.h b/drivers/staging/rtl8723au/include/hal_intf.h index 5bd47136def7..a5306e618f9a 100644 --- a/drivers/staging/rtl8723au/include/hal_intf.h +++ b/drivers/staging/rtl8723au/include/hal_intf.h @@ -53,7 +53,6 @@ enum HW_VARIABLES { HW_VAR_RESP_SIFS, HW_VAR_ACK_PREAMBLE, HW_VAR_SEC_CFG, - HW_VAR_BCN_VALID, HW_VAR_RF_TYPE, HW_VAR_DM_FLAG, HW_VAR_DM_FUNC_OP, -- cgit v1.2.3 From 03aa3ec054e9b2354a587cf3652c4e4ffd67c5b8 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 9 Apr 2014 23:20:16 +0200 Subject: staging: rtl8723au: Remove HW_VAR_MEDIA_STATUS* usage Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_wlan_util.c | 7 +------ drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c | 8 -------- drivers/staging/rtl8723au/include/hal_intf.h | 2 -- 3 files changed, 1 insertion(+), 16 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_wlan_util.c b/drivers/staging/rtl8723au/core/rtw_wlan_util.c index 3ed3beb2e6d3..0114c46c36a1 100644 --- a/drivers/staging/rtl8723au/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8723au/core/rtw_wlan_util.c @@ -304,14 +304,9 @@ void Switch_DM_Func23a(struct rtw_adapter *padapter, unsigned long mode, u8 enab rtw_hal_set_hwreg23a(padapter, HW_VAR_DM_FUNC_CLR, (u8 *)(&mode)); } -static void Set_NETYPE0_MSR(struct rtw_adapter *padapter, u8 type) -{ - rtw_hal_set_hwreg23a(padapter, HW_VAR_MEDIA_STATUS, (u8 *)(&type)); -} - void Set_MSR23a(struct rtw_adapter *padapter, u8 type) { - Set_NETYPE0_MSR(padapter, type); + rtl8723a_set_media_status(padapter, type); } inline u8 rtw_get_oper_ch23a(struct rtw_adapter *adapter) diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c index 26efc7069977..d6afc049548f 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c @@ -3135,14 +3135,6 @@ void SetHwReg8723A(struct rtw_adapter *padapter, u8 variable, u8 *val) u32 *val32 = (u32 *)val; switch (variable) { - case HW_VAR_MEDIA_STATUS: - rtl8723a_set_media_status(padapter, *val); - break; - - case HW_VAR_MEDIA_STATUS1: - rtl8723a_set_media_status1(padapter, *val); - break; - case HW_VAR_SET_OPMODE: hw_var_set_opmode(padapter, *val); break; diff --git a/drivers/staging/rtl8723au/include/hal_intf.h b/drivers/staging/rtl8723au/include/hal_intf.h index a5306e618f9a..c4a1869527e7 100644 --- a/drivers/staging/rtl8723au/include/hal_intf.h +++ b/drivers/staging/rtl8723au/include/hal_intf.h @@ -36,8 +36,6 @@ enum _CHIP_TYPE { }; enum HW_VARIABLES { - HW_VAR_MEDIA_STATUS, - HW_VAR_MEDIA_STATUS1, HW_VAR_SET_OPMODE, HW_VAR_MAC_ADDR, HW_VAR_BSSID, -- cgit v1.2.3 From dbdcd36b2e8c23d4abb871993754878086cec920 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 9 Apr 2014 23:20:17 +0200 Subject: staging: rtl8723au: Eliminate HW_VAR_SET_OPMODE usage Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 16 ++++------------ drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c | 6 +----- drivers/staging/rtl8723au/include/hal_intf.h | 2 +- 3 files changed, 6 insertions(+), 18 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index 28750eb4169e..d91e88e0f955 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -9189,27 +9189,19 @@ u8 setopmode_hdl23a(struct rtw_adapter *padapter, u8 *pbuf) struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; struct setopmode_parm *psetop = (struct setopmode_parm *)pbuf; - if (psetop->mode == Ndis802_11APMode) - { + if (psetop->mode == Ndis802_11APMode) { pmlmeinfo->state = WIFI_FW_AP_STATE; type = _HW_STATE_AP_; - } - else if (psetop->mode == Ndis802_11Infrastructure) - { + } else if (psetop->mode == Ndis802_11Infrastructure) { pmlmeinfo->state &= ~(BIT(0)|BIT(1));/* clear state */ pmlmeinfo->state |= WIFI_FW_STATION_STATE;/* set to STATION_STATE */ type = _HW_STATE_STATION_; - } - else if (psetop->mode == Ndis802_11IBSS) - { + } else if (psetop->mode == Ndis802_11IBSS) type = _HW_STATE_ADHOC_; - } else - { type = _HW_STATE_NOLINK_; - } - rtw_hal_set_hwreg23a(padapter, HW_VAR_SET_OPMODE, (u8 *)(&type)); + hw_var_set_opmode(padapter, type); /* Set_NETYPE0_MSR(padapter, type); */ return H2C_SUCCESS; diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c index d6afc049548f..eebd01cea138 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c @@ -2935,7 +2935,7 @@ void rtl8723a_fill_fake_txdesc(struct rtw_adapter *padapter, u8 *pDesc, rtl8723a_cal_txdesc_chksum(ptxdesc); } -static void hw_var_set_opmode(struct rtw_adapter *padapter, u8 mode) +void hw_var_set_opmode(struct rtw_adapter *padapter, u8 mode) { u8 val8; @@ -3135,10 +3135,6 @@ void SetHwReg8723A(struct rtw_adapter *padapter, u8 variable, u8 *val) u32 *val32 = (u32 *)val; switch (variable) { - case HW_VAR_SET_OPMODE: - hw_var_set_opmode(padapter, *val); - break; - case HW_VAR_MAC_ADDR: hw_var_set_macaddr(padapter, val); break; diff --git a/drivers/staging/rtl8723au/include/hal_intf.h b/drivers/staging/rtl8723au/include/hal_intf.h index c4a1869527e7..ee3315ec7d77 100644 --- a/drivers/staging/rtl8723au/include/hal_intf.h +++ b/drivers/staging/rtl8723au/include/hal_intf.h @@ -36,7 +36,6 @@ enum _CHIP_TYPE { }; enum HW_VARIABLES { - HW_VAR_SET_OPMODE, HW_VAR_MAC_ADDR, HW_VAR_BSSID, HW_VAR_INIT_RTS_RATE, @@ -381,5 +380,6 @@ s32 rtw_hal_c2h_handler23a(struct rtw_adapter *adapter, struct c2h_evt_hdr *c2h_ c2h_id_filter rtw_hal_c2h_id_filter_ccx23a(struct rtw_adapter *adapter); void hw_var_set_correct_tsf(struct rtw_adapter *padapter); void hw_var_set_mlme_disconnect(struct rtw_adapter *padapter); +void hw_var_set_opmode(struct rtw_adapter *padapter, u8 mode); #endif /* __HAL_INTF_H__ */ -- cgit v1.2.3 From fa2e52092ad5a6877dbf3819006c3e2c655f7aa4 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 9 Apr 2014 23:20:18 +0200 Subject: staging: rtl8723au: Eliminate usage of HW_VAR_BASIC_RATE Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_ap.c | 2 +- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 2 +- drivers/staging/rtl8723au/core/rtw_wlan_util.c | 2 +- drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c | 2 +- drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c | 8 -------- drivers/staging/rtl8723au/include/hal_intf.h | 1 - 6 files changed, 4 insertions(+), 13 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_ap.c b/drivers/staging/rtl8723au/core/rtw_ap.c index a357e98cb83e..95311bd8fe76 100644 --- a/drivers/staging/rtl8723au/core/rtw_ap.c +++ b/drivers/staging/rtl8723au/core/rtw_ap.c @@ -715,7 +715,7 @@ static void start_bss_network(struct rtw_adapter *padapter, u8 *pbuf) rtw_hal_set_hwreg23a(padapter, HW_VAR_BEACON_INTERVAL, (u8 *)(&bcn_interval)); UpdateBrateTbl23a(padapter, pnetwork->SupportedRates); - rtw_hal_set_hwreg23a(padapter, HW_VAR_BASIC_RATE, pnetwork->SupportedRates); + HalSetBrateCfg23a(padapter, pnetwork->SupportedRates); if (!pmlmepriv->cur_network.join_res) { /* setting only at first time */ diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index d91e88e0f955..36b8a732824a 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -8724,7 +8724,7 @@ void mlmeext_joinbss_event_callback23a(struct rtw_adapter *padapter, int join_re /* update IOT-releated issue */ update_IOT_info23a(padapter); - rtw_hal_set_hwreg23a(padapter, HW_VAR_BASIC_RATE, cur_network->SupportedRates); + HalSetBrateCfg23a(padapter, cur_network->SupportedRates); /* BCN interval */ rtw_hal_set_hwreg23a(padapter, HW_VAR_BEACON_INTERVAL, (u8 *)(&pmlmeinfo->bcn_interval)); diff --git a/drivers/staging/rtl8723au/core/rtw_wlan_util.c b/drivers/staging/rtl8723au/core/rtw_wlan_util.c index 0114c46c36a1..8f1bd0708a13 100644 --- a/drivers/staging/rtl8723au/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8723au/core/rtw_wlan_util.c @@ -1452,7 +1452,7 @@ void update_tx_basic_rate23a(struct rtw_adapter *padapter, u8 wirelessmode) else update_mgnt_tx_rate23a(padapter, IEEE80211_OFDM_RATE_6MB); - rtw_hal_set_hwreg23a(padapter, HW_VAR_BASIC_RATE, supported_rates); + HalSetBrateCfg23a(padapter, supported_rates); } unsigned char check_assoc_AP23a(u8 *pframe, uint len) diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c b/drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c index 9d738d79de4b..e4496c840b4d 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c @@ -4677,7 +4677,7 @@ bthci_StateConnected(struct rtw_adapter *padapter, if (padapter->HalFunc.UpdateRAMaskHandler) padapter->HalFunc.UpdateRAMaskHandler(padapter, MAX_FW_SUPPORT_MACID_NUM-1-EntryNum, 0); - rtw_hal_set_hwreg23a(padapter, HW_VAR_BASIC_RATE, padapter->mlmepriv.cur_network.network.SupportedRates); + HalSetBrateCfg23a(padapter, padapter->mlmepriv.cur_network.network.SupportedRates); BTDM_SetFwChnlInfo(padapter, RT_MEDIA_CONNECT); break; default: diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c index eebd01cea138..b66ab21d0073 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c @@ -3143,10 +3143,6 @@ void SetHwReg8723A(struct rtw_adapter *padapter, u8 variable, u8 *val) hw_var_set_bssid(padapter, val); break; - case HW_VAR_BASIC_RATE: - HalSetBrateCfg23a(padapter, val); - break; - case HW_VAR_TXPAUSE: rtl8723a_set_tx_pause(padapter, *val); break; @@ -3285,10 +3281,6 @@ void GetHwReg8723A(struct rtw_adapter *padapter, u8 variable, u8 *val) struct hal_data_8723a *pHalData = GET_HAL_DATA(padapter); switch (variable) { - case HW_VAR_BASIC_RATE: - *((u16 *) val) = pHalData->BasicRateSet; - break; - case HW_VAR_TXPAUSE: *val = rtw_read8(padapter, REG_TXPAUSE); break; diff --git a/drivers/staging/rtl8723au/include/hal_intf.h b/drivers/staging/rtl8723au/include/hal_intf.h index ee3315ec7d77..7e6cb41a8355 100644 --- a/drivers/staging/rtl8723au/include/hal_intf.h +++ b/drivers/staging/rtl8723au/include/hal_intf.h @@ -39,7 +39,6 @@ enum HW_VARIABLES { HW_VAR_MAC_ADDR, HW_VAR_BSSID, HW_VAR_INIT_RTS_RATE, - HW_VAR_BASIC_RATE, HW_VAR_TXPAUSE, HW_VAR_BCN_FUNC, HW_VAR_CHECK_BSSID, -- cgit v1.2.3 From 3c5660e7573eecc6423322a27e851185a4f8e58c Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 9 Apr 2014 23:20:19 +0200 Subject: staging: rtl8723au: Eliminate HW_VAR_MAC_ADDR usage .... and rip out a couple of unnecessary layers of function calls Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/hal/hal_com.c | 6 ------ drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c | 6 +----- drivers/staging/rtl8723au/hal/usb_halinit.c | 2 +- drivers/staging/rtl8723au/include/hal_com.h | 2 -- drivers/staging/rtl8723au/include/hal_intf.h | 2 +- 5 files changed, 3 insertions(+), 15 deletions(-) diff --git a/drivers/staging/rtl8723au/hal/hal_com.c b/drivers/staging/rtl8723au/hal/hal_com.c index 5f20117e4e4f..29f42068d3b9 100644 --- a/drivers/staging/rtl8723au/hal/hal_com.c +++ b/drivers/staging/rtl8723au/hal/hal_com.c @@ -344,12 +344,6 @@ bool Hal_MappingOutPipe23a(struct rtw_adapter *pAdapter, u8 NumOutPipe) return result; } -void hal_init_macaddr23a(struct rtw_adapter *adapter) -{ - rtw_hal_set_hwreg23a(adapter, HW_VAR_MAC_ADDR, - adapter->eeprompriv.mac_addr); -} - /* * C2H event format: * Field TRIGGER CONTENT CMD_SEQ CMD_LEN CMD_ID diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c index b66ab21d0073..0eccf5304c67 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c @@ -2996,7 +2996,7 @@ void hw_var_set_opmode(struct rtw_adapter *padapter, u8 mode) rtw_write8(padapter, MSR, val8); } -static void hw_var_set_macaddr(struct rtw_adapter *padapter, u8 *val) +void hw_var_set_macaddr(struct rtw_adapter *padapter, u8 *val) { u8 idx = 0; u32 reg_macid; @@ -3135,10 +3135,6 @@ void SetHwReg8723A(struct rtw_adapter *padapter, u8 variable, u8 *val) u32 *val32 = (u32 *)val; switch (variable) { - case HW_VAR_MAC_ADDR: - hw_var_set_macaddr(padapter, val); - break; - case HW_VAR_BSSID: hw_var_set_bssid(padapter, val); break; diff --git a/drivers/staging/rtl8723au/hal/usb_halinit.c b/drivers/staging/rtl8723au/hal/usb_halinit.c index e206829d50fa..eae95ec38516 100644 --- a/drivers/staging/rtl8723au/hal/usb_halinit.c +++ b/drivers/staging/rtl8723au/hal/usb_halinit.c @@ -779,7 +779,7 @@ static u32 rtl8723au_hal_init(struct rtw_adapter *Adapter) _InitDriverInfoSize(Adapter, DRVINFO_SZ); _InitInterrupt(Adapter); - hal_init_macaddr23a(Adapter);/* set mac_address */ + hw_var_set_macaddr(Adapter, Adapter->eeprompriv.mac_addr); _InitNetworkType(Adapter);/* set msr */ _InitWMACSetting(Adapter); _InitAdaptiveCtrl(Adapter); diff --git a/drivers/staging/rtl8723au/include/hal_com.h b/drivers/staging/rtl8723au/include/hal_com.h index 8e94d2e3ecef..b62ca2d4b5b4 100644 --- a/drivers/staging/rtl8723au/include/hal_com.h +++ b/drivers/staging/rtl8723au/include/hal_com.h @@ -165,8 +165,6 @@ void HalSetBrateCfg23a(struct rtw_adapter *padapter, u8 *mBratesOS); bool Hal_MappingOutPipe23a(struct rtw_adapter *pAdapter, u8 NumOutPipe); -void hal_init_macaddr23a(struct rtw_adapter *adapter); - void c2h_evt_clear23a(struct rtw_adapter *adapter); s32 c2h_evt_read23a(struct rtw_adapter *adapter, u8 *buf); diff --git a/drivers/staging/rtl8723au/include/hal_intf.h b/drivers/staging/rtl8723au/include/hal_intf.h index 7e6cb41a8355..8334ab084047 100644 --- a/drivers/staging/rtl8723au/include/hal_intf.h +++ b/drivers/staging/rtl8723au/include/hal_intf.h @@ -36,7 +36,6 @@ enum _CHIP_TYPE { }; enum HW_VARIABLES { - HW_VAR_MAC_ADDR, HW_VAR_BSSID, HW_VAR_INIT_RTS_RATE, HW_VAR_TXPAUSE, @@ -380,5 +379,6 @@ c2h_id_filter rtw_hal_c2h_id_filter_ccx23a(struct rtw_adapter *adapter); void hw_var_set_correct_tsf(struct rtw_adapter *padapter); void hw_var_set_mlme_disconnect(struct rtw_adapter *padapter); void hw_var_set_opmode(struct rtw_adapter *padapter, u8 mode); +void hw_var_set_macaddr(struct rtw_adapter *padapter, u8 *val); #endif /* __HAL_INTF_H__ */ -- cgit v1.2.3 From 38dd10b59b726e05cce1abc797cd7f2ead1bc681 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 9 Apr 2014 23:20:20 +0200 Subject: staging: rtl8723au: Eliminate HW_VAR_BSSID usage Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_ap.c | 2 +- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 11 +++++------ drivers/staging/rtl8723au/core/rtw_sreset.c | 2 +- drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c | 6 +----- drivers/staging/rtl8723au/include/hal_intf.h | 2 +- 5 files changed, 9 insertions(+), 14 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_ap.c b/drivers/staging/rtl8723au/core/rtw_ap.c index 95311bd8fe76..5b89c206928e 100644 --- a/drivers/staging/rtl8723au/core/rtw_ap.c +++ b/drivers/staging/rtl8723au/core/rtw_ap.c @@ -695,7 +695,7 @@ static void start_bss_network(struct rtw_adapter *padapter, u8 *pbuf) Set_MSR23a(padapter, _HW_STATE_AP_); /* Set BSSID REG */ - rtw_hal_set_hwreg23a(padapter, HW_VAR_BSSID, pnetwork->MacAddress); + hw_var_set_bssid(padapter, pnetwork->MacAddress); /* Set EDCA param reg */ acparm = 0x002F3217; /* VO */ diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index 36b8a732824a..87e4df63b283 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -8008,7 +8008,7 @@ void start_create_ibss23a(struct rtw_adapter* padapter) } else { - rtw_hal_set_hwreg23a(padapter, HW_VAR_BSSID, padapter->registrypriv.dev_network.MacAddress); + hw_var_set_bssid(padapter, padapter->registrypriv.dev_network.MacAddress); join_type = 0; rtw_hal_set_hwreg23a(padapter, HW_VAR_MLME_JOIN, (u8 *)(&join_type)); @@ -8698,7 +8698,7 @@ void mlmeext_joinbss_event_callback23a(struct rtw_adapter *padapter, int join_re { join_type = 1; rtw_hal_set_hwreg23a(padapter, HW_VAR_MLME_JOIN, (u8 *)(&join_type)); - rtw_hal_set_hwreg23a(padapter, HW_VAR_BSSID, null_addr); + hw_var_set_bssid(padapter, null_addr); /* restore to initial setting. */ update_tx_basic_rate23a(padapter, padapter->registrypriv.wireless_mode); @@ -8833,7 +8833,7 @@ void mlmeext_sta_del_event_callback23a(struct rtw_adapter *padapter) /* set_opmode_cmd(padapter, infra_client_with_mlme); */ hw_var_set_mlme_disconnect(padapter); - rtw_hal_set_hwreg23a(padapter, HW_VAR_BSSID, null_addr); + hw_var_set_bssid(padapter, null_addr); /* restore to initial setting. */ update_tx_basic_rate23a(padapter, padapter->registrypriv.wireless_mode); @@ -9386,8 +9386,7 @@ u8 join_cmd_hdl23a(struct rtw_adapter *padapter, u8 *pbuf) /* rtw_hal_set_hwreg23a(padapter, HW_VAR_INITIAL_GAIN, (u8 *)(&initialgain)); */ - rtw_hal_set_hwreg23a(padapter, HW_VAR_BSSID, - pmlmeinfo->network.MacAddress); + hw_var_set_bssid(padapter, pmlmeinfo->network.MacAddress); join_type = 0; rtw_hal_set_hwreg23a(padapter, HW_VAR_MLME_JOIN, (u8 *)(&join_type)); @@ -9417,7 +9416,7 @@ u8 disconnect_hdl23a(struct rtw_adapter *padapter, unsigned char *pbuf) /* pmlmeinfo->state = WIFI_FW_NULL_STATE; */ hw_var_set_mlme_disconnect(padapter); - rtw_hal_set_hwreg23a(padapter, HW_VAR_BSSID, null_addr); + hw_var_set_bssid(padapter, null_addr); /* restore to initial setting. */ update_tx_basic_rate23a(padapter, padapter->registrypriv.wireless_mode); diff --git a/drivers/staging/rtl8723au/core/rtw_sreset.c b/drivers/staging/rtl8723au/core/rtw_sreset.c index 4f7459203390..625760d2a67b 100644 --- a/drivers/staging/rtl8723au/core/rtw_sreset.c +++ b/drivers/staging/rtl8723au/core/rtw_sreset.c @@ -142,7 +142,7 @@ static void sreset_restore_network_station(struct rtw_adapter *padapter) /* disable dynamic functions, such as high power, DIG */ /* Switch_DM_Func23a(padapter, DYNAMIC_FUNC_DISABLE, false); */ - rtw_hal_set_hwreg23a(padapter, HW_VAR_BSSID, pmlmeinfo->network.MacAddress); + hw_var_set_bssid(padapter, pmlmeinfo->network.MacAddress); { u8 join_type = 0; diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c index 0eccf5304c67..0c1eaed9d44a 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c @@ -3007,7 +3007,7 @@ void hw_var_set_macaddr(struct rtw_adapter *padapter, u8 *val) rtw_write8(padapter, (reg_macid + idx), val[idx]); } -static void hw_var_set_bssid(struct rtw_adapter *padapter, u8 *val) +void hw_var_set_bssid(struct rtw_adapter *padapter, u8 *val) { u8 idx = 0; u32 reg_bssid; @@ -3135,10 +3135,6 @@ void SetHwReg8723A(struct rtw_adapter *padapter, u8 variable, u8 *val) u32 *val32 = (u32 *)val; switch (variable) { - case HW_VAR_BSSID: - hw_var_set_bssid(padapter, val); - break; - case HW_VAR_TXPAUSE: rtl8723a_set_tx_pause(padapter, *val); break; diff --git a/drivers/staging/rtl8723au/include/hal_intf.h b/drivers/staging/rtl8723au/include/hal_intf.h index 8334ab084047..eb011360cc0e 100644 --- a/drivers/staging/rtl8723au/include/hal_intf.h +++ b/drivers/staging/rtl8723au/include/hal_intf.h @@ -36,7 +36,6 @@ enum _CHIP_TYPE { }; enum HW_VARIABLES { - HW_VAR_BSSID, HW_VAR_INIT_RTS_RATE, HW_VAR_TXPAUSE, HW_VAR_BCN_FUNC, @@ -380,5 +379,6 @@ void hw_var_set_correct_tsf(struct rtw_adapter *padapter); void hw_var_set_mlme_disconnect(struct rtw_adapter *padapter); void hw_var_set_opmode(struct rtw_adapter *padapter, u8 mode); void hw_var_set_macaddr(struct rtw_adapter *padapter, u8 *val); +void hw_var_set_bssid(struct rtw_adapter *padapter, u8 *val); #endif /* __HAL_INTF_H__ */ -- cgit v1.2.3 From a086023ac5bbc14019c2c17e07b98e2e6ee95208 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 9 Apr 2014 23:20:21 +0200 Subject: staging: rtl8723au: Eliminate HW_VAR_MLME_SITESURVEY usage Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 10 +++------ drivers/staging/rtl8723au/core/rtw_p2p.c | 27 +++++++++-------------- drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c | 4 ---- drivers/staging/rtl8723au/include/hal_intf.h | 1 - 4 files changed, 14 insertions(+), 28 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index 87e4df63b283..ef0a829e365a 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -7615,7 +7615,7 @@ bool IsLegal5GChannel(struct rtw_adapter *Adapter, u8 channel) void site_survey23a(struct rtw_adapter *padapter) { - unsigned char survey_channel = 0, val8; + unsigned char survey_channel = 0; enum rt_scan_type ScanType = SCAN_PASSIVE; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; @@ -7761,8 +7761,7 @@ void site_survey23a(struct rtw_adapter *padapter) } - val8 = 0; /* survey done */ - rtw_hal_set_hwreg23a(padapter, HW_VAR_MLME_SITESURVEY, (u8 *)(&val8)); + rtl8723a_mlme_sitesurvey(padapter, 0); report_surveydone_event23a(padapter); @@ -9518,7 +9517,6 @@ u8 sitesurvey_cmd_hdl23a(struct rtw_adapter *padapter, u8 *pbuf) struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct sitesurvey_parm *pparm = (struct sitesurvey_parm *)pbuf; u8 bdelayscan = false; - u8 val8; u32 initialgain; u32 i; @@ -9589,9 +9587,7 @@ u8 sitesurvey_cmd_hdl23a(struct rtw_adapter *padapter, u8 *pbuf) /* set MSR to no link state */ Set_MSR23a(padapter, _HW_STATE_NOLINK_); - val8 = 1; /* under site survey */ - rtw_hal_set_hwreg23a(padapter, HW_VAR_MLME_SITESURVEY, - (u8 *)(&val8)); + rtl8723a_mlme_sitesurvey(padapter, 1); pmlmeext->sitesurvey_res.state = SCAN_PROCESS; } diff --git a/drivers/staging/rtl8723au/core/rtw_p2p.c b/drivers/staging/rtl8723au/core/rtw_p2p.c index 27a6cc76973d..67d17a17a6b1 100644 --- a/drivers/staging/rtl8723au/core/rtw_p2p.c +++ b/drivers/staging/rtl8723au/core/rtw_p2p.c @@ -3120,45 +3120,40 @@ static void restore_p2p_state_handler(struct rtw_adapter *padapter) static void pre_tx_invitereq_handler(struct rtw_adapter *padapter) { struct wifidirect_info *pwdinfo = &padapter->wdinfo; - u8 val8 = 1; set_channel_bwmode23a(padapter, pwdinfo->invitereq_info.peer_ch, HAL_PRIME_CHNL_OFFSET_DONT_CARE, HT_CHANNEL_WIDTH_20); - padapter->HalFunc.SetHwRegHandler(padapter, HW_VAR_MLME_SITESURVEY, (u8 *)(&val8)); + rtl8723a_mlme_sitesurvey(padapter, 1); issue23a_probereq_p2p(padapter, NULL); mod_timer(&pwdinfo->pre_tx_scan_timer, jiffies + msecs_to_jiffies(P2P_TX_PRESCAN_TIMEOUT)); - - } static void pre_tx_provdisc_handler(struct rtw_adapter *padapter) { struct wifidirect_info *pwdinfo = &padapter->wdinfo; - u8 val8 = 1; - - set_channel_bwmode23a(padapter, pwdinfo->tx_prov_disc_info.peer_channel_num[0], HAL_PRIME_CHNL_OFFSET_DONT_CARE, HT_CHANNEL_WIDTH_20); - rtw_hal_set_hwreg23a(padapter, HW_VAR_MLME_SITESURVEY, (u8 *)(&val8)); + set_channel_bwmode23a(padapter, + pwdinfo->tx_prov_disc_info.peer_channel_num[0], + HAL_PRIME_CHNL_OFFSET_DONT_CARE, + HT_CHANNEL_WIDTH_20); + rtl8723a_mlme_sitesurvey(padapter, 1); issue23a_probereq_p2p(padapter, NULL); mod_timer(&pwdinfo->pre_tx_scan_timer, jiffies + msecs_to_jiffies(P2P_TX_PRESCAN_TIMEOUT)); - - } static void pre_tx_negoreq_handler(struct rtw_adapter *padapter) { struct wifidirect_info *pwdinfo = &padapter->wdinfo; - u8 val8 = 1; - - set_channel_bwmode23a(padapter, pwdinfo->nego_req_info.peer_channel_num[0], HAL_PRIME_CHNL_OFFSET_DONT_CARE, HT_CHANNEL_WIDTH_20); - rtw_hal_set_hwreg23a(padapter, HW_VAR_MLME_SITESURVEY, (u8 *)(&val8)); + set_channel_bwmode23a(padapter, + pwdinfo->nego_req_info.peer_channel_num[0], + HAL_PRIME_CHNL_OFFSET_DONT_CARE, + HT_CHANNEL_WIDTH_20); + rtl8723a_mlme_sitesurvey(padapter, 1); issue23a_probereq_p2p(padapter, NULL); mod_timer(&pwdinfo->pre_tx_scan_timer, jiffies + msecs_to_jiffies(P2P_TX_PRESCAN_TIMEOUT)); - - } static void ro_ch_handler(struct rtw_adapter *padapter) diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c index 0c1eaed9d44a..bcf400dcb823 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c @@ -3147,10 +3147,6 @@ void SetHwReg8723A(struct rtw_adapter *padapter, u8 variable, u8 *val) rtl8723a_check_bssid(padapter, *val); break; - case HW_VAR_MLME_SITESURVEY: - rtl8723a_mlme_sitesurvey(padapter, *val); - break; - case HW_VAR_MLME_JOIN: hw_var_set_mlme_join(padapter, *val); break; diff --git a/drivers/staging/rtl8723au/include/hal_intf.h b/drivers/staging/rtl8723au/include/hal_intf.h index eb011360cc0e..163743190625 100644 --- a/drivers/staging/rtl8723au/include/hal_intf.h +++ b/drivers/staging/rtl8723au/include/hal_intf.h @@ -40,7 +40,6 @@ enum HW_VARIABLES { HW_VAR_TXPAUSE, HW_VAR_BCN_FUNC, HW_VAR_CHECK_BSSID, - HW_VAR_MLME_SITESURVEY, HW_VAR_MLME_JOIN, HW_VAR_BEACON_INTERVAL, HW_VAR_SLOT_TIME, -- cgit v1.2.3 From ea0cd73023ec317ea92ea69e0193746f44c236d4 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 9 Apr 2014 23:20:22 +0200 Subject: staging: rtl8723au: Eliminate HW_VAR_CHECK_BSSID and HW_VAR_MLME_JOIN Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 28 +++++++--------------- drivers/staging/rtl8723au/core/rtw_sreset.c | 6 +---- .../staging/rtl8723au/hal/rtl8723a_bt-coexist.c | 6 ++--- drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c | 10 +------- drivers/staging/rtl8723au/include/hal_intf.h | 3 +-- 5 files changed, 14 insertions(+), 39 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index ef0a829e365a..bed8829b00bd 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -7969,7 +7969,6 @@ void start_create_ibss23a(struct rtw_adapter* padapter) { unsigned short caps; u8 val8; - u8 join_type; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; struct wlan_bssid_ex *pnetwork = &pmlmeinfo->network; @@ -8008,8 +8007,7 @@ void start_create_ibss23a(struct rtw_adapter* padapter) else { hw_var_set_bssid(padapter, padapter->registrypriv.dev_network.MacAddress); - join_type = 0; - rtw_hal_set_hwreg23a(padapter, HW_VAR_MLME_JOIN, (u8 *)(&join_type)); + hw_var_set_mlme_join(padapter, 0); report_join_res23a(padapter, 1); pmlmeinfo->state |= WIFI_FW_ASSOC_SUCCESS; @@ -8690,17 +8688,15 @@ void mlmeext_joinbss_event_callback23a(struct rtw_adapter *padapter, int join_re struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; struct wlan_bssid_ex *cur_network = &pmlmeinfo->network; struct sta_priv *pstapriv = &padapter->stapriv; - u8 join_type; u16 media_status; - if (join_res < 0) - { - join_type = 1; - rtw_hal_set_hwreg23a(padapter, HW_VAR_MLME_JOIN, (u8 *)(&join_type)); + if (join_res < 0) { + hw_var_set_mlme_join(padapter, 1); hw_var_set_bssid(padapter, null_addr); /* restore to initial setting. */ - update_tx_basic_rate23a(padapter, padapter->registrypriv.wireless_mode); + update_tx_basic_rate23a(padapter, + padapter->registrypriv.wireless_mode); goto exit_mlmeext_joinbss_event_callback23a; } @@ -8756,11 +8752,9 @@ void mlmeext_joinbss_event_callback23a(struct rtw_adapter *padapter, int join_re rtw_hal_set_hwreg23a(padapter, HW_VAR_H2C_MEDIA_STATUS_RPT, (u8 *)&media_status); } - join_type = 2; - rtw_hal_set_hwreg23a(padapter, HW_VAR_MLME_JOIN, (u8 *)(&join_type)); + hw_var_set_mlme_join(padapter, 2); - if ((pmlmeinfo->state&0x03) == WIFI_FW_STATION_STATE) - { + if ((pmlmeinfo->state&0x03) == WIFI_FW_STATION_STATE) { /* correcting TSF */ correct_TSF23a(padapter, pmlmeext); @@ -8777,7 +8771,6 @@ void mlmeext_sta_add_event_callback23a(struct rtw_adapter *padapter, struct sta_ { struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; - u8 join_type; DBG_8723A("%s\n", __func__); @@ -8809,8 +8802,7 @@ void mlmeext_sta_add_event_callback23a(struct rtw_adapter *padapter, struct sta_ } - join_type = 2; - rtw_hal_set_hwreg23a(padapter, HW_VAR_MLME_JOIN, (u8 *)(&join_type)); + hw_var_set_mlme_join(padapter, 2); } pmlmeinfo->FW_sta_info[psta->mac_id].psta = psta; @@ -9266,7 +9258,6 @@ u8 createbss_hdl23a(struct rtw_adapter *padapter, u8 *pbuf) u8 join_cmd_hdl23a(struct rtw_adapter *padapter, u8 *pbuf) { - u8 join_type; struct ndis_802_11_var_ies * pIE; struct registry_priv *pregpriv = &padapter->registrypriv; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; @@ -9386,8 +9377,7 @@ u8 join_cmd_hdl23a(struct rtw_adapter *padapter, u8 *pbuf) (u8 *)(&initialgain)); */ hw_var_set_bssid(padapter, pmlmeinfo->network.MacAddress); - join_type = 0; - rtw_hal_set_hwreg23a(padapter, HW_VAR_MLME_JOIN, (u8 *)(&join_type)); + hw_var_set_mlme_join(padapter, 0); /* cancel link timer */ del_timer_sync(&pmlmeext->link_timer); diff --git a/drivers/staging/rtl8723au/core/rtw_sreset.c b/drivers/staging/rtl8723au/core/rtw_sreset.c index 625760d2a67b..e3c189556794 100644 --- a/drivers/staging/rtl8723au/core/rtw_sreset.c +++ b/drivers/staging/rtl8723au/core/rtw_sreset.c @@ -143,11 +143,7 @@ static void sreset_restore_network_station(struct rtw_adapter *padapter) /* Switch_DM_Func23a(padapter, DYNAMIC_FUNC_DISABLE, false); */ hw_var_set_bssid(padapter, pmlmeinfo->network.MacAddress); - - { - u8 join_type = 0; - rtw_hal_set_hwreg23a(padapter, HW_VAR_MLME_JOIN, (u8 *)(&join_type)); - } + hw_var_set_mlme_join(padapter, 0); Set_MSR23a(padapter, (pmlmeinfo->state & 0x3)); diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c b/drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c index e4496c840b4d..5ff540e8241c 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c @@ -3944,7 +3944,6 @@ bthci_CmdAMPTestEnd(struct rtw_adapter *padapter, enum hci_status status = HCI_STATUS_SUCCESS; struct bt_30info *pBTInfo = GET_BT_INFO(padapter); struct bt_hci_info *pBtHciInfo = &pBTInfo->BtHciInfo; - u8 bFilterOutNonAssociatedBSSID = true; if (!pBtHciInfo->bInTestMode) { RTPRINT(FIOCTL, (IOCTL_BT_EVENT|IOCTL_BT_LOGO), ("Not in Test mode, return status = HCI_STATUS_CMD_DISALLOW\n")); @@ -3956,7 +3955,7 @@ bthci_CmdAMPTestEnd(struct rtw_adapter *padapter, del_timer_sync(&pBTInfo->BTTestSendPacketTimer); - rtw_hal_set_hwreg23a(padapter, HW_VAR_CHECK_BSSID, (u8 *)(&bFilterOutNonAssociatedBSSID)); + rtl8723a_check_bssid(padapter, true); /* send command complete event here when all data are received. */ { @@ -4057,8 +4056,7 @@ bthci_CmdAMPTestCommand(struct rtw_adapter *padapter, jiffies + msecs_to_jiffies(50)); RTPRINT(FIOCTL, (IOCTL_BT_EVENT|IOCTL_BT_LOGO), ("TX Single Test \n")); } else if (pBtHciInfo->TestScenario == 0x02) { - u8 bFilterOutNonAssociatedBSSID = false; - rtw_hal_set_hwreg23a(padapter, HW_VAR_CHECK_BSSID, (u8 *)(&bFilterOutNonAssociatedBSSID)); + rtl8723a_check_bssid(padapter, false); RTPRINT(FIOCTL, (IOCTL_BT_EVENT|IOCTL_BT_LOGO), ("Receive Frame Test \n")); } diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c index bcf400dcb823..ac64815861aa 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c @@ -3067,7 +3067,7 @@ void hw_var_set_mlme_disconnect(struct rtw_adapter *padapter) SetBcnCtrlReg23a(padapter, DIS_TSF_UDT, 0); } -static void hw_var_set_mlme_join(struct rtw_adapter *padapter, u8 type) +void hw_var_set_mlme_join(struct rtw_adapter *padapter, u8 type) { u8 RetryLimit = 0x30; @@ -3143,14 +3143,6 @@ void SetHwReg8723A(struct rtw_adapter *padapter, u8 variable, u8 *val) rtl8723a_set_bcn_func(padapter, *val); break; - case HW_VAR_CHECK_BSSID: - rtl8723a_check_bssid(padapter, *val); - break; - - case HW_VAR_MLME_JOIN: - hw_var_set_mlme_join(padapter, *val); - break; - case HW_VAR_BEACON_INTERVAL: rtl8723a_set_beacon_interval(padapter, *((u16 *) val)); break; diff --git a/drivers/staging/rtl8723au/include/hal_intf.h b/drivers/staging/rtl8723au/include/hal_intf.h index 163743190625..2ca5713b0232 100644 --- a/drivers/staging/rtl8723au/include/hal_intf.h +++ b/drivers/staging/rtl8723au/include/hal_intf.h @@ -39,8 +39,6 @@ enum HW_VARIABLES { HW_VAR_INIT_RTS_RATE, HW_VAR_TXPAUSE, HW_VAR_BCN_FUNC, - HW_VAR_CHECK_BSSID, - HW_VAR_MLME_JOIN, HW_VAR_BEACON_INTERVAL, HW_VAR_SLOT_TIME, HW_VAR_RESP_SIFS, @@ -379,5 +377,6 @@ void hw_var_set_mlme_disconnect(struct rtw_adapter *padapter); void hw_var_set_opmode(struct rtw_adapter *padapter, u8 mode); void hw_var_set_macaddr(struct rtw_adapter *padapter, u8 *val); void hw_var_set_bssid(struct rtw_adapter *padapter, u8 *val); +void hw_var_set_mlme_join(struct rtw_adapter *padapter, u8 type); #endif /* __HAL_INTF_H__ */ -- cgit v1.2.3 From 477f008d55654bc30ef8adca4286925c2da969e1 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 9 Apr 2014 23:20:23 +0200 Subject: staging: rtl8723au: Eliminate HW_VAR_BEACON_INTERVAL Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_ap.c | 2 +- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 2 +- drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c | 4 ---- drivers/staging/rtl8723au/include/hal_intf.h | 1 - 4 files changed, 2 insertions(+), 7 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_ap.c b/drivers/staging/rtl8723au/core/rtw_ap.c index 5b89c206928e..888901aa9b13 100644 --- a/drivers/staging/rtl8723au/core/rtw_ap.c +++ b/drivers/staging/rtl8723au/core/rtw_ap.c @@ -712,7 +712,7 @@ static void start_bss_network(struct rtw_adapter *padapter, u8 *pbuf) rtw_hal_set_hwreg23a(padapter, HW_VAR_SEC_CFG, (u8 *)(&val8)); /* Beacon Control related register */ - rtw_hal_set_hwreg23a(padapter, HW_VAR_BEACON_INTERVAL, (u8 *)(&bcn_interval)); + rtl8723a_set_beacon_interval(padapter, bcn_interval); UpdateBrateTbl23a(padapter, pnetwork->SupportedRates); HalSetBrateCfg23a(padapter, pnetwork->SupportedRates); diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index bed8829b00bd..90efa4738d96 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -8722,7 +8722,7 @@ void mlmeext_joinbss_event_callback23a(struct rtw_adapter *padapter, int join_re HalSetBrateCfg23a(padapter, cur_network->SupportedRates); /* BCN interval */ - rtw_hal_set_hwreg23a(padapter, HW_VAR_BEACON_INTERVAL, (u8 *)(&pmlmeinfo->bcn_interval)); + rtl8723a_set_beacon_interval(padapter, pmlmeinfo->bcn_interval); /* udpate capability */ update_capinfo23a(padapter, pmlmeinfo->capability); diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c index ac64815861aa..8931626a6946 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c @@ -3143,10 +3143,6 @@ void SetHwReg8723A(struct rtw_adapter *padapter, u8 variable, u8 *val) rtl8723a_set_bcn_func(padapter, *val); break; - case HW_VAR_BEACON_INTERVAL: - rtl8723a_set_beacon_interval(padapter, *((u16 *) val)); - break; - case HW_VAR_SLOT_TIME: rtl8723a_set_slot_time(padapter, *val); break; diff --git a/drivers/staging/rtl8723au/include/hal_intf.h b/drivers/staging/rtl8723au/include/hal_intf.h index 2ca5713b0232..395660193c81 100644 --- a/drivers/staging/rtl8723au/include/hal_intf.h +++ b/drivers/staging/rtl8723au/include/hal_intf.h @@ -39,7 +39,6 @@ enum HW_VARIABLES { HW_VAR_INIT_RTS_RATE, HW_VAR_TXPAUSE, HW_VAR_BCN_FUNC, - HW_VAR_BEACON_INTERVAL, HW_VAR_SLOT_TIME, HW_VAR_RESP_SIFS, HW_VAR_ACK_PREAMBLE, -- cgit v1.2.3 From 04c3842773aff89c3c0bce54d982c07513b4a24d Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 9 Apr 2014 23:20:24 +0200 Subject: staging: rtl8723au: Eliminate HW_VAR_SLOT_TIME Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_wlan_util.c | 2 +- drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c | 4 ---- drivers/staging/rtl8723au/include/hal_intf.h | 1 - 3 files changed, 1 insertion(+), 6 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_wlan_util.c b/drivers/staging/rtl8723au/core/rtw_wlan_util.c index 8f1bd0708a13..183b2665abdd 100644 --- a/drivers/staging/rtl8723au/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8723au/core/rtw_wlan_util.c @@ -1600,7 +1600,7 @@ void update_capinfo23a(struct rtw_adapter *Adapter, u16 updateCap) pmlmeinfo->slotTime = NON_SHORT_SLOT_TIME; } } - rtw_hal_set_hwreg23a(Adapter, HW_VAR_SLOT_TIME, &pmlmeinfo->slotTime); + rtl8723a_set_slot_time(Adapter, pmlmeinfo->slotTime); } void update_wireless_mode23a(struct rtw_adapter *padapter) diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c index 8931626a6946..9c5d8310376d 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c @@ -3143,10 +3143,6 @@ void SetHwReg8723A(struct rtw_adapter *padapter, u8 variable, u8 *val) rtl8723a_set_bcn_func(padapter, *val); break; - case HW_VAR_SLOT_TIME: - rtl8723a_set_slot_time(padapter, *val); - break; - case HW_VAR_RESP_SIFS: rtl8723a_set_resp_sifs(padapter, val[0], val[1], val[2], val[3]); diff --git a/drivers/staging/rtl8723au/include/hal_intf.h b/drivers/staging/rtl8723au/include/hal_intf.h index 395660193c81..edf54b77172d 100644 --- a/drivers/staging/rtl8723au/include/hal_intf.h +++ b/drivers/staging/rtl8723au/include/hal_intf.h @@ -39,7 +39,6 @@ enum HW_VARIABLES { HW_VAR_INIT_RTS_RATE, HW_VAR_TXPAUSE, HW_VAR_BCN_FUNC, - HW_VAR_SLOT_TIME, HW_VAR_RESP_SIFS, HW_VAR_ACK_PREAMBLE, HW_VAR_SEC_CFG, -- cgit v1.2.3 From 7b7aefaab13773c3f54ddc492df04872f8d60d36 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 9 Apr 2014 23:20:25 +0200 Subject: staging: rtl8723au: Eliminate HW_VAR_RESP_SIFS Yet another case of an endian bug from treating a 32 bit integer as an array of 8 bit numbers... Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_wlan_util.c | 8 +++----- drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c | 5 ----- drivers/staging/rtl8723au/include/hal_intf.h | 1 - 3 files changed, 3 insertions(+), 11 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_wlan_util.c b/drivers/staging/rtl8723au/core/rtw_wlan_util.c index 183b2665abdd..ab9d98d5fc7e 100644 --- a/drivers/staging/rtl8723au/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8723au/core/rtw_wlan_util.c @@ -1606,7 +1606,6 @@ void update_capinfo23a(struct rtw_adapter *Adapter, u16 updateCap) void update_wireless_mode23a(struct rtw_adapter *padapter) { int ratelen, network_type = 0; - 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; @@ -1635,10 +1634,9 @@ void update_wireless_mode23a(struct rtw_adapter *padapter) pmlmeext->cur_wireless_mode = network_type & padapter->registrypriv.wireless_mode; - SIFS_Timer = 0x0a0a0808; /* 0x0808 -> for CCK, 0x0a0a -> for OFDM */ - /* change this value if having IOT issues. */ - - padapter->HalFunc.SetHwRegHandler(padapter, HW_VAR_RESP_SIFS, (u8 *)&SIFS_Timer); + /* 0x0808 -> for CCK, 0x0a0a -> for OFDM */ + /* change this value if having IOT issues. */ + rtl8723a_set_resp_sifs(padapter, 0x08, 0x08, 0x0a, 0x0a); if (pmlmeext->cur_wireless_mode & WIRELESS_11B) update_mgnt_tx_rate23a(padapter, IEEE80211_CCK_RATE_1MB); diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c index 9c5d8310376d..27752fd30c7e 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c @@ -3143,11 +3143,6 @@ void SetHwReg8723A(struct rtw_adapter *padapter, u8 variable, u8 *val) rtl8723a_set_bcn_func(padapter, *val); break; - case HW_VAR_RESP_SIFS: - rtl8723a_set_resp_sifs(padapter, val[0], val[1], - val[2], val[3]); - break; - case HW_VAR_ACK_PREAMBLE: rtl8723a_ack_preamble(padapter, *val); break; diff --git a/drivers/staging/rtl8723au/include/hal_intf.h b/drivers/staging/rtl8723au/include/hal_intf.h index edf54b77172d..81ebefea0157 100644 --- a/drivers/staging/rtl8723au/include/hal_intf.h +++ b/drivers/staging/rtl8723au/include/hal_intf.h @@ -39,7 +39,6 @@ enum HW_VARIABLES { HW_VAR_INIT_RTS_RATE, HW_VAR_TXPAUSE, HW_VAR_BCN_FUNC, - HW_VAR_RESP_SIFS, HW_VAR_ACK_PREAMBLE, HW_VAR_SEC_CFG, HW_VAR_RF_TYPE, -- cgit v1.2.3 From 093dd41e03d89e13e56a821feda3eefbc1ecbf5a Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 9 Apr 2014 23:20:26 +0200 Subject: staging: rtl8723au: Eliminate HW_VAR_ACK_PREAMBLE Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_wlan_util.c | 7 ++----- drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c | 4 ---- drivers/staging/rtl8723au/include/hal_intf.h | 1 - 3 files changed, 2 insertions(+), 10 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_wlan_util.c b/drivers/staging/rtl8723au/core/rtw_wlan_util.c index ab9d98d5fc7e..d675891ad23e 100644 --- a/drivers/staging/rtl8723au/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8723au/core/rtw_wlan_util.c @@ -1562,22 +1562,19 @@ void update_capinfo23a(struct rtw_adapter *Adapter, u16 updateCap) { struct mlme_ext_priv *pmlmeext = &Adapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; - bool ShortPreamble; if (updateCap & cShortPreamble) { /* Short Preamble */ if (pmlmeinfo->preamble_mode != PREAMBLE_SHORT) { /* PREAMBLE_LONG or PREAMBLE_AUTO */ - ShortPreamble = true; pmlmeinfo->preamble_mode = PREAMBLE_SHORT; - rtw_hal_set_hwreg23a(Adapter, HW_VAR_ACK_PREAMBLE, (u8 *)&ShortPreamble); + rtl8723a_ack_preamble(Adapter, true); } } else { /* Long Preamble */ if (pmlmeinfo->preamble_mode != PREAMBLE_LONG) { /* PREAMBLE_SHORT or PREAMBLE_AUTO */ - ShortPreamble = false; pmlmeinfo->preamble_mode = PREAMBLE_LONG; - rtw_hal_set_hwreg23a(Adapter, HW_VAR_ACK_PREAMBLE, (u8 *)&ShortPreamble); + rtl8723a_ack_preamble(Adapter, false); } } if (updateCap & cIBSS) { diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c index 27752fd30c7e..fba69da87dd4 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c @@ -3143,10 +3143,6 @@ void SetHwReg8723A(struct rtw_adapter *padapter, u8 variable, u8 *val) rtl8723a_set_bcn_func(padapter, *val); break; - case HW_VAR_ACK_PREAMBLE: - rtl8723a_ack_preamble(padapter, *val); - break; - case HW_VAR_SEC_CFG: rtl8723a_set_sec_cfg(padapter, *val); break; diff --git a/drivers/staging/rtl8723au/include/hal_intf.h b/drivers/staging/rtl8723au/include/hal_intf.h index 81ebefea0157..b63643641e62 100644 --- a/drivers/staging/rtl8723au/include/hal_intf.h +++ b/drivers/staging/rtl8723au/include/hal_intf.h @@ -39,7 +39,6 @@ enum HW_VARIABLES { HW_VAR_INIT_RTS_RATE, HW_VAR_TXPAUSE, HW_VAR_BCN_FUNC, - HW_VAR_ACK_PREAMBLE, HW_VAR_SEC_CFG, HW_VAR_RF_TYPE, HW_VAR_DM_FLAG, -- cgit v1.2.3 From b8e99163b3181142bb781c3113facb194eae8e49 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 9 Apr 2014 23:20:27 +0200 Subject: staging: rtl8723au: Eliminate HW_VAR_SEC_CFG usage Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_ap.c | 5 +++-- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 18 +++++++----------- drivers/staging/rtl8723au/core/rtw_sreset.c | 3 ++- drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c | 4 ---- drivers/staging/rtl8723au/include/hal_intf.h | 1 - 5 files changed, 12 insertions(+), 19 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_ap.c b/drivers/staging/rtl8723au/core/rtw_ap.c index 888901aa9b13..18ade6036b23 100644 --- a/drivers/staging/rtl8723au/core/rtw_ap.c +++ b/drivers/staging/rtl8723au/core/rtw_ap.c @@ -708,8 +708,9 @@ static void start_bss_network(struct rtw_adapter *padapter, u8 *pbuf) rtw_hal_set_hwreg23a(padapter, HW_VAR_AC_PARAM_BK, (u8 *)(&acparm)); /* Set Security */ - val8 = (psecuritypriv->dot11AuthAlgrthm == dot11AuthAlgrthm_8021X)? 0xcc: 0xcf; - rtw_hal_set_hwreg23a(padapter, HW_VAR_SEC_CFG, (u8 *)(&val8)); + val8 = (psecuritypriv->dot11AuthAlgrthm == dot11AuthAlgrthm_8021X) ? + 0xcc: 0xcf; + rtl8723a_set_sec_cfg(padapter, val8); /* Beacon Control related register */ rtl8723a_set_beacon_interval(padapter, bcn_interval); diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index 90efa4738d96..068203e62688 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -7968,7 +7968,6 @@ u8 collect_bss_info23a(struct rtw_adapter *padapter, struct recv_frame *precv_fr void start_create_ibss23a(struct rtw_adapter* padapter) { unsigned short caps; - u8 val8; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; struct wlan_bssid_ex *pnetwork = &pmlmeinfo->network; @@ -7981,10 +7980,8 @@ void start_create_ibss23a(struct rtw_adapter* padapter) /* udpate capability */ caps = rtw_get_capability23a(pnetwork); update_capinfo23a(padapter, caps); - if (caps&cap_IBSS)/* adhoc master */ - { - val8 = 0xcf; - rtw_hal_set_hwreg23a(padapter, HW_VAR_SEC_CFG, (u8 *)(&val8)); + if (caps&cap_IBSS) { /* adhoc master */ + rtl8723a_set_sec_cfg(padapter, 0xcf); /* switch channel */ /* SelectChannel23a(padapter, pmlmeext->cur_channel, HAL_PRIME_CHNL_OFFSET_DONT_CARE); */ @@ -8044,9 +8041,10 @@ void start_clnt_join23a(struct rtw_adapter* padapter) Set_MSR23a(padapter, WIFI_FW_STATION_STATE); - val8 = (pmlmeinfo->auth_algo == dot11AuthAlgrthm_8021X)? 0xcc: 0xcf; + val8 = (pmlmeinfo->auth_algo == dot11AuthAlgrthm_8021X) ? + 0xcc: 0xcf; - rtw_hal_set_hwreg23a(padapter, HW_VAR_SEC_CFG, (u8 *)(&val8)); + rtl8723a_set_sec_cfg(padapter, val8); /* switch channel */ /* set_channel_bwmode23a(padapter, pmlmeext->cur_channel, pmlmeext->cur_ch_offset, pmlmeext->cur_bwmode); */ @@ -8059,12 +8057,10 @@ void start_clnt_join23a(struct rtw_adapter* padapter) msecs_to_jiffies((REAUTH_TO * REAUTH_LIMIT) + (REASSOC_TO*REASSOC_LIMIT) + beacon_timeout)); pmlmeinfo->state = WIFI_FW_AUTH_NULL | WIFI_FW_STATION_STATE; } - else if (caps&cap_IBSS) /* adhoc client */ - { + else if (caps&cap_IBSS) { /* adhoc client */ Set_MSR23a(padapter, WIFI_FW_ADHOC_STATE); - val8 = 0xcf; - rtw_hal_set_hwreg23a(padapter, HW_VAR_SEC_CFG, (u8 *)(&val8)); + rtl8723a_set_sec_cfg(padapter, 0xcf); /* switch channel */ set_channel_bwmode23a(padapter, pmlmeext->cur_channel, pmlmeext->cur_ch_offset, pmlmeext->cur_bwmode); diff --git a/drivers/staging/rtl8723au/core/rtw_sreset.c b/drivers/staging/rtl8723au/core/rtw_sreset.c index e3c189556794..e243a3afcdcd 100644 --- a/drivers/staging/rtl8723au/core/rtw_sreset.c +++ b/drivers/staging/rtl8723au/core/rtw_sreset.c @@ -99,7 +99,8 @@ static void sreset_restore_security_station(struct rtw_adapter *padapter) val8 = 0xcc; else val8 = 0xcf; - rtw_hal_set_hwreg23a(padapter, HW_VAR_SEC_CFG, (u8 *)(&val8)); + + rtl8723a_set_sec_cfg(padapter, val8); if ((padapter->securitypriv.dot11PrivacyAlgrthm == _TKIP_) || (padapter->securitypriv.dot11PrivacyAlgrthm == _AES_)) { diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c index fba69da87dd4..6d574cd96129 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c @@ -3143,10 +3143,6 @@ void SetHwReg8723A(struct rtw_adapter *padapter, u8 variable, u8 *val) rtl8723a_set_bcn_func(padapter, *val); break; - case HW_VAR_SEC_CFG: - rtl8723a_set_sec_cfg(padapter, *val); - break; - case HW_VAR_DM_FLAG: rtl8723a_odm_support_ability_write(padapter, *val32); break; diff --git a/drivers/staging/rtl8723au/include/hal_intf.h b/drivers/staging/rtl8723au/include/hal_intf.h index b63643641e62..8e3dd1264380 100644 --- a/drivers/staging/rtl8723au/include/hal_intf.h +++ b/drivers/staging/rtl8723au/include/hal_intf.h @@ -39,7 +39,6 @@ enum HW_VARIABLES { HW_VAR_INIT_RTS_RATE, HW_VAR_TXPAUSE, HW_VAR_BCN_FUNC, - HW_VAR_SEC_CFG, HW_VAR_RF_TYPE, HW_VAR_DM_FLAG, HW_VAR_DM_FUNC_OP, -- cgit v1.2.3 From a15a46a7b96f7a5bd780ba6689cb4d23322473b3 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 9 Apr 2014 23:20:28 +0200 Subject: staging: rtl8723au: Kill off HW_VAR_CAM_EMPTY_ENTRY and some function layers wrapping it Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_wlan_util.c | 5 ----- drivers/staging/rtl8723au/hal/hal_com.c | 6 ++++-- drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c | 6 ++++-- drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c | 4 ---- drivers/staging/rtl8723au/include/hal_intf.h | 1 - drivers/staging/rtl8723au/include/rtw_mlme_ext.h | 1 - 6 files changed, 8 insertions(+), 15 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_wlan_util.c b/drivers/staging/rtl8723au/core/rtw_wlan_util.c index d675891ad23e..1e538854dbb4 100644 --- a/drivers/staging/rtl8723au/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8723au/core/rtw_wlan_util.c @@ -478,11 +478,6 @@ unsigned int decide_wait_for_beacon_timeout23a(unsigned int bcn_interval) return bcn_interval << 2; } -void CAM_empty_entry23a(struct rtw_adapter *Adapter, u8 ucIndex) -{ - rtw_hal_set_hwreg23a(Adapter, HW_VAR_CAM_EMPTY_ENTRY, (u8 *)(&ucIndex)); -} - void invalidate_cam_all23a(struct rtw_adapter *padapter) { rtl8723a_cam_invalid_all(padapter); diff --git a/drivers/staging/rtl8723au/hal/hal_com.c b/drivers/staging/rtl8723au/hal/hal_com.c index 29f42068d3b9..06ea165ceddd 100644 --- a/drivers/staging/rtl8723au/hal/hal_com.c +++ b/drivers/staging/rtl8723au/hal/hal_com.c @@ -670,11 +670,13 @@ void rtl8723a_cam_empty_entry(struct rtw_adapter *padapter, u8 ucIndex) /* delay_ms(40); */ rtw_write32(padapter, WCAMI, ulContent); /* RT_TRACE(COMP_SEC, DBG_LOUD, - ("CAM_empty_entry23a(): WRITE A4: %lx \n", ulContent));*/ + ("rtl8723a_cam_empty_entry(): WRITE A4: %lx \n", + ulContent));*/ /* delay_ms(40); */ rtw_write32(padapter, RWCAM, ulCommand); /* RT_TRACE(COMP_SEC, DBG_LOUD, - ("CAM_empty_entry23a(): WRITE A0: %lx \n", ulCommand));*/ + ("rtl8723a_cam_empty_entry(): WRITE A0: %lx \n", + ulCommand));*/ } } diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c b/drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c index 5ff540e8241c..3de077b3ed5b 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c @@ -11232,8 +11232,10 @@ void HALBT_RemoveKey(struct rtw_adapter *padapter, u8 EntryNum) if (pBTinfo->BtAsocEntry[EntryNum].HwCAMIndex != 0) { /* ToDo : add New HALBT_RemoveKey function !! */ - if (pBtAssocEntry->HwCAMIndex >= BT_HWCAM_STAR && pBtAssocEntry->HwCAMIndex < HALF_CAM_ENTRY) - CAM_empty_entry23a(padapter, pBtAssocEntry->HwCAMIndex); + if (pBtAssocEntry->HwCAMIndex >= BT_HWCAM_STAR && + pBtAssocEntry->HwCAMIndex < HALF_CAM_ENTRY) + rtl8723a_cam_empty_entry(padapter, + pBtAssocEntry->HwCAMIndex); pBTinfo->BtAsocEntry[EntryNum].HwCAMIndex = 0; } } diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c index 6d574cd96129..cfc9eb1276ea 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c @@ -3157,10 +3157,6 @@ void SetHwReg8723A(struct rtw_adapter *padapter, u8 variable, u8 *val) rtl8723a_odm_support_ability_clr(padapter, *val32); break; - case HW_VAR_CAM_EMPTY_ENTRY: - rtl8723a_cam_empty_entry(padapter, *val); - break; - case HW_VAR_CAM_WRITE: rtl8723a_cam_write(padapter, val32[0], val32[1]); break; diff --git a/drivers/staging/rtl8723au/include/hal_intf.h b/drivers/staging/rtl8723au/include/hal_intf.h index 8e3dd1264380..72da07444212 100644 --- a/drivers/staging/rtl8723au/include/hal_intf.h +++ b/drivers/staging/rtl8723au/include/hal_intf.h @@ -44,7 +44,6 @@ enum HW_VARIABLES { HW_VAR_DM_FUNC_OP, HW_VAR_DM_FUNC_SET, HW_VAR_DM_FUNC_CLR, - HW_VAR_CAM_EMPTY_ENTRY, HW_VAR_CAM_WRITE, HW_VAR_CAM_READ, HW_VAR_AC_PARAM_VO, diff --git a/drivers/staging/rtl8723au/include/rtw_mlme_ext.h b/drivers/staging/rtl8723au/include/rtw_mlme_ext.h index 0aaf0d5d8aea..060de9f3de83 100644 --- a/drivers/staging/rtl8723au/include/rtw_mlme_ext.h +++ b/drivers/staging/rtl8723au/include/rtw_mlme_ext.h @@ -500,7 +500,6 @@ void write_cam23a(struct rtw_adapter *padapter, u8 entry, u16 ctrl, void clear_cam_entry23a(struct rtw_adapter *padapter, u8 entry); void invalidate_cam_all23a(struct rtw_adapter *padapter); -void CAM_empty_entry23a(struct rtw_adapter *Adapter, u8 ucIndex); int allocate_fw_sta_entry23a(struct rtw_adapter *padapter); void flush_all_cam_entry23a(struct rtw_adapter *padapter); -- cgit v1.2.3 From dc0d16a1079320282c272de69c14e08802b46ea8 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 9 Apr 2014 23:20:29 +0200 Subject: staging: rtl8723au: Eliminate HW_VAR_CAM_WRITE and clean up all the wrapping around it Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 7 ++-- drivers/staging/rtl8723au/core/rtw_wlan_util.c | 39 +--------------------- drivers/staging/rtl8723au/hal/hal_com.c | 31 ++++++++++++++--- .../staging/rtl8723au/hal/rtl8723a_bt-coexist.c | 4 ++- drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c | 4 --- drivers/staging/rtl8723au/include/hal_com.h | 3 +- drivers/staging/rtl8723au/include/hal_intf.h | 1 - drivers/staging/rtl8723au/include/rtw_mlme_ext.h | 2 -- 8 files changed, 37 insertions(+), 54 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index 068203e62688..a40bb035187f 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -9614,7 +9614,7 @@ u8 setkey_hdl23a(struct rtw_adapter *padapter, u8 *pbuf) DBG_8723A_LEVEL(_drv_always_, "set group key to hw: alg:%d(WEP40-1 WEP104-5 TKIP-2 AES-4) " "keyid:%d\n", pparm->algorithm, pparm->keyid); - write_cam23a(padapter, pparm->keyid, ctrl, null_sta, pparm->key); + rtl8723a_cam_write(padapter, pparm->keyid, ctrl, null_sta, pparm->key); /* allow multicast packets to driver */ rtl8723a_on_rcr_am(padapter); @@ -9678,7 +9678,8 @@ u8 set_stakey_hdl23a(struct rtw_adapter *padapter, u8 *pbuf) pparm->addr[1], pparm->addr[2], pparm->addr[3], pparm->addr[4], pparm->addr[5], cam_id); - write_cam23a(padapter, cam_id, ctrl, pparm->addr, pparm->key); + rtl8723a_cam_write(padapter, cam_id, ctrl, + pparm->addr, pparm->key); return H2C_SUCCESS_RSP; @@ -9701,7 +9702,7 @@ u8 set_stakey_hdl23a(struct rtw_adapter *padapter, u8 *pbuf) ctrl = BIT(15) | ((pparm->algorithm) << 2); - write_cam23a(padapter, cam_id, ctrl, pparm->addr, pparm->key); + rtl8723a_cam_write(padapter, cam_id, ctrl, pparm->addr, pparm->key); pmlmeinfo->enc_algo = pparm->algorithm; diff --git a/drivers/staging/rtl8723au/core/rtw_wlan_util.c b/drivers/staging/rtl8723au/core/rtw_wlan_util.c index 1e538854dbb4..221184457b71 100644 --- a/drivers/staging/rtl8723au/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8723au/core/rtw_wlan_util.c @@ -483,50 +483,13 @@ void invalidate_cam_all23a(struct rtw_adapter *padapter) rtl8723a_cam_invalid_all(padapter); } -void write_cam23a(struct rtw_adapter *padapter, u8 entry, u16 ctrl, u8 *mac, u8 *key) -{ - unsigned int i, val, addr; - int j; - u32 cam_val[2]; - - addr = entry << 3; - - for (j = 5; j >= 0; j--) { - switch (j) { - case 0: - val = (ctrl | (mac[0] << 16) | (mac[1] << 24)); - break; - case 1: - val = (mac[2] | (mac[3] << 8) | (mac[4] << 16) | (mac[5] << 24)); - break; - default: - i = (j - 2) << 2; - val = (key[i] | (key[i+1] << 8) | (key[i+2] << 16) | (key[i+3] << 24)); - break; - } - - cam_val[0] = val; - cam_val[1] = addr + (unsigned int)j; - - rtw_hal_set_hwreg23a(padapter, HW_VAR_CAM_WRITE, (u8 *)cam_val); - - /* rtw_write32(padapter, WCAMI, val); */ - - /* cmd = CAM_POLLINIG | CAM_WRITE | (addr + j); */ - /* rtw_write32(padapter, RWCAM, cmd); */ - - /* DBG_8723A("%s => cam write: %x, %x\n", __func__, cmd, val); */ - - } -} - void clear_cam_entry23a(struct rtw_adapter *padapter, u8 entry) { unsigned char null_sta[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; unsigned char null_key[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; - write_cam23a(padapter, entry, 0, null_sta, null_key); + rtl8723a_cam_write(padapter, entry, 0, null_sta, null_key); } int allocate_fw_sta_entry23a(struct rtw_adapter *padapter) diff --git a/drivers/staging/rtl8723au/hal/hal_com.c b/drivers/staging/rtl8723au/hal/hal_com.c index 06ea165ceddd..5d4e51c493e6 100644 --- a/drivers/staging/rtl8723au/hal/hal_com.c +++ b/drivers/staging/rtl8723au/hal/hal_com.c @@ -685,14 +685,37 @@ void rtl8723a_cam_invalid_all(struct rtw_adapter *padapter) rtw_write32(padapter, RWCAM, BIT(31) | BIT(30)); } -void rtl8723a_cam_write(struct rtw_adapter *padapter, u32 val1, u32 val2) +void rtl8723a_cam_write(struct rtw_adapter *padapter, + u8 entry, u16 ctrl, u8 *mac, u8 *key) { u32 cmd; + unsigned int i, val, addr; + int j; - rtw_write32(padapter, WCAMI, val1); + addr = entry << 3; - cmd = CAM_POLLINIG | CAM_WRITE | val2; - rtw_write32(padapter, RWCAM, cmd); + for (j = 5; j >= 0; j--) { + switch (j) { + case 0: + val = ctrl | (mac[0] << 16) | (mac[1] << 24); + break; + case 1: + val = mac[2] | (mac[3] << 8) | + (mac[4] << 16) | (mac[5] << 24); + break; + default: + i = (j - 2) << 2; + val = key[i] | (key[i+1] << 8) | + (key[i+2] << 16) | (key[i+3] << 24); + break; + } + + rtw_write32(padapter, WCAMI, val); + cmd = CAM_POLLINIG | CAM_WRITE | (addr + j); + rtw_write32(padapter, RWCAM, cmd); + + /* DBG_8723A("%s => cam write: %x, %x\n", __func__, cmd, val);*/ + } } void rtl8723a_fifo_cleanup(struct rtw_adapter *padapter) diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c b/drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c index 3de077b3ed5b..69041efe5c36 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_bt-coexist.c @@ -11219,7 +11219,9 @@ void HALBT_SetKey(struct rtw_adapter *padapter, u8 EntryNum) pBtAssocEntry->HwCAMIndex = BT_HWCAM_STAR + EntryNum; usConfig = CAM_VALID | (CAM_AES << 2); - write_cam23a(padapter, pBtAssocEntry->HwCAMIndex, usConfig, pBtAssocEntry->BTRemoteMACAddr, pBtAssocEntry->PTK + TKIP_ENC_KEY_POS); + rtl8723a_cam_write(padapter, pBtAssocEntry->HwCAMIndex, usConfig, + pBtAssocEntry->BTRemoteMACAddr, + pBtAssocEntry->PTK + TKIP_ENC_KEY_POS); } void HALBT_RemoveKey(struct rtw_adapter *padapter, u8 EntryNum) diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c index cfc9eb1276ea..ba58bab2a3f6 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c @@ -3157,10 +3157,6 @@ void SetHwReg8723A(struct rtw_adapter *padapter, u8 variable, u8 *val) rtl8723a_odm_support_ability_clr(padapter, *val32); break; - case HW_VAR_CAM_WRITE: - rtl8723a_cam_write(padapter, val32[0], val32[1]); - break; - case HW_VAR_AC_PARAM_VO: rtl8723a_set_ac_param_vo(padapter, *val32); break; diff --git a/drivers/staging/rtl8723au/include/hal_com.h b/drivers/staging/rtl8723au/include/hal_com.h index b62ca2d4b5b4..9d036132ac4f 100644 --- a/drivers/staging/rtl8723au/include/hal_com.h +++ b/drivers/staging/rtl8723au/include/hal_com.h @@ -183,7 +183,8 @@ void rtl8723a_ack_preamble(struct rtw_adapter *padapter, u8 bShortPreamble); void rtl8723a_set_sec_cfg(struct rtw_adapter *padapter, u8 sec); void rtl8723a_cam_empty_entry(struct rtw_adapter *padapter, u8 ucIndex); void rtl8723a_cam_invalid_all(struct rtw_adapter *padapter); -void rtl8723a_cam_write(struct rtw_adapter *padapter, u32 val1, u32 val2); +void rtl8723a_cam_write(struct rtw_adapter *padapter, + u8 entry, u16 ctrl, u8 *mac, u8 *key); void rtl8723a_fifo_cleanup(struct rtw_adapter *padapter); void rtl8723a_set_apfm_on_mac(struct rtw_adapter *padapter, u8 val); void rtl8723a_bcn_valid(struct rtw_adapter *padapter); diff --git a/drivers/staging/rtl8723au/include/hal_intf.h b/drivers/staging/rtl8723au/include/hal_intf.h index 72da07444212..64fed853c2fa 100644 --- a/drivers/staging/rtl8723au/include/hal_intf.h +++ b/drivers/staging/rtl8723au/include/hal_intf.h @@ -44,7 +44,6 @@ enum HW_VARIABLES { HW_VAR_DM_FUNC_OP, HW_VAR_DM_FUNC_SET, HW_VAR_DM_FUNC_CLR, - HW_VAR_CAM_WRITE, HW_VAR_CAM_READ, HW_VAR_AC_PARAM_VO, HW_VAR_AC_PARAM_VI, diff --git a/drivers/staging/rtl8723au/include/rtw_mlme_ext.h b/drivers/staging/rtl8723au/include/rtw_mlme_ext.h index 060de9f3de83..b61fc95b1037 100644 --- a/drivers/staging/rtl8723au/include/rtw_mlme_ext.h +++ b/drivers/staging/rtl8723au/include/rtw_mlme_ext.h @@ -495,8 +495,6 @@ void SetBWMode23a(struct rtw_adapter *padapter, unsigned short bwmode, unsigned int decide_wait_for_beacon_timeout23a(unsigned int bcn_interval); -void write_cam23a(struct rtw_adapter *padapter, u8 entry, u16 ctrl, - u8 *mac, u8 *key); void clear_cam_entry23a(struct rtw_adapter *padapter, u8 entry); void invalidate_cam_all23a(struct rtw_adapter *padapter); -- cgit v1.2.3 From 2487205e0e7fbe997981b78f758b46cd86e320ef Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 9 Apr 2014 23:20:30 +0200 Subject: staging: rtl8723au: Eiminate the use of HW_VAR_AC_PARAM_{VO,VI,BE,BK} Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_ap.c | 8 ++++---- drivers/staging/rtl8723au/core/rtw_wlan_util.c | 8 ++++---- drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c | 16 ---------------- drivers/staging/rtl8723au/include/hal_intf.h | 4 ---- 4 files changed, 8 insertions(+), 28 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_ap.c b/drivers/staging/rtl8723au/core/rtw_ap.c index 18ade6036b23..59e161c16678 100644 --- a/drivers/staging/rtl8723au/core/rtw_ap.c +++ b/drivers/staging/rtl8723au/core/rtw_ap.c @@ -699,13 +699,13 @@ static void start_bss_network(struct rtw_adapter *padapter, u8 *pbuf) /* Set EDCA param reg */ acparm = 0x002F3217; /* VO */ - rtw_hal_set_hwreg23a(padapter, HW_VAR_AC_PARAM_VO, (u8 *)(&acparm)); + rtl8723a_set_ac_param_vo(padapter, acparm); acparm = 0x005E4317; /* VI */ - rtw_hal_set_hwreg23a(padapter, HW_VAR_AC_PARAM_VI, (u8 *)(&acparm)); + rtl8723a_set_ac_param_vi(padapter, acparm); acparm = 0x005ea42b; - rtw_hal_set_hwreg23a(padapter, HW_VAR_AC_PARAM_BE, (u8 *)(&acparm)); + rtl8723a_set_ac_param_be(padapter, acparm); acparm = 0x0000A444; /* BK */ - rtw_hal_set_hwreg23a(padapter, HW_VAR_AC_PARAM_BK, (u8 *)(&acparm)); + rtl8723a_set_ac_param_bk(padapter, acparm); /* Set Security */ val8 = (psecuritypriv->dot11AuthAlgrthm == dot11AuthAlgrthm_8021X) ? diff --git a/drivers/staging/rtl8723au/core/rtw_wlan_util.c b/drivers/staging/rtl8723au/core/rtw_wlan_util.c index 221184457b71..8ede5d08f289 100644 --- a/drivers/staging/rtl8723au/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8723au/core/rtw_wlan_util.c @@ -602,22 +602,22 @@ void WMMOnAssocRsp23a(struct rtw_adapter *padapter) switch (ACI) { case 0x0: - rtw_hal_set_hwreg23a(padapter, HW_VAR_AC_PARAM_BE, (u8 *)(&acParm)); + rtl8723a_set_ac_param_be(padapter, acParm); acm_mask |= (ACM? BIT(1):0); edca[XMIT_BE_QUEUE] = acParm; break; case 0x1: - rtw_hal_set_hwreg23a(padapter, HW_VAR_AC_PARAM_BK, (u8 *)(&acParm)); + rtl8723a_set_ac_param_bk(padapter, acParm); /* acm_mask |= (ACM? BIT(0):0); */ edca[XMIT_BK_QUEUE] = acParm; break; case 0x2: - rtw_hal_set_hwreg23a(padapter, HW_VAR_AC_PARAM_VI, (u8 *)(&acParm)); + rtl8723a_set_ac_param_vi(padapter, acParm); acm_mask |= (ACM? BIT(2):0); edca[XMIT_VI_QUEUE] = acParm; break; case 0x3: - rtw_hal_set_hwreg23a(padapter, HW_VAR_AC_PARAM_VO, (u8 *)(&acParm)); + rtl8723a_set_ac_param_vo(padapter, acParm); acm_mask |= (ACM? BIT(3):0); edca[XMIT_VO_QUEUE] = acParm; break; diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c index ba58bab2a3f6..0e2c4031c14d 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c @@ -3157,22 +3157,6 @@ void SetHwReg8723A(struct rtw_adapter *padapter, u8 variable, u8 *val) rtl8723a_odm_support_ability_clr(padapter, *val32); break; - case HW_VAR_AC_PARAM_VO: - rtl8723a_set_ac_param_vo(padapter, *val32); - break; - - case HW_VAR_AC_PARAM_VI: - rtl8723a_set_ac_param_vi(padapter, *val32); - break; - - case HW_VAR_AC_PARAM_BE: - rtl8723a_set_ac_param_be(padapter, *val32); - break; - - case HW_VAR_AC_PARAM_BK: - rtl8723a_set_ac_param_bk(padapter, *val32); - break; - case HW_VAR_ACM_CTRL: rtl8723a_set_acm_ctrl(padapter, *val); break; diff --git a/drivers/staging/rtl8723au/include/hal_intf.h b/drivers/staging/rtl8723au/include/hal_intf.h index 64fed853c2fa..a768957b8f8b 100644 --- a/drivers/staging/rtl8723au/include/hal_intf.h +++ b/drivers/staging/rtl8723au/include/hal_intf.h @@ -45,10 +45,6 @@ enum HW_VARIABLES { HW_VAR_DM_FUNC_SET, HW_VAR_DM_FUNC_CLR, HW_VAR_CAM_READ, - HW_VAR_AC_PARAM_VO, - HW_VAR_AC_PARAM_VI, - HW_VAR_AC_PARAM_BE, - HW_VAR_AC_PARAM_BK, HW_VAR_ACM_CTRL, HW_VAR_AMPDU_MIN_SPACE, HW_VAR_AMPDU_FACTOR, -- cgit v1.2.3 From d5cdb9e1daecdc72a9b2f5facee3d6481fe61673 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 9 Apr 2014 23:20:31 +0200 Subject: staging: rtl8723au: Kill off HW_VAR_ACM_CTRL Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_wlan_util.c | 2 +- drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c | 4 ---- drivers/staging/rtl8723au/include/hal_intf.h | 1 - 3 files changed, 1 insertion(+), 6 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_wlan_util.c b/drivers/staging/rtl8723au/core/rtw_wlan_util.c index 8ede5d08f289..2d0cc6b3c52d 100644 --- a/drivers/staging/rtl8723au/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8723au/core/rtw_wlan_util.c @@ -627,7 +627,7 @@ void WMMOnAssocRsp23a(struct rtw_adapter *padapter) } if (padapter->registrypriv.acm_method == 1) - rtw_hal_set_hwreg23a(padapter, HW_VAR_ACM_CTRL, (u8 *)(&acm_mask)); + rtl8723a_set_acm_ctrl(padapter, acm_mask); else padapter->mlmepriv.acm_mask = acm_mask; diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c index 0e2c4031c14d..8c8e98b55255 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c @@ -3157,10 +3157,6 @@ void SetHwReg8723A(struct rtw_adapter *padapter, u8 variable, u8 *val) rtl8723a_odm_support_ability_clr(padapter, *val32); break; - case HW_VAR_ACM_CTRL: - rtl8723a_set_acm_ctrl(padapter, *val); - break; - case HW_VAR_AMPDU_MIN_SPACE: rtl8723a_set_ampdu_min_space(padapter, *val); break; diff --git a/drivers/staging/rtl8723au/include/hal_intf.h b/drivers/staging/rtl8723au/include/hal_intf.h index a768957b8f8b..30398d3028d2 100644 --- a/drivers/staging/rtl8723au/include/hal_intf.h +++ b/drivers/staging/rtl8723au/include/hal_intf.h @@ -45,7 +45,6 @@ enum HW_VARIABLES { HW_VAR_DM_FUNC_SET, HW_VAR_DM_FUNC_CLR, HW_VAR_CAM_READ, - HW_VAR_ACM_CTRL, HW_VAR_AMPDU_MIN_SPACE, HW_VAR_AMPDU_FACTOR, HW_VAR_RXDMA_AGG_PG_TH, -- cgit v1.2.3 From dce610a77fdb33ccb13d93dd54342e2fab9310e6 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 9 Apr 2014 23:20:32 +0200 Subject: staging: rtl8723au: Make direct calls for HW_VAR_AMPDU_{MIN_SPACE,FACTOR} Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_ap.c | 5 ++--- drivers/staging/rtl8723au/core/rtw_wlan_util.c | 5 ++--- drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c | 8 -------- drivers/staging/rtl8723au/include/hal_intf.h | 2 -- 4 files changed, 4 insertions(+), 16 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_ap.c b/drivers/staging/rtl8723au/core/rtw_ap.c index 59e161c16678..f55e86d8be65 100644 --- a/drivers/staging/rtl8723au/core/rtw_ap.c +++ b/drivers/staging/rtl8723au/core/rtw_ap.c @@ -632,9 +632,8 @@ static void update_hw_ht_param(struct rtw_adapter *padapter) min_MPDU_spacing = (pmlmeinfo->HT_caps.u.HT_cap_element.AMPDU_para & 0x1c) >> 2; - rtw_hal_set_hwreg23a(padapter, HW_VAR_AMPDU_MIN_SPACE, (u8 *)(&min_MPDU_spacing)); - - rtw_hal_set_hwreg23a(padapter, HW_VAR_AMPDU_FACTOR, (u8 *)(&max_AMPDU_len)); + rtl8723a_set_ampdu_min_space(padapter, min_MPDU_spacing); + rtl8723a_set_ampdu_factor(padapter, max_AMPDU_len); /* Config SM Power Save setting */ pmlmeinfo->SM_PS = (pmlmeinfo->HT_caps.u.HT_cap_element.HT_caps_info & 0x0C) >> 2; diff --git a/drivers/staging/rtl8723au/core/rtw_wlan_util.c b/drivers/staging/rtl8723au/core/rtw_wlan_util.c index 2d0cc6b3c52d..91bb7a451fba 100644 --- a/drivers/staging/rtl8723au/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8723au/core/rtw_wlan_util.c @@ -849,9 +849,8 @@ void HTOnAssocRsp23a(struct rtw_adapter *padapter) min_MPDU_spacing = (pmlmeinfo->HT_caps.u.HT_cap_element.AMPDU_para & 0x1c) >> 2; - rtw_hal_set_hwreg23a(padapter, HW_VAR_AMPDU_MIN_SPACE, (u8 *)(&min_MPDU_spacing)); - - rtw_hal_set_hwreg23a(padapter, HW_VAR_AMPDU_FACTOR, (u8 *)(&max_AMPDU_len)); + rtl8723a_set_ampdu_min_space(padapter, min_MPDU_spacing); + rtl8723a_set_ampdu_factor(padapter, max_AMPDU_len); } void ERP_IE_handler23a(struct rtw_adapter *padapter, struct ndis_802_11_var_ies * pIE) diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c index 8c8e98b55255..56c6654d61e0 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c @@ -3157,14 +3157,6 @@ void SetHwReg8723A(struct rtw_adapter *padapter, u8 variable, u8 *val) rtl8723a_odm_support_ability_clr(padapter, *val32); break; - case HW_VAR_AMPDU_MIN_SPACE: - rtl8723a_set_ampdu_min_space(padapter, *val); - break; - - case HW_VAR_AMPDU_FACTOR: - rtl8723a_set_ampdu_factor(padapter, *val); - break; - case HW_VAR_RXDMA_AGG_PG_TH: rtl8723a_set_rxdma_agg_pg_th(padapter, *val); break; diff --git a/drivers/staging/rtl8723au/include/hal_intf.h b/drivers/staging/rtl8723au/include/hal_intf.h index 30398d3028d2..01aec72ab77c 100644 --- a/drivers/staging/rtl8723au/include/hal_intf.h +++ b/drivers/staging/rtl8723au/include/hal_intf.h @@ -45,8 +45,6 @@ enum HW_VARIABLES { HW_VAR_DM_FUNC_SET, HW_VAR_DM_FUNC_CLR, HW_VAR_CAM_READ, - HW_VAR_AMPDU_MIN_SPACE, - HW_VAR_AMPDU_FACTOR, HW_VAR_RXDMA_AGG_PG_TH, HW_VAR_SET_RPWM, HW_VAR_H2C_FW_PWRMODE, -- cgit v1.2.3 From 7c82a2b91d8c57d78ae2059664fd23ad3b542e97 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 9 Apr 2014 23:20:33 +0200 Subject: staging: rtl8723au: Kill off HW_VAR_INITIAL_GAIN Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 26 ++++++----------------- drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c | 3 --- drivers/staging/rtl8723au/include/hal_intf.h | 1 - 3 files changed, 7 insertions(+), 23 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index a40bb035187f..8757a13086ce 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -7619,7 +7619,6 @@ void site_survey23a(struct rtw_adapter *padapter) enum rt_scan_type ScanType = SCAN_PASSIVE; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; - u32 initialgain = 0; #ifdef CONFIG_8723AU_P2P struct wifidirect_info *pwdinfo = &padapter->wdinfo; @@ -7719,8 +7718,8 @@ void site_survey23a(struct rtw_adapter *padapter) rtw_p2p_set_state(pwdinfo, P2P_STATE_FIND_PHASE_LISTEN); pmlmeext->sitesurvey_res.state = SCAN_DISABLE; - initialgain = 0xff; /* restore RX GAIN */ - rtw_hal_set_hwreg23a(padapter, HW_VAR_INITIAL_GAIN, (u8 *)(&initialgain)); + /* restore RX GAIN */ + rtl8723a_set_initial_gain(padapter, 0xff); /* turn on dynamic functions */ Restore_DM_Func_Flag23a(padapter); /* Switch_DM_Func23a(padapter, DYNAMIC_FUNC_DIG|DYNAMIC_FUNC_HP|DYNAMIC_FUNC_SS, true); */ @@ -7749,8 +7748,8 @@ void site_survey23a(struct rtw_adapter *padapter) /* config MSR */ Set_MSR23a(padapter, (pmlmeinfo->state & 0x3)); - initialgain = 0xff; /* restore RX GAIN */ - rtw_hal_set_hwreg23a(padapter, HW_VAR_INITIAL_GAIN, (u8 *)(&initialgain)); + /* restore RX GAIN */ + rtl8723a_set_initial_gain(padapter, 0xff); /* turn on dynamic functions */ Restore_DM_Func_Flag23a(padapter); /* Switch_DM_Func23a(padapter, DYNAMIC_ALL_FUNC_ENABLE, true); */ @@ -9231,10 +9230,6 @@ u8 createbss_hdl23a(struct rtw_adapter *padapter, u8 *pbuf) Save_DM_Func_Flag23a(padapter); Switch_DM_Func23a(padapter, DYNAMIC_FUNC_DISABLE, false); - /* config the initial gain under linking, need to write the BB registers */ - /* initialgain = 0x1E; */ - /* rtw_hal_set_hwreg23a(padapter, HW_VAR_INITIAL_GAIN, (u8 *)(&initialgain)); */ - /* cancel link timer */ del_timer_sync(&pmlmeext->link_timer); @@ -9366,12 +9361,6 @@ u8 join_cmd_hdl23a(struct rtw_adapter *padapter, u8 *pbuf) /* disable dynamic functions, such as high power, DIG */ /* Switch_DM_Func23a(padapter, DYNAMIC_FUNC_DISABLE, false); */ - /* config the initial gain under linking, need to write the BB - registers */ - /* initialgain = 0x1E; */ - /* rtw_hal_set_hwreg23a(padapter, HW_VAR_INITIAL_GAIN, - (u8 *)(&initialgain)); */ - hw_var_set_bssid(padapter, pmlmeinfo->network.MacAddress); hw_var_set_mlme_join(padapter, 0); @@ -9562,13 +9551,12 @@ u8 sitesurvey_cmd_hdl23a(struct rtw_adapter *padapter, u8 *pbuf) /* config the initial gain under scaning, need to write the BB registers */ - if ((wdev_to_priv(padapter->rtw_wdev))->p2p_enabled == true) { + if (wdev_to_priv(padapter->rtw_wdev)->p2p_enabled == true) initialgain = 0x30; - } else + else initialgain = 0x1E; - rtw_hal_set_hwreg23a(padapter, HW_VAR_INITIAL_GAIN, - (u8 *)(&initialgain)); + rtl8723a_set_initial_gain(padapter, initialgain); /* set MSR to no link state */ Set_MSR23a(padapter, _HW_STATE_NOLINK_); diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c index 56c6654d61e0..330289b88895 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c @@ -3175,9 +3175,6 @@ void SetHwReg8723A(struct rtw_adapter *padapter, u8 variable, u8 *val) break; #endif /* CONFIG_8723AU_P2P */ - case HW_VAR_INITIAL_GAIN: - rtl8723a_set_initial_gain(padapter, *val32); - break; case HW_VAR_EFUSE_BYTES: pHalData->EfuseUsedBytes = *((u16 *) val); break; diff --git a/drivers/staging/rtl8723au/include/hal_intf.h b/drivers/staging/rtl8723au/include/hal_intf.h index 01aec72ab77c..45d6cfbe8797 100644 --- a/drivers/staging/rtl8723au/include/hal_intf.h +++ b/drivers/staging/rtl8723au/include/hal_intf.h @@ -55,7 +55,6 @@ enum HW_VARIABLES { HW_VAR_TDLS_INIT_CH_SEN, HW_VAR_TDLS_RS_RCR, HW_VAR_TDLS_DONE_CH_SEN, - HW_VAR_INITIAL_GAIN, HW_VAR_TRIGGER_GPIO_0, HW_VAR_BT_SET_COEXIST, HW_VAR_BT_ISSUE_DELBA, -- cgit v1.2.3 From dc451608f3456f94b55d73cf513b32984b3d73c5 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 9 Apr 2014 23:20:34 +0200 Subject: staging: rtl8723au: Nuke HW_VAR_BCN_FUNC Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 10 +++------- drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c | 4 ---- drivers/staging/rtl8723au/include/hal_intf.h | 1 - 3 files changed, 3 insertions(+), 12 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index 8757a13086ce..96d744152903 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -9378,7 +9378,6 @@ u8 disconnect_hdl23a(struct rtw_adapter *padapter, unsigned char *pbuf) struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; struct wlan_bssid_ex *pnetwork = &pmlmeinfo->network; - u8 val8; if (is_client_associated_to_ap23a(padapter)) { @@ -9395,12 +9394,9 @@ u8 disconnect_hdl23a(struct rtw_adapter *padapter, unsigned char *pbuf) /* restore to initial setting. */ update_tx_basic_rate23a(padapter, padapter->registrypriv.wireless_mode); - if (((pmlmeinfo->state&0x03) == WIFI_FW_ADHOC_STATE) || ((pmlmeinfo->state&0x03) == WIFI_FW_AP_STATE)) - { - /* Stop BCN */ - val8 = 0; - rtw_hal_set_hwreg23a(padapter, HW_VAR_BCN_FUNC, (u8 *)(&val8)); - } + if (((pmlmeinfo->state & 0x03) == WIFI_FW_ADHOC_STATE) || + ((pmlmeinfo->state & 0x03) == WIFI_FW_AP_STATE)) + rtl8723a_set_bcn_func(padapter, 0); /* Stop BCN */ /* set MSR to no link state -> infra. mode */ Set_MSR23a(padapter, _HW_STATE_STATION_); diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c index 330289b88895..d496330a23c6 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c @@ -3139,10 +3139,6 @@ void SetHwReg8723A(struct rtw_adapter *padapter, u8 variable, u8 *val) rtl8723a_set_tx_pause(padapter, *val); break; - case HW_VAR_BCN_FUNC: - rtl8723a_set_bcn_func(padapter, *val); - break; - case HW_VAR_DM_FLAG: rtl8723a_odm_support_ability_write(padapter, *val32); break; diff --git a/drivers/staging/rtl8723au/include/hal_intf.h b/drivers/staging/rtl8723au/include/hal_intf.h index 45d6cfbe8797..75e751cedcd7 100644 --- a/drivers/staging/rtl8723au/include/hal_intf.h +++ b/drivers/staging/rtl8723au/include/hal_intf.h @@ -38,7 +38,6 @@ enum _CHIP_TYPE { enum HW_VARIABLES { HW_VAR_INIT_RTS_RATE, HW_VAR_TXPAUSE, - HW_VAR_BCN_FUNC, HW_VAR_RF_TYPE, HW_VAR_DM_FLAG, HW_VAR_DM_FUNC_OP, -- cgit v1.2.3 From 6952905d216474fb494995e41a61f9ebdcfa8090 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 9 Apr 2014 23:20:35 +0200 Subject: staging: rtl8723au: Nuke HW_VAR_CHECK_TXBUF, which was also a no-op Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 3 --- drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c | 2 -- drivers/staging/rtl8723au/include/hal_intf.h | 1 - 3 files changed, 6 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index 96d744152903..ab42739366ea 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -9492,9 +9492,6 @@ u8 sitesurvey_cmd_hdl23a(struct rtw_adapter *padapter, u8 *pbuf) u32 i; if (pmlmeext->sitesurvey_res.state == SCAN_DISABLE) { - /* for first time sitesurvey_cmd */ - rtw_hal_set_hwreg23a(padapter, HW_VAR_CHECK_TXBUF, NULL); - pmlmeext->sitesurvey_res.state = SCAN_START; pmlmeext->sitesurvey_res.bss_cnt = 0; pmlmeext->sitesurvey_res.channel_idx = 0; diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c index d496330a23c6..e6e501217e6d 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c @@ -3177,8 +3177,6 @@ void SetHwReg8723A(struct rtw_adapter *padapter, u8 variable, u8 *val) case HW_VAR_EFUSE_BT_BYTES: pHalData->BTEfuseUsedBytes = *((u16 *) val); break; - case HW_VAR_CHECK_TXBUF: - break; case HW_VAR_APFM_ON_MAC: rtl8723a_set_apfm_on_mac(padapter, *val); break; diff --git a/drivers/staging/rtl8723au/include/hal_intf.h b/drivers/staging/rtl8723au/include/hal_intf.h index 75e751cedcd7..fcb441154b31 100644 --- a/drivers/staging/rtl8723au/include/hal_intf.h +++ b/drivers/staging/rtl8723au/include/hal_intf.h @@ -63,7 +63,6 @@ enum HW_VARIABLES { HW_VAR_SWITCH_EPHY_WoWLAN, HW_VAR_EFUSE_BYTES, HW_VAR_EFUSE_BT_BYTES, - HW_VAR_CHECK_TXBUF, HW_VAR_APFM_ON_MAC, /* Auto FSM to Turn On, include clock, isolation, power control for MAC only */ /* The valid upper nav range for the HW updating, if the true value is larger than the upper range, the HW won't update it. */ /* Unit in microsecond. 0 means disable this function. */ -- cgit v1.2.3 From 1e7b6ebe193a23faf3f559c9611dc1b5ca87c287 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 9 Apr 2014 23:20:36 +0200 Subject: staging: rtl8723au: Make direct calls for HW_VAR_TXDMA_AGG_PG_TH This was in fact turned into a no-op for the RTL8723AU, but it looks like a bug, so this reenables it. Keep an eye out for side-effects here and revert this, if it causes issues. Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme.c | 9 +++------ drivers/staging/rtl8723au/core/rtw_sreset.c | 10 +++++----- drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c | 4 ---- drivers/staging/rtl8723au/hal/usb_halinit.c | 2 -- drivers/staging/rtl8723au/include/hal_intf.h | 1 - 5 files changed, 8 insertions(+), 18 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme.c b/drivers/staging/rtl8723au/core/rtw_mlme.c index 6cee78785bdc..9cf26ea0088b 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme.c @@ -2193,13 +2193,10 @@ void rtw_joinbss_reset23a(struct rtw_adapter *padapter) threshold = 1; else threshold = 0; - rtw_hal_set_hwreg23a(padapter, HW_VAR_RXDMA_AGG_PG_TH, - (u8 *)(&threshold)); - } else { + } else threshold = 1; - rtw_hal_set_hwreg23a(padapter, HW_VAR_RXDMA_AGG_PG_TH, - (u8 *)(&threshold)); - } + + rtl8723a_set_rxdma_agg_pg_th(padapter, threshold); } /* the fucntion is >= passive_level */ diff --git a/drivers/staging/rtl8723au/core/rtw_sreset.c b/drivers/staging/rtl8723au/core/rtw_sreset.c index e243a3afcdcd..dd2a6f18f7d7 100644 --- a/drivers/staging/rtl8723au/core/rtw_sreset.c +++ b/drivers/staging/rtl8723au/core/rtw_sreset.c @@ -132,13 +132,13 @@ static void sreset_restore_network_station(struct rtw_adapter *padapter) threshold = 1; else threshold = 0; - rtw_hal_set_hwreg23a(padapter, HW_VAR_RXDMA_AGG_PG_TH, (u8 *)(&threshold)); - } else { + } else threshold = 1; - rtw_hal_set_hwreg23a(padapter, HW_VAR_RXDMA_AGG_PG_TH, (u8 *)(&threshold)); - } - set_channel_bwmode23a(padapter, pmlmeext->cur_channel, pmlmeext->cur_ch_offset, pmlmeext->cur_bwmode); + rtl8723a_set_rxdma_agg_pg_th(padapter, threshold); + + set_channel_bwmode23a(padapter, pmlmeext->cur_channel, + pmlmeext->cur_ch_offset, pmlmeext->cur_bwmode); /* disable dynamic functions, such as high power, DIG */ /* Switch_DM_Func23a(padapter, DYNAMIC_FUNC_DISABLE, false); */ diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c index e6e501217e6d..fee79d1a190a 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c @@ -3153,10 +3153,6 @@ void SetHwReg8723A(struct rtw_adapter *padapter, u8 variable, u8 *val) rtl8723a_odm_support_ability_clr(padapter, *val32); break; - case HW_VAR_RXDMA_AGG_PG_TH: - rtl8723a_set_rxdma_agg_pg_th(padapter, *val); - break; - case HW_VAR_H2C_FW_PWRMODE: rtl8723a_set_FwPwrMode_cmd(padapter, *val); break; diff --git a/drivers/staging/rtl8723au/hal/usb_halinit.c b/drivers/staging/rtl8723au/hal/usb_halinit.c index eae95ec38516..2b44b17acc70 100644 --- a/drivers/staging/rtl8723au/hal/usb_halinit.c +++ b/drivers/staging/rtl8723au/hal/usb_halinit.c @@ -1519,8 +1519,6 @@ static void rtl8723au_trigger_gpio_0(struct rtw_adapter *padapter) static void SetHwReg8723AU(struct rtw_adapter *Adapter, u8 variable, u8 *val) { switch (variable) { - case HW_VAR_RXDMA_AGG_PG_TH: - break; case HW_VAR_SET_RPWM: rtl8723a_set_rpwm(Adapter, *val); break; diff --git a/drivers/staging/rtl8723au/include/hal_intf.h b/drivers/staging/rtl8723au/include/hal_intf.h index fcb441154b31..e2b9fdcb2192 100644 --- a/drivers/staging/rtl8723au/include/hal_intf.h +++ b/drivers/staging/rtl8723au/include/hal_intf.h @@ -44,7 +44,6 @@ enum HW_VARIABLES { HW_VAR_DM_FUNC_SET, HW_VAR_DM_FUNC_CLR, HW_VAR_CAM_READ, - HW_VAR_RXDMA_AGG_PG_TH, HW_VAR_SET_RPWM, HW_VAR_H2C_FW_PWRMODE, HW_VAR_H2C_FW_JOINBSSRPT, -- cgit v1.2.3 From 327c70c04b2d045b9eea15d1ac30e4254ac4f687 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 9 Apr 2014 23:20:37 +0200 Subject: staging: rtl8723au: Make direct calls for HW_VAR_H2C_FW_{PWRMODE,JOINBSSRPT} Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_cmd.c | 6 ++---- drivers/staging/rtl8723au/core/rtw_p2p.c | 17 +++++++---------- drivers/staging/rtl8723au/core/rtw_pwrctrl.c | 13 ++++--------- drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c | 8 -------- drivers/staging/rtl8723au/include/hal_intf.h | 2 -- 5 files changed, 13 insertions(+), 33 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_cmd.c b/drivers/staging/rtl8723au/core/rtw_cmd.c index 5e3088a01800..0b25cd2f6584 100644 --- a/drivers/staging/rtl8723au/core/rtw_cmd.c +++ b/drivers/staging/rtl8723au/core/rtw_cmd.c @@ -1269,8 +1269,7 @@ void lps_ctrl_wk_hdl(struct rtw_adapter *padapter, u8 lps_ctrl_type) mstatus = 1;/* connect */ /* Reset LPS Setting */ padapter->pwrctrlpriv.LpsIdleCount = 0; - rtw_hal_set_hwreg23a(padapter, HW_VAR_H2C_FW_JOINBSSRPT, - (u8 *)&mstatus); + rtl8723a_set_FwJoinBssReport_cmd(padapter, 1); #ifdef CONFIG_8723AU_BT_COEXIST BT_WifiMediaStatusNotify(padapter, mstatus); #endif @@ -1284,8 +1283,7 @@ void lps_ctrl_wk_hdl(struct rtw_adapter *padapter, u8 lps_ctrl_type) { LPS_Leave23a(padapter); } - rtw_hal_set_hwreg23a(padapter, HW_VAR_H2C_FW_JOINBSSRPT, - (u8 *)&mstatus); + rtl8723a_set_FwJoinBssReport_cmd(padapter, 0); break; case LPS_CTRL_SPECIAL_PACKET: pwrpriv->DelayLPSLastTimeStamp = jiffies; diff --git a/drivers/staging/rtl8723au/core/rtw_p2p.c b/drivers/staging/rtl8723au/core/rtw_p2p.c index 67d17a17a6b1..81eebe5b74d9 100644 --- a/drivers/staging/rtl8723au/core/rtw_p2p.c +++ b/drivers/staging/rtl8723au/core/rtw_p2p.c @@ -16,6 +16,7 @@ #include #include +#include #include #ifdef CONFIG_8723AU_P2P @@ -3573,12 +3574,10 @@ void p2p_ps_wk_hdl23a(struct rtw_adapter *padapter, u8 p2p_ps_state) pwdinfo->opp_ps = 0; pwdinfo->noa_num = 0; pwdinfo->p2p_ps_mode = P2P_PS_NONE; - if (padapter->pwrctrlpriv.bFwCurrentInPSMode == true) - { - if (pwrpriv->smart_ps == 0) - { + if (padapter->pwrctrlpriv.bFwCurrentInPSMode == true) { + if (pwrpriv->smart_ps == 0) { pwrpriv->smart_ps = 2; - rtw_hal_set_hwreg23a(padapter, HW_VAR_H2C_FW_PWRMODE, (u8 *)&padapter->pwrctrlpriv.pwr_mode); + rtl8723a_set_FwPwrMode_cmd(padapter, padapter->pwrctrlpriv.pwr_mode); } } break; @@ -3586,13 +3585,11 @@ void p2p_ps_wk_hdl23a(struct rtw_adapter *padapter, u8 p2p_ps_state) if (pwdinfo->p2p_ps_mode > P2P_PS_NONE) { pwdinfo->p2p_ps_state = p2p_ps_state; - if (pwdinfo->ctwindow > 0) - { - if (pwrpriv->smart_ps != 0) - { + if (pwdinfo->ctwindow > 0) { + if (pwrpriv->smart_ps != 0) { pwrpriv->smart_ps = 0; DBG_8723A("%s(): Enter CTW, change SmartPS\n", __func__); - rtw_hal_set_hwreg23a(padapter, HW_VAR_H2C_FW_PWRMODE, (u8 *)&padapter->pwrctrlpriv.pwr_mode); + rtl8723a_set_FwPwrMode_cmd(padapter, padapter->pwrctrlpriv.pwr_mode); } } rtw_hal_set_hwreg23a(padapter, HW_VAR_H2C_FW_P2P_PS_OFFLOAD, (u8 *)(&p2p_ps_state)); diff --git a/drivers/staging/rtl8723au/core/rtw_pwrctrl.c b/drivers/staging/rtl8723au/core/rtw_pwrctrl.c index 8ddd67f194ba..c2e86529047b 100644 --- a/drivers/staging/rtl8723au/core/rtw_pwrctrl.c +++ b/drivers/staging/rtl8723au/core/rtw_pwrctrl.c @@ -341,25 +341,22 @@ void rtw_set_ps_mode23a(struct rtw_adapter *padapter, u8 ps_mode, u8 smart_ps, u pwrpriv->pwr_mode = ps_mode; rtw_set_rpwm23a(padapter, PS_STATE_S4); - rtw_hal_set_hwreg23a(padapter, HW_VAR_H2C_FW_PWRMODE, (u8 *)(&ps_mode)); + rtl8723a_set_FwPwrMode_cmd(padapter, ps_mode); pwrpriv->bFwCurrentInPSMode = false; } - } - else - { + } else { if (PS_RDY_CHECK(padapter) #ifdef CONFIG_8723AU_BT_COEXIST || (BT_1Ant(padapter) == true) #endif - ) - { + ) { DBG_8723A("%s: Enter 802.11 power save\n", __func__); pwrpriv->bFwCurrentInPSMode = true; pwrpriv->pwr_mode = ps_mode; pwrpriv->smart_ps = smart_ps; pwrpriv->bcn_ant_mode = bcn_ant_mode; - rtw_hal_set_hwreg23a(padapter, HW_VAR_H2C_FW_PWRMODE, (u8 *)(&ps_mode)); + rtl8723a_set_FwPwrMode_cmd(padapter, ps_mode); #ifdef CONFIG_8723AU_P2P /* Set CTWindow after LPS */ @@ -370,8 +367,6 @@ void rtw_set_ps_mode23a(struct rtw_adapter *padapter, u8 ps_mode, u8 smart_ps, u rtw_set_rpwm23a(padapter, PS_STATE_S2); } } - - } /* diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c index fee79d1a190a..2e0350952d0a 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c @@ -3153,14 +3153,6 @@ void SetHwReg8723A(struct rtw_adapter *padapter, u8 variable, u8 *val) rtl8723a_odm_support_ability_clr(padapter, *val32); break; - case HW_VAR_H2C_FW_PWRMODE: - rtl8723a_set_FwPwrMode_cmd(padapter, *val); - break; - - case HW_VAR_H2C_FW_JOINBSSRPT: - rtl8723a_set_FwJoinBssReport_cmd(padapter, *val); - break; - #ifdef CONFIG_8723AU_P2P case HW_VAR_H2C_FW_P2P_PS_OFFLOAD: rtl8723a_set_p2p_ps_offload_cmd(padapter, *val); diff --git a/drivers/staging/rtl8723au/include/hal_intf.h b/drivers/staging/rtl8723au/include/hal_intf.h index e2b9fdcb2192..27b0eb8bb866 100644 --- a/drivers/staging/rtl8723au/include/hal_intf.h +++ b/drivers/staging/rtl8723au/include/hal_intf.h @@ -45,8 +45,6 @@ enum HW_VARIABLES { HW_VAR_DM_FUNC_CLR, HW_VAR_CAM_READ, HW_VAR_SET_RPWM, - HW_VAR_H2C_FW_PWRMODE, - HW_VAR_H2C_FW_JOINBSSRPT, HW_VAR_FWLPS_RF_ON, HW_VAR_H2C_FW_P2P_PS_OFFLOAD, HW_VAR_TDLS_WRCR, -- cgit v1.2.3 From c6d921c5808c78a3b89a4dfdba2c8c979fec5581 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 9 Apr 2014 23:20:38 +0200 Subject: staging: rtl8723au: Make direct calls for HW_VAR_H2C_P2P_PS_OFFLOAD Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_p2p.c | 8 +++++--- drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c | 6 ------ drivers/staging/rtl8723au/include/hal_intf.h | 1 - 3 files changed, 5 insertions(+), 10 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_p2p.c b/drivers/staging/rtl8723au/core/rtw_p2p.c index 81eebe5b74d9..e5d9991040bb 100644 --- a/drivers/staging/rtl8723au/core/rtw_p2p.c +++ b/drivers/staging/rtl8723au/core/rtw_p2p.c @@ -3567,7 +3567,7 @@ void p2p_ps_wk_hdl23a(struct rtw_adapter *padapter, u8 p2p_ps_state) case P2P_PS_DISABLE: pwdinfo->p2p_ps_state = p2p_ps_state; - rtw_hal_set_hwreg23a(padapter, HW_VAR_H2C_FW_P2P_PS_OFFLOAD, (u8 *)(&p2p_ps_state)); + rtl8723a_set_p2p_ps_offload_cmd(padapter, p2p_ps_state); pwdinfo->noa_index = 0; pwdinfo->ctwindow = 0; @@ -3592,7 +3592,8 @@ void p2p_ps_wk_hdl23a(struct rtw_adapter *padapter, u8 p2p_ps_state) rtl8723a_set_FwPwrMode_cmd(padapter, padapter->pwrctrlpriv.pwr_mode); } } - rtw_hal_set_hwreg23a(padapter, HW_VAR_H2C_FW_P2P_PS_OFFLOAD, (u8 *)(&p2p_ps_state)); + rtl8723a_set_p2p_ps_offload_cmd(padapter, + p2p_ps_state); } break; case P2P_PS_SCAN: @@ -3600,7 +3601,8 @@ void p2p_ps_wk_hdl23a(struct rtw_adapter *padapter, u8 p2p_ps_state) case P2P_PS_ALLSTASLEEP: if (pwdinfo->p2p_ps_mode > P2P_PS_NONE) { pwdinfo->p2p_ps_state = p2p_ps_state; - rtw_hal_set_hwreg23a(padapter, HW_VAR_H2C_FW_P2P_PS_OFFLOAD, (u8 *)(&p2p_ps_state)); + rtl8723a_set_p2p_ps_offload_cmd(padapter, + p2p_ps_state); } break; default: diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c index 2e0350952d0a..f8d4ef3e7b0b 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c @@ -3153,12 +3153,6 @@ void SetHwReg8723A(struct rtw_adapter *padapter, u8 variable, u8 *val) rtl8723a_odm_support_ability_clr(padapter, *val32); break; -#ifdef CONFIG_8723AU_P2P - case HW_VAR_H2C_FW_P2P_PS_OFFLOAD: - rtl8723a_set_p2p_ps_offload_cmd(padapter, *val); - break; -#endif /* CONFIG_8723AU_P2P */ - case HW_VAR_EFUSE_BYTES: pHalData->EfuseUsedBytes = *((u16 *) val); break; diff --git a/drivers/staging/rtl8723au/include/hal_intf.h b/drivers/staging/rtl8723au/include/hal_intf.h index 27b0eb8bb866..f1cab544a44c 100644 --- a/drivers/staging/rtl8723au/include/hal_intf.h +++ b/drivers/staging/rtl8723au/include/hal_intf.h @@ -46,7 +46,6 @@ enum HW_VARIABLES { HW_VAR_CAM_READ, HW_VAR_SET_RPWM, HW_VAR_FWLPS_RF_ON, - HW_VAR_H2C_FW_P2P_PS_OFFLOAD, HW_VAR_TDLS_WRCR, HW_VAR_TDLS_INIT_CH_SEN, HW_VAR_TDLS_RS_RCR, -- cgit v1.2.3 From 9ff3513cb4d77d468ca0d0b5fd05d8a268d13cc9 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 9 Apr 2014 23:20:39 +0200 Subject: staging: rtl8723au: Make direct calls for HW_VAR_SET_RPWM Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_pwrctrl.c | 2 +- drivers/staging/rtl8723au/hal/usb_halinit.c | 3 --- drivers/staging/rtl8723au/include/hal_intf.h | 1 - 3 files changed, 1 insertion(+), 5 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_pwrctrl.c b/drivers/staging/rtl8723au/core/rtw_pwrctrl.c index c2e86529047b..da6645e9b9fc 100644 --- a/drivers/staging/rtl8723au/core/rtw_pwrctrl.c +++ b/drivers/staging/rtl8723au/core/rtw_pwrctrl.c @@ -263,7 +263,7 @@ void rtw_set_rpwm23a(struct rtw_adapter *padapter, u8 pslv) pwrpriv->rpwm = pslv; - rtw_hal_set_hwreg23a(padapter, HW_VAR_SET_RPWM, (u8 *)(&rpwm)); + rtl8723a_set_rpwm(padapter, rpwm); pwrpriv->tog += 0x80; pwrpriv->cpwm = pslv; diff --git a/drivers/staging/rtl8723au/hal/usb_halinit.c b/drivers/staging/rtl8723au/hal/usb_halinit.c index 2b44b17acc70..0bbc56a95481 100644 --- a/drivers/staging/rtl8723au/hal/usb_halinit.c +++ b/drivers/staging/rtl8723au/hal/usb_halinit.c @@ -1519,9 +1519,6 @@ static void rtl8723au_trigger_gpio_0(struct rtw_adapter *padapter) static void SetHwReg8723AU(struct rtw_adapter *Adapter, u8 variable, u8 *val) { switch (variable) { - case HW_VAR_SET_RPWM: - rtl8723a_set_rpwm(Adapter, *val); - break; case HW_VAR_TRIGGER_GPIO_0: rtl8723au_trigger_gpio_0(Adapter); break; diff --git a/drivers/staging/rtl8723au/include/hal_intf.h b/drivers/staging/rtl8723au/include/hal_intf.h index f1cab544a44c..2d5ace57d834 100644 --- a/drivers/staging/rtl8723au/include/hal_intf.h +++ b/drivers/staging/rtl8723au/include/hal_intf.h @@ -44,7 +44,6 @@ enum HW_VARIABLES { HW_VAR_DM_FUNC_SET, HW_VAR_DM_FUNC_CLR, HW_VAR_CAM_READ, - HW_VAR_SET_RPWM, HW_VAR_FWLPS_RF_ON, HW_VAR_TDLS_WRCR, HW_VAR_TDLS_INIT_CH_SEN, -- cgit v1.2.3 From a3252966e137fc047175cdb9f17c532972ce37c9 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 9 Apr 2014 23:20:40 +0200 Subject: staging: rtl8723au: Remove commented out set_hwreg calls Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index ab42739366ea..b0c082039c1f 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -7651,9 +7651,6 @@ void site_survey23a(struct rtw_adapter *padapter) if (survey_channel != 0) { /* PAUSE 4-AC Queue when site_survey23a */ - /* rtw23a_hal_get_hwreg(padapter, HW_VAR_TXPAUSE, (u8 *)(&val8)); */ - /* val8 |= 0x0f; */ - /* rtw_hal_set_hwreg23a(padapter, HW_VAR_TXPAUSE, (u8 *)(&val8)); */ if (pmlmeext->sitesurvey_res.channel_idx == 0) set_channel_bwmode23a(padapter, survey_channel, HAL_PRIME_CHNL_OFFSET_DONT_CARE, @@ -7743,7 +7740,6 @@ void site_survey23a(struct rtw_adapter *padapter) /* flush 4-AC Queue after site_survey23a */ /* val8 = 0; */ - /* rtw_hal_set_hwreg23a(padapter, HW_VAR_TXPAUSE, (u8 *)(&val8)); */ /* config MSR */ Set_MSR23a(padapter, (pmlmeinfo->state & 0x3)); -- cgit v1.2.3 From 6883e7c720e90de5b0af6f0ea293a8eb090ca263 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 9 Apr 2014 23:20:41 +0200 Subject: staging: rtl8723au: Make direct calls for HW_VAR_NAV_UPPER Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c | 3 --- drivers/staging/rtl8723au/hal/usb_halinit.c | 3 +-- drivers/staging/rtl8723au/include/hal_intf.h | 1 - 3 files changed, 1 insertion(+), 6 deletions(-) diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c index f8d4ef3e7b0b..8d7f124df497 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c @@ -3163,9 +3163,6 @@ void SetHwReg8723A(struct rtw_adapter *padapter, u8 variable, u8 *val) rtl8723a_set_apfm_on_mac(padapter, *val); break; - case HW_VAR_NAV_UPPER: - rtl8723a_set_nav_upper(padapter, *val32); - break; default: break; } diff --git a/drivers/staging/rtl8723au/hal/usb_halinit.c b/drivers/staging/rtl8723au/hal/usb_halinit.c index 0bbc56a95481..aaa81f87cc6e 100644 --- a/drivers/staging/rtl8723au/hal/usb_halinit.c +++ b/drivers/staging/rtl8723au/hal/usb_halinit.c @@ -621,7 +621,6 @@ static u32 rtl8723au_hal_init(struct rtw_adapter *Adapter) struct hal_data_8723a *pHalData = GET_HAL_DATA(Adapter); struct pwrctrl_priv *pwrctrlpriv = &Adapter->pwrctrlpriv; struct registry_priv *pregistrypriv = &Adapter->registrypriv; - u32 NavUpper = WiFiNavUpperUs; unsigned long init_start_time = jiffies; @@ -888,7 +887,7 @@ static u32 rtl8723au_hal_init(struct rtw_adapter *Adapter) rtl8723a_InitHalDm(Adapter); HAL_INIT_PROFILE_TAG(HAL_INIT_STAGES_MISC31); - rtw_hal_set_hwreg23a(Adapter, HW_VAR_NAV_UPPER, (u8 *)&NavUpper); + rtl8723a_set_nav_upper(Adapter, WiFiNavUpperUs); /* 2011/03/09 MH debug only, UMC-B cut pass 2500 S5 test, but we need to fin root cause. */ if (((rtw_read32(Adapter, rFPGA0_RFMOD) & 0xFF000000) != 0x83000000)) { diff --git a/drivers/staging/rtl8723au/include/hal_intf.h b/drivers/staging/rtl8723au/include/hal_intf.h index 2d5ace57d834..9c94b13b3329 100644 --- a/drivers/staging/rtl8723au/include/hal_intf.h +++ b/drivers/staging/rtl8723au/include/hal_intf.h @@ -61,7 +61,6 @@ enum HW_VARIABLES { HW_VAR_APFM_ON_MAC, /* Auto FSM to Turn On, include clock, isolation, power control for MAC only */ /* The valid upper nav range for the HW updating, if the true value is larger than the upper range, the HW won't update it. */ /* Unit in microsecond. 0 means disable this function. */ - HW_VAR_NAV_UPPER, HW_VAR_RPT_TIMER_SETTING, HW_VAR_TX_RPT_MAX_MACID, HW_VAR_H2C_MEDIA_STATUS_RPT, -- cgit v1.2.3 From a945bf30129d60659d4f983db93d7b7dc08c8571 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 9 Apr 2014 23:20:42 +0200 Subject: staging: rtl8723au: Eliminate HW_VAR_DM_FUNC_OP calls Demux the code and remove multiple call layers Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 9 +++++---- drivers/staging/rtl8723au/core/rtw_wlan_util.c | 13 ------------- drivers/staging/rtl8723au/hal/hal_com.c | 16 +++++++++------- drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c | 3 --- drivers/staging/rtl8723au/include/hal_com.h | 3 ++- drivers/staging/rtl8723au/include/hal_intf.h | 1 - drivers/staging/rtl8723au/include/rtw_mlme_ext.h | 2 -- 7 files changed, 16 insertions(+), 31 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index b0c082039c1f..316200ea0c50 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -7718,7 +7718,7 @@ void site_survey23a(struct rtw_adapter *padapter) /* restore RX GAIN */ rtl8723a_set_initial_gain(padapter, 0xff); /* turn on dynamic functions */ - Restore_DM_Func_Flag23a(padapter); + rtl8723a_odm_support_ability_restore(padapter); /* Switch_DM_Func23a(padapter, DYNAMIC_FUNC_DIG|DYNAMIC_FUNC_HP|DYNAMIC_FUNC_SS, true); */ mod_timer(&pwdinfo->find_phase_timer, jiffies + @@ -7747,7 +7747,7 @@ void site_survey23a(struct rtw_adapter *padapter) /* restore RX GAIN */ rtl8723a_set_initial_gain(padapter, 0xff); /* turn on dynamic functions */ - Restore_DM_Func_Flag23a(padapter); + rtl8723a_odm_support_ability_restore(padapter); /* Switch_DM_Func23a(padapter, DYNAMIC_ALL_FUNC_ENABLE, true); */ if (is_client_associated_to_ap23a(padapter) == true) @@ -9223,7 +9223,8 @@ u8 createbss_hdl23a(struct rtw_adapter *padapter, u8 *pbuf) pmlmeinfo->candidate_tid_bitmap = 0; /* disable dynamic functions, such as high power, DIG */ - Save_DM_Func_Flag23a(padapter); + rtl8723a_odm_support_ability_backup(padapter); + Switch_DM_Func23a(padapter, DYNAMIC_FUNC_DISABLE, false); /* cancel link timer */ @@ -9535,7 +9536,7 @@ u8 sitesurvey_cmd_hdl23a(struct rtw_adapter *padapter, u8 *pbuf) if ((pmlmeext->sitesurvey_res.state == SCAN_START) || (pmlmeext->sitesurvey_res.state == SCAN_TXNULL)) { /* disable dynamic functions, such as high power, DIG */ - Save_DM_Func_Flag23a(padapter); + rtl8723a_odm_support_ability_backup(padapter); Switch_DM_Func23a(padapter, DYNAMIC_FUNC_DISABLE, false); /* config the initial gain under scaning, need to diff --git a/drivers/staging/rtl8723au/core/rtw_wlan_util.c b/drivers/staging/rtl8723au/core/rtw_wlan_util.c index 91bb7a451fba..809d4167731f 100644 --- a/drivers/staging/rtl8723au/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8723au/core/rtw_wlan_util.c @@ -283,19 +283,6 @@ void Update23aTblForSoftAP(u8 *bssrateset, u32 bssratelen) } } -void Save_DM_Func_Flag23a(struct rtw_adapter *padapter) -{ - u8 bSaveFlag = true; - - rtw_hal_set_hwreg23a(padapter, HW_VAR_DM_FUNC_OP, (u8 *)(&bSaveFlag)); -} - -void Restore_DM_Func_Flag23a(struct rtw_adapter *padapter) -{ - u8 bSaveFlag = false; - rtw_hal_set_hwreg23a(padapter, HW_VAR_DM_FUNC_OP, (u8 *)(&bSaveFlag)); -} - void Switch_DM_Func23a(struct rtw_adapter *padapter, unsigned long mode, u8 enable) { if (enable == true) diff --git a/drivers/staging/rtl8723au/hal/hal_com.c b/drivers/staging/rtl8723au/hal/hal_com.c index 5d4e51c493e6..66adec743a85 100644 --- a/drivers/staging/rtl8723au/hal/hal_com.c +++ b/drivers/staging/rtl8723au/hal/hal_com.c @@ -872,16 +872,18 @@ void rtl8723a_odm_support_ability_write(struct rtw_adapter *padapter, u32 val) pHalData->odmpriv.SupportAbility = val; } -void rtl8723a_odm_support_ability_backup(struct rtw_adapter *padapter, u8 val) +void rtl8723a_odm_support_ability_restore(struct rtw_adapter *padapter) { struct hal_data_8723a *pHalData = GET_HAL_DATA(padapter); - if (val) /* save dm flag */ - pHalData->odmpriv.BK_SupportAbility = - pHalData->odmpriv.SupportAbility; - else /* restore dm flag */ - pHalData->odmpriv.SupportAbility = - pHalData->odmpriv.BK_SupportAbility; + pHalData->odmpriv.SupportAbility = pHalData->odmpriv.BK_SupportAbility; +} + +void rtl8723a_odm_support_ability_backup(struct rtw_adapter *padapter) +{ + struct hal_data_8723a *pHalData = GET_HAL_DATA(padapter); + + pHalData->odmpriv.BK_SupportAbility = pHalData->odmpriv.SupportAbility; } void rtl8723a_odm_support_ability_set(struct rtw_adapter *padapter, u32 val) diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c index 8d7f124df497..79e63bfb0b2e 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c @@ -3142,9 +3142,6 @@ void SetHwReg8723A(struct rtw_adapter *padapter, u8 variable, u8 *val) case HW_VAR_DM_FLAG: rtl8723a_odm_support_ability_write(padapter, *val32); break; - case HW_VAR_DM_FUNC_OP: - rtl8723a_odm_support_ability_backup(padapter, *val); - break; case HW_VAR_DM_FUNC_SET: rtl8723a_odm_support_ability_set(padapter, *val32); break; diff --git a/drivers/staging/rtl8723au/include/hal_com.h b/drivers/staging/rtl8723au/include/hal_com.h index 9d036132ac4f..e8774fc602c0 100644 --- a/drivers/staging/rtl8723au/include/hal_com.h +++ b/drivers/staging/rtl8723au/include/hal_com.h @@ -202,7 +202,8 @@ void rtl8723a_set_nav_upper(struct rtw_adapter *padapter, u32 usNavUpper); void rtl8723a_set_initial_gain(struct rtw_adapter *padapter, u32 rx_gain); void rtl8723a_odm_support_ability_write(struct rtw_adapter *padapter, u32 val); -void rtl8723a_odm_support_ability_backup(struct rtw_adapter *padapter, u8 val); +void rtl8723a_odm_support_ability_backup(struct rtw_adapter *padapter); +void rtl8723a_odm_support_ability_restore(struct rtw_adapter *padapter); void rtl8723a_odm_support_ability_set(struct rtw_adapter *padapter, u32 val); void rtl8723a_odm_support_ability_clr(struct rtw_adapter *padapter, u32 val); diff --git a/drivers/staging/rtl8723au/include/hal_intf.h b/drivers/staging/rtl8723au/include/hal_intf.h index 9c94b13b3329..2218032ef617 100644 --- a/drivers/staging/rtl8723au/include/hal_intf.h +++ b/drivers/staging/rtl8723au/include/hal_intf.h @@ -40,7 +40,6 @@ enum HW_VARIABLES { HW_VAR_TXPAUSE, HW_VAR_RF_TYPE, HW_VAR_DM_FLAG, - HW_VAR_DM_FUNC_OP, HW_VAR_DM_FUNC_SET, HW_VAR_DM_FUNC_CLR, HW_VAR_CAM_READ, diff --git a/drivers/staging/rtl8723au/include/rtw_mlme_ext.h b/drivers/staging/rtl8723au/include/rtw_mlme_ext.h index b61fc95b1037..53b2d0a34734 100644 --- a/drivers/staging/rtl8723au/include/rtw_mlme_ext.h +++ b/drivers/staging/rtl8723au/include/rtw_mlme_ext.h @@ -474,8 +474,6 @@ void get_rate_set23a(struct rtw_adapter *padapter, unsigned char *pbssrate, void UpdateBrateTbl23a(struct rtw_adapter *padapter,u8 *mBratesOS); void Update23aTblForSoftAP(u8 *bssrateset, u32 bssratelen); -void Save_DM_Func_Flag23a(struct rtw_adapter *padapter); -void Restore_DM_Func_Flag23a(struct rtw_adapter *padapter); void Switch_DM_Func23a(struct rtw_adapter *padapter, unsigned long mode, u8 enable); void Set_MSR23a(struct rtw_adapter *padapter, u8 type); -- cgit v1.2.3 From 585eefb45398abdc9d330785e2ef7e084655f1ff Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 9 Apr 2014 23:20:43 +0200 Subject: staging: rtl8723au: Eliminate HW_VAR_DM_FUNC_{SET,CLR} Unroll two layers of mux/demux in the call chain for each. Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_ap.c | 3 ++- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 12 +++++------- drivers/staging/rtl8723au/core/rtw_sreset.c | 3 --- drivers/staging/rtl8723au/core/rtw_wlan_util.c | 16 ++++------------ drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c | 7 ------- drivers/staging/rtl8723au/include/hal_intf.h | 2 -- drivers/staging/rtl8723au/include/rtw_mlme_ext.h | 2 -- 7 files changed, 11 insertions(+), 34 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_ap.c b/drivers/staging/rtl8723au/core/rtw_ap.c index f55e86d8be65..c18eee9222ce 100644 --- a/drivers/staging/rtl8723au/core/rtw_ap.c +++ b/drivers/staging/rtl8723au/core/rtw_ap.c @@ -723,7 +723,8 @@ static void start_bss_network(struct rtw_adapter *padapter, u8 *pbuf) /* disable dynamic functions, such as high power, DIG */ /* turn on all dynamic functions */ - Switch_DM_Func23a(padapter, DYNAMIC_ALL_FUNC_ENABLE, true); + rtl8723a_odm_support_ability_set(padapter, + DYNAMIC_ALL_FUNC_ENABLE); } /* set channel, bwmode */ p = rtw_get_ie23a((pnetwork->IEs + sizeof(struct ndis_802_11_fixed_ies)), diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index 316200ea0c50..94ba6ef8f24b 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -7719,7 +7719,6 @@ void site_survey23a(struct rtw_adapter *padapter) rtl8723a_set_initial_gain(padapter, 0xff); /* turn on dynamic functions */ rtl8723a_odm_support_ability_restore(padapter); - /* Switch_DM_Func23a(padapter, DYNAMIC_FUNC_DIG|DYNAMIC_FUNC_HP|DYNAMIC_FUNC_SS, true); */ mod_timer(&pwdinfo->find_phase_timer, jiffies + msecs_to_jiffies(pwdinfo->listen_dwell * 100)); @@ -7748,7 +7747,6 @@ void site_survey23a(struct rtw_adapter *padapter) rtl8723a_set_initial_gain(padapter, 0xff); /* turn on dynamic functions */ rtl8723a_odm_support_ability_restore(padapter); - /* Switch_DM_Func23a(padapter, DYNAMIC_ALL_FUNC_ENABLE, true); */ if (is_client_associated_to_ap23a(padapter) == true) { @@ -8705,7 +8703,7 @@ void mlmeext_joinbss_event_callback23a(struct rtw_adapter *padapter, int join_re } /* turn on dynamic functions */ - Switch_DM_Func23a(padapter, DYNAMIC_ALL_FUNC_ENABLE, true); + rtl8723a_odm_support_ability_set(padapter, DYNAMIC_ALL_FUNC_ENABLE); /* update IOT-releated issue */ update_IOT_info23a(padapter); @@ -9225,7 +9223,8 @@ u8 createbss_hdl23a(struct rtw_adapter *padapter, u8 *pbuf) /* disable dynamic functions, such as high power, DIG */ rtl8723a_odm_support_ability_backup(padapter); - Switch_DM_Func23a(padapter, DYNAMIC_FUNC_DISABLE, false); + rtl8723a_odm_support_ability_clr(padapter, + DYNAMIC_FUNC_DISABLE); /* cancel link timer */ del_timer_sync(&pmlmeext->link_timer); @@ -9355,8 +9354,6 @@ u8 join_cmd_hdl23a(struct rtw_adapter *padapter, u8 *pbuf) i += (pIE->Length + 2); } - /* disable dynamic functions, such as high power, DIG */ - /* Switch_DM_Func23a(padapter, DYNAMIC_FUNC_DISABLE, false); */ hw_var_set_bssid(padapter, pmlmeinfo->network.MacAddress); hw_var_set_mlme_join(padapter, 0); @@ -9537,7 +9534,8 @@ u8 sitesurvey_cmd_hdl23a(struct rtw_adapter *padapter, u8 *pbuf) (pmlmeext->sitesurvey_res.state == SCAN_TXNULL)) { /* disable dynamic functions, such as high power, DIG */ rtl8723a_odm_support_ability_backup(padapter); - Switch_DM_Func23a(padapter, DYNAMIC_FUNC_DISABLE, false); + rtl8723a_odm_support_ability_clr(padapter, + DYNAMIC_FUNC_DISABLE); /* config the initial gain under scaning, need to write the BB registers */ diff --git a/drivers/staging/rtl8723au/core/rtw_sreset.c b/drivers/staging/rtl8723au/core/rtw_sreset.c index dd2a6f18f7d7..5bf7beb6d19c 100644 --- a/drivers/staging/rtl8723au/core/rtw_sreset.c +++ b/drivers/staging/rtl8723au/core/rtw_sreset.c @@ -140,9 +140,6 @@ static void sreset_restore_network_station(struct rtw_adapter *padapter) set_channel_bwmode23a(padapter, pmlmeext->cur_channel, pmlmeext->cur_ch_offset, pmlmeext->cur_bwmode); - /* disable dynamic functions, such as high power, DIG */ - /* Switch_DM_Func23a(padapter, DYNAMIC_FUNC_DISABLE, false); */ - hw_var_set_bssid(padapter, pmlmeinfo->network.MacAddress); hw_var_set_mlme_join(padapter, 0); diff --git a/drivers/staging/rtl8723au/core/rtw_wlan_util.c b/drivers/staging/rtl8723au/core/rtw_wlan_util.c index 809d4167731f..227280230dee 100644 --- a/drivers/staging/rtl8723au/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8723au/core/rtw_wlan_util.c @@ -283,14 +283,6 @@ void Update23aTblForSoftAP(u8 *bssrateset, u32 bssratelen) } } -void Switch_DM_Func23a(struct rtw_adapter *padapter, unsigned long mode, u8 enable) -{ - if (enable == true) - rtw_hal_set_hwreg23a(padapter, HW_VAR_DM_FUNC_SET, (u8 *)(&mode)); - else - rtw_hal_set_hwreg23a(padapter, HW_VAR_DM_FUNC_CLR, (u8 *)(&mode)); -} - void Set_MSR23a(struct rtw_adapter *padapter, u8 type) { rtl8723a_set_media_status(padapter, type); @@ -1485,15 +1477,15 @@ void update_IOT_info23a(struct rtw_adapter *padapter) pmlmeinfo->turboMode_cts2self = 0; pmlmeinfo->turboMode_rtsen = 1; /* disable high power */ - Switch_DM_Func23a(padapter, ~DYNAMIC_BB_DYNAMIC_TXPWR, - false); + rtl8723a_odm_support_ability_clr(padapter, (u32) + ~DYNAMIC_BB_DYNAMIC_TXPWR); break; case HT_IOT_PEER_REALTEK: /* rtw_write16(padapter, 0x4cc, 0xffff); */ /* rtw_write16(padapter, 0x546, 0x01c0); */ /* disable high power */ - Switch_DM_Func23a(padapter, ~DYNAMIC_BB_DYNAMIC_TXPWR, - false); + rtl8723a_odm_support_ability_clr(padapter, (u32) + ~DYNAMIC_BB_DYNAMIC_TXPWR); break; default: pmlmeinfo->turboMode_cts2self = 0; diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c index 79e63bfb0b2e..62089f846838 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c @@ -3142,13 +3142,6 @@ void SetHwReg8723A(struct rtw_adapter *padapter, u8 variable, u8 *val) case HW_VAR_DM_FLAG: rtl8723a_odm_support_ability_write(padapter, *val32); break; - case HW_VAR_DM_FUNC_SET: - rtl8723a_odm_support_ability_set(padapter, *val32); - break; - - case HW_VAR_DM_FUNC_CLR: - rtl8723a_odm_support_ability_clr(padapter, *val32); - break; case HW_VAR_EFUSE_BYTES: pHalData->EfuseUsedBytes = *((u16 *) val); diff --git a/drivers/staging/rtl8723au/include/hal_intf.h b/drivers/staging/rtl8723au/include/hal_intf.h index 2218032ef617..2675fc09fecf 100644 --- a/drivers/staging/rtl8723au/include/hal_intf.h +++ b/drivers/staging/rtl8723au/include/hal_intf.h @@ -40,8 +40,6 @@ enum HW_VARIABLES { HW_VAR_TXPAUSE, HW_VAR_RF_TYPE, HW_VAR_DM_FLAG, - HW_VAR_DM_FUNC_SET, - HW_VAR_DM_FUNC_CLR, HW_VAR_CAM_READ, HW_VAR_FWLPS_RF_ON, HW_VAR_TDLS_WRCR, diff --git a/drivers/staging/rtl8723au/include/rtw_mlme_ext.h b/drivers/staging/rtl8723au/include/rtw_mlme_ext.h index 53b2d0a34734..7729b2be25ae 100644 --- a/drivers/staging/rtl8723au/include/rtw_mlme_ext.h +++ b/drivers/staging/rtl8723au/include/rtw_mlme_ext.h @@ -474,8 +474,6 @@ void get_rate_set23a(struct rtw_adapter *padapter, unsigned char *pbssrate, void UpdateBrateTbl23a(struct rtw_adapter *padapter,u8 *mBratesOS); void Update23aTblForSoftAP(u8 *bssrateset, u32 bssratelen); -void Switch_DM_Func23a(struct rtw_adapter *padapter, unsigned long mode, u8 enable); - void Set_MSR23a(struct rtw_adapter *padapter, u8 type); u8 rtw_get_oper_ch23a(struct rtw_adapter *adapter); -- cgit v1.2.3 From df09df24d0d682c926eee174dc1f1692b03f577a Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 9 Apr 2014 23:20:44 +0200 Subject: staging: rtl8723au: Eliminate HW_VAR_DM_FLAG Both the read and write calls were never used Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/hal/hal_com.c | 7 ------- drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c | 12 ------------ drivers/staging/rtl8723au/include/hal_intf.h | 1 - 3 files changed, 20 deletions(-) diff --git a/drivers/staging/rtl8723au/hal/hal_com.c b/drivers/staging/rtl8723au/hal/hal_com.c index 66adec743a85..62281287456f 100644 --- a/drivers/staging/rtl8723au/hal/hal_com.c +++ b/drivers/staging/rtl8723au/hal/hal_com.c @@ -865,13 +865,6 @@ void rtl8723a_set_initial_gain(struct rtw_adapter *padapter, u32 rx_gain) } } -void rtl8723a_odm_support_ability_write(struct rtw_adapter *padapter, u32 val) -{ - struct hal_data_8723a *pHalData = GET_HAL_DATA(padapter); - - pHalData->odmpriv.SupportAbility = val; -} - void rtl8723a_odm_support_ability_restore(struct rtw_adapter *padapter) { struct hal_data_8723a *pHalData = GET_HAL_DATA(padapter); diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c index 62089f846838..2c5334512129 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c @@ -3132,17 +3132,12 @@ void hw_var_set_mlme_join(struct rtw_adapter *padapter, u8 type) void SetHwReg8723A(struct rtw_adapter *padapter, u8 variable, u8 *val) { struct hal_data_8723a *pHalData = GET_HAL_DATA(padapter); - u32 *val32 = (u32 *)val; switch (variable) { case HW_VAR_TXPAUSE: rtl8723a_set_tx_pause(padapter, *val); break; - case HW_VAR_DM_FLAG: - rtl8723a_odm_support_ability_write(padapter, *val32); - break; - case HW_VAR_EFUSE_BYTES: pHalData->EfuseUsedBytes = *((u16 *) val); break; @@ -3172,13 +3167,6 @@ void GetHwReg8723A(struct rtw_adapter *padapter, u8 variable, u8 *val) *val = pHalData->rf_type; break; - case HW_VAR_DM_FLAG: - { - struct dm_odm_t *podmpriv = &pHalData->odmpriv; - *((u32 *) val) = podmpriv->SupportAbility; - } - break; - case HW_VAR_FWLPS_RF_ON: { /* When we halt NIC, we should check if FW LPS is leave. */ diff --git a/drivers/staging/rtl8723au/include/hal_intf.h b/drivers/staging/rtl8723au/include/hal_intf.h index 2675fc09fecf..1fd253733277 100644 --- a/drivers/staging/rtl8723au/include/hal_intf.h +++ b/drivers/staging/rtl8723au/include/hal_intf.h @@ -39,7 +39,6 @@ enum HW_VARIABLES { HW_VAR_INIT_RTS_RATE, HW_VAR_TXPAUSE, HW_VAR_RF_TYPE, - HW_VAR_DM_FLAG, HW_VAR_CAM_READ, HW_VAR_FWLPS_RF_ON, HW_VAR_TDLS_WRCR, -- cgit v1.2.3 From 441ffea706564f710af1d532ff708ef0b0e24911 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 9 Apr 2014 23:20:45 +0200 Subject: staging: rtl8723au: Remove HW_VAR_APFM_ON_MAC None of this was ever used, so pull it out together with related variables Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/hal/hal_com.c | 8 -------- drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c | 6 ------ drivers/staging/rtl8723au/include/hal_intf.h | 1 - drivers/staging/rtl8723au/include/rtl8723a_hal.h | 8 -------- 4 files changed, 23 deletions(-) diff --git a/drivers/staging/rtl8723au/hal/hal_com.c b/drivers/staging/rtl8723au/hal/hal_com.c index 62281287456f..7e657af460b1 100644 --- a/drivers/staging/rtl8723au/hal/hal_com.c +++ b/drivers/staging/rtl8723au/hal/hal_com.c @@ -755,14 +755,6 @@ void rtl8723a_fifo_cleanup(struct rtw_adapter *padapter) } } -void rtl8723a_set_apfm_on_mac(struct rtw_adapter *padapter, u8 val) -{ - struct hal_data_8723a *pHalData = GET_HAL_DATA(padapter); - - pHalData->bMacPwrCtrlOn = val; - DBG_8723A("%s: bMacPwrCtrlOn =%d\n", __func__, pHalData->bMacPwrCtrlOn); -} - void rtl8723a_bcn_valid(struct rtw_adapter *padapter) { /* BCN_VALID, BIT16 of REG_TDECTRL = BIT0 of REG_TDECTRL+2, diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c index 2c5334512129..d5ab4d787861 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c @@ -3144,9 +3144,6 @@ void SetHwReg8723A(struct rtw_adapter *padapter, u8 variable, u8 *val) case HW_VAR_EFUSE_BT_BYTES: pHalData->BTEfuseUsedBytes = *((u16 *) val); break; - case HW_VAR_APFM_ON_MAC: - rtl8723a_set_apfm_on_mac(padapter, *val); - break; default: break; @@ -3195,9 +3192,6 @@ void GetHwReg8723A(struct rtw_adapter *padapter, u8 variable, u8 *val) *((u16 *) val) = pHalData->BTEfuseUsedBytes; break; - case HW_VAR_APFM_ON_MAC: - *val = pHalData->bMacPwrCtrlOn; - break; case HW_VAR_CHK_HI_QUEUE_EMPTY: *val = ((rtw_read32(padapter, REG_HGQ_INFORMATION) & 0x0000ff00) == diff --git a/drivers/staging/rtl8723au/include/hal_intf.h b/drivers/staging/rtl8723au/include/hal_intf.h index 1fd253733277..39ddbcb3d717 100644 --- a/drivers/staging/rtl8723au/include/hal_intf.h +++ b/drivers/staging/rtl8723au/include/hal_intf.h @@ -54,7 +54,6 @@ enum HW_VARIABLES { HW_VAR_SWITCH_EPHY_WoWLAN, HW_VAR_EFUSE_BYTES, HW_VAR_EFUSE_BT_BYTES, - HW_VAR_APFM_ON_MAC, /* Auto FSM to Turn On, include clock, isolation, power control for MAC only */ /* The valid upper nav range for the HW updating, if the true value is larger than the upper range, the HW won't update it. */ /* Unit in microsecond. 0 means disable this function. */ HW_VAR_RPT_TIMER_SETTING, diff --git a/drivers/staging/rtl8723au/include/rtl8723a_hal.h b/drivers/staging/rtl8723au/include/rtl8723a_hal.h index c20248bab717..5fce43cd55a4 100644 --- a/drivers/staging/rtl8723au/include/rtl8723a_hal.h +++ b/drivers/staging/rtl8723au/include/rtl8723a_hal.h @@ -437,14 +437,6 @@ struct hal_data_8723a { /* Interrupt related register information. */ u32 IntArray[2]; u32 IntrMask[2]; - - /* */ - /* For SDIO Interface HAL related */ - /* */ - - /* Auto FSM to Turn On, include clock, isolation, power control for MAC only */ - u8 bMacPwrCtrlOn; - }; #define GET_HAL_DATA(__pAdapter) ((struct hal_data_8723a *)((__pAdapter)->HalData)) -- cgit v1.2.3 From a2342292e59a42d357ad98cc516438d476855a0b Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 9 Apr 2014 23:20:46 +0200 Subject: staging: rtl8723au: Remove HW_VAR_EFUSE_{BT_,}BYTES Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c | 45 ++++++++--------------- drivers/staging/rtl8723au/include/hal_intf.h | 2 - 2 files changed, 16 insertions(+), 31 deletions(-) diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c index d5ab4d787861..6c1af4919214 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c @@ -619,6 +619,7 @@ hal_ReadEFuse_WiFi(struct rtw_adapter *padapter, u8 offset, wden; u8 efuseHeader, efuseExtHdr, efuseData; u16 i, total, used; + struct hal_data_8723a *pHalData = GET_HAL_DATA(padapter); /* Do NOT excess total size of EFuse table. Added by Roger, 2008.11.10. */ @@ -696,7 +697,7 @@ hal_ReadEFuse_WiFi(struct rtw_adapter *padapter, EFUSE_GetEfuseDefinition23a(padapter, EFUSE_WIFI, TYPE_AVAILABLE_EFUSE_BYTES_TOTAL, &total); used = eFuse_Addr - 1; - rtw_hal_set_hwreg23a(padapter, HW_VAR_EFUSE_BYTES, (u8 *)&used); + pHalData->EfuseUsedBytes = used; kfree(efuseTbl); } @@ -711,6 +712,7 @@ hal_ReadEFuse_BT(struct rtw_adapter *padapter, u8 efuseHeader, efuseExtHdr, efuseData; u8 offset, wden; u16 i, total, used; + struct hal_data_8723a *pHalData = GET_HAL_DATA(padapter); /* Do NOT excess total size of EFuse table. Added by Roger, 2008.11.10. */ @@ -812,7 +814,7 @@ hal_ReadEFuse_BT(struct rtw_adapter *padapter, EFUSE_GetEfuseDefinition23a(padapter, EFUSE_BT, TYPE_AVAILABLE_EFUSE_BYTES_TOTAL, &total); used = (EFUSE_BT_REAL_BANK_CONTENT_LEN * (bank - 1)) + eFuse_Addr - 1; - rtw_hal_set_hwreg23a(padapter, HW_VAR_EFUSE_BT_BYTES, (u8 *) &used); + pHalData->BTEfuseUsedBytes = used; exit: kfree(efuseTbl); @@ -834,8 +836,9 @@ hal_EfuseGetCurrentSize_WiFi(struct rtw_adapter *padapter) u16 efuse_addr = 0; u8 hoffset = 0, hworden = 0; u8 efuse_data, word_cnts = 0; + struct hal_data_8723a *pHalData = GET_HAL_DATA(padapter); - rtw23a_hal_get_hwreg(padapter, HW_VAR_EFUSE_BYTES, (u8 *) &efuse_addr); + efuse_addr = pHalData->EfuseUsedBytes; DBG_8723A("%s: start_efuse_addr = 0x%X\n", __func__, efuse_addr); @@ -872,7 +875,7 @@ hal_EfuseGetCurrentSize_WiFi(struct rtw_adapter *padapter) efuse_addr += (word_cnts * 2) + 1; } - rtw_hal_set_hwreg23a(padapter, HW_VAR_EFUSE_BYTES, (u8 *) &efuse_addr); + pHalData->EfuseUsedBytes = efuse_addr; DBG_8723A("%s: CurrentSize =%d\n", __func__, efuse_addr); @@ -888,8 +891,9 @@ hal_EfuseGetCurrentSize_BT(struct rtw_adapter *padapter) u8 hoffset = 0, hworden = 0; u8 efuse_data, word_cnts = 0; u16 retU2 = 0; + struct hal_data_8723a *pHalData = GET_HAL_DATA(padapter); - rtw23a_hal_get_hwreg(padapter, HW_VAR_EFUSE_BT_BYTES, (u8 *) &btusedbytes); + btusedbytes = pHalData->BTEfuseUsedBytes; efuse_addr = (u16) ((btusedbytes % EFUSE_BT_REAL_BANK_CONTENT_LEN)); startBank = (u8) (1 + (btusedbytes / EFUSE_BT_REAL_BANK_CONTENT_LEN)); @@ -954,7 +958,7 @@ hal_EfuseGetCurrentSize_BT(struct rtw_adapter *padapter) } retU2 = ((bank - 1) * EFUSE_BT_REAL_BANK_CONTENT_LEN) + efuse_addr; - rtw_hal_set_hwreg23a(padapter, HW_VAR_EFUSE_BT_BYTES, (u8 *)&retU2); + pHalData->BTEfuseUsedBytes = retU2; DBG_8723A("%s: CurrentSize =%d\n", __func__, retU2); return retU2; @@ -1144,6 +1148,7 @@ static u8 hal_EfusePartialWriteCheck(struct rtw_adapter *padapter, u8 efuseType, u16 *pAddr, struct pg_pkt_struct *pTargetPkt) { + struct hal_data_8723a *pHalData = GET_HAL_DATA(padapter); u8 bRet = false; u16 startAddr = 0, efuse_max_available_len = 0, efuse_max = 0; u8 efuse_data = 0; @@ -1154,13 +1159,11 @@ hal_EfusePartialWriteCheck(struct rtw_adapter *padapter, u8 efuseType, EFUSE_GetEfuseDefinition23a(padapter, efuseType, TYPE_EFUSE_CONTENT_LEN_BANK, &efuse_max); - if (efuseType == EFUSE_WIFI) { - rtw23a_hal_get_hwreg(padapter, HW_VAR_EFUSE_BYTES, - (u8 *) &startAddr); - } else { - rtw23a_hal_get_hwreg(padapter, HW_VAR_EFUSE_BT_BYTES, - (u8 *) &startAddr); - } + if (efuseType == EFUSE_WIFI) + startAddr = pHalData->EfuseUsedBytes; + else + startAddr = pHalData->BTEfuseUsedBytes; + startAddr %= efuse_max; while (1) { @@ -3131,20 +3134,11 @@ void hw_var_set_mlme_join(struct rtw_adapter *padapter, u8 type) void SetHwReg8723A(struct rtw_adapter *padapter, u8 variable, u8 *val) { - struct hal_data_8723a *pHalData = GET_HAL_DATA(padapter); - switch (variable) { case HW_VAR_TXPAUSE: rtl8723a_set_tx_pause(padapter, *val); break; - case HW_VAR_EFUSE_BYTES: - pHalData->EfuseUsedBytes = *((u16 *) val); - break; - case HW_VAR_EFUSE_BT_BYTES: - pHalData->BTEfuseUsedBytes = *((u16 *) val); - break; - default: break; } @@ -3184,13 +3178,6 @@ void GetHwReg8723A(struct rtw_adapter *padapter, u8 variable, u8 *val) } } break; - case HW_VAR_EFUSE_BYTES: - *((u16 *) val) = pHalData->EfuseUsedBytes; - break; - - case HW_VAR_EFUSE_BT_BYTES: - *((u16 *) val) = pHalData->BTEfuseUsedBytes; - break; case HW_VAR_CHK_HI_QUEUE_EMPTY: *val = diff --git a/drivers/staging/rtl8723au/include/hal_intf.h b/drivers/staging/rtl8723au/include/hal_intf.h index 39ddbcb3d717..b6362deff01a 100644 --- a/drivers/staging/rtl8723au/include/hal_intf.h +++ b/drivers/staging/rtl8723au/include/hal_intf.h @@ -52,8 +52,6 @@ enum HW_VARIABLES { HW_VAR_ANTENNA_DIVERSITY_LINK, HW_VAR_ANTENNA_DIVERSITY_SELECT, HW_VAR_SWITCH_EPHY_WoWLAN, - HW_VAR_EFUSE_BYTES, - HW_VAR_EFUSE_BT_BYTES, /* The valid upper nav range for the HW updating, if the true value is larger than the upper range, the HW won't update it. */ /* Unit in microsecond. 0 means disable this function. */ HW_VAR_RPT_TIMER_SETTING, -- cgit v1.2.3 From aafb8684a8540a9266d0953b815ea55fb4f6c50a Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 9 Apr 2014 23:20:47 +0200 Subject: staging: rtl8723au: Remove HW_VAR_TXPAUSE This wasn't used at all Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/hal/hal_com.c | 5 ----- drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c | 8 -------- drivers/staging/rtl8723au/include/hal_com.h | 1 - drivers/staging/rtl8723au/include/hal_intf.h | 1 - 4 files changed, 15 deletions(-) diff --git a/drivers/staging/rtl8723au/hal/hal_com.c b/drivers/staging/rtl8723au/hal/hal_com.c index 7e657af460b1..38fef52c6020 100644 --- a/drivers/staging/rtl8723au/hal/hal_com.c +++ b/drivers/staging/rtl8723au/hal/hal_com.c @@ -772,11 +772,6 @@ bool rtl8723a_get_bcn_valid(struct rtw_adapter *padapter) return retval; } -void rtl8723a_set_tx_pause(struct rtw_adapter *padapter, u8 pause) -{ - rtw_write8(padapter, REG_TXPAUSE, pause); -} - void rtl8723a_set_beacon_interval(struct rtw_adapter *padapter, u16 interval) { rtw_write16(padapter, REG_BCN_INTERVAL, interval); diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c index 6c1af4919214..29ec6ab61c7c 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c @@ -3135,10 +3135,6 @@ void hw_var_set_mlme_join(struct rtw_adapter *padapter, u8 type) void SetHwReg8723A(struct rtw_adapter *padapter, u8 variable, u8 *val) { switch (variable) { - case HW_VAR_TXPAUSE: - rtl8723a_set_tx_pause(padapter, *val); - break; - default: break; } @@ -3150,10 +3146,6 @@ void GetHwReg8723A(struct rtw_adapter *padapter, u8 variable, u8 *val) struct hal_data_8723a *pHalData = GET_HAL_DATA(padapter); switch (variable) { - case HW_VAR_TXPAUSE: - *val = rtw_read8(padapter, REG_TXPAUSE); - break; - case HW_VAR_RF_TYPE: *val = pHalData->rf_type; break; diff --git a/drivers/staging/rtl8723au/include/hal_com.h b/drivers/staging/rtl8723au/include/hal_com.h index e8774fc602c0..832cbac4ac9e 100644 --- a/drivers/staging/rtl8723au/include/hal_com.h +++ b/drivers/staging/rtl8723au/include/hal_com.h @@ -189,7 +189,6 @@ void rtl8723a_fifo_cleanup(struct rtw_adapter *padapter); void rtl8723a_set_apfm_on_mac(struct rtw_adapter *padapter, u8 val); void rtl8723a_bcn_valid(struct rtw_adapter *padapter); bool rtl8723a_get_bcn_valid(struct rtw_adapter *padapter); -void rtl8723a_set_tx_pause(struct rtw_adapter *padapter, u8 pause); void rtl8723a_set_beacon_interval(struct rtw_adapter *padapter, u16 interval); void rtl8723a_set_resp_sifs(struct rtw_adapter *padapter, u8 r2t1, u8 r2t2, u8 t2t1, u8 t2t2); diff --git a/drivers/staging/rtl8723au/include/hal_intf.h b/drivers/staging/rtl8723au/include/hal_intf.h index b6362deff01a..d86a8f12b822 100644 --- a/drivers/staging/rtl8723au/include/hal_intf.h +++ b/drivers/staging/rtl8723au/include/hal_intf.h @@ -37,7 +37,6 @@ enum _CHIP_TYPE { enum HW_VARIABLES { HW_VAR_INIT_RTS_RATE, - HW_VAR_TXPAUSE, HW_VAR_RF_TYPE, HW_VAR_CAM_READ, HW_VAR_FWLPS_RF_ON, -- cgit v1.2.3 From 4b03eb73ca441ea9756e304c9115a8009eb33b04 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 9 Apr 2014 23:20:48 +0200 Subject: staging: rtl8723au: Eliminate unused HW_VAR_TRIGGER_GPIO_0 ... and related functions Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/hal/usb_halinit.c | 18 ------------------ drivers/staging/rtl8723au/include/hal_intf.h | 1 - 2 files changed, 19 deletions(-) diff --git a/drivers/staging/rtl8723au/hal/usb_halinit.c b/drivers/staging/rtl8723au/hal/usb_halinit.c index aaa81f87cc6e..382bca56825a 100644 --- a/drivers/staging/rtl8723au/hal/usb_halinit.c +++ b/drivers/staging/rtl8723au/hal/usb_halinit.c @@ -1496,21 +1496,6 @@ static void ReadAdapterInfo8723AU(struct rtw_adapter *Adapter) _ReadAdapterInfo8723AU(Adapter); } -#define GPIO_DEBUG_PORT_NUM 0 -static void rtl8723au_trigger_gpio_0(struct rtw_adapter *padapter) -{ - u32 gpioctrl; - DBG_8723A("==> trigger_gpio_0...\n"); - rtw_write16_async(padapter, REG_GPIO_PIN_CTRL, 0); - rtw_write8_async(padapter, REG_GPIO_PIN_CTRL+2, 0xFF); - gpioctrl = (BIT(GPIO_DEBUG_PORT_NUM) << 24)| - (BIT(GPIO_DEBUG_PORT_NUM) << 16); - rtw_write32_async(padapter, REG_GPIO_PIN_CTRL, gpioctrl); - gpioctrl |= (BIT(GPIO_DEBUG_PORT_NUM)<<8); - rtw_write32_async(padapter, REG_GPIO_PIN_CTRL, gpioctrl); - DBG_8723A("<=== trigger_gpio_0...\n"); -} - /* * If variable not handled here, * some variables will be processed in SetHwReg8723A() @@ -1518,9 +1503,6 @@ static void rtl8723au_trigger_gpio_0(struct rtw_adapter *padapter) static void SetHwReg8723AU(struct rtw_adapter *Adapter, u8 variable, u8 *val) { switch (variable) { - case HW_VAR_TRIGGER_GPIO_0: - rtl8723au_trigger_gpio_0(Adapter); - break; default: SetHwReg8723A(Adapter, variable, val); break; diff --git a/drivers/staging/rtl8723au/include/hal_intf.h b/drivers/staging/rtl8723au/include/hal_intf.h index d86a8f12b822..a4b48772fd88 100644 --- a/drivers/staging/rtl8723au/include/hal_intf.h +++ b/drivers/staging/rtl8723au/include/hal_intf.h @@ -44,7 +44,6 @@ enum HW_VARIABLES { HW_VAR_TDLS_INIT_CH_SEN, HW_VAR_TDLS_RS_RCR, HW_VAR_TDLS_DONE_CH_SEN, - HW_VAR_TRIGGER_GPIO_0, HW_VAR_BT_SET_COEXIST, HW_VAR_BT_ISSUE_DELBA, HW_VAR_CURRENT_ANTENNA, -- cgit v1.2.3 From 3d577f60da985a2d0ed8935b517a3d84a98023dd Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 9 Apr 2014 23:20:49 +0200 Subject: staging: rtl8723au: Remove calls to HW_VAR_H2C_MEDIA_STATUS This call was unhandled, so these calls were effectively a no-op Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme.c | 15 ++------------- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 4 ---- drivers/staging/rtl8723au/include/hal_intf.h | 1 - 3 files changed, 2 insertions(+), 18 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme.c b/drivers/staging/rtl8723au/core/rtw_mlme.c index 9cf26ea0088b..e6969362261d 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme.c @@ -1299,12 +1299,8 @@ void rtw23a_joinbss_event_cb(struct rtw_adapter *adapter, u8 *pbuf) /* FOR AP , AD-HOC mode */ void rtw_stassoc_hw_rpt23a(struct rtw_adapter *adapter, struct sta_info *psta) { - u16 media_status; - - if (psta == NULL) return; - - media_status = (psta->mac_id<<8)|1; /* MACID|OPMODE:1 connect */ - rtw_hal_set_hwreg23a(adapter, HW_VAR_H2C_MEDIA_STATUS_RPT, (u8 *)&media_status); + if (psta == NULL) + return; } void rtw_stassoc_event_callback23a(struct rtw_adapter *adapter, u8 *pbuf) @@ -1402,13 +1398,6 @@ void rtw_stadel_event_callback23a(struct rtw_adapter *adapter, u8 *pbuf) DBG_8723A("%s(mac_id=%d)=" MAC_FMT "\n", __func__, mac_id, MAC_ARG(pstadel->macaddr)); - 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_hwreg23a(adapter, HW_VAR_H2C_MEDIA_STATUS_RPT, (u8 *)&media_status); - } - if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) { return; diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index 94ba6ef8f24b..ff7ff9eb2403 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -8677,7 +8677,6 @@ void mlmeext_joinbss_event_callback23a(struct rtw_adapter *padapter, int join_re struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; struct wlan_bssid_ex *cur_network = &pmlmeinfo->network; struct sta_priv *pstapriv = &padapter->stapriv; - u16 media_status; if (join_res < 0) { hw_var_set_mlme_join(padapter, 1); @@ -8736,9 +8735,6 @@ void mlmeext_joinbss_event_callback23a(struct rtw_adapter *padapter, int join_re /* set per sta rate after updating HT cap. */ set_sta_rate23a(padapter, psta); - - media_status = (psta->mac_id<<8)|1; /* MACID|OPMODE: 1 means connect */ - rtw_hal_set_hwreg23a(padapter, HW_VAR_H2C_MEDIA_STATUS_RPT, (u8 *)&media_status); } hw_var_set_mlme_join(padapter, 2); diff --git a/drivers/staging/rtl8723au/include/hal_intf.h b/drivers/staging/rtl8723au/include/hal_intf.h index a4b48772fd88..bb27488e12eb 100644 --- a/drivers/staging/rtl8723au/include/hal_intf.h +++ b/drivers/staging/rtl8723au/include/hal_intf.h @@ -54,7 +54,6 @@ enum HW_VARIABLES { /* Unit in microsecond. 0 means disable this function. */ HW_VAR_RPT_TIMER_SETTING, HW_VAR_TX_RPT_MAX_MACID, - HW_VAR_H2C_MEDIA_STATUS_RPT, HW_VAR_CHK_HI_QUEUE_EMPTY, HW_VAR_READ_LLT_TAB, }; -- cgit v1.2.3 From 891d3decbb7ea6999a87dbca3774be4580586af0 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 9 Apr 2014 23:20:50 +0200 Subject: staging: rtl8723au: Remove SetHwReg*() related code Remove all references to this odd mux/demux pseudo hw register handling code. Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/hal/hal_intf.c | 6 ------ drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c | 9 --------- drivers/staging/rtl8723au/hal/usb_halinit.c | 15 --------------- drivers/staging/rtl8723au/include/hal_intf.h | 3 --- drivers/staging/rtl8723au/include/rtl8723a_hal.h | 1 - 5 files changed, 34 deletions(-) diff --git a/drivers/staging/rtl8723au/hal/hal_intf.c b/drivers/staging/rtl8723au/hal/hal_intf.c index de3608b4010a..cafe347de63b 100644 --- a/drivers/staging/rtl8723au/hal/hal_intf.c +++ b/drivers/staging/rtl8723au/hal/hal_intf.c @@ -117,12 +117,6 @@ uint rtw_hal_deinit23a(struct rtw_adapter *padapter) return status; } -void rtw_hal_set_hwreg23a(struct rtw_adapter *padapter, u8 variable, u8 *val) -{ - if (padapter->HalFunc.SetHwRegHandler) - padapter->HalFunc.SetHwRegHandler(padapter, variable, val); -} - void rtw23a_hal_get_hwreg(struct rtw_adapter *padapter, u8 variable, u8 *val) { if (padapter->HalFunc.GetHwRegHandler) diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c index 29ec6ab61c7c..f8ceeb27fb76 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c @@ -3132,15 +3132,6 @@ void hw_var_set_mlme_join(struct rtw_adapter *padapter, u8 type) #endif } -void SetHwReg8723A(struct rtw_adapter *padapter, u8 variable, u8 *val) -{ - switch (variable) { - default: - break; - } - -} - void GetHwReg8723A(struct rtw_adapter *padapter, u8 variable, u8 *val) { struct hal_data_8723a *pHalData = GET_HAL_DATA(padapter); diff --git a/drivers/staging/rtl8723au/hal/usb_halinit.c b/drivers/staging/rtl8723au/hal/usb_halinit.c index 382bca56825a..53ef7c39eae5 100644 --- a/drivers/staging/rtl8723au/hal/usb_halinit.c +++ b/drivers/staging/rtl8723au/hal/usb_halinit.c @@ -1496,20 +1496,6 @@ static void ReadAdapterInfo8723AU(struct rtw_adapter *Adapter) _ReadAdapterInfo8723AU(Adapter); } -/* - * If variable not handled here, - * some variables will be processed in SetHwReg8723A() - */ -static void SetHwReg8723AU(struct rtw_adapter *Adapter, u8 variable, u8 *val) -{ - switch (variable) { - default: - SetHwReg8723A(Adapter, variable, val); - break; - } - -} - /* * If variable not handled here, * some variables will be processed in GetHwReg8723A() @@ -1796,7 +1782,6 @@ int rtl8723au_set_hal_ops(struct rtw_adapter *padapter) pHalFunc->init_default_value = &rtl8723au_init_default_value; pHalFunc->intf_chip_configure = &rtl8723au_interface_configure; pHalFunc->read_adapter_info = &ReadAdapterInfo8723AU; - pHalFunc->SetHwRegHandler = &SetHwReg8723AU; pHalFunc->GetHwRegHandler = &GetHwReg8723AU; pHalFunc->GetHalDefVarHandler = &GetHalDefVar8192CUsb; pHalFunc->SetHalDefVarHandler = &SetHalDefVar8192CUsb; diff --git a/drivers/staging/rtl8723au/include/hal_intf.h b/drivers/staging/rtl8723au/include/hal_intf.h index bb27488e12eb..d38a670ca431 100644 --- a/drivers/staging/rtl8723au/include/hal_intf.h +++ b/drivers/staging/rtl8723au/include/hal_intf.h @@ -126,8 +126,6 @@ struct hal_ops { void (*hal_dm_watchdog)(struct rtw_adapter *padapter); - void (*SetHwRegHandler)(struct rtw_adapter *padapter, - u8 variable, u8 *val); void (*GetHwRegHandler)(struct rtw_adapter *padapter, u8 variable, u8 *val); @@ -263,7 +261,6 @@ u32 rtw_hal_power_on23a(struct rtw_adapter *padapter); uint rtw_hal_init23a(struct rtw_adapter *padapter); uint rtw_hal_deinit23a(struct rtw_adapter *padapter); void rtw_hal_stop(struct rtw_adapter *padapter); -void rtw_hal_set_hwreg23a(struct rtw_adapter *padapter, u8 variable, u8 *val); void rtw23a_hal_get_hwreg(struct rtw_adapter *padapter, u8 variable, u8 *val); void rtw_hal_chip_configure23a(struct rtw_adapter *padapter); diff --git a/drivers/staging/rtl8723au/include/rtl8723a_hal.h b/drivers/staging/rtl8723au/include/rtl8723a_hal.h index 5fce43cd55a4..49d743dc68de 100644 --- a/drivers/staging/rtl8723au/include/rtl8723a_hal.h +++ b/drivers/staging/rtl8723au/include/rtl8723a_hal.h @@ -548,7 +548,6 @@ void Hal_EfuseParseThermalMeter_8723A(struct rtw_adapter *padapter, u8 *hwinfo, void Hal_InitChannelPlan23a(struct rtw_adapter *padapter); void rtl8723a_set_hal_ops(struct hal_ops *pHalFunc); -void SetHwReg8723A(struct rtw_adapter *padapter, u8 variable, u8 *val); void GetHwReg8723A(struct rtw_adapter *padapter, u8 variable, u8 *val); #ifdef CONFIG_8723AU_BT_COEXIST void rtl8723a_SingleDualAntennaDetection(struct rtw_adapter *padapter); -- cgit v1.2.3 From f075870605b496794041430519f43fd37024ae07 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 9 Apr 2014 23:20:51 +0200 Subject: staging: rtl8723au: Remove empty function rtw_stassoc_hw_rpt23a() Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_ap.c | 2 -- drivers/staging/rtl8723au/core/rtw_mlme.c | 11 ----------- drivers/staging/rtl8723au/include/rtw_mlme.h | 1 - 3 files changed, 14 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_ap.c b/drivers/staging/rtl8723au/core/rtw_ap.c index c18eee9222ce..75b52bf5dccf 100644 --- a/drivers/staging/rtl8723au/core/rtw_ap.c +++ b/drivers/staging/rtl8723au/core/rtw_ap.c @@ -523,8 +523,6 @@ static void update_bmc_sta(struct rtw_adapter *padapter) psta->raid = raid; psta->init_rate = init_rate; - rtw_stassoc_hw_rpt23a(padapter, psta); - spin_lock_bh(&psta->lock); psta->state = _FW_LINKED; spin_unlock_bh(&psta->lock); diff --git a/drivers/staging/rtl8723au/core/rtw_mlme.c b/drivers/staging/rtl8723au/core/rtw_mlme.c index e6969362261d..22e71702a84a 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme.c @@ -1296,13 +1296,6 @@ void rtw23a_joinbss_event_cb(struct rtw_adapter *adapter, u8 *pbuf) } -/* FOR AP , AD-HOC mode */ -void rtw_stassoc_hw_rpt23a(struct rtw_adapter *adapter, struct sta_info *psta) -{ - if (psta == NULL) - return; -} - void rtw_stassoc_event_callback23a(struct rtw_adapter *adapter, u8 *pbuf) { struct sta_info *psta; @@ -1322,8 +1315,6 @@ void rtw_stassoc_event_callback23a(struct rtw_adapter *adapter, u8 *pbuf) /* bss_cap_update_on_sta_join23a(adapter, psta); */ /* sta_info_update23a(adapter, psta); */ ap_sta_info_defer_update23a(adapter, psta); - - rtw_stassoc_hw_rpt23a(adapter,psta); } return; } @@ -1350,8 +1341,6 @@ void rtw_stassoc_event_callback23a(struct rtw_adapter *adapter, u8 *pbuf) /* for ad-hoc mode */ rtw_hal_set_odm_var23a(adapter,HAL_ODM_STA_INFO,psta,true); - rtw_stassoc_hw_rpt23a(adapter,psta); - if(adapter->securitypriv.dot11AuthAlgrthm==dot11AuthAlgrthm_8021X) psta->dot118021XPrivacy = adapter->securitypriv.dot11PrivacyAlgrthm; diff --git a/drivers/staging/rtl8723au/include/rtw_mlme.h b/drivers/staging/rtl8723au/include/rtw_mlme.h index 31f96f39b498..dac930c77c01 100644 --- a/drivers/staging/rtl8723au/include/rtw_mlme.h +++ b/drivers/staging/rtl8723au/include/rtw_mlme.h @@ -619,6 +619,5 @@ void rtw23a_roaming(struct rtw_adapter *adapter, struct wlan_network *tgt_network); void rtw_set_roaming(struct rtw_adapter *adapter, u8 to_roaming); u8 rtw_to_roaming(struct rtw_adapter *adapter); -void rtw_stassoc_hw_rpt23a(struct rtw_adapter *adapter, struct sta_info *psta); #endif /* __RTL871X_MLME_H_ */ -- cgit v1.2.3 From b54e8804400773680a08ec73c127515c527440a8 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 9 Apr 2014 23:20:52 +0200 Subject: staging: rtl8723au: Improve some bad switch() formatting Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_ap.c | 61 ++++++++++-------------- drivers/staging/rtl8723au/core/rtw_mlme.c | 19 ++++---- drivers/staging/rtl8723au/core/rtw_p2p.c | 78 +++++++++++++++---------------- 3 files changed, 72 insertions(+), 86 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_ap.c b/drivers/staging/rtl8723au/core/rtw_ap.c index 75b52bf5dccf..e68d13aa5db5 100644 --- a/drivers/staging/rtl8723au/core/rtw_ap.c +++ b/drivers/staging/rtl8723au/core/rtw_ap.c @@ -1349,50 +1349,37 @@ void update_beacon23a(struct rtw_adapter *padapter, u8 ie_id, u8 *oui, u8 tx) switch (ie_id) { - case 0xFF: - - update_bcn_fixed_ie(padapter);/* 8: TimeStamp, 2: Beacon Interval 2:Capability */ - - break; - - case _TIM_IE_: - - update_BCNTIM(padapter); - - break; - - case _ERPINFO_IE_: - - update_bcn_erpinfo_ie(padapter); - - break; - - case _HT_CAPABILITY_IE_: - - update_bcn_htcap_ie(padapter); - - break; - - case _RSN_IE_2_: - - update_bcn_rsn_ie(padapter); - - break; + case 0xFF: + /* 8: TimeStamp, 2: Beacon Interval 2:Capability */ + update_bcn_fixed_ie(padapter); + break; - case _HT_ADD_INFO_IE_: + case _TIM_IE_: + update_BCNTIM(padapter); + break; - update_bcn_htinfo_ie(padapter); + case _ERPINFO_IE_: + update_bcn_erpinfo_ie(padapter); + break; - break; + case _HT_CAPABILITY_IE_: + update_bcn_htcap_ie(padapter); + break; - case _VENDOR_SPECIFIC_IE_: + case _RSN_IE_2_: + update_bcn_rsn_ie(padapter); + break; - update_bcn_vendor_spec_ie(padapter, oui); + case _HT_ADD_INFO_IE_: + update_bcn_htinfo_ie(padapter); + break; - break; + case _VENDOR_SPECIFIC_IE_: + update_bcn_vendor_spec_ie(padapter, oui); + break; - default: - break; + default: + break; } pmlmepriv->update_bcn = true; diff --git a/drivers/staging/rtl8723au/core/rtw_mlme.c b/drivers/staging/rtl8723au/core/rtw_mlme.c index 22e71702a84a..717ba10c66a5 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme.c @@ -2324,17 +2324,18 @@ void rtw_update_ht_cap23a(struct rtw_adapter *padapter, u8 *pie, uint ie_len) pmlmeext->cur_bwmode = HT_CHANNEL_WIDTH_40; switch ((pmlmeinfo->HT_info.infos[0] & 0x3)) { - case HT_EXTCHNL_OFFSET_UPPER: - pmlmeext->cur_ch_offset = HAL_PRIME_CHNL_OFFSET_LOWER; - break; + case HT_EXTCHNL_OFFSET_UPPER: + pmlmeext->cur_ch_offset = HAL_PRIME_CHNL_OFFSET_LOWER; + break; - case HT_EXTCHNL_OFFSET_LOWER: - pmlmeext->cur_ch_offset = HAL_PRIME_CHNL_OFFSET_UPPER; - break; + case HT_EXTCHNL_OFFSET_LOWER: + pmlmeext->cur_ch_offset = HAL_PRIME_CHNL_OFFSET_UPPER; + break; - default: - pmlmeext->cur_ch_offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE; - break; + default: + pmlmeext->cur_ch_offset = + HAL_PRIME_CHNL_OFFSET_DONT_CARE; + break; } } diff --git a/drivers/staging/rtl8723au/core/rtw_p2p.c b/drivers/staging/rtl8723au/core/rtw_p2p.c index e5d9991040bb..ba851cf4f992 100644 --- a/drivers/staging/rtl8723au/core/rtw_p2p.c +++ b/drivers/staging/rtl8723au/core/rtw_p2p.c @@ -3564,52 +3564,50 @@ void p2p_ps_wk_hdl23a(struct rtw_adapter *padapter, u8 p2p_ps_state) /* Pre action for p2p state */ switch (p2p_ps_state) { - case P2P_PS_DISABLE: + case P2P_PS_DISABLE: + pwdinfo->p2p_ps_state = p2p_ps_state; + + rtl8723a_set_p2p_ps_offload_cmd(padapter, p2p_ps_state); + + pwdinfo->noa_index = 0; + pwdinfo->ctwindow = 0; + pwdinfo->opp_ps = 0; + pwdinfo->noa_num = 0; + pwdinfo->p2p_ps_mode = P2P_PS_NONE; + if (padapter->pwrctrlpriv.bFwCurrentInPSMode == true) { + if (pwrpriv->smart_ps == 0) { + pwrpriv->smart_ps = 2; + rtl8723a_set_FwPwrMode_cmd(padapter, padapter->pwrctrlpriv.pwr_mode); + } + } + break; + case P2P_PS_ENABLE: + if (pwdinfo->p2p_ps_mode > P2P_PS_NONE) { pwdinfo->p2p_ps_state = p2p_ps_state; - rtl8723a_set_p2p_ps_offload_cmd(padapter, p2p_ps_state); - - pwdinfo->noa_index = 0; - pwdinfo->ctwindow = 0; - pwdinfo->opp_ps = 0; - pwdinfo->noa_num = 0; - pwdinfo->p2p_ps_mode = P2P_PS_NONE; - if (padapter->pwrctrlpriv.bFwCurrentInPSMode == true) { - if (pwrpriv->smart_ps == 0) { - pwrpriv->smart_ps = 2; + if (pwdinfo->ctwindow > 0) { + if (pwrpriv->smart_ps != 0) { + pwrpriv->smart_ps = 0; + DBG_8723A("%s(): Enter CTW, change " + "SmartPS\n", __func__); rtl8723a_set_FwPwrMode_cmd(padapter, padapter->pwrctrlpriv.pwr_mode); } } - break; - case P2P_PS_ENABLE: - if (pwdinfo->p2p_ps_mode > P2P_PS_NONE) { - pwdinfo->p2p_ps_state = p2p_ps_state; - - if (pwdinfo->ctwindow > 0) { - if (pwrpriv->smart_ps != 0) { - pwrpriv->smart_ps = 0; - DBG_8723A("%s(): Enter CTW, change SmartPS\n", __func__); - rtl8723a_set_FwPwrMode_cmd(padapter, padapter->pwrctrlpriv.pwr_mode); - } - } - rtl8723a_set_p2p_ps_offload_cmd(padapter, - p2p_ps_state); - } - break; - case P2P_PS_SCAN: - case P2P_PS_SCAN_DONE: - case P2P_PS_ALLSTASLEEP: - if (pwdinfo->p2p_ps_mode > P2P_PS_NONE) { - pwdinfo->p2p_ps_state = p2p_ps_state; - rtl8723a_set_p2p_ps_offload_cmd(padapter, - p2p_ps_state); - } - break; - default: - break; + rtl8723a_set_p2p_ps_offload_cmd(padapter, + p2p_ps_state); + } + break; + case P2P_PS_SCAN: + case P2P_PS_SCAN_DONE: + case P2P_PS_ALLSTASLEEP: + if (pwdinfo->p2p_ps_mode > P2P_PS_NONE) { + pwdinfo->p2p_ps_state = p2p_ps_state; + rtl8723a_set_p2p_ps_offload_cmd(padapter, p2p_ps_state); + } + break; + default: + break; } - - } u8 p2p_ps_wk_cmd23a(struct rtw_adapter*padapter, u8 p2p_ps_state, u8 enqueue) -- cgit v1.2.3 From c2370e83ab5432e2d32e9c097930c69366d27b4c Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 9 Apr 2014 23:20:53 +0200 Subject: staging: rtl8723au: Eliminate HW_VAR_RF_TYPE usage Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_ap.c | 8 ++++---- drivers/staging/rtl8723au/core/rtw_ioctl_set.c | 3 +-- drivers/staging/rtl8723au/core/rtw_mlme.c | 10 ++++------ drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 3 +-- drivers/staging/rtl8723au/core/rtw_wlan_util.c | 2 +- drivers/staging/rtl8723au/hal/hal_com.c | 7 +++++++ drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c | 6 ------ drivers/staging/rtl8723au/include/hal_com.h | 1 + drivers/staging/rtl8723au/include/hal_intf.h | 1 - drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c | 2 +- 10 files changed, 20 insertions(+), 23 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_ap.c b/drivers/staging/rtl8723au/core/rtw_ap.c index e68d13aa5db5..131d787dac78 100644 --- a/drivers/staging/rtl8723au/core/rtw_ap.c +++ b/drivers/staging/rtl8723au/core/rtw_ap.c @@ -374,9 +374,9 @@ void add_RATid23a(struct rtw_adapter *padapter, struct sta_info *psta, u8 rssi_l tx_ra_bitmap |= rtw_get_bit_value_from_ieee_value23a(psta->bssrateset[i]&0x7f); } /* n mode ra_bitmap */ - if (psta_ht->ht_option) - { - rtw23a_hal_get_hwreg(padapter, HW_VAR_RF_TYPE, (u8 *)(&rf_type)); + if (psta_ht->ht_option) { + rf_type = rtl8723a_get_rf_type(padapter); + if (rf_type == RF_2T2R) limit = 16;/* 2R */ else @@ -989,7 +989,7 @@ int rtw_check_beacon_data23a(struct rtw_adapter *padapter, u8 *pbuf, int len) ht_cap = true; network_type |= WIRELESS_11_24N; - rtw23a_hal_get_hwreg(padapter, HW_VAR_RF_TYPE, (u8 *)(&rf_type)); + rf_type = rtl8723a_get_rf_type(padapter); if ((psecuritypriv->wpa_pairwise_cipher & WPA_CIPHER_CCMP) || (psecuritypriv->wpa2_pairwise_cipher & WPA_CIPHER_CCMP)) diff --git a/drivers/staging/rtl8723au/core/rtw_ioctl_set.c b/drivers/staging/rtl8723au/core/rtw_ioctl_set.c index 30d7185e5637..1f9d3a3d4920 100644 --- a/drivers/staging/rtl8723au/core/rtw_ioctl_set.c +++ b/drivers/staging/rtl8723au/core/rtw_ioctl_set.c @@ -577,8 +577,7 @@ u16 rtw_get_cur_max_rate23a(struct rtw_adapter *adapter) short_GI_20 = (pmlmeinfo->HT_caps.u.HT_cap_element.HT_caps_info&IEEE80211_HT_CAP_SGI_20) ? 1:0; short_GI_40 = (pmlmeinfo->HT_caps.u.HT_cap_element.HT_caps_info&IEEE80211_HT_CAP_SGI_40) ? 1:0; - rtw23a_hal_get_hwreg(adapter, HW_VAR_RF_TYPE, - (u8 *)(&rf_type)); + rf_type = rtl8723a_get_rf_type(adapter); max_rate = rtw_mcs_rate23a(rf_type, bw_40MHz & pregistrypriv->cbw40_enable, short_GI_20, short_GI_40, diff --git a/drivers/staging/rtl8723au/core/rtw_mlme.c b/drivers/staging/rtl8723au/core/rtw_mlme.c index 717ba10c66a5..f72bae42dcb0 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme.c @@ -2305,16 +2305,14 @@ void rtw_update_ht_cap23a(struct rtw_adapter *padapter, u8 *pie, uint ie_len) /* update cur_bwmode & cur_ch_offset */ if ((pregistrypriv->cbw40_enable) && (pmlmeinfo->HT_caps.u.HT_cap_element.HT_caps_info & BIT(1)) && - (pmlmeinfo->HT_info.infos[0] & BIT(2))) - { + (pmlmeinfo->HT_info.infos[0] & BIT(2))) { int i; - u8 rf_type; + u8 rf_type; - padapter->HalFunc.GetHwRegHandler(padapter, HW_VAR_RF_TYPE, (u8 *)(&rf_type)); + rf_type = rtl8723a_get_rf_type(padapter); /* update the MCS rates */ - for (i = 0; i < 16; i++) - { + for (i = 0; i < 16; i++) { if ((rf_type == RF_1T1R) || (rf_type == RF_1T2R)) pmlmeinfo->HT_caps.u.HT_cap_element.MCS_rate[i] &= MCS_rate_1R23A[i]; else diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index ff7ff9eb2403..ae6ef6532af0 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -6454,8 +6454,7 @@ void issue_assocreq23a(struct rtw_adapter *padapter) pmlmeinfo->HT_caps.u.HT_cap_element.HT_caps_info |= 0x000c; - rtw23a_hal_get_hwreg(padapter, HW_VAR_RF_TYPE, - (u8 *)(&rf_type)); + rf_type = rtl8723a_get_rf_type(padapter); /* switch (pregpriv->rf_config) */ switch (rf_type) { diff --git a/drivers/staging/rtl8723au/core/rtw_wlan_util.c b/drivers/staging/rtl8723au/core/rtw_wlan_util.c index 227280230dee..e364d7afc08d 100644 --- a/drivers/staging/rtl8723au/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8723au/core/rtw_wlan_util.c @@ -770,7 +770,7 @@ void HT_caps_handler23a(struct rtw_adapter *padapter, struct ndis_802_11_var_ies pmlmeinfo->HT_caps.u.HT_cap_element.HT_caps_info = le16_to_cpu(pmlmeinfo->HT_caps.u.HT_cap_element.HT_caps_info); pmlmeinfo->HT_caps.u.HT_cap_element.HT_ext_caps = le16_to_cpu(pmlmeinfo->HT_caps.u.HT_cap_element.HT_ext_caps); - rtw23a_hal_get_hwreg(padapter, HW_VAR_RF_TYPE, (u8 *)(&rf_type)); + rf_type = rtl8723a_get_rf_type(padapter); /* update the MCS rates */ for (i = 0; i < 16; i++) { diff --git a/drivers/staging/rtl8723au/hal/hal_com.c b/drivers/staging/rtl8723au/hal/hal_com.c index 38fef52c6020..c41781e6a5e5 100644 --- a/drivers/staging/rtl8723au/hal/hal_com.c +++ b/drivers/staging/rtl8723au/hal/hal_com.c @@ -889,3 +889,10 @@ void rtl8723a_set_rpwm(struct rtw_adapter *padapter, u8 val) { rtw_write8(padapter, REG_USB_HRPWM, val); } + +u8 rtl8723a_get_rf_type(struct rtw_adapter *padapter) +{ + struct hal_data_8723a *pHalData = GET_HAL_DATA(padapter); + + return pHalData->rf_type; +} diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c index f8ceeb27fb76..b3d398a75512 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c @@ -3134,13 +3134,7 @@ void hw_var_set_mlme_join(struct rtw_adapter *padapter, u8 type) void GetHwReg8723A(struct rtw_adapter *padapter, u8 variable, u8 *val) { - struct hal_data_8723a *pHalData = GET_HAL_DATA(padapter); - switch (variable) { - case HW_VAR_RF_TYPE: - *val = pHalData->rf_type; - break; - case HW_VAR_FWLPS_RF_ON: { /* When we halt NIC, we should check if FW LPS is leave. */ diff --git a/drivers/staging/rtl8723au/include/hal_com.h b/drivers/staging/rtl8723au/include/hal_com.h index 832cbac4ac9e..d2e372c302f7 100644 --- a/drivers/staging/rtl8723au/include/hal_com.h +++ b/drivers/staging/rtl8723au/include/hal_com.h @@ -207,5 +207,6 @@ void rtl8723a_odm_support_ability_set(struct rtw_adapter *padapter, u32 val); void rtl8723a_odm_support_ability_clr(struct rtw_adapter *padapter, u32 val); void rtl8723a_set_rpwm(struct rtw_adapter *padapter, u8 val); +u8 rtl8723a_get_rf_type(struct rtw_adapter *padapter); #endif /* __HAL_COMMON_H__ */ diff --git a/drivers/staging/rtl8723au/include/hal_intf.h b/drivers/staging/rtl8723au/include/hal_intf.h index d38a670ca431..5bdf34b0e3d6 100644 --- a/drivers/staging/rtl8723au/include/hal_intf.h +++ b/drivers/staging/rtl8723au/include/hal_intf.h @@ -37,7 +37,6 @@ enum _CHIP_TYPE { enum HW_VARIABLES { HW_VAR_INIT_RTS_RATE, - HW_VAR_RF_TYPE, HW_VAR_CAM_READ, HW_VAR_FWLPS_RF_ON, HW_VAR_TDLS_WRCR, diff --git a/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c b/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c index 58366236777f..fadc53cf6266 100644 --- a/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c +++ b/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c @@ -4347,7 +4347,7 @@ void rtw_cfg80211_init_wiphy(struct rtw_adapter *padapter) struct wireless_dev *pwdev = padapter->rtw_wdev; struct wiphy *wiphy = pwdev->wiphy; - rtw23a_hal_get_hwreg(padapter, HW_VAR_RF_TYPE, (u8 *)(&rf_type)); + rf_type = rtl8723a_get_rf_type(padapter); DBG_8723A("%s:rf_type =%d\n", __func__, rf_type); -- cgit v1.2.3 From 0cee8101d83bbc5cc3d8e44ab601e2fdb15cf887 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 9 Apr 2014 23:20:54 +0200 Subject: staging: rtl8723au: Eliminate HW_VAR_FWLPS_RF_ON usage Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_pwrctrl.c | 7 +++---- drivers/staging/rtl8723au/hal/hal_com.c | 23 +++++++++++++++++++++++ drivers/staging/rtl8723au/hal/rtl8723a_dm.c | 2 +- drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c | 21 --------------------- drivers/staging/rtl8723au/include/hal_com.h | 1 + drivers/staging/rtl8723au/include/hal_intf.h | 1 - 6 files changed, 28 insertions(+), 27 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_pwrctrl.c b/drivers/staging/rtl8723au/core/rtw_pwrctrl.c index da6645e9b9fc..07c63246ca31 100644 --- a/drivers/staging/rtl8723au/core/rtw_pwrctrl.c +++ b/drivers/staging/rtl8723au/core/rtw_pwrctrl.c @@ -386,12 +386,11 @@ s32 LPS_RF_ON_check23a(struct rtw_adapter *padapter, u32 delay_ms) while (1) { - rtw23a_hal_get_hwreg(padapter, HW_VAR_FWLPS_RF_ON, &bAwake); - if (true == bAwake) + bAwake = rtl8723a_get_fwlps_rf_on(padapter); + if (bAwake == true) break; - if (true == padapter->bSurpriseRemoved) - { + if (padapter->bSurpriseRemoved == true) { err = -2; DBG_8723A("%s: device surprise removed!!\n", __func__); break; diff --git a/drivers/staging/rtl8723au/hal/hal_com.c b/drivers/staging/rtl8723au/hal/hal_com.c index c41781e6a5e5..7b00dbadf105 100644 --- a/drivers/staging/rtl8723au/hal/hal_com.c +++ b/drivers/staging/rtl8723au/hal/hal_com.c @@ -896,3 +896,26 @@ u8 rtl8723a_get_rf_type(struct rtw_adapter *padapter) return pHalData->rf_type; } + +bool rtl8723a_get_fwlps_rf_on(struct rtw_adapter *padapter) +{ + bool retval; + u32 valRCR; + + /* When we halt NIC, we should check if FW LPS is leave. */ + + if ((padapter->bSurpriseRemoved == true) || + (padapter->pwrctrlpriv.rf_pwrstate == rf_off)) { + /* If it is in HW/SW Radio OFF or IPS state, we do + not check Fw LPS Leave, because Fw is unload. */ + retval = true; + } else { + valRCR = rtw_read32(padapter, REG_RCR); + if (valRCR & 0x00070000) + retval = false; + else + retval = true; + } + + return retval; +} diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_dm.c b/drivers/staging/rtl8723au/hal/rtl8723a_dm.c index f204ab1714e7..b3907ca2e96b 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_dm.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_dm.c @@ -217,7 +217,7 @@ rtl8723a_HalDmWatchDog( goto skip_dm; bFwCurrentInPSMode = Adapter->pwrctrlpriv.bFwCurrentInPSMode; - rtw23a_hal_get_hwreg(Adapter, HW_VAR_FWLPS_RF_ON, (u8 *)(&bFwPSAwake)); + bFwPSAwake = rtl8723a_get_fwlps_rf_on(Adapter); #ifdef CONFIG_8723AU_P2P /* Fw is under p2p powersaving mode, driver should stop dynamic mechanism. */ diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c index b3d398a75512..f9cf4c88f7ff 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c @@ -3135,27 +3135,6 @@ void hw_var_set_mlme_join(struct rtw_adapter *padapter, u8 type) void GetHwReg8723A(struct rtw_adapter *padapter, u8 variable, u8 *val) { switch (variable) { - case HW_VAR_FWLPS_RF_ON: - { - /* When we halt NIC, we should check if FW LPS is leave. */ - u32 valRCR; - - if ((padapter->bSurpriseRemoved == true) || - (padapter->pwrctrlpriv.rf_pwrstate == rf_off)) { - /* If it is in HW/SW Radio OFF or IPS state, we do - not check Fw LPS Leave, because Fw is unload. */ - *val = true; - } else { - valRCR = rtw_read32(padapter, REG_RCR); - valRCR &= 0x00070000; - if (valRCR) - *val = false; - else - *val = true; - } - } - break; - case HW_VAR_CHK_HI_QUEUE_EMPTY: *val = ((rtw_read32(padapter, REG_HGQ_INFORMATION) & 0x0000ff00) == diff --git a/drivers/staging/rtl8723au/include/hal_com.h b/drivers/staging/rtl8723au/include/hal_com.h index d2e372c302f7..84e472e671d1 100644 --- a/drivers/staging/rtl8723au/include/hal_com.h +++ b/drivers/staging/rtl8723au/include/hal_com.h @@ -208,5 +208,6 @@ void rtl8723a_odm_support_ability_clr(struct rtw_adapter *padapter, u32 val); void rtl8723a_set_rpwm(struct rtw_adapter *padapter, u8 val); u8 rtl8723a_get_rf_type(struct rtw_adapter *padapter); +bool rtl8723a_get_fwlps_rf_on(struct rtw_adapter *padapter); #endif /* __HAL_COMMON_H__ */ diff --git a/drivers/staging/rtl8723au/include/hal_intf.h b/drivers/staging/rtl8723au/include/hal_intf.h index 5bdf34b0e3d6..35bedf984ba9 100644 --- a/drivers/staging/rtl8723au/include/hal_intf.h +++ b/drivers/staging/rtl8723au/include/hal_intf.h @@ -38,7 +38,6 @@ enum _CHIP_TYPE { enum HW_VARIABLES { HW_VAR_INIT_RTS_RATE, HW_VAR_CAM_READ, - HW_VAR_FWLPS_RF_ON, HW_VAR_TDLS_WRCR, HW_VAR_TDLS_INIT_CH_SEN, HW_VAR_TDLS_RS_RCR, -- cgit v1.2.3 From 8d3fd6145b963c5d156e442677193c3fa10df708 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 9 Apr 2014 23:20:55 +0200 Subject: staging: rtl8723au: Eliminate HW_WAR_CHK_HI_QUEUE_EMPTY usage Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_cmd.c | 9 ++++----- drivers/staging/rtl8723au/hal/hal_com.c | 9 +++++++++ drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c | 5 ----- drivers/staging/rtl8723au/include/hal_com.h | 1 + drivers/staging/rtl8723au/include/hal_intf.h | 1 - 5 files changed, 14 insertions(+), 11 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_cmd.c b/drivers/staging/rtl8723au/core/rtw_cmd.c index 0b25cd2f6584..2c558e0dd12b 100644 --- a/drivers/staging/rtl8723au/core/rtw_cmd.c +++ b/drivers/staging/rtl8723au/core/rtw_cmd.c @@ -1441,11 +1441,11 @@ static void rtw_chk_hi_queue_hdl(struct rtw_adapter *padapter) return; if (psta_bmc->sleepq_len == 0) { - u8 val = 0; + bool val; - rtw23a_hal_get_hwreg(padapter, HW_VAR_CHK_HI_QUEUE_EMPTY, &val); + val = rtl8723a_chk_hi_queue_empty(padapter); - while(val == false) { + while (val == false) { msleep(100); cnt++; @@ -1453,8 +1453,7 @@ static void rtw_chk_hi_queue_hdl(struct rtw_adapter *padapter) if (cnt>10) break; - rtw23a_hal_get_hwreg(padapter, - HW_VAR_CHK_HI_QUEUE_EMPTY, &val); + val = rtl8723a_chk_hi_queue_empty(padapter); } if (cnt <= 10) { diff --git a/drivers/staging/rtl8723au/hal/hal_com.c b/drivers/staging/rtl8723au/hal/hal_com.c index 7b00dbadf105..d1701a35bc90 100644 --- a/drivers/staging/rtl8723au/hal/hal_com.c +++ b/drivers/staging/rtl8723au/hal/hal_com.c @@ -919,3 +919,12 @@ bool rtl8723a_get_fwlps_rf_on(struct rtw_adapter *padapter) return retval; } + +bool rtl8723a_chk_hi_queue_empty(struct rtw_adapter *padapter) +{ + u32 hgq; + + hgq = rtw_read32(padapter, REG_HGQ_INFORMATION); + + return ((hgq & 0x0000ff00) == 0) ? true : false; +} diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c index f9cf4c88f7ff..9967c075a702 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c @@ -3135,11 +3135,6 @@ void hw_var_set_mlme_join(struct rtw_adapter *padapter, u8 type) void GetHwReg8723A(struct rtw_adapter *padapter, u8 variable, u8 *val) { switch (variable) { - case HW_VAR_CHK_HI_QUEUE_EMPTY: - *val = - ((rtw_read32(padapter, REG_HGQ_INFORMATION) & 0x0000ff00) == - 0) ? true : false; - break; } } diff --git a/drivers/staging/rtl8723au/include/hal_com.h b/drivers/staging/rtl8723au/include/hal_com.h index 84e472e671d1..5f050a346a8a 100644 --- a/drivers/staging/rtl8723au/include/hal_com.h +++ b/drivers/staging/rtl8723au/include/hal_com.h @@ -209,5 +209,6 @@ void rtl8723a_odm_support_ability_clr(struct rtw_adapter *padapter, u32 val); void rtl8723a_set_rpwm(struct rtw_adapter *padapter, u8 val); u8 rtl8723a_get_rf_type(struct rtw_adapter *padapter); bool rtl8723a_get_fwlps_rf_on(struct rtw_adapter *padapter); +bool rtl8723a_chk_hi_queue_empty(struct rtw_adapter *padapter); #endif /* __HAL_COMMON_H__ */ diff --git a/drivers/staging/rtl8723au/include/hal_intf.h b/drivers/staging/rtl8723au/include/hal_intf.h index 35bedf984ba9..e5b71ca639dc 100644 --- a/drivers/staging/rtl8723au/include/hal_intf.h +++ b/drivers/staging/rtl8723au/include/hal_intf.h @@ -52,7 +52,6 @@ enum HW_VARIABLES { /* Unit in microsecond. 0 means disable this function. */ HW_VAR_RPT_TIMER_SETTING, HW_VAR_TX_RPT_MAX_MACID, - HW_VAR_CHK_HI_QUEUE_EMPTY, HW_VAR_READ_LLT_TAB, }; -- cgit v1.2.3 From 0a44991073d38604fe7d422d39b7de7896b9e844 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 9 Apr 2014 23:20:56 +0200 Subject: staging: rtl8723au: Kill off ugly GetHwReg*() interface Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/hal/hal_intf.c | 6 ------ drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c | 6 ------ drivers/staging/rtl8723au/hal/usb_halinit.c | 10 ---------- drivers/staging/rtl8723au/include/hal_intf.h | 4 ---- drivers/staging/rtl8723au/include/rtl8723a_hal.h | 1 - 5 files changed, 27 deletions(-) diff --git a/drivers/staging/rtl8723au/hal/hal_intf.c b/drivers/staging/rtl8723au/hal/hal_intf.c index cafe347de63b..04cc53424b51 100644 --- a/drivers/staging/rtl8723au/hal/hal_intf.c +++ b/drivers/staging/rtl8723au/hal/hal_intf.c @@ -117,12 +117,6 @@ uint rtw_hal_deinit23a(struct rtw_adapter *padapter) return status; } -void rtw23a_hal_get_hwreg(struct rtw_adapter *padapter, u8 variable, u8 *val) -{ - if (padapter->HalFunc.GetHwRegHandler) - padapter->HalFunc.GetHwRegHandler(padapter, variable, val); -} - u8 rtw_hal_set_def_var23a(struct rtw_adapter *padapter, enum hal_def_variable eVariable, void *pValue) { if (padapter->HalFunc.SetHalDefVarHandler) diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c index 9967c075a702..8ea00ba851a2 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c @@ -3132,12 +3132,6 @@ void hw_var_set_mlme_join(struct rtw_adapter *padapter, u8 type) #endif } -void GetHwReg8723A(struct rtw_adapter *padapter, u8 variable, u8 *val) -{ - switch (variable) { - } -} - #ifdef CONFIG_8723AU_BT_COEXIST void rtl8723a_SingleDualAntennaDetection(struct rtw_adapter *padapter) diff --git a/drivers/staging/rtl8723au/hal/usb_halinit.c b/drivers/staging/rtl8723au/hal/usb_halinit.c index 53ef7c39eae5..0a6e343373ff 100644 --- a/drivers/staging/rtl8723au/hal/usb_halinit.c +++ b/drivers/staging/rtl8723au/hal/usb_halinit.c @@ -1496,15 +1496,6 @@ static void ReadAdapterInfo8723AU(struct rtw_adapter *Adapter) _ReadAdapterInfo8723AU(Adapter); } -/* - * If variable not handled here, - * some variables will be processed in GetHwReg8723A() - */ -static void GetHwReg8723AU(struct rtw_adapter *Adapter, u8 variable, u8 *val) -{ - GetHwReg8723A(Adapter, variable, val); -} - /* */ /* Description: */ /* Query setting of specified variable. */ @@ -1782,7 +1773,6 @@ int rtl8723au_set_hal_ops(struct rtw_adapter *padapter) pHalFunc->init_default_value = &rtl8723au_init_default_value; pHalFunc->intf_chip_configure = &rtl8723au_interface_configure; pHalFunc->read_adapter_info = &ReadAdapterInfo8723AU; - pHalFunc->GetHwRegHandler = &GetHwReg8723AU; pHalFunc->GetHalDefVarHandler = &GetHalDefVar8192CUsb; pHalFunc->SetHalDefVarHandler = &SetHalDefVar8192CUsb; pHalFunc->UpdateRAMaskHandler = &UpdateHalRAMask8192CUsb; diff --git a/drivers/staging/rtl8723au/include/hal_intf.h b/drivers/staging/rtl8723au/include/hal_intf.h index e5b71ca639dc..0284ec054d0d 100644 --- a/drivers/staging/rtl8723au/include/hal_intf.h +++ b/drivers/staging/rtl8723au/include/hal_intf.h @@ -123,9 +123,6 @@ struct hal_ops { void (*hal_dm_watchdog)(struct rtw_adapter *padapter); - void (*GetHwRegHandler)(struct rtw_adapter *padapter, - u8 variable, u8 *val); - u8 (*GetHalDefVarHandler)(struct rtw_adapter *padapter, enum hal_def_variable eVariable, void *pValue); @@ -258,7 +255,6 @@ u32 rtw_hal_power_on23a(struct rtw_adapter *padapter); uint rtw_hal_init23a(struct rtw_adapter *padapter); uint rtw_hal_deinit23a(struct rtw_adapter *padapter); void rtw_hal_stop(struct rtw_adapter *padapter); -void rtw23a_hal_get_hwreg(struct rtw_adapter *padapter, u8 variable, u8 *val); void rtw_hal_chip_configure23a(struct rtw_adapter *padapter); void rtw_hal_read_chip_info23a(struct rtw_adapter *padapter); diff --git a/drivers/staging/rtl8723au/include/rtl8723a_hal.h b/drivers/staging/rtl8723au/include/rtl8723a_hal.h index 49d743dc68de..ce11245fefd7 100644 --- a/drivers/staging/rtl8723au/include/rtl8723a_hal.h +++ b/drivers/staging/rtl8723au/include/rtl8723a_hal.h @@ -548,7 +548,6 @@ void Hal_EfuseParseThermalMeter_8723A(struct rtw_adapter *padapter, u8 *hwinfo, void Hal_InitChannelPlan23a(struct rtw_adapter *padapter); void rtl8723a_set_hal_ops(struct hal_ops *pHalFunc); -void GetHwReg8723A(struct rtw_adapter *padapter, u8 variable, u8 *val); #ifdef CONFIG_8723AU_BT_COEXIST void rtl8723a_SingleDualAntennaDetection(struct rtw_adapter *padapter); #endif -- cgit v1.2.3 From ec21da4696ea7a94ca44b9a221daa49d172b565f Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 9 Apr 2014 23:20:57 +0200 Subject: staging: rtl8723au: Remove obsolete HW_VARIABLES enum Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/include/hal_intf.h | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/drivers/staging/rtl8723au/include/hal_intf.h b/drivers/staging/rtl8723au/include/hal_intf.h index 0284ec054d0d..946bce045d5f 100644 --- a/drivers/staging/rtl8723au/include/hal_intf.h +++ b/drivers/staging/rtl8723au/include/hal_intf.h @@ -35,26 +35,6 @@ enum _CHIP_TYPE { MAX_CHIP_TYPE }; -enum HW_VARIABLES { - HW_VAR_INIT_RTS_RATE, - HW_VAR_CAM_READ, - HW_VAR_TDLS_WRCR, - HW_VAR_TDLS_INIT_CH_SEN, - HW_VAR_TDLS_RS_RCR, - HW_VAR_TDLS_DONE_CH_SEN, - HW_VAR_BT_SET_COEXIST, - HW_VAR_BT_ISSUE_DELBA, - HW_VAR_CURRENT_ANTENNA, - HW_VAR_ANTENNA_DIVERSITY_LINK, - HW_VAR_ANTENNA_DIVERSITY_SELECT, - HW_VAR_SWITCH_EPHY_WoWLAN, - /* The valid upper nav range for the HW updating, if the true value is larger than the upper range, the HW won't update it. */ - /* Unit in microsecond. 0 means disable this function. */ - HW_VAR_RPT_TIMER_SETTING, - HW_VAR_TX_RPT_MAX_MACID, - HW_VAR_READ_LLT_TAB, -}; - enum hal_def_variable { HAL_DEF_UNDERCORATEDSMOOTHEDPWDB, HAL_DEF_IS_SUPPORT_ANT_DIV, -- cgit v1.2.3 From 3f58bf2ec0682bb00cdefd5bc7f3e91bcc2e30fa Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 9 Apr 2014 23:20:58 +0200 Subject: staging: rtl8723au: Remove unused is_boot_from_eeprom() macro Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/include/hal_intf.h | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/rtl8723au/include/hal_intf.h b/drivers/staging/rtl8723au/include/hal_intf.h index 946bce045d5f..0b07e8b1f068 100644 --- a/drivers/staging/rtl8723au/include/hal_intf.h +++ b/drivers/staging/rtl8723au/include/hal_intf.h @@ -214,7 +214,6 @@ enum hardware_type { }; #define GET_EEPROM_EFUSE_PRIV(adapter) (&adapter->eeprompriv) -#define is_boot_from_eeprom(adapter) (adapter->eeprompriv.EepromOrEfuse) extern int rtw_ht_enable23A; extern int rtw_cbw40_enable23A; -- cgit v1.2.3 From 141bd353c5a9ba987dbe7b28ffdd034bb3ed55ba Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 9 Apr 2014 23:20:59 +0200 Subject: staging: rtl8723au: Remove #ifdef CONFIG_DEBUG_CFG80211 Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c | 65 +---------------------- 1 file changed, 2 insertions(+), 63 deletions(-) diff --git a/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c b/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c index fadc53cf6266..86721dc7c1b9 100644 --- a/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c +++ b/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c @@ -1298,10 +1298,8 @@ static int cfg80211_rtw_get_station(struct wiphy *wiphy, ret = -ENOENT; goto exit; } -#ifdef CONFIG_DEBUG_CFG80211 DBG_8723A(FUNC_NDEV_FMT " mac =" MAC_FMT "\n", FUNC_NDEV_ARG(ndev), MAC_ARG(mac)); -#endif /* for infra./P2PClient mode */ if (check_fwstate(pmlmepriv, WIFI_STATION_STATE) && @@ -1438,9 +1436,8 @@ void rtw_cfg80211_indicate_scan_done(struct rtw_wdev_priv *pwdev_priv, { spin_lock_bh(&pwdev_priv->scan_req_lock); if (pwdev_priv->scan_request != NULL) { -#ifdef CONFIG_DEBUG_CFG80211 DBG_8723A("%s with scan req\n", __func__); -#endif + if (pwdev_priv->scan_request->wiphy != pwdev_priv->rtw_wdev->wiphy) DBG_8723A("error wiphy compare\n"); @@ -1449,9 +1446,7 @@ void rtw_cfg80211_indicate_scan_done(struct rtw_wdev_priv *pwdev_priv, pwdev_priv->scan_request = NULL; } else { -#ifdef CONFIG_DEBUG_CFG80211 DBG_8723A("%s without scan req\n", __func__); -#endif } spin_unlock_bh(&pwdev_priv->scan_req_lock); } @@ -1463,10 +1458,6 @@ void rtw_cfg80211_surveydone_event_callback(struct rtw_adapter *padapter) struct rtw_queue *queue = &pmlmepriv->scanned_queue; struct wlan_network *pnetwork; -#ifdef CONFIG_DEBUG_CFG80211 - DBG_8723A("%s\n", __func__); -#endif - spin_lock_bh(&pmlmepriv->scanned_queue.lock); phead = get_list_head(queue); @@ -1502,16 +1493,13 @@ static int rtw_cfg80211_set_probe_req_wpsp2pie(struct rtw_adapter *padapter, #endif struct mlme_priv *pmlmepriv = &padapter->mlmepriv; -#ifdef CONFIG_DEBUG_CFG80211 DBG_8723A("%s, ielen =%d\n", __func__, len); -#endif if (len > 0) { wps_ie = rtw_get_wps_ie23a(buf, len, NULL, &wps_ielen); if (wps_ie) { -#ifdef CONFIG_DEBUG_CFG80211 DBG_8723A("probe_req_wps_ielen =%d\n", wps_ielen); -#endif + if (pmlmepriv->wps_probe_req_ie) { pmlmepriv->wps_probe_req_ie_len = 0; kfree(pmlmepriv->wps_probe_req_ie); @@ -1531,9 +1519,7 @@ static int rtw_cfg80211_set_probe_req_wpsp2pie(struct rtw_adapter *padapter, #ifdef CONFIG_8723AU_P2P p2p_ie = rtw_get_p2p_ie23a(buf, len, NULL, &p2p_ielen); if (p2p_ie) { -#ifdef CONFIG_DEBUG_CFG80211 DBG_8723A("probe_req_p2p_ielen =%d\n", p2p_ielen); -#endif if (pmlmepriv->p2p_probe_req_ie) { pmlmepriv->p2p_probe_req_ie_len = 0; @@ -1559,9 +1545,7 @@ static int rtw_cfg80211_set_probe_req_wpsp2pie(struct rtw_adapter *padapter, #ifdef CONFIG_8723AU_P2P if (rtw_get_wfd_ie(buf, len, NULL, &wfd_ielen)) { -#ifdef CONFIG_DEBUG_CFG80211 DBG_8723A("probe_req_wfd_ielen =%d\n", wfd_ielen); -#endif if (pmlmepriv->wfd_probe_req_ie) { pmlmepriv->wfd_probe_req_ie_len = 0; @@ -1605,19 +1589,14 @@ static int cfg80211_rtw_scan(struct wiphy *wiphy, #endif /* CONFIG_8723AU_P2P */ bool need_indicate_scan_done = false; -#ifdef CONFIG_DEBUG_CFG80211 DBG_8723A(FUNC_ADPT_FMT "\n", FUNC_ADPT_ARG(padapter)); -#endif spin_lock_bh(&pwdev_priv->scan_req_lock); pwdev_priv->scan_request = request; spin_unlock_bh(&pwdev_priv->scan_req_lock); if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) { - -#ifdef CONFIG_DEBUG_CFG80211 DBG_8723A("%s under WIFI_AP_STATE\n", __func__); -#endif /* need_indicate_scan_done = true; */ /* goto check_need_indicate_scan_done; */ } @@ -1634,11 +1613,9 @@ static int cfg80211_rtw_scan(struct wiphy *wiphy, wdev_to_priv(padapter->rtw_wdev)->p2p_enabled = true; } else { rtw_p2p_set_pre_state(pwdinfo, rtw_p2p_state(pwdinfo)); -#ifdef CONFIG_DEBUG_CFG80211 DBG_8723A("%s, role =%d, p2p_state =%d\n", __func__, rtw_p2p_role(pwdinfo), rtw_p2p_state(pwdinfo)); -#endif } rtw_p2p_set_state(pwdinfo, P2P_STATE_LISTEN); @@ -1692,10 +1669,8 @@ static int cfg80211_rtw_scan(struct wiphy *wiphy, memset(ssid, 0, sizeof(struct cfg80211_ssid) * RTW_SSID_SCAN_AMOUNT); /* parsing request ssids, n_ssids */ for (i = 0; i < request->n_ssids && i < RTW_SSID_SCAN_AMOUNT; i++) { -#ifdef CONFIG_DEBUG_CFG80211 DBG_8723A("ssid =%s, len =%d\n", ssids[i].ssid, ssids[i].ssid_len); -#endif memcpy(ssid[i].ssid, ssids[i].ssid, ssids[i].ssid_len); ssid[i].ssid_len = ssids[i].ssid_len; } @@ -1707,11 +1682,9 @@ static int cfg80211_rtw_scan(struct wiphy *wiphy, if (request->n_channels == 1) { for (i = 0; i < request->n_channels && i < RTW_CHANNEL_SCAN_AMOUNT; i++) { -#ifdef CONFIG_DEBUG_CFG80211 DBG_8723A(FUNC_ADPT_FMT CHAN_FMT "\n", FUNC_ADPT_ARG(padapter), CHAN_ARG(request->channels[i])); -#endif ch[i].hw_value = request->channels[i]->hw_value; ch[i].flags = request->channels[i]->flags; } @@ -2036,10 +2009,8 @@ static int rtw_cfg80211_set_wpa_ie(struct rtw_adapter *padapter, const u8 *pie, p2p_ie = rtw_get_p2p_ie23a(buf, ielen, NULL, &p2p_ielen); if (p2p_ie) { -#ifdef CONFIG_DEBUG_CFG80211 DBG_8723A("%s p2p_assoc_req_ielen =%d\n", __func__, p2p_ielen); -#endif if (pmlmepriv->p2p_assoc_req_ie) { pmlmepriv->p2p_assoc_req_ie_len = 0; @@ -2066,10 +2037,8 @@ static int rtw_cfg80211_set_wpa_ie(struct rtw_adapter *padapter, const u8 *pie, struct mlme_priv *pmlmepriv = &padapter->mlmepriv; if (rtw_get_wfd_ie(buf, ielen, NULL, &wfd_ielen)) { -#ifdef CONFIG_DEBUG_CFG80211 DBG_8723A("%s wfd_assoc_req_ielen =%d\n", __func__, wfd_ielen); -#endif if (pmlmepriv->wfd_assoc_req_ie) { pmlmepriv->wfd_assoc_req_ie_len = 0; @@ -3616,10 +3585,8 @@ static s32 cfg80211_rtw_remain_on_channel(struct wiphy *wiphy, wdev_to_priv(padapter->rtw_wdev)->p2p_enabled = true; } else { rtw_p2p_set_pre_state(pwdinfo, rtw_p2p_state(pwdinfo)); -#ifdef CONFIG_DEBUG_CFG80211 DBG_8723A("%s, role =%d, p2p_state =%d\n", __func__, rtw_p2p_role(pwdinfo), rtw_p2p_state(pwdinfo)); -#endif } rtw_p2p_set_state(pwdinfo, P2P_STATE_LISTEN); @@ -3685,10 +3652,8 @@ static s32 cfg80211_rtw_cancel_remain_on_channel(struct wiphy *wiphy, } rtw_p2p_set_state(pwdinfo, rtw_p2p_pre_state(pwdinfo)); -#ifdef CONFIG_DEBUG_CFG80211 DBG_8723A("%s, role =%d, p2p_state =%d\n", __func__, rtw_p2p_role(pwdinfo), rtw_p2p_state(pwdinfo)); -#endif pcfg80211_wdinfo->is_ro_ch = false; return err; @@ -3770,21 +3735,15 @@ static int _cfg80211_rtw_mgmt_tx(struct rtw_adapter *padapter, u8 tx_ch, ack = false; ret = _FAIL; -#ifdef CONFIG_DEBUG_CFG80211 DBG_8723A("%s, ack == _FAIL\n", __func__); -#endif } else { -#ifdef CONFIG_DEBUG_CFG80211 DBG_8723A("%s, ack =%d, ok!\n", __func__, ack); -#endif ret = _SUCCESS; } exit: -#ifdef CONFIG_DEBUG_CFG80211 DBG_8723A("%s, ret =%d\n", __func__, ret); -#endif return ret; } @@ -3823,10 +3782,8 @@ static int cfg80211_rtw_mgmt_tx(struct wiphy *wiphy, struct wireless_dev *wdev, /* cookie generation */ *cookie = (unsigned long)buf; -#ifdef CONFIG_DEBUG_CFG80211 DBG_8723A(FUNC_ADPT_FMT " len =%zu, ch =%d" "\n", FUNC_ADPT_ARG(padapter), len, tx_ch); -#endif /* CONFIG_DEBUG_CFG80211 */ /* indicate ack before issue frame to avoid racing with rsp frame */ rtw_cfg80211_mgmt_tx_status(padapter, *cookie, buf, len, ack, @@ -3892,12 +3849,6 @@ static void cfg80211_rtw_mgmt_frame_register(struct wiphy *wiphy, struct wireless_dev *wdev, u16 frame_type, bool reg) { - -#ifdef CONFIG_DEBUG_CFG80211 - DBG_8723A(FUNC_ADPT_FMT " frame_type:%x, reg:%d\n", - FUNC_ADPT_ARG(adapter), frame_type, reg); -#endif - if (frame_type != (IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_PROBE_REQ)) return; @@ -3927,9 +3878,7 @@ static int rtw_cfg80211_set_beacon_wpsp2pie(struct net_device *ndev, char *buf, if (len > 0) { wps_ie = rtw_get_wps_ie23a(buf, len, NULL, &wps_ielen); if (wps_ie) { -#ifdef CONFIG_DEBUG_CFG80211 DBG_8723A("bcn_wps_ielen =%d\n", wps_ielen); -#endif if (pmlmepriv->wps_beacon_ie) { pmlmepriv->wps_beacon_ie_len = 0; @@ -3955,9 +3904,7 @@ static int rtw_cfg80211_set_beacon_wpsp2pie(struct net_device *ndev, char *buf, #ifdef CONFIG_8723AU_P2P p2p_ie = rtw_get_p2p_ie23a(buf, len, NULL, &p2p_ielen); if (p2p_ie) { -#ifdef CONFIG_DEBUG_CFG80211 DBG_8723A("bcn_p2p_ielen =%d\n", p2p_ielen); -#endif if (pmlmepriv->p2p_beacon_ie) { pmlmepriv->p2p_beacon_ie_len = 0; @@ -3983,9 +3930,7 @@ static int rtw_cfg80211_set_beacon_wpsp2pie(struct net_device *ndev, char *buf, #ifdef CONFIG_8723AU_P2P if (rtw_get_wfd_ie(buf, len, NULL, &wfd_ielen)) { -#ifdef CONFIG_DEBUG_CFG80211 DBG_8723A("bcn_wfd_ielen =%d\n", wfd_ielen); -#endif if (pmlmepriv->wfd_beacon_ie) { pmlmepriv->wfd_beacon_ie_len = 0; @@ -4076,9 +4021,7 @@ static int rtw_cfg80211_set_probe_resp_wpsp2pie(struct net_device *net, u32 attr_contentlen = 0; u16 cap_attr = 0; -#ifdef CONFIG_DEBUG_CFG80211 DBG_8723A("probe_resp_p2p_ielen =%d\n", p2p_ielen); -#endif /* Check P2P Capability ATTR */ if (rtw_get_p2p_attr23a_content(p2p_ie, p2p_ielen, @@ -4142,9 +4085,7 @@ static int rtw_cfg80211_set_probe_resp_wpsp2pie(struct net_device *net, #ifdef CONFIG_8723AU_P2P if (rtw_get_wfd_ie(buf, len, NULL, &wfd_ielen)) { -#ifdef CONFIG_DEBUG_CFG80211 DBG_8723A("probe_resp_wfd_ielen =%d\n", wfd_ielen); -#endif if (pmlmepriv->wfd_probe_resp_ie) { pmlmepriv->wfd_probe_resp_ie_len = 0; @@ -4208,9 +4149,7 @@ int rtw_cfg80211_set_mgnt_wpsp2pie(struct net_device *net, char *buf, int len, u32 p2p_ielen = 0; #endif -#ifdef CONFIG_DEBUG_CFG80211 DBG_8723A("%s, ielen =%d\n", __func__, len); -#endif if ((rtw_get_wps_ie23a(buf, len, NULL, &wps_ielen) && (wps_ielen > 0)) #ifdef CONFIG_8723AU_P2P -- cgit v1.2.3 From 810c832f5d9b99cec69b3dcb763c8c35215abf94 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 9 Apr 2014 23:21:00 +0200 Subject: staging: rtl8723au: Remove two layers of wrappers around rtw_cfg80211_indicate_scan_done() Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme.c | 10 +++------- drivers/staging/rtl8723au/include/mlme_osdep.h | 1 - drivers/staging/rtl8723au/include/rtw_mlme.h | 1 - drivers/staging/rtl8723au/os_dep/mlme_linux.c | 6 ------ drivers/staging/rtl8723au/os_dep/usb_intf.c | 3 ++- 5 files changed, 5 insertions(+), 16 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme.c b/drivers/staging/rtl8723au/core/rtw_mlme.c index f72bae42dcb0..8d45c1c841ef 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme.c @@ -959,11 +959,6 @@ void rtw_indicate_disconnect23a(struct rtw_adapter *padapter) } -inline void rtw_indicate_scan_done23a(struct rtw_adapter *padapter, bool aborted) -{ - rtw_os_indicate_scan_done23a(padapter, aborted); -} - void rtw_scan_abort23a(struct rtw_adapter *adapter) { unsigned long start; @@ -985,7 +980,8 @@ void rtw_scan_abort23a(struct rtw_adapter *adapter) if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY)) { if (!adapter->bDriverStopped && !adapter->bSurpriseRemoved) DBG_8723A(FUNC_NDEV_FMT"waiting for scan_abort time out!\n", FUNC_NDEV_ARG(adapter->pnetdev)); - rtw_indicate_scan_done23a(adapter, true); + rtw_cfg80211_indicate_scan_done(wdev_to_priv(adapter->rtw_wdev), + true); } pmlmeext->scan_abort = false; } @@ -1546,7 +1542,7 @@ void rtw_scan_timeout_handler23a(unsigned long data) spin_unlock_bh(&pmlmepriv->lock); - rtw_indicate_scan_done23a(adapter, true); + rtw_cfg80211_indicate_scan_done(wdev_to_priv(adapter->rtw_wdev), true); } static void rtw_auto_scan_handler(struct rtw_adapter *padapter) diff --git a/drivers/staging/rtl8723au/include/mlme_osdep.h b/drivers/staging/rtl8723au/include/mlme_osdep.h index b7132a9a1378..82584dad1864 100644 --- a/drivers/staging/rtl8723au/include/mlme_osdep.h +++ b/drivers/staging/rtl8723au/include/mlme_osdep.h @@ -20,7 +20,6 @@ void rtw_os_indicate_disconnect23a(struct rtw_adapter *adapter); void rtw_os_indicate_connect23a(struct rtw_adapter *adapter); -void rtw_os_indicate_scan_done23a(struct rtw_adapter *padapter, bool aborted); void rtw_report_sec_ie23a(struct rtw_adapter *adapter, u8 authmode, u8 *sec_ie); void rtw_reset_securitypriv23a(struct rtw_adapter *adapter); diff --git a/drivers/staging/rtl8723au/include/rtw_mlme.h b/drivers/staging/rtl8723au/include/rtw_mlme.h index dac930c77c01..2d4f61b91943 100644 --- a/drivers/staging/rtl8723au/include/rtw_mlme.h +++ b/drivers/staging/rtl8723au/include/rtw_mlme.h @@ -553,7 +553,6 @@ void rtw_free_assoc_resources23a(struct rtw_adapter *adapter, int lock_scanned_queue); void rtw_indicate_disconnect23a(struct rtw_adapter *adapter); void rtw_indicate_connect23a(struct rtw_adapter *adapter); -void rtw_indicate_scan_done23a(struct rtw_adapter *padapter, bool aborted); void rtw_scan_abort23a(struct rtw_adapter *adapter); int rtw_restruct_sec_ie23a(struct rtw_adapter *adapter, u8 *in_ie, u8 *out_ie, diff --git a/drivers/staging/rtl8723au/os_dep/mlme_linux.c b/drivers/staging/rtl8723au/os_dep/mlme_linux.c index b30d4d37556a..37ecdb4eba2d 100644 --- a/drivers/staging/rtl8723au/os_dep/mlme_linux.c +++ b/drivers/staging/rtl8723au/os_dep/mlme_linux.c @@ -30,12 +30,6 @@ void rtw_os_indicate_connect23a(struct rtw_adapter *adapter) rtw_signal_process(adapter->pid[2], SIGALRM); } -void rtw_os_indicate_scan_done23a(struct rtw_adapter *padapter, bool aborted) -{ - rtw_cfg80211_indicate_scan_done(wdev_to_priv(padapter->rtw_wdev), - aborted); -} - static struct rt_pmkid_list backupPMKIDList[NUM_PMKID_CACHE]; void rtw_reset_securitypriv23a(struct rtw_adapter *adapter) diff --git a/drivers/staging/rtl8723au/os_dep/usb_intf.c b/drivers/staging/rtl8723au/os_dep/usb_intf.c index 612806e0de2e..778508d3a047 100644 --- a/drivers/staging/rtl8723au/os_dep/usb_intf.c +++ b/drivers/staging/rtl8723au/os_dep/usb_intf.c @@ -509,7 +509,8 @@ static int rtw_suspend(struct usb_interface *pusb_intf, pm_message_t message) up(&pwrpriv->lock); if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY)) - rtw_indicate_scan_done23a(padapter, 1); + rtw_cfg80211_indicate_scan_done( + wdev_to_priv(padapter->rtw_wdev), true); if (check_fwstate(pmlmepriv, _FW_UNDER_LINKING)) rtw_indicate_disconnect23a(padapter); -- cgit v1.2.3 From ce16d2f18944f9ba6cafbc73be20803d848adf78 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 9 Apr 2014 23:21:01 +0200 Subject: staging: rtl8723au: Don't wrap kill_pid() in an unnecessary macro Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/hal/rtl8723a_dm.c | 2 +- drivers/staging/rtl8723au/include/osdep_service.h | 2 -- drivers/staging/rtl8723au/os_dep/mlme_linux.c | 2 +- drivers/staging/rtl8723au/os_dep/usb_intf.c | 2 +- 4 files changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_dm.c b/drivers/staging/rtl8723au/hal/rtl8723a_dm.c index b3907ca2e96b..71ee47abcace 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_dm.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_dm.c @@ -76,7 +76,7 @@ static void dm_CheckPbcGPIO(struct rtw_adapter *padapter) return; } - rtw_signal_process(padapter->pid[0], SIGUSR1); + kill_pid(find_vpid(padapter->pid[0]), SIGUSR1, 1); } } diff --git a/drivers/staging/rtl8723au/include/osdep_service.h b/drivers/staging/rtl8723au/include/osdep_service.h index 039bc7285ed0..e03d19b84bcb 100644 --- a/drivers/staging/rtl8723au/include/osdep_service.h +++ b/drivers/staging/rtl8723au/include/osdep_service.h @@ -174,8 +174,6 @@ void rtw_unlock_suspend(void); #define FUNC_ADPT_FMT "%s(%s)" #define FUNC_ADPT_ARG(adapter) __func__, adapter->pnetdev->name -#define rtw_signal_process(pid, sig) kill_pid(find_vpid((pid)),(sig), 1) - u64 rtw_modular6423a(u64 x, u64 y); u64 rtw_division6423a(u64 x, u64 y); diff --git a/drivers/staging/rtl8723au/os_dep/mlme_linux.c b/drivers/staging/rtl8723au/os_dep/mlme_linux.c index 37ecdb4eba2d..d07e2203950c 100644 --- a/drivers/staging/rtl8723au/os_dep/mlme_linux.c +++ b/drivers/staging/rtl8723au/os_dep/mlme_linux.c @@ -27,7 +27,7 @@ void rtw_os_indicate_connect23a(struct rtw_adapter *adapter) netif_carrier_on(adapter->pnetdev); if (adapter->pid[2] != 0) - rtw_signal_process(adapter->pid[2], SIGALRM); + kill_pid(find_vpid(adapter->pid[2]), SIGALRM, 1); } static struct rt_pmkid_list backupPMKIDList[NUM_PMKID_CACHE]; diff --git a/drivers/staging/rtl8723au/os_dep/usb_intf.c b/drivers/staging/rtl8723au/os_dep/usb_intf.c index 778508d3a047..e6fbe6a62a6b 100644 --- a/drivers/staging/rtl8723au/os_dep/usb_intf.c +++ b/drivers/staging/rtl8723au/os_dep/usb_intf.c @@ -566,7 +566,7 @@ int rtw_resume_process23a(struct rtw_adapter *padapter) if (padapter->pid[1] != 0) { DBG_8723A("pid[1]:%d\n", padapter->pid[1]); - rtw_signal_process(padapter->pid[1], SIGUSR2); + kill_pid(find_vpid(padapter->pid[1]), SIGUSR2, 1); } rtw23a_roaming(padapter, NULL); -- cgit v1.2.3 From 483557be8e63221dfb6d4193085415ba742c47f8 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 9 Apr 2014 23:21:02 +0200 Subject: staging: rtl8723au: rtw_os_indicate_connect23a() is only called from one place - fold it in Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme.c | 7 ++++++- drivers/staging/rtl8723au/include/mlme_osdep.h | 1 - drivers/staging/rtl8723au/os_dep/mlme_linux.c | 10 ---------- 3 files changed, 6 insertions(+), 12 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme.c b/drivers/staging/rtl8723au/core/rtw_mlme.c index 8d45c1c841ef..4846768809c1 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme.c @@ -908,7 +908,12 @@ void rtw_indicate_connect23a(struct rtw_adapter *padapter) rtw_led_control(padapter, LED_CTL_LINK); - rtw_os_indicate_connect23a(padapter); + rtw_cfg80211_indicate_connect(padapter); + + netif_carrier_on(padapter->pnetdev); + + if (padapter->pid[2] != 0) + kill_pid(find_vpid(padapter->pid[2]), SIGALRM, 1); } rtw_set_roaming(padapter, 0); diff --git a/drivers/staging/rtl8723au/include/mlme_osdep.h b/drivers/staging/rtl8723au/include/mlme_osdep.h index 82584dad1864..e2cae3d63527 100644 --- a/drivers/staging/rtl8723au/include/mlme_osdep.h +++ b/drivers/staging/rtl8723au/include/mlme_osdep.h @@ -19,7 +19,6 @@ #include void rtw_os_indicate_disconnect23a(struct rtw_adapter *adapter); -void rtw_os_indicate_connect23a(struct rtw_adapter *adapter); void rtw_report_sec_ie23a(struct rtw_adapter *adapter, u8 authmode, u8 *sec_ie); void rtw_reset_securitypriv23a(struct rtw_adapter *adapter); diff --git a/drivers/staging/rtl8723au/os_dep/mlme_linux.c b/drivers/staging/rtl8723au/os_dep/mlme_linux.c index d07e2203950c..73a54a4ae792 100644 --- a/drivers/staging/rtl8723au/os_dep/mlme_linux.c +++ b/drivers/staging/rtl8723au/os_dep/mlme_linux.c @@ -20,16 +20,6 @@ #include #include -void rtw_os_indicate_connect23a(struct rtw_adapter *adapter) -{ - rtw_cfg80211_indicate_connect(adapter); - - netif_carrier_on(adapter->pnetdev); - - if (adapter->pid[2] != 0) - kill_pid(find_vpid(adapter->pid[2]), SIGALRM, 1); -} - static struct rt_pmkid_list backupPMKIDList[NUM_PMKID_CACHE]; void rtw_reset_securitypriv23a(struct rtw_adapter *adapter) -- cgit v1.2.3 From b319c6a35d0cc9a860946bebe1bd667ebc8aafb2 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 9 Apr 2014 23:21:03 +0200 Subject: staging: rtl8723au: Remove unnecessary memset() followed by a memcpy() into the same space Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/os_dep/mlme_linux.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/staging/rtl8723au/os_dep/mlme_linux.c b/drivers/staging/rtl8723au/os_dep/mlme_linux.c index 73a54a4ae792..ab5550650e21 100644 --- a/drivers/staging/rtl8723au/os_dep/mlme_linux.c +++ b/drivers/staging/rtl8723au/os_dep/mlme_linux.c @@ -36,9 +36,6 @@ void rtw_reset_securitypriv23a(struct rtw_adapter *adapter) * When the countermeasure is trigger, the driver have to * disconnect with AP for 60 seconds. */ - memset(&backupPMKIDList[0], 0x00, sizeof(struct rt_pmkid_list) * - NUM_PMKID_CACHE); - memcpy(&backupPMKIDList[0], &adapter->securitypriv.PMKIDList[0], sizeof(struct rt_pmkid_list) * NUM_PMKID_CACHE); backupPMKIDIndex = adapter->securitypriv.PMKIDIndex; -- cgit v1.2.3 From 90102edc28162210694b68a422192017e80fcbfd Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 9 Apr 2014 23:21:04 +0200 Subject: staging: rtl8723au: Fix hopeless brackets for declaring a variable mid-function Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/os_dep/usb_intf.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/drivers/staging/rtl8723au/os_dep/usb_intf.c b/drivers/staging/rtl8723au/os_dep/usb_intf.c index e6fbe6a62a6b..dd5899f21388 100644 --- a/drivers/staging/rtl8723au/os_dep/usb_intf.c +++ b/drivers/staging/rtl8723au/os_dep/usb_intf.c @@ -353,6 +353,7 @@ int rtw_hw_suspend23a(struct rtw_adapter *padapter) { struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv; struct net_device *pnetdev = padapter->pnetdev; + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; if ((!padapter->bup) || (padapter->bDriverStopped) || (padapter->bSurpriseRemoved)) { @@ -380,20 +381,16 @@ int rtw_hw_suspend23a(struct rtw_adapter *padapter) /* s2-2. indicate disconnect to os */ /* rtw_indicate_disconnect23a(padapter); */ - { - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - - if (check_fwstate(pmlmepriv, _FW_LINKED)) { - _clr_fwstate_(pmlmepriv, _FW_LINKED); + if (check_fwstate(pmlmepriv, _FW_LINKED)) { + _clr_fwstate_(pmlmepriv, _FW_LINKED); - rtw_led_control(padapter, LED_CTL_NO_LINK); + rtw_led_control(padapter, LED_CTL_NO_LINK); - rtw_os_indicate_disconnect23a(padapter); + rtw_os_indicate_disconnect23a(padapter); - /* donnot enqueue cmd */ - rtw_lps_ctrl_wk_cmd23a(padapter, - LPS_CTRL_DISCONNECT, 0); - } + /* donnot enqueue cmd */ + rtw_lps_ctrl_wk_cmd23a(padapter, + LPS_CTRL_DISCONNECT, 0); } /* s2-3. */ rtw_free_assoc_resources23a(padapter, 1); -- cgit v1.2.3 From 1eb663227f9aaf886ac0d7db7623462705ad3c69 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 9 Apr 2014 23:21:05 +0200 Subject: staging: rtl8723au: Remove unused functions rtw_indicate_sta_{dis,}assoc_event23a() Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/include/rtw_ap.h | 2 -- drivers/staging/rtl8723au/os_dep/mlme_linux.c | 46 --------------------------- 2 files changed, 48 deletions(-) diff --git a/drivers/staging/rtl8723au/include/rtw_ap.h b/drivers/staging/rtl8723au/include/rtw_ap.h index 76f82d68f633..7bcadff02ef9 100644 --- a/drivers/staging/rtl8723au/include/rtw_ap.h +++ b/drivers/staging/rtl8723au/include/rtw_ap.h @@ -22,8 +22,6 @@ #ifdef CONFIG_8723AU_AP_MODE /* external function */ -void rtw_indicate_sta_assoc_event23a(struct rtw_adapter *padapter, struct sta_info *psta); -void rtw_indicate_sta_disassoc_event23a(struct rtw_adapter *padapter, struct sta_info *psta); void init_mlme_ap_info23a(struct rtw_adapter *padapter); void free_mlme_ap_info23a(struct rtw_adapter *padapter); diff --git a/drivers/staging/rtl8723au/os_dep/mlme_linux.c b/drivers/staging/rtl8723au/os_dep/mlme_linux.c index ab5550650e21..959c1d1d838a 100644 --- a/drivers/staging/rtl8723au/os_dep/mlme_linux.c +++ b/drivers/staging/rtl8723au/os_dep/mlme_linux.c @@ -120,49 +120,3 @@ void rtw_report_sec_ie23a(struct rtw_adapter *adapter, u8 authmode, u8 *sec_ie) kfree(buff); } } - -#ifdef CONFIG_8723AU_AP_MODE -void rtw_indicate_sta_assoc_event23a(struct rtw_adapter *padapter, - struct sta_info *psta) -{ - struct sta_priv *pstapriv = &padapter->stapriv; - union iwreq_data wrqu; - - if (psta == NULL) - return; - - if (psta->aid > NUM_STA) - return; - - if (pstapriv->sta_aid[psta->aid - 1] != psta) - return; - - wrqu.addr.sa_family = ARPHRD_ETHER; - - memcpy(wrqu.addr.sa_data, psta->hwaddr, ETH_ALEN); - - DBG_8723A("+rtw_indicate_sta_assoc_event23a\n"); -} - -void rtw_indicate_sta_disassoc_event23a(struct rtw_adapter *padapter, - struct sta_info *psta) -{ - struct sta_priv *pstapriv = &padapter->stapriv; - union iwreq_data wrqu; - - if (psta == NULL) - return; - - if (psta->aid > NUM_STA) - return; - - if (pstapriv->sta_aid[psta->aid - 1] != psta) - return; - - wrqu.addr.sa_family = ARPHRD_ETHER; - - memcpy(wrqu.addr.sa_data, psta->hwaddr, ETH_ALEN); - - DBG_8723A("+rtw_indicate_sta_disassoc_event23a\n"); -} -#endif -- cgit v1.2.3 From 814a1d900e4a31f0205bbba0d8a6c0fedac70aae Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 9 Apr 2014 23:21:06 +0200 Subject: staging: rtl8723au: rtw_report_sec_ie23a() is only called from rtw_mlme.c Move it there and declare it static Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme.c | 46 ++++++++++++++++++++++++-- drivers/staging/rtl8723au/include/mlme_osdep.h | 2 -- drivers/staging/rtl8723au/os_dep/mlme_linux.c | 40 ---------------------- 3 files changed, 44 insertions(+), 44 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme.c b/drivers/staging/rtl8723au/core/rtw_mlme.c index 4846768809c1..1060a9fab64f 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme.c @@ -2002,6 +2002,48 @@ static int rtw_append_pmkid(struct rtw_adapter *Adapter, int iEntry, } return ie_len; } + +static void +_rtw_report_sec_ie(struct rtw_adapter *adapter, u8 authmode, u8 *sec_ie) +{ + uint len; + u8 *buff, *p, i; + union iwreq_data wrqu; + + RT_TRACE(_module_mlme_osdep_c_, _drv_info_, + ("+_rtw_report_sec_ie, authmode =%d\n", authmode)); + + buff = NULL; + if (authmode == _WPA_IE_ID_) { + RT_TRACE(_module_mlme_osdep_c_, _drv_info_, + ("_rtw_report_sec_ie, authmode =%d\n", authmode)); + + buff = kzalloc(IW_CUSTOM_MAX, GFP_KERNEL); + if (!buff) + return; + p = buff; + + p += sprintf(p, "ASSOCINFO(ReqIEs ="); + + len = sec_ie[1]+2; + len = (len < IW_CUSTOM_MAX) ? len : IW_CUSTOM_MAX; + + for (i = 0; i < len; i++) + p += sprintf(p, "%02x", sec_ie[i]); + + p += sprintf(p, ")"); + + memset(&wrqu, 0, sizeof(wrqu)); + + wrqu.data.length = p-buff; + + wrqu.data.length = (wrqu.data.length < IW_CUSTOM_MAX) ? + wrqu.data.length : IW_CUSTOM_MAX; + + kfree(buff); + } +} + int rtw_restruct_sec_ie23a(struct rtw_adapter *adapter, u8 *in_ie, u8 *out_ie, uint in_len) { @@ -2037,8 +2079,8 @@ int rtw_restruct_sec_ie23a(struct rtw_adapter *adapter, u8 *in_ie, u8 *out_ie, memcpy(&out_ie[ielength], &psecuritypriv->supplicant_ie[0], psecuritypriv->supplicant_ie[1] + 2); ielength += psecuritypriv->supplicant_ie[1] + 2; - rtw_report_sec_ie23a(adapter, authmode, - psecuritypriv->supplicant_ie); + _rtw_report_sec_ie(adapter, authmode, + psecuritypriv->supplicant_ie); } iEntry = SecIsInPMKIDList(adapter, pmlmepriv->assoc_bssid); diff --git a/drivers/staging/rtl8723au/include/mlme_osdep.h b/drivers/staging/rtl8723au/include/mlme_osdep.h index e2cae3d63527..4bb5525b7a68 100644 --- a/drivers/staging/rtl8723au/include/mlme_osdep.h +++ b/drivers/staging/rtl8723au/include/mlme_osdep.h @@ -19,8 +19,6 @@ #include void rtw_os_indicate_disconnect23a(struct rtw_adapter *adapter); -void rtw_report_sec_ie23a(struct rtw_adapter *adapter, u8 authmode, u8 *sec_ie); - void rtw_reset_securitypriv23a(struct rtw_adapter *adapter); #endif /* _MLME_OSDEP_H_ */ diff --git a/drivers/staging/rtl8723au/os_dep/mlme_linux.c b/drivers/staging/rtl8723au/os_dep/mlme_linux.c index 959c1d1d838a..c0e79f56d2eb 100644 --- a/drivers/staging/rtl8723au/os_dep/mlme_linux.c +++ b/drivers/staging/rtl8723au/os_dep/mlme_linux.c @@ -80,43 +80,3 @@ void rtw_os_indicate_disconnect23a(struct rtw_adapter *adapter) rtw_reset_securitypriv23a(adapter); } - -void rtw_report_sec_ie23a(struct rtw_adapter *adapter, u8 authmode, u8 *sec_ie) -{ - uint len; - u8 *buff, *p, i; - union iwreq_data wrqu; - - RT_TRACE(_module_mlme_osdep_c_, _drv_info_, - ("+rtw_report_sec_ie23a, authmode =%d\n", authmode)); - - buff = NULL; - if (authmode == _WPA_IE_ID_) { - RT_TRACE(_module_mlme_osdep_c_, _drv_info_, - ("rtw_report_sec_ie23a, authmode =%d\n", authmode)); - - buff = kzalloc(IW_CUSTOM_MAX, GFP_KERNEL); - if (!buff) - return; - p = buff; - - p += sprintf(p, "ASSOCINFO(ReqIEs ="); - - len = sec_ie[1]+2; - len = (len < IW_CUSTOM_MAX) ? len : IW_CUSTOM_MAX; - - for (i = 0; i < len; i++) - p += sprintf(p, "%02x", sec_ie[i]); - - p += sprintf(p, ")"); - - memset(&wrqu, 0, sizeof(wrqu)); - - wrqu.data.length = p-buff; - - wrqu.data.length = (wrqu.data.length < IW_CUSTOM_MAX) ? - wrqu.data.length : IW_CUSTOM_MAX; - - kfree(buff); - } -} -- cgit v1.2.3 From 41ed2cb92e3a9b4591f5ca76bd28fe0d0f3d4cc7 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 9 Apr 2014 23:21:07 +0200 Subject: staging: rtl8723au: Remove last remnants of CONFIG_BR_EXT Reported-by: Paul Bolle Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/include/drv_types.h | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/drivers/staging/rtl8723au/include/drv_types.h b/drivers/staging/rtl8723au/include/drv_types.h index 53eecea48cec..14c7f2e915e0 100644 --- a/drivers/staging/rtl8723au/include/drv_types.h +++ b/drivers/staging/rtl8723au/include/drv_types.h @@ -327,21 +327,6 @@ struct rtw_adapter { /* IFACE_ID1 is equals to SECONDARY_ADAPTER */ u8 iface_id; -#ifdef CONFIG_BR_EXT - _lock br_ext_lock; - /* unsigned int macclone_completed; */ - struct nat25_network_db_entry *nethash[NAT25_HASH_SIZE]; - int pppoe_connection_in_progress; - unsigned char pppoe_addr[MACADDRLEN]; - unsigned char scdb_mac[MACADDRLEN]; - unsigned char scdb_ip[4]; - struct nat25_network_db_entry *scdb_entry; - unsigned char br_mac[MACADDRLEN]; - unsigned char br_ip[4]; - - struct br_ext_info ethBrExtInfo; -#endif /* CONFIG_BR_EXT */ - u8 fix_rate; unsigned char in_cta_test; -- cgit v1.2.3 From f4f1cb92ae7966a6c65237beabb541af655ff9d9 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 9 Apr 2014 23:21:08 +0200 Subject: staging: rtl8723au: Fold rtw_remainder_len23a() into _rtw_open_pktfile23a() Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/include/xmit_osdep.h | 1 - drivers/staging/rtl8723au/os_dep/xmit_linux.c | 9 ++------- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/drivers/staging/rtl8723au/include/xmit_osdep.h b/drivers/staging/rtl8723au/include/xmit_osdep.h index 0eca53ece75d..b94e5467c408 100644 --- a/drivers/staging/rtl8723au/include/xmit_osdep.h +++ b/drivers/staging/rtl8723au/include/xmit_osdep.h @@ -44,7 +44,6 @@ int rtw_os_xmit_resource_alloc23a(struct rtw_adapter *padapter, struct xmit_buf *pxmitbuf, u32 alloc_sz); void rtw_os_xmit_resource_free23a(struct rtw_adapter *padapter, struct xmit_buf *pxmitbuf); -uint rtw_remainder_len23a(struct pkt_file *pfile); void _rtw_open_pktfile23a(struct sk_buff *pkt, struct pkt_file *pfile); uint _rtw_pktfile_read23a(struct pkt_file *pfile, u8 *rmem, uint rlen); int rtw_endofpktfile23a(struct pkt_file *pfile); diff --git a/drivers/staging/rtl8723au/os_dep/xmit_linux.c b/drivers/staging/rtl8723au/os_dep/xmit_linux.c index e1c6fc746233..3cf539a2dd0f 100644 --- a/drivers/staging/rtl8723au/os_dep/xmit_linux.c +++ b/drivers/staging/rtl8723au/os_dep/xmit_linux.c @@ -24,12 +24,6 @@ #include #include -uint rtw_remainder_len23a(struct pkt_file *pfile) -{ - return pfile->buf_len - ((unsigned long)(pfile->cur_addr) - - (unsigned long)(pfile->buf_start)); -} - void _rtw_open_pktfile23a(struct sk_buff *pktptr, struct pkt_file *pfile) { pfile->pkt = pktptr; @@ -45,7 +39,8 @@ uint _rtw_pktfile_read23a(struct pkt_file *pfile, u8 *rmem, uint rlen) { uint len = 0; - len = rtw_remainder_len23a(pfile); + len = pfile->buf_len - ((unsigned long)(pfile->cur_addr) - + (unsigned long)(pfile->buf_start)); len = (rlen > len) ? len : rlen; if (rmem) -- cgit v1.2.3 From 3483b8ae77ce81130dd379417131f8687e4a24d9 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 9 Apr 2014 23:21:09 +0200 Subject: staging: rtl8723au: Use proper ETH_P_* types instead of hard coded constants in rtw_xmit.c Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_xmit.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_xmit.c b/drivers/staging/rtl8723au/core/rtw_xmit.c index 0f10cfa10d39..6fcf4e29cb3c 100644 --- a/drivers/staging/rtl8723au/core/rtw_xmit.c +++ b/drivers/staging/rtl8723au/core/rtw_xmit.c @@ -453,11 +453,11 @@ static void set_qos(struct pkt_file *ppktfile, struct pkt_attrib *pattrib) _rtw_pktfile_read23a(ppktfile, (unsigned char*)ðerhdr, ETH_HLEN); /* get UserPriority from IP hdr */ - if (pattrib->ether_type == 0x0800) { + if (pattrib->ether_type == ETH_P_IP) { _rtw_pktfile_read23a(ppktfile, (u8*)&ip_hdr, sizeof(ip_hdr)); /* UserPriority = (ntohs(ip_hdr.tos) >> 5) & 0x3; */ UserPriority = ip_hdr.tos >> 5; - } else if (pattrib->ether_type == 0x888e) { + } else if (pattrib->ether_type == ETH_P_PAE) { /* "When priority processing of data frames is supported, */ /* a STA's SME should send EAPOL-Key frames at the highest priority." */ @@ -518,7 +518,7 @@ static s32 update_attrib(struct rtw_adapter *padapter, _rtw_pktfile_read23a(&pktfile, &tmp[0], 24); pattrib->dhcp_pkt = 0; if (pktfile.pkt_len > 282) {/* MINIMUM_DHCP_PACKET_SIZE) { */ - if (ETH_P_IP == pattrib->ether_type) {/* IP header */ + if (pattrib->ether_type == ETH_P_IP) {/* IP header */ if (((tmp[21] == 68) && (tmp[23] == 67)) || ((tmp[21] == 67) && (tmp[23] == 68))) { /* 68 : UDP BOOTP client */ @@ -532,17 +532,17 @@ static s32 update_attrib(struct rtw_adapter *padapter, } } } - } else if (0x888e == pattrib->ether_type) { + } else if (pattrib->ether_type == ETH_P_PAE) { DBG_8723A_LEVEL(_drv_always_, "send eapol packet\n"); } - if ((pattrib->ether_type == 0x888e) || (pattrib->dhcp_pkt == 1)) { + if ((pattrib->ether_type == ETH_P_PAE) || (pattrib->dhcp_pkt == 1)) { rtw_set_scan_deny(padapter, 3000); } /* If EAPOL , ARP , OR DHCP packet, driver must be in active mode. */ - if ((pattrib->ether_type == 0x0806) || - (pattrib->ether_type == 0x888e) || (pattrib->dhcp_pkt == 1)) { + if ((pattrib->ether_type == ETH_P_ARP) || + (pattrib->ether_type == ETH_P_PAE) || (pattrib->dhcp_pkt == 1)) { rtw_lps_ctrl_wk_cmd23a(padapter, LPS_CTRL_SPECIAL_PACKET, 1); } @@ -610,7 +610,7 @@ static s32 update_attrib(struct rtw_adapter *padapter, pattrib->encrypt = 0; - if ((pattrib->ether_type != 0x888e) && + if ((pattrib->ether_type != ETH_P_PAE) && (check_fwstate(pmlmepriv, WIFI_MP_STATE) == false)) { RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("\npsta->ieee8021x_blocked == true, " -- cgit v1.2.3 From e59cb424d76440275f3667a3a173b9e6e81bb363 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 9 Apr 2014 23:21:10 +0200 Subject: staging: rtl8723au: Fix update_attrib() and set_qos() to not use pktfile nonsense Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_xmit.c | 60 ++++++++++++++----------------- 1 file changed, 26 insertions(+), 34 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_xmit.c b/drivers/staging/rtl8723au/core/rtw_xmit.c index 6fcf4e29cb3c..2fba6815455f 100644 --- a/drivers/staging/rtl8723au/core/rtw_xmit.c +++ b/drivers/staging/rtl8723au/core/rtw_xmit.c @@ -443,20 +443,16 @@ u8 qos_acm23a(u8 acm_mask, u8 priority) return change_priority; } -static void set_qos(struct pkt_file *ppktfile, struct pkt_attrib *pattrib) +static void set_qos(struct sk_buff *skb, struct pkt_attrib *pattrib) { - struct ethhdr etherhdr; - struct iphdr ip_hdr; + u8 *pframe = skb->data; + struct iphdr *ip_hdr; s32 UserPriority = 0; - _rtw_open_pktfile23a(ppktfile->pkt, ppktfile); - _rtw_pktfile_read23a(ppktfile, (unsigned char*)ðerhdr, ETH_HLEN); - /* get UserPriority from IP hdr */ if (pattrib->ether_type == ETH_P_IP) { - _rtw_pktfile_read23a(ppktfile, (u8*)&ip_hdr, sizeof(ip_hdr)); -/* UserPriority = (ntohs(ip_hdr.tos) >> 5) & 0x3; */ - UserPriority = ip_hdr.tos >> 5; + ip_hdr = (struct iphdr *)(pframe + ETH_HLEN); + UserPriority = ip_hdr->tos >> 5; } else if (pattrib->ether_type == ETH_P_PAE) { /* "When priority processing of data frames is supported, */ /* a STA's SME should send EAPOL-Key frames at the highest @@ -470,57 +466,53 @@ static void set_qos(struct pkt_file *ppktfile, struct pkt_attrib *pattrib) } static s32 update_attrib(struct rtw_adapter *padapter, - struct sk_buff *pkt, struct pkt_attrib *pattrib) + struct sk_buff *skb, struct pkt_attrib *pattrib) { - uint i; - struct pkt_file pktfile; struct sta_info *psta = NULL; - struct ethhdr etherhdr; - int bmcast; struct sta_priv *pstapriv = &padapter->stapriv; struct security_priv *psecuritypriv = &padapter->securitypriv; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct qos_priv *pqospriv = &pmlmepriv->qospriv; int res = _SUCCESS; + struct ethhdr *ehdr = (struct ethhdr *) skb->data; - _rtw_open_pktfile23a(pkt, &pktfile); - i = _rtw_pktfile_read23a(&pktfile, (u8*)ðerhdr, ETH_HLEN); - - pattrib->ether_type = ntohs(etherhdr.h_proto); + pattrib->ether_type = ntohs(ehdr->h_proto); - memcpy(pattrib->dst, ðerhdr.h_dest, ETH_ALEN); - memcpy(pattrib->src, ðerhdr.h_source, ETH_ALEN); + ether_addr_copy(pattrib->dst, ehdr->h_dest); + ether_addr_copy(pattrib->src, ehdr->h_source); pattrib->pctrl = 0; if ((check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) == true) || (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) == true)) { - memcpy(pattrib->ra, pattrib->dst, ETH_ALEN); - memcpy(pattrib->ta, pattrib->src, ETH_ALEN); + ether_addr_copy(pattrib->ra, pattrib->dst); + ether_addr_copy(pattrib->ta, pattrib->src); } else if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)) { - memcpy(pattrib->ra, get_bssid(pmlmepriv), ETH_ALEN); - memcpy(pattrib->ta, pattrib->src, ETH_ALEN); + ether_addr_copy(pattrib->ra, get_bssid(pmlmepriv)); + ether_addr_copy(pattrib->ta, pattrib->src); } else if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) { - memcpy(pattrib->ra, pattrib->dst, ETH_ALEN); - memcpy(pattrib->ta, get_bssid(pmlmepriv), ETH_ALEN); + ether_addr_copy(pattrib->ra, pattrib->dst); + ether_addr_copy(pattrib->ta, get_bssid(pmlmepriv)); } - pattrib->pktlen = pktfile.pkt_len; + pattrib->pktlen = skb->len - ETH_HLEN; if (pattrib->ether_type == ETH_P_IP) { /* The following is for DHCP and ARP packet, we use cck1M to tx these packets and let LPS awake some time */ /* to prevent DHCP protocol fail */ - u8 tmp[24]; - _rtw_pktfile_read23a(&pktfile, &tmp[0], 24); pattrib->dhcp_pkt = 0; - if (pktfile.pkt_len > 282) {/* MINIMUM_DHCP_PACKET_SIZE) { */ + /* MINIMUM_DHCP_PACKET_SIZE) { */ + if (pattrib->pktlen > 282 + 24) { if (pattrib->ether_type == ETH_P_IP) {/* IP header */ - if (((tmp[21] == 68) && (tmp[23] == 67)) || - ((tmp[21] == 67) && (tmp[23] == 68))) { + u8 *pframe = skb->data; + pframe += ETH_HLEN; + + if ((pframe[21] == 68 && pframe[23] == 67) || + (pframe[21] == 67 && pframe[23] == 68)) { /* 68 : UDP BOOTP client */ /* 67 : UDP BOOTP server */ RT_TRACE(_module_rtl871x_xmit_c_, @@ -592,10 +584,10 @@ static s32 update_attrib(struct rtw_adapter *padapter, if (check_fwstate(pmlmepriv, WIFI_AP_STATE | WIFI_ADHOC_STATE | WIFI_ADHOC_MASTER_STATE)) { if (psta->qos_option) - set_qos(&pktfile, pattrib); + set_qos(skb, pattrib); } else { if (pqospriv->qos_option) { - set_qos(&pktfile, pattrib); + set_qos(skb, pattrib); if (pmlmepriv->acm_mask != 0) { pattrib->priority = qos_acm23a(pmlmepriv->acm_mask, -- cgit v1.2.3 From 69a0f9745c963de5ea1e42cdb8370913248c4872 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 9 Apr 2014 23:21:11 +0200 Subject: staging: rtl8723au: Make rtw_xmitframe_coalesce23a() more readable Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_xmit.c | 56 +++++++++++++++++++------------ 1 file changed, 34 insertions(+), 22 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_xmit.c b/drivers/staging/rtl8723au/core/rtw_xmit.c index 2fba6815455f..7ab436b0c88d 100644 --- a/drivers/staging/rtl8723au/core/rtw_xmit.c +++ b/drivers/staging/rtl8723au/core/rtw_xmit.c @@ -1112,9 +1112,9 @@ s32 rtw_xmitframe_coalesce23a(struct rtw_adapter *padapter, struct sk_buff *pkt, struct xmit_frame *pxmitframe) { struct pkt_file pktfile; - struct sta_info *psta; - struct xmit_priv *pxmitpriv = &padapter->xmitpriv; - struct pkt_attrib *pattrib = &pxmitframe->attrib; + struct sta_info *psta; + struct xmit_priv *pxmitpriv = &padapter->xmitpriv; + struct pkt_attrib *pattrib = &pxmitframe->attrib; s32 frg_inx, frg_len, mpdu_len, llc_sz, mem_sz; u8 *pframe, *mem_start; u8 hw_hdr_offset; @@ -1123,24 +1123,25 @@ s32 rtw_xmitframe_coalesce23a(struct rtw_adapter *padapter, struct sk_buff *pkt, s32 bmcst = is_multicast_ether_addr(pattrib->ra); s32 res = _SUCCESS; - if (pattrib->psta) { + if (pattrib->psta) psta = pattrib->psta; - } else { + else { DBG_8723A("%s, call rtw_get_stainfo23a()\n", __func__); psta = rtw_get_stainfo23a(&padapter->stapriv, pattrib->ra); } - if (psta == NULL) { + if (!psta) { DBG_8723A("%s, psta == NUL\n", __func__); return _FAIL; } if (!(psta->state &_FW_LINKED)) { - DBG_8723A("%s, psta->state(0x%x) != _FW_LINKED\n", __func__, psta->state); + DBG_8723A("%s, psta->state(0x%x) != _FW_LINKED\n", + __func__, psta->state); return _FAIL; } - if (pxmitframe->buf_addr == NULL) { + if (!pxmitframe->buf_addr) { DBG_8723A("==> %s buf_addr == NULL\n", __func__); return _FAIL; } @@ -1149,7 +1150,7 @@ s32 rtw_xmitframe_coalesce23a(struct rtw_adapter *padapter, struct sk_buff *pkt, hw_hdr_offset = TXDESC_OFFSET; - mem_start = pbuf_start + hw_hdr_offset; + mem_start = pbuf_start + hw_hdr_offset; if (rtw_make_wlanhdr23a(padapter, mem_start, pattrib) == _FAIL) { RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, @@ -1179,23 +1180,30 @@ s32 rtw_xmitframe_coalesce23a(struct rtw_adapter *padapter, struct sk_buff *pkt, /* adding icv, if necessary... */ if (pattrib->iv_len) { - if (psta != NULL) { + if (psta) { switch (pattrib->encrypt) { case _WEP40_: case _WEP104_: - WEP_IV(pattrib->iv, psta->dot11txpn, pattrib->key_idx); + WEP_IV(pattrib->iv, psta->dot11txpn, + pattrib->key_idx); break; case _TKIP_: if (bmcst) - TKIP_IV(pattrib->iv, psta->dot11txpn, pattrib->key_idx); + TKIP_IV(pattrib->iv, + psta->dot11txpn, + pattrib->key_idx); else - TKIP_IV(pattrib->iv, psta->dot11txpn, 0); + TKIP_IV(pattrib->iv, + psta->dot11txpn, 0); break; case _AES_: if (bmcst) - AES_IV(pattrib->iv, psta->dot11txpn, pattrib->key_idx); + AES_IV(pattrib->iv, + psta->dot11txpn, + pattrib->key_idx); else - AES_IV(pattrib->iv, psta->dot11txpn, 0); + AES_IV(pattrib->iv, + psta->dot11txpn, 0); break; } } @@ -1217,14 +1225,16 @@ s32 rtw_xmitframe_coalesce23a(struct rtw_adapter *padapter, struct sk_buff *pkt, mpdu_len -= llc_sz; } - if ((pattrib->icv_len >0) && (pattrib->bswenc)) + if (pattrib->icv_len > 0 && pattrib->bswenc) mpdu_len -= pattrib->icv_len; if (bmcst) { /* don't do fragment to broadcat/multicast packets */ - mem_sz = _rtw_pktfile_read23a(&pktfile, pframe, pattrib->pktlen); + mem_sz = _rtw_pktfile_read23a(&pktfile, pframe, + pattrib->pktlen); } else { - mem_sz = _rtw_pktfile_read23a(&pktfile, pframe, mpdu_len); + mem_sz = _rtw_pktfile_read23a(&pktfile, pframe, + mpdu_len); } pframe += mem_sz; @@ -1235,7 +1245,7 @@ s32 rtw_xmitframe_coalesce23a(struct rtw_adapter *padapter, struct sk_buff *pkt, frg_inx++; - if (bmcst || (rtw_endofpktfile23a(&pktfile))) { + if (bmcst || rtw_endofpktfile23a(&pktfile)) { pattrib->nr_frags = frg_inx; pattrib->last_txcmdsz = pattrib->hdrlen + @@ -1249,16 +1259,18 @@ s32 rtw_xmitframe_coalesce23a(struct rtw_adapter *padapter, struct sk_buff *pkt, break; } else { - RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("%s: There're still something in packet!\n", __func__)); + RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, + ("%s: There're still something in packet!\n", + __func__)); } mem_start = PTR_ALIGN(pframe, 4) + hw_hdr_offset; memcpy(mem_start, pbuf_start + hw_hdr_offset, pattrib->hdrlen); - } if (xmitframe_addmic(padapter, pxmitframe) == _FAIL) { - RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("xmitframe_addmic(padapter, pxmitframe) == _FAIL\n")); + RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, + ("xmitframe_addmic(padapter, pxmitframe) == _FAIL\n")); DBG_8723A("xmitframe_addmic(padapter, pxmitframe) == _FAIL\n"); res = _FAIL; goto exit; -- cgit v1.2.3 From 3e689a9ff53952aad8aca5bd7d01c09268e8deea Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 9 Apr 2014 23:21:12 +0200 Subject: staging: rtl8723au: Don't use pktfile interface in rtw_xmitframe_coalesce23a() The pktfil interface is horrible, no idea where it came from, but not using it is a win. Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_xmit.c | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_xmit.c b/drivers/staging/rtl8723au/core/rtw_xmit.c index 7ab436b0c88d..c0e2d7607b72 100644 --- a/drivers/staging/rtl8723au/core/rtw_xmit.c +++ b/drivers/staging/rtl8723au/core/rtw_xmit.c @@ -1108,10 +1108,9 @@ This sub-routine will perform all the following: 6. apply sw-encrypt, if necessary. */ -s32 rtw_xmitframe_coalesce23a(struct rtw_adapter *padapter, struct sk_buff *pkt, +s32 rtw_xmitframe_coalesce23a(struct rtw_adapter *padapter, struct sk_buff *skb, struct xmit_frame *pxmitframe) { - struct pkt_file pktfile; struct sta_info *psta; struct xmit_priv *pxmitpriv = &padapter->xmitpriv; struct pkt_attrib *pattrib = &pxmitframe->attrib; @@ -1119,7 +1118,8 @@ s32 rtw_xmitframe_coalesce23a(struct rtw_adapter *padapter, struct sk_buff *pkt, u8 *pframe, *mem_start; u8 hw_hdr_offset; u8 *pbuf_start; - + u8 *pdata = skb->data; + int data_len = skb->len; s32 bmcst = is_multicast_ether_addr(pattrib->ra); s32 res = _SUCCESS; @@ -1160,8 +1160,8 @@ s32 rtw_xmitframe_coalesce23a(struct rtw_adapter *padapter, struct sk_buff *pkt, goto exit; } - _rtw_open_pktfile23a(pkt, &pktfile); - _rtw_pktfile_read23a(&pktfile, NULL, pattrib->pkt_hdrlen); + pdata += pattrib->pkt_hdrlen; + data_len -= pattrib->pkt_hdrlen; frg_inx = 0; frg_len = pxmitpriv->frag_len - 4;/* 2346-4 = 2342 */ @@ -1228,15 +1228,17 @@ s32 rtw_xmitframe_coalesce23a(struct rtw_adapter *padapter, struct sk_buff *pkt, if (pattrib->icv_len > 0 && pattrib->bswenc) mpdu_len -= pattrib->icv_len; - if (bmcst) { + if (bmcst) /* don't do fragment to broadcat/multicast packets */ - mem_sz = _rtw_pktfile_read23a(&pktfile, pframe, - pattrib->pktlen); - } else { - mem_sz = _rtw_pktfile_read23a(&pktfile, pframe, - mpdu_len); - } + mem_sz = min_t(s32, data_len, pattrib->pktlen); + else + mem_sz = min_t(s32, data_len, mpdu_len); + + memcpy(pframe, pdata, mem_sz); + pframe += mem_sz; + pdata += mem_sz; + data_len -= mem_sz; if ((pattrib->icv_len >0) && (pattrib->bswenc)) { memcpy(pframe, pattrib->icv, pattrib->icv_len); @@ -1245,7 +1247,7 @@ s32 rtw_xmitframe_coalesce23a(struct rtw_adapter *padapter, struct sk_buff *pkt, frg_inx++; - if (bmcst || rtw_endofpktfile23a(&pktfile)) { + if (bmcst || data_len <= 0) { pattrib->nr_frags = frg_inx; pattrib->last_txcmdsz = pattrib->hdrlen + -- cgit v1.2.3 From 4c9c5700d6719f2e7b45e1c71fdfbc88b5ce44d5 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 9 Apr 2014 23:21:13 +0200 Subject: staging: rtl8723au: Remove ugly pktfile interface Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/include/xmit_osdep.h | 12 --------- drivers/staging/rtl8723au/os_dep/xmit_linux.c | 36 -------------------------- 2 files changed, 48 deletions(-) diff --git a/drivers/staging/rtl8723au/include/xmit_osdep.h b/drivers/staging/rtl8723au/include/xmit_osdep.h index b94e5467c408..9740ef6d96f9 100644 --- a/drivers/staging/rtl8723au/include/xmit_osdep.h +++ b/drivers/staging/rtl8723au/include/xmit_osdep.h @@ -18,15 +18,6 @@ #include #include -struct pkt_file { - struct sk_buff *pkt; - __kernel_size_t pkt_len; /* the remainder length of the open_file */ - unsigned char *cur_buffer; - u8 *buf_start; - u8 *cur_addr; - __kernel_size_t buf_len; -}; - #define NR_XMITFRAME 256 @@ -44,9 +35,6 @@ int rtw_os_xmit_resource_alloc23a(struct rtw_adapter *padapter, struct xmit_buf *pxmitbuf, u32 alloc_sz); void rtw_os_xmit_resource_free23a(struct rtw_adapter *padapter, struct xmit_buf *pxmitbuf); -void _rtw_open_pktfile23a(struct sk_buff *pkt, struct pkt_file *pfile); -uint _rtw_pktfile_read23a(struct pkt_file *pfile, u8 *rmem, uint rlen); -int rtw_endofpktfile23a(struct pkt_file *pfile); void rtw_os_pkt_complete23a(struct rtw_adapter *padapter, struct sk_buff *pkt); void rtw_os_xmit_complete23a(struct rtw_adapter *padapter, diff --git a/drivers/staging/rtl8723au/os_dep/xmit_linux.c b/drivers/staging/rtl8723au/os_dep/xmit_linux.c index 3cf539a2dd0f..69f88848715a 100644 --- a/drivers/staging/rtl8723au/os_dep/xmit_linux.c +++ b/drivers/staging/rtl8723au/os_dep/xmit_linux.c @@ -24,42 +24,6 @@ #include #include -void _rtw_open_pktfile23a(struct sk_buff *pktptr, struct pkt_file *pfile) -{ - pfile->pkt = pktptr; - pfile->buf_start = pktptr->data; - pfile->cur_addr = pktptr->data; - pfile->buf_len = pktptr->len; - pfile->pkt_len = pktptr->len; - - pfile->cur_buffer = pfile->buf_start; -} - -uint _rtw_pktfile_read23a(struct pkt_file *pfile, u8 *rmem, uint rlen) -{ - uint len = 0; - - len = pfile->buf_len - ((unsigned long)(pfile->cur_addr) - - (unsigned long)(pfile->buf_start)); - len = (rlen > len) ? len : rlen; - - if (rmem) - skb_copy_bits(pfile->pkt, pfile->buf_len-pfile->pkt_len, - rmem, len); - - pfile->cur_addr += len; - pfile->pkt_len -= len; - - return len; -} - -int rtw_endofpktfile23a(struct pkt_file *pfile) -{ - if (pfile->pkt_len == 0) - return true; - return false; -} - int rtw_os_xmit_resource_alloc23a(struct rtw_adapter *padapter, struct xmit_buf *pxmitbuf, u32 alloc_sz) { -- cgit v1.2.3 From 458dc03913b77501f069b268198d0751b8837e46 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 9 Apr 2014 23:21:14 +0200 Subject: staging: rtl8723au: Remove unnecessary forward struct declarations from xmit_osdep.h Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/include/xmit_osdep.h | 6 ------ 1 file changed, 6 deletions(-) diff --git a/drivers/staging/rtl8723au/include/xmit_osdep.h b/drivers/staging/rtl8723au/include/xmit_osdep.h index 9740ef6d96f9..2be04c48656c 100644 --- a/drivers/staging/rtl8723au/include/xmit_osdep.h +++ b/drivers/staging/rtl8723au/include/xmit_osdep.h @@ -21,12 +21,6 @@ #define NR_XMITFRAME 256 -struct xmit_priv; -struct pkt_attrib; -struct sta_xmit_priv; -struct xmit_frame; -struct xmit_buf; - int rtw_xmit23a_entry23a(struct sk_buff *pkt, struct net_device *pnetdev); void rtw_os_xmit_schedule23a(struct rtw_adapter *padapter); -- cgit v1.2.3 From 8000d1c413059c7d6b84bc57610353b2b546d74d Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 9 Apr 2014 23:21:15 +0200 Subject: staging: rtl8723au: No need to include header files for unused circ_buf and old iwpriv bits Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/include/osdep_service.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/staging/rtl8723au/include/osdep_service.h b/drivers/staging/rtl8723au/include/osdep_service.h index e03d19b84bcb..a2cc21cd318b 100644 --- a/drivers/staging/rtl8723au/include/osdep_service.h +++ b/drivers/staging/rtl8723au/include/osdep_service.h @@ -30,7 +30,6 @@ #include #include #include -#include #include #include #include @@ -40,7 +39,6 @@ #include #include #include -#include #include #include #include -- cgit v1.2.3 From 9cd81fa609eaa23c95817f2afeb516c24a9c3001 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 9 Apr 2014 23:21:16 +0200 Subject: staging: rtl8723au: Remove a couple of unused prototypes Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/include/osdep_service.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/staging/rtl8723au/include/osdep_service.h b/drivers/staging/rtl8723au/include/osdep_service.h index a2cc21cd318b..c5fb356d6be2 100644 --- a/drivers/staging/rtl8723au/include/osdep_service.h +++ b/drivers/staging/rtl8723au/include/osdep_service.h @@ -195,9 +195,7 @@ bool rtw_cbuf_push23a(struct rtw_cbuf *cbuf, void *buf); void *rtw_cbuf_pop23a(struct rtw_cbuf *cbuf); struct rtw_cbuf *rtw_cbuf_alloc23a(u32 size); void rtw_cbuf_free(struct rtw_cbuf *cbuf); -int rtw_change_ifname(struct rtw_adapter *padapter, const char *ifname); s32 c2h_evt_hdl(struct rtw_adapter *adapter, struct c2h_evt_hdr *c2h_evt, c2h_id_filter filter); -void indicate_wx_scan_complete_event(struct rtw_adapter *padapter); u8 rtw_do_join23a(struct rtw_adapter *padapter); #endif -- cgit v1.2.3 From 6484767b93e3cb81b0e70dc3c877f5d721e89c27 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 9 Apr 2014 23:21:17 +0200 Subject: staging: rtl8723au: Remove unused bitshift() function Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/include/osdep_service.h | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/drivers/staging/rtl8723au/include/osdep_service.h b/drivers/staging/rtl8723au/include/osdep_service.h index c5fb356d6be2..6b7d7aa464fd 100644 --- a/drivers/staging/rtl8723au/include/osdep_service.h +++ b/drivers/staging/rtl8723au/include/osdep_service.h @@ -147,16 +147,6 @@ extern unsigned char MCS_rate_1R23A[16]; void _rtw_init_queue23a(struct rtw_queue *pqueue); u32 _rtw_queue_empty23a(struct rtw_queue *pqueue); -static inline u32 bitshift(u32 bitmask) -{ - u32 i; - - for (i = 0; i <= 31; i++) - if (((bitmask>>i) & 0x1) == 1) break; - - return i; -} - void rtw_suspend_lock_init(void); void rtw_suspend_lock_uninit(void); void rtw_lock_suspend(void); -- cgit v1.2.3 From 88cdc943c5d8fc5e5920c20a275ec1759fd8e6fd Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Wed, 9 Apr 2014 23:21:18 +0200 Subject: staging: rtl8723au: Fix build error due to bad commit 6c89f82 Two routines are missing includes of a necessary header. Signed-off-by: Larry Finger Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_cmd.c | 1 + drivers/staging/rtl8723au/core/rtw_pwrctrl.c | 1 + 2 files changed, 2 insertions(+) diff --git a/drivers/staging/rtl8723au/core/rtw_cmd.c b/drivers/staging/rtl8723au/core/rtw_cmd.c index 2c558e0dd12b..592f0ee274e4 100644 --- a/drivers/staging/rtl8723au/core/rtw_cmd.c +++ b/drivers/staging/rtl8723au/core/rtw_cmd.c @@ -19,6 +19,7 @@ #include #include #include +#include #ifdef CONFIG_8723AU_BT_COEXIST #include diff --git a/drivers/staging/rtl8723au/core/rtw_pwrctrl.c b/drivers/staging/rtl8723au/core/rtw_pwrctrl.c index 07c63246ca31..c14b8193ce02 100644 --- a/drivers/staging/rtl8723au/core/rtw_pwrctrl.c +++ b/drivers/staging/rtl8723au/core/rtw_pwrctrl.c @@ -17,6 +17,7 @@ #include #include #include +#include #ifdef CONFIG_8723AU_BT_COEXIST #include -- cgit v1.2.3 From f4337aa31d67202f8d9db84ec43f2270b8878cd5 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 9 Apr 2014 23:21:19 +0200 Subject: staging: rtl8723au: Call do_div() directly and get rid of unnecessary wrapper functions Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c | 4 ++-- drivers/staging/rtl8723au/include/osdep_service.h | 4 ---- drivers/staging/rtl8723au/os_dep/osdep_service.c | 11 ----------- 3 files changed, 2 insertions(+), 17 deletions(-) diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c index 8ea00ba851a2..0a86923e7def 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c @@ -3031,8 +3031,8 @@ void hw_var_set_correct_tsf(struct rtw_adapter *padapter) /* tsf = pmlmeext->TSFValue - ((u32)pmlmeext->TSFValue % (pmlmeinfo->bcn_interval*1024)) - 1024; us */ tsf = pmlmeext->TSFValue - - rtw_modular6423a(pmlmeext->TSFValue, - (pmlmeinfo->bcn_interval * 1024)) - 1024; /* us */ + do_div(pmlmeext->TSFValue, + (pmlmeinfo->bcn_interval * 1024)) - 1024; /* us */ if (((pmlmeinfo->state & 0x03) == WIFI_FW_ADHOC_STATE) || ((pmlmeinfo->state & 0x03) == WIFI_FW_AP_STATE)) { diff --git a/drivers/staging/rtl8723au/include/osdep_service.h b/drivers/staging/rtl8723au/include/osdep_service.h index 6b7d7aa464fd..92c954eb2179 100644 --- a/drivers/staging/rtl8723au/include/osdep_service.h +++ b/drivers/staging/rtl8723au/include/osdep_service.h @@ -162,10 +162,6 @@ void rtw_unlock_suspend(void); #define FUNC_ADPT_FMT "%s(%s)" #define FUNC_ADPT_ARG(adapter) __func__, adapter->pnetdev->name -u64 rtw_modular6423a(u64 x, u64 y); -u64 rtw_division6423a(u64 x, u64 y); - - /* Macros for handling unaligned memory accesses */ #define RTW_GET_BE24(a) ((((u32) (a)[0]) << 16) | (((u32) (a)[1]) << 8) | \ diff --git a/drivers/staging/rtl8723au/os_dep/osdep_service.c b/drivers/staging/rtl8723au/os_dep/osdep_service.c index 97fc27dce19c..b89e779fa045 100644 --- a/drivers/staging/rtl8723au/os_dep/osdep_service.c +++ b/drivers/staging/rtl8723au/os_dep/osdep_service.c @@ -71,17 +71,6 @@ u32 _rtw_queue_empty23a(struct rtw_queue *pqueue) return false; } -u64 rtw_modular6423a(u64 x, u64 y) -{ - return do_div(x, y); -} - -u64 rtw_division6423a(u64 x, u64 y) -{ - do_div(x, y); - return x; -} - /* rtw_cbuf_full23a - test if cbuf is full * @cbuf: pointer of struct rtw_cbuf * -- cgit v1.2.3 From 7dd1e720256ebd5628fb9e9193d95eacaeb42b27 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 9 Apr 2014 23:21:20 +0200 Subject: staging: rtl8723au: Use proper ETH_P_* types in rtw_recv.c Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_recv.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_recv.c b/drivers/staging/rtl8723au/core/rtw_recv.c index 0b2455e4f5b6..8ae191654a42 100644 --- a/drivers/staging/rtl8723au/core/rtw_recv.c +++ b/drivers/staging/rtl8723au/core/rtw_recv.c @@ -576,7 +576,7 @@ static struct recv_frame *portctrl(struct rtw_adapter *adapter, struct sta_priv *pstapriv ; struct recv_frame *prtnframe; u16 ether_type = 0; - u16 eapol_type = 0x888e;/* for Funia BD's WPA issue */ + u16 eapol_type = ETH_P_PAE;/* for Funia BD's WPA issue */ struct rx_pkt_attrib *pattrib; pstapriv = &adapter->stapriv; @@ -2102,7 +2102,7 @@ int recv_indicatepkt_reorder(struct rtw_adapter *padapter, /* s1. */ wlanhdr_to_ethhdr(prframe); - if ((pattrib->qos!= 1) || (pattrib->eth_type == 0x0806) || + if ((pattrib->qos!= 1) || (pattrib->eth_type == ETH_P_ARP) || (pattrib->ack_policy != 0)) { if ((padapter->bDriverStopped == false) && (padapter->bSurpriseRemoved == false)) { -- cgit v1.2.3 From 514c485c01676927feb77c2a3e350bb3985fa11e Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 9 Apr 2014 23:21:21 +0200 Subject: staging: rtl8723au: Fix case where ethtype was never obtained and always be checked against 0 Zero-initializing ether_type masked that the ether type would never be obtained for 8021x packets and the comparition against eapol_type would always fail. Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_recv.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_recv.c b/drivers/staging/rtl8723au/core/rtw_recv.c index 8ae191654a42..e448511d2f45 100644 --- a/drivers/staging/rtl8723au/core/rtw_recv.c +++ b/drivers/staging/rtl8723au/core/rtw_recv.c @@ -575,7 +575,7 @@ static struct recv_frame *portctrl(struct rtw_adapter *adapter, struct sta_info *psta; struct sta_priv *pstapriv ; struct recv_frame *prtnframe; - u16 ether_type = 0; + u16 ether_type; u16 eapol_type = ETH_P_PAE;/* for Funia BD's WPA issue */ struct rx_pkt_attrib *pattrib; @@ -593,7 +593,12 @@ static struct recv_frame *portctrl(struct rtw_adapter *adapter, ("########portctrl:adapter->securitypriv.dot11AuthAlgrthm =" "%d\n", adapter->securitypriv.dot11AuthAlgrthm)); - if (auth_alg == 2) { + if (auth_alg == dot11AuthAlgrthm_8021X) { + /* get ether_type */ + ptr = ptr + pfhdr->attrib.hdrlen + LLC_HEADER_SIZE; + memcpy(ðer_type, ptr, 2); + ether_type = ntohs((unsigned short)ether_type); + if ((psta != NULL) && (psta->ieee8021x_blocked)) { /* blocked */ /* only accept EAPOL frame */ @@ -601,13 +606,6 @@ static struct recv_frame *portctrl(struct rtw_adapter *adapter, ("########portctrl:psta->ieee8021x_blocked ==" "1\n")); - prtnframe = precv_frame; - - /* get ether_type */ - ptr = ptr + pfhdr->attrib.hdrlen + LLC_HEADER_SIZE; - memcpy(ðer_type, ptr, 2); - ether_type = ntohs((unsigned short)ether_type); - if (ether_type == eapol_type) { prtnframe = precv_frame; } else { @@ -651,9 +649,7 @@ static struct recv_frame *portctrl(struct rtw_adapter *adapter, prtnframe = precv_frame; } - - - return prtnframe; + return prtnframe; } int recv_decache(struct recv_frame *precv_frame, u8 bretry, -- cgit v1.2.3 From 7d0d2b15a0e06ce18c5fd69c4c9692f5670aa9d4 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 9 Apr 2014 23:21:22 +0200 Subject: staging: rtl8723au: Calling rtw_get_stainfo() with a NULL sta_addr will return NULL This makes the follow-on check for psta != NULL pointless and makes the whole exercise rather pointless. This is another case of why blindly zero-initializing variables when they are declared is bad. This bug seems to be present in multiple drivers provided by Realtek. Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_recv.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_recv.c b/drivers/staging/rtl8723au/core/rtw_recv.c index e448511d2f45..5292bc2fd29a 100644 --- a/drivers/staging/rtl8723au/core/rtw_recv.c +++ b/drivers/staging/rtl8723au/core/rtw_recv.c @@ -569,7 +569,7 @@ struct recv_frame *decryptor(struct rtw_adapter *padapter, static struct recv_frame *portctrl(struct rtw_adapter *adapter, struct recv_frame *precv_frame) { - u8 *psta_addr = NULL, *ptr; + u8 *psta_addr, *ptr; uint auth_alg; struct recv_frame *pfhdr; struct sta_info *psta; @@ -580,7 +580,6 @@ static struct recv_frame *portctrl(struct rtw_adapter *adapter, struct rx_pkt_attrib *pattrib; pstapriv = &adapter->stapriv; - psta = rtw_get_stainfo23a(pstapriv, psta_addr); auth_alg = adapter->securitypriv.dot11AuthAlgrthm; @@ -588,6 +587,7 @@ static struct recv_frame *portctrl(struct rtw_adapter *adapter, pfhdr = precv_frame; pattrib = &pfhdr->attrib; psta_addr = pattrib->ta; + psta = rtw_get_stainfo23a(pstapriv, psta_addr); RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("########portctrl:adapter->securitypriv.dot11AuthAlgrthm =" -- cgit v1.2.3 From 94b080bc7005ad7be2519040410fdfef7345eb9d Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Wed, 9 Apr 2014 23:21:23 +0200 Subject: staging: rtl8723au: Simplify retrieving the ether_type in portctrl() This renders the last element in include/ethernet.h unnecessary, so remove it as well. Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 1 - drivers/staging/rtl8723au/core/rtw_recv.c | 8 +++----- drivers/staging/rtl8723au/hal/rtl8723au_recv.c | 1 - drivers/staging/rtl8723au/include/ethernet.h | 22 ---------------------- drivers/staging/rtl8723au/os_dep/os_intfs.c | 1 - drivers/staging/rtl8723au/os_dep/recv_linux.c | 1 - 6 files changed, 3 insertions(+), 31 deletions(-) delete mode 100644 drivers/staging/rtl8723au/include/ethernet.h diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index ae6ef6532af0..be593989aec7 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -21,7 +21,6 @@ #include #include #include -#include #include #ifdef CONFIG_8723AU_BT_COEXIST diff --git a/drivers/staging/rtl8723au/core/rtw_recv.c b/drivers/staging/rtl8723au/core/rtw_recv.c index 5292bc2fd29a..713a377ce28f 100644 --- a/drivers/staging/rtl8723au/core/rtw_recv.c +++ b/drivers/staging/rtl8723au/core/rtw_recv.c @@ -19,7 +19,6 @@ #include #include #include -#include #include #include #include @@ -583,7 +582,6 @@ static struct recv_frame *portctrl(struct rtw_adapter *adapter, auth_alg = adapter->securitypriv.dot11AuthAlgrthm; - ptr = precv_frame->pkt->data; pfhdr = precv_frame; pattrib = &pfhdr->attrib; psta_addr = pattrib->ta; @@ -595,9 +593,9 @@ static struct recv_frame *portctrl(struct rtw_adapter *adapter, if (auth_alg == dot11AuthAlgrthm_8021X) { /* get ether_type */ - ptr = ptr + pfhdr->attrib.hdrlen + LLC_HEADER_SIZE; - memcpy(ðer_type, ptr, 2); - ether_type = ntohs((unsigned short)ether_type); + ptr = pfhdr->pkt->data + pfhdr->attrib.hdrlen; + + ether_type = (ptr[6] << 8) | ptr[7]; if ((psta != NULL) && (psta->ieee8021x_blocked)) { /* blocked */ diff --git a/drivers/staging/rtl8723au/hal/rtl8723au_recv.c b/drivers/staging/rtl8723au/hal/rtl8723au_recv.c index 213d1936109d..a7568bb65e2a 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723au_recv.c +++ b/drivers/staging/rtl8723au/hal/rtl8723au_recv.c @@ -19,7 +19,6 @@ #include #include #include -#include #include #include #include diff --git a/drivers/staging/rtl8723au/include/ethernet.h b/drivers/staging/rtl8723au/include/ethernet.h deleted file mode 100644 index 39fc6df88188..000000000000 --- a/drivers/staging/rtl8723au/include/ethernet.h +++ /dev/null @@ -1,22 +0,0 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * - ******************************************************************************/ -/*! \file */ -#ifndef __INC_ETHERNET_H -#define __INC_ETHERNET_H - -#define LLC_HEADER_SIZE 6 /* LLC Header Length */ - -#endif /* #ifndef __INC_ETHERNET_H */ diff --git a/drivers/staging/rtl8723au/os_dep/os_intfs.c b/drivers/staging/rtl8723au/os_dep/os_intfs.c index eab40d21fb3d..7c7c2c93e413 100644 --- a/drivers/staging/rtl8723au/os_dep/os_intfs.c +++ b/drivers/staging/rtl8723au/os_dep/os_intfs.c @@ -20,7 +20,6 @@ #include #include #include -#include #include #include diff --git a/drivers/staging/rtl8723au/os_dep/recv_linux.c b/drivers/staging/rtl8723au/os_dep/recv_linux.c index 84402a589f25..18572090ac48 100644 --- a/drivers/staging/rtl8723au/os_dep/recv_linux.c +++ b/drivers/staging/rtl8723au/os_dep/recv_linux.c @@ -21,7 +21,6 @@ #include #include -#include #include -- cgit v1.2.3 From f619621f409a9e8d5c56b2089d359fe3b5b8ad57 Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Mon, 31 Mar 2014 10:50:36 +0300 Subject: staging: comedi: remove an unneeded variable "chanlist" was left over, we don't need it any more. Signed-off-by: Dan Carpenter Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/comedi_fops.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/staging/comedi/comedi_fops.c b/drivers/staging/comedi/comedi_fops.c index ea6dc36d753b..1e91161fb38f 100644 --- a/drivers/staging/comedi/comedi_fops.c +++ b/drivers/staging/comedi/comedi_fops.c @@ -1597,7 +1597,6 @@ static int do_cmdtest_ioctl(struct comedi_device *dev, { struct comedi_cmd cmd; struct comedi_subdevice *s; - unsigned int *chanlist = NULL; unsigned int __user *user_chanlist; int ret; @@ -1626,8 +1625,6 @@ static int do_cmdtest_ioctl(struct comedi_device *dev, ret = -EFAULT; } - kfree(chanlist); - return ret; } -- cgit v1.2.3 From b2f4874174b17db72d4a67aec2dac56304ceb8ba Mon Sep 17 00:00:00 2001 From: Yves Deweerdt Date: Mon, 31 Mar 2014 22:55:39 +0200 Subject: staging: comedi: comedy_fops.c: fix line over 80, characters warnings Signed-off-by: Yves Deweerdt Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/comedi_fops.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/staging/comedi/comedi_fops.c b/drivers/staging/comedi/comedi_fops.c index 1e91161fb38f..e283e6c7b52b 100644 --- a/drivers/staging/comedi/comedi_fops.c +++ b/drivers/staging/comedi/comedi_fops.c @@ -1435,13 +1435,15 @@ static int __comedi_get_user_cmd(struct comedi_device *dev, s = &dev->subdevices[cmd->subdev]; if (s->type == COMEDI_SUBD_UNUSED) { - dev_dbg(dev->class_dev, "%d not valid subdevice\n", cmd->subdev); + dev_dbg(dev->class_dev, "%d not valid subdevice\n", + cmd->subdev); return -EIO; } if (!s->do_cmd || !s->do_cmdtest || !s->async) { dev_dbg(dev->class_dev, - "subdevice %d does not support commands\n", cmd->subdev); + "subdevice %d does not support commands\n", + cmd->subdev); return -EIO; } -- cgit v1.2.3 From 1e4742df19bee14669e72ee3da670c3b6b33cd5e Mon Sep 17 00:00:00 2001 From: Yves Deweerdt Date: Mon, 31 Mar 2014 22:55:44 +0200 Subject: staging: comedi: drivers.c: Fix missing a blank line, after declarations warning Signed-off-by: Yves Deweerdt Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/staging/comedi/drivers.c b/drivers/staging/comedi/drivers.c index ab0e8ed47291..cb5d21411a0c 100644 --- a/drivers/staging/comedi/drivers.c +++ b/drivers/staging/comedi/drivers.c @@ -258,6 +258,7 @@ static int insn_rw_emulate_bits(struct comedi_device *dev, const unsigned base_bitfield_channel = (chan < channels_per_bitfield) ? 0 : chan; unsigned int new_data[2]; + memset(new_data, 0, sizeof(new_data)); memset(&new_insn, 0, sizeof(new_insn)); new_insn.insn = INSN_BITS; -- cgit v1.2.3 From 571845c6f47de51a41ab7964a144b22d297d06ce Mon Sep 17 00:00:00 2001 From: Chase Southwood Date: Thu, 3 Apr 2014 18:43:27 -0500 Subject: staging: comedi: s626: use comedi_timeout() on remaining loops There were just a handful of more while loops in this file that needed timeouts, and this patch takes care of them. One new callback is introduced, and all of the proper comedi_timeout() calls are then used. The return type of s626_i2c_handshake() has been changed from uint32_t to int so that a negative error code from comedi_timeout() can be propagated if necessary. Signed-off-by: Chase Southwood Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/s626.c | 36 ++++++++++++++++++++++++++--------- 1 file changed, 27 insertions(+), 9 deletions(-) diff --git a/drivers/staging/comedi/drivers/s626.c b/drivers/staging/comedi/drivers/s626.c index 95fadf343f27..6da43de51eb3 100644 --- a/drivers/staging/comedi/drivers/s626.c +++ b/drivers/staging/comedi/drivers/s626.c @@ -295,10 +295,24 @@ static void s626_debi_replace(struct comedi_device *dev, unsigned int addr, /* ************** EEPROM ACCESS FUNCTIONS ************** */ -static uint32_t s626_i2c_handshake(struct comedi_device *dev, uint32_t val) +static int s626_i2c_handshake_eoc(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned long context) +{ + bool status; + + status = s626_mc_test(dev, S626_MC2_UPLD_IIC, S626_P_MC2); + if (status) + return 0; + return -EBUSY; +} + +static int s626_i2c_handshake(struct comedi_device *dev, uint32_t val) { struct s626_private *devpriv = dev->private; unsigned int ctrl; + int ret; /* Write I2C command to I2C Transfer Control shadow register */ writel(val, devpriv->mmio + S626_P_I2CCTRL); @@ -308,8 +322,9 @@ static uint32_t s626_i2c_handshake(struct comedi_device *dev, uint32_t val) * wait for upload confirmation. */ s626_mc_enable(dev, S626_MC2_UPLD_IIC, S626_P_MC2); - while (!s626_mc_test(dev, S626_MC2_UPLD_IIC, S626_P_MC2)) - ; + ret = comedi_timeout(dev, NULL, NULL, s626_i2c_handshake_eoc, 0); + if (ret) + return ret; /* Wait until I2C bus transfer is finished or an error occurs */ do { @@ -2029,8 +2044,9 @@ static int s626_ai_insn_read(struct comedi_device *dev, /* Wait for the data to arrive in FB BUFFER 1 register. */ /* Wait for ADC done */ - while (!(readl(devpriv->mmio + S626_P_PSR) & S626_PSR_GPIO2)) - ; + ret = comedi_timeout(dev, s, insn, s626_ai_eoc, 0); + if (ret) + return ret; /* Fetch ADC data from audio interface's input shift register. */ @@ -2681,8 +2697,9 @@ static int s626_initialize(struct comedi_device *dev) writel(S626_I2C_CLKSEL | S626_I2C_ABORT, devpriv->mmio + S626_P_I2CSTAT); s626_mc_enable(dev, S626_MC2_UPLD_IIC, S626_P_MC2); - while (!(readl(devpriv->mmio + S626_P_MC2) & S626_MC2_UPLD_IIC)) - ; + ret = comedi_timeout(dev, NULL, NULL, s626_i2c_handshake_eoc, 0); + if (ret) + return ret; /* * Per SAA7146 data sheet, write to STATUS @@ -2691,8 +2708,9 @@ static int s626_initialize(struct comedi_device *dev) for (i = 0; i < 2; i++) { writel(S626_I2C_CLKSEL, devpriv->mmio + S626_P_I2CSTAT); s626_mc_enable(dev, S626_MC2_UPLD_IIC, S626_P_MC2); - while (!s626_mc_test(dev, S626_MC2_UPLD_IIC, S626_P_MC2)) - ; + ret = comedi_timeout(dev, NULL, NULL, s626_i2c_handshake_eoc, 0); + if (ret) + return ret; } /* -- cgit v1.2.3 From 6425b1c2d25d9cdcaa23c266a5845e8cd2e4f2d6 Mon Sep 17 00:00:00 2001 From: Kumar Amit Mehta Date: Fri, 4 Apr 2014 18:44:44 +0300 Subject: staging: comedi: drivers: pcl812.c: add curly braces for checkpatch Kernel style is that if one side of the if else statement gets has curly braces then both side should have them. Signed-off-by: Kumar Amit Mehta Acked-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/pcl812.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/staging/comedi/drivers/pcl812.c b/drivers/staging/comedi/drivers/pcl812.c index 160eac8083db..5cc01fe45cf2 100644 --- a/drivers/staging/comedi/drivers/pcl812.c +++ b/drivers/staging/comedi/drivers/pcl812.c @@ -811,8 +811,9 @@ static int pcl812_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) devpriv->ai_dma = 0; break; } - } else + } else { devpriv->ai_dma = 0; + } devpriv->ai_act_scan = 0; devpriv->ai_poll_ptr = 0; -- cgit v1.2.3 From b5ebcaa8d3405e14ca431257fd6c6cdc30df13c5 Mon Sep 17 00:00:00 2001 From: Georg Gast Date: Tue, 8 Apr 2014 18:52:58 +0200 Subject: staging: comedi: more descriptive names for addi-data drivers - more descriptive module description for following boards: ADDI-DATA APCI 1032/1500/1564/2032/3120 Signed-off-by: Georg Gast Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi_apci_1032.c | 2 +- drivers/staging/comedi/drivers/addi_apci_1500.c | 2 +- drivers/staging/comedi/drivers/addi_apci_1564.c | 2 +- drivers/staging/comedi/drivers/addi_apci_2032.c | 2 +- drivers/staging/comedi/drivers/addi_apci_3120.c | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi_apci_1032.c b/drivers/staging/comedi/drivers/addi_apci_1032.c index 0daa0ea63b5e..d6a5424654fc 100644 --- a/drivers/staging/comedi/drivers/addi_apci_1032.c +++ b/drivers/staging/comedi/drivers/addi_apci_1032.c @@ -379,5 +379,5 @@ static struct pci_driver apci1032_pci_driver = { module_comedi_pci_driver(apci1032_driver, apci1032_pci_driver); MODULE_AUTHOR("Comedi http://www.comedi.org"); -MODULE_DESCRIPTION("Comedi low-level driver"); +MODULE_DESCRIPTION("ADDI-DATA APCI-1032, 32 channel DI boards"); MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/addi_apci_1500.c b/drivers/staging/comedi/drivers/addi_apci_1500.c index bd8e08ca14c0..eab75eb26478 100644 --- a/drivers/staging/comedi/drivers/addi_apci_1500.c +++ b/drivers/staging/comedi/drivers/addi_apci_1500.c @@ -72,5 +72,5 @@ static struct pci_driver apci1500_pci_driver = { module_comedi_pci_driver(apci1500_driver, apci1500_pci_driver); MODULE_AUTHOR("Comedi http://www.comedi.org"); -MODULE_DESCRIPTION("Comedi low-level driver"); +MODULE_DESCRIPTION("ADDI-DATA APCI-1500, 16 channel DI / 16 channel DO boards"); MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/addi_apci_1564.c b/drivers/staging/comedi/drivers/addi_apci_1564.c index 27aa9ae1bdd9..11aa0bd5d7b1 100644 --- a/drivers/staging/comedi/drivers/addi_apci_1564.c +++ b/drivers/staging/comedi/drivers/addi_apci_1564.c @@ -70,5 +70,5 @@ static struct pci_driver apci1564_pci_driver = { module_comedi_pci_driver(apci1564_driver, apci1564_pci_driver); MODULE_AUTHOR("Comedi http://www.comedi.org"); -MODULE_DESCRIPTION("Comedi low-level driver"); +MODULE_DESCRIPTION("ADDI-DATA APCI-1564, 32 channel DI / 32 channel DO boards"); MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/addi_apci_2032.c b/drivers/staging/comedi/drivers/addi_apci_2032.c index c9b933cb5987..feefc7a5ca9a 100644 --- a/drivers/staging/comedi/drivers/addi_apci_2032.c +++ b/drivers/staging/comedi/drivers/addi_apci_2032.c @@ -374,5 +374,5 @@ static struct pci_driver apci2032_pci_driver = { module_comedi_pci_driver(apci2032_driver, apci2032_pci_driver); MODULE_AUTHOR("Comedi http://www.comedi.org"); -MODULE_DESCRIPTION("Comedi low-level driver"); +MODULE_DESCRIPTION("ADDI-DATA APCI-2032, 32 channel DO boards"); MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c b/drivers/staging/comedi/drivers/addi_apci_3120.c index 57ee6e5c7635..0cfb12fa1cbc 100644 --- a/drivers/staging/comedi/drivers/addi_apci_3120.c +++ b/drivers/staging/comedi/drivers/addi_apci_3120.c @@ -246,5 +246,5 @@ static struct pci_driver apci3120_pci_driver = { module_comedi_pci_driver(apci3120_driver, apci3120_pci_driver); MODULE_AUTHOR("Comedi http://www.comedi.org"); -MODULE_DESCRIPTION("Comedi low-level driver"); +MODULE_DESCRIPTION("ADDI-DATA APCI-3120, Analog input board"); MODULE_LICENSE("GPL"); -- cgit v1.2.3 From 110775bd5dbc811ab4d55f7498a57ef96994dbde Mon Sep 17 00:00:00 2001 From: Richard Leitner Date: Wed, 9 Apr 2014 18:27:13 +0200 Subject: staging: comedi: adl_pci9118: fix whitespace issues Removed not needed spaces and fixed too long lines Signed-off-by: Richard Leitner Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adl_pci9118.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/comedi/drivers/adl_pci9118.c b/drivers/staging/comedi/drivers/adl_pci9118.c index 3cfa1756fa6a..b6abef6ceab7 100644 --- a/drivers/staging/comedi/drivers/adl_pci9118.c +++ b/drivers/staging/comedi/drivers/adl_pci9118.c @@ -96,7 +96,7 @@ Configuration options: * correct channel number on every 12 bit sample */ -#define IORANGE_9118 64 /* I hope */ +#define IORANGE_9118 64 /* I hope */ #define PCI9118_CHANLEN 255 /* * len of chanlist, some source say 256, * but reality looks like 255 :-( @@ -383,7 +383,7 @@ struct pci9118_private { * users(0-AI, 1-AO, 2-DI, 3-DO) */ unsigned int cnt0_divisor; /* actual CNT0 divisor */ - void (*int_ai_func) (struct comedi_device *, struct comedi_subdevice *, + void (*int_ai_func)(struct comedi_device *, struct comedi_subdevice *, unsigned short, unsigned int, unsigned short); /* @@ -1045,7 +1045,7 @@ static void interrupt_pci9118_ai_dma(struct comedi_device *dev, move_block_from_dma(dev, s, devpriv->dmabuf_virt[devpriv->dma_actbuf], samplesinbuf); - m = m - sampls; /* m= how many samples was transferred */ + m = m - sampls; /* m=how many samples was transferred */ } if (!devpriv->ai_neverending) { -- cgit v1.2.3 From bee2d6a82cc31ebcc44a0ec9484ec1670c07ca6a Mon Sep 17 00:00:00 2001 From: Michele Curti Date: Thu, 10 Apr 2014 16:38:00 +0200 Subject: staging: comedi: declare das6402_boards as static das6402_boards array is used in das6402.c only, so declare it as static. Signed-off-by: Michele Curti Reviewed-by: Ian Abbott Acked-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das6402.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/comedi/drivers/das6402.c b/drivers/staging/comedi/drivers/das6402.c index e0cfb6cb547b..d18eea6c01aa 100644 --- a/drivers/staging/comedi/drivers/das6402.c +++ b/drivers/staging/comedi/drivers/das6402.c @@ -125,7 +125,7 @@ struct das6402_boardinfo { unsigned int maxdata; }; -struct das6402_boardinfo das6402_boards[] = { +static struct das6402_boardinfo das6402_boards[] = { { .name = "das6402-12", .maxdata = 0x0fff, -- cgit v1.2.3 From a47a0f506414022075c750e680ef84ce97dc2fb2 Mon Sep 17 00:00:00 2001 From: Gary Rookard Date: Thu, 20 Mar 2014 23:28:43 -0400 Subject: Staging: bcm: CmHost: remove temp bracing from switch/cases. Remove the temp bracing afixed to case labels. Properly indent switch/case breaks. Signed-off-by: Gary Alan Rookard Signed-off-by: Greg Kroah-Hartman --- drivers/staging/bcm/CmHost.c | 50 +++++++------------------------------------- 1 file changed, 7 insertions(+), 43 deletions(-) diff --git a/drivers/staging/bcm/CmHost.c b/drivers/staging/bcm/CmHost.c index 632f81a7c63f..4564c63f908c 100644 --- a/drivers/staging/bcm/CmHost.c +++ b/drivers/staging/bcm/CmHost.c @@ -460,42 +460,30 @@ static VOID CopyToAdapter(register struct bcm_mini_adapter *Adapter, /* u8CSSpecification); switch (psfLocalSet->u8CSSpecification) { case eCSPacketIPV4: - { Adapter->PackInfo[uiSearchRuleIndex].bIPCSSupport = IPV4_CS; break; - } case eCSPacketIPV6: - { Adapter->PackInfo[uiSearchRuleIndex].bIPCSSupport = IPV6_CS; break; - } case eCS802_3PacketEthernet: case eCS802_1QPacketVLAN: - { Adapter->PackInfo[uiSearchRuleIndex].bEthCSSupport = ETH_CS_802_3; break; - } case eCSPacketIPV4Over802_1QVLAN: case eCSPacketIPV4Over802_3Ethernet: - { Adapter->PackInfo[uiSearchRuleIndex].bIPCSSupport = IPV4_CS; Adapter->PackInfo[uiSearchRuleIndex].bEthCSSupport = ETH_CS_802_3; break; - } case eCSPacketIPV6Over802_1QVLAN: case eCSPacketIPV6Over802_3Ethernet: - { Adapter->PackInfo[uiSearchRuleIndex].bIPCSSupport = IPV6_CS; Adapter->PackInfo[uiSearchRuleIndex].bEthCSSupport = ETH_CS_802_3; break; - } default: - { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Error in value of CS Classification.. setting default to IP CS\n"); Adapter->PackInfo[uiSearchRuleIndex].bIPCSSupport = IPV4_CS; break; } - } BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "CopyToAdapter : Queue No : %X ETH CS Support : %X , IP CS Support : %X\n", uiSearchRuleIndex, @@ -542,32 +530,23 @@ static VOID CopyToAdapter(register struct bcm_mini_adapter *Adapter, /* u8ClassfierDSCAction) { case 0: /* DSC Add Classifier */ - { eClassifierAction = eAddClassifier; - } - break; + break; case 1: /* DSC Replace Classifier */ - { eClassifierAction = eReplaceClassifier; - } - break; + break; case 2: /* DSC Delete Classifier */ - { eClassifierAction = eDeleteClassifier; - } - break; + break; default: - { eClassifierAction = eInvalidClassifierAction; } - } } u16PacketClassificationRuleIndex = ntohs(psfCSType->cCPacketClassificationRule.u16PacketClassificationRuleIndex); switch (eClassifierAction) { case eAddClassifier: - { /* Get a Free Classifier Index From Classifier table for this SF to add the Classifier */ /* Contained in this message */ nClassifierIndex = SearchClsid(Adapter, ulSFID, u16PacketClassificationRuleIndex); @@ -587,10 +566,8 @@ static VOID CopyToAdapter(register struct bcm_mini_adapter *Adapter, /* u8PhsDSCAction) { case eDeleteAllPHSRules: - { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "Deleting All PHS Rules For VCID: 0x%X\n", uVCID); /* Delete All the PHS rules for this Service flow */ PhsDeleteSFRules(&Adapter->stBCMPhsContext, uVCID); break; - } case eDeletePHSRule: - { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, CONN_MSG, DBG_LVL_ALL, "PHS DSC Action = Delete PHS Rule\n"); if (psfCSType->cPhsRule.u8PHSI) PhsDeletePHSRule(&Adapter->stBCMPhsContext, uVCID, psfCSType->cCPacketClassificationRule.u8AssociatedPHSI); break; - } default: - { if (ucDsxType == DSC_ACK) { /* BCM_DEBUG_PRINT(CONN_MSG,("Invalid PHS DSC Action For DSC\n",psfCSType->cPhsRule.u8PHSI)); */ break; /* FOr DSC ACK Case PHS DSC Action must be in valid set */ } - } /* Proceed To Add PHS rule for DSA_ACK case even if PHS DSC action is unspecified */ /* No Break Here . Intentionally! */ case eAddPHSRule: case eSetPHSRule: - { if (psfCSType->cPhsRule.u8PHSI) { /* Apply This PHS Rule to all classifiers whose Associated PHSI Match */ unsigned int uiClassifierIndex = 0; @@ -738,8 +703,7 @@ static VOID CopyToAdapter(register struct bcm_mini_adapter *Adapter, /* Date: Fri, 4 Apr 2014 12:25:55 -0600 Subject: staging/bcm fix hostmibs.c checkpatch problems Fix 4 checkpatch errors, many warnings in bcm/hostmibs.c Signed-off-by: Jake Edge Signed-off-by: Greg Kroah-Hartman --- drivers/staging/bcm/hostmibs.c | 51 +++++++++++++++++++++++++----------------- 1 file changed, 30 insertions(+), 21 deletions(-) diff --git a/drivers/staging/bcm/hostmibs.c b/drivers/staging/bcm/hostmibs.c index 39ace5510c43..42d9004e357d 100644 --- a/drivers/staging/bcm/hostmibs.c +++ b/drivers/staging/bcm/hostmibs.c @@ -9,37 +9,40 @@ #include "headers.h" -INT ProcessGetHostMibs(struct bcm_mini_adapter *Adapter, struct bcm_host_stats_mibs *pstHostMibs) +INT ProcessGetHostMibs(struct bcm_mini_adapter *Adapter, + struct bcm_host_stats_mibs *pstHostMibs) { struct bcm_phs_entry *pstServiceFlowEntry = NULL; struct bcm_phs_rule *pstPhsRule = NULL; struct bcm_phs_classifier_table *pstClassifierTable = NULL; struct bcm_phs_classifier_entry *pstClassifierRule = NULL; - struct bcm_phs_extension *pDeviceExtension = (struct bcm_phs_extension *) &Adapter->stBCMPhsContext; - - UINT nClassifierIndex = 0, nPhsTableIndex = 0, nSfIndex = 0, uiIndex = 0; + struct bcm_phs_extension *pDeviceExtension = &Adapter->stBCMPhsContext; + UINT nClassifierIndex = 0; + UINT nPhsTableIndex = 0; + UINT nSfIndex = 0; + UINT uiIndex = 0; if (pDeviceExtension == NULL) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, HOST_MIBS, DBG_LVL_ALL, "Invalid Device Extension\n"); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, HOST_MIBS, + DBG_LVL_ALL, "Invalid Device Extension\n"); return STATUS_FAILURE; } /* Copy the classifier Table */ - for (nClassifierIndex = 0; nClassifierIndex < MAX_CLASSIFIERS; nClassifierIndex++) { + for (nClassifierIndex = 0; nClassifierIndex < MAX_CLASSIFIERS; + nClassifierIndex++) { if (Adapter->astClassifierTable[nClassifierIndex].bUsed == TRUE) - memcpy((PVOID) &pstHostMibs-> - astClassifierTable[nClassifierIndex], - (PVOID) &Adapter-> - astClassifierTable[nClassifierIndex], + memcpy(&pstHostMibs->astClassifierTable[nClassifierIndex], + &Adapter->astClassifierTable[nClassifierIndex], sizeof(struct bcm_mibs_classifier_rule)); } /* Copy the SF Table */ for (nSfIndex = 0; nSfIndex < NO_OF_QUEUES; nSfIndex++) { if (Adapter->PackInfo[nSfIndex].bValid) { - memcpy((PVOID) &pstHostMibs->astSFtable[nSfIndex], - (PVOID) &Adapter->PackInfo[nSfIndex], - sizeof(struct bcm_mibs_table)); + memcpy(&pstHostMibs->astSFtable[nSfIndex], + &Adapter->PackInfo[nSfIndex], + sizeof(struct bcm_mibs_table)); } else { /* If index in not valid, * don't process this for the PHS table. @@ -68,9 +71,9 @@ INT ProcessGetHostMibs(struct bcm_mini_adapter *Adapter, struct bcm_host_stats_m pstHostMibs->astPhsRulesTable[nPhsTableIndex]. ulSFID = Adapter->PackInfo[nSfIndex].ulSFID; - memcpy(&pstHostMibs-> - astPhsRulesTable[nPhsTableIndex].u8PHSI, - &pstPhsRule->u8PHSI, sizeof(struct bcm_phs_rule)); + memcpy(&pstHostMibs->astPhsRulesTable[nPhsTableIndex].u8PHSI, + &pstPhsRule->u8PHSI, + sizeof(struct bcm_phs_rule)); nPhsTableIndex++; } @@ -82,26 +85,32 @@ INT ProcessGetHostMibs(struct bcm_mini_adapter *Adapter, struct bcm_host_stats_m /* Copy other Host Statistics parameters */ pstHostMibs->stHostInfo.GoodTransmits = Adapter->dev->stats.tx_packets; pstHostMibs->stHostInfo.GoodReceives = Adapter->dev->stats.rx_packets; - pstHostMibs->stHostInfo.CurrNumFreeDesc = atomic_read(&Adapter->CurrNumFreeTxDesc); + pstHostMibs->stHostInfo.CurrNumFreeDesc = + atomic_read(&Adapter->CurrNumFreeTxDesc); pstHostMibs->stHostInfo.BEBucketSize = Adapter->BEBucketSize; pstHostMibs->stHostInfo.rtPSBucketSize = Adapter->rtPSBucketSize; pstHostMibs->stHostInfo.TimerActive = Adapter->TimerActive; pstHostMibs->stHostInfo.u32TotalDSD = Adapter->u32TotalDSD; - memcpy(pstHostMibs->stHostInfo.aTxPktSizeHist, Adapter->aTxPktSizeHist, sizeof(UINT32) * MIBS_MAX_HIST_ENTRIES); - memcpy(pstHostMibs->stHostInfo.aRxPktSizeHist, Adapter->aRxPktSizeHist, sizeof(UINT32) * MIBS_MAX_HIST_ENTRIES); + memcpy(pstHostMibs->stHostInfo.aTxPktSizeHist, Adapter->aTxPktSizeHist, + sizeof(UINT32) * MIBS_MAX_HIST_ENTRIES); + memcpy(pstHostMibs->stHostInfo.aRxPktSizeHist, Adapter->aRxPktSizeHist, + sizeof(UINT32) * MIBS_MAX_HIST_ENTRIES); return STATUS_SUCCESS; } -VOID GetDroppedAppCntrlPktMibs(struct bcm_host_stats_mibs *pstHostMibs, struct bcm_tarang_data *pTarang) +VOID GetDroppedAppCntrlPktMibs(struct bcm_host_stats_mibs *pstHostMibs, + struct bcm_tarang_data *pTarang) { memcpy(&(pstHostMibs->stDroppedAppCntrlMsgs), &(pTarang->stDroppedAppCntrlMsgs), sizeof(struct bcm_mibs_dropped_cntrl_msg)); } -VOID CopyMIBSExtendedSFParameters(struct bcm_mini_adapter *Adapter, struct bcm_connect_mgr_params *psfLocalSet, UINT uiSearchRuleIndex) +VOID CopyMIBSExtendedSFParameters(struct bcm_mini_adapter *Adapter, + struct bcm_connect_mgr_params *psfLocalSet, + UINT uiSearchRuleIndex) { struct bcm_mibs_parameters *t = &Adapter->PackInfo[uiSearchRuleIndex].stMibsExtServiceFlowTable; -- cgit v1.2.3 From 2315e49e788be1eef57c45d230303cc929c976c8 Mon Sep 17 00:00:00 2001 From: Luis Ortega Date: Wed, 9 Apr 2014 13:56:09 +0200 Subject: Staging: bcm: Qos: fixed braces' coding style Fixed badly placed and unnecessary braces. PS: Performed as task 10 of the Eudyptula Challenge. Signed-off-by: Luis Ortega Signed-off-by: Greg Kroah-Hartman --- drivers/staging/bcm/Qos.c | 174 +++++++++++++--------------------------------- 1 file changed, 48 insertions(+), 126 deletions(-) diff --git a/drivers/staging/bcm/Qos.c b/drivers/staging/bcm/Qos.c index 4f315835ddfc..09e548aef812 100644 --- a/drivers/staging/bcm/Qos.c +++ b/drivers/staging/bcm/Qos.c @@ -33,14 +33,11 @@ static bool MatchSrcIpAddress(struct bcm_classifier_rule *pstClassifierRule, ULO ulSrcIP = ntohl(ulSrcIP); if (0 == pstClassifierRule->ucIPSourceAddressLength) return TRUE; - for (ucLoopIndex = 0; ucLoopIndex < (pstClassifierRule->ucIPSourceAddressLength); ucLoopIndex++) - { + for (ucLoopIndex = 0; ucLoopIndex < (pstClassifierRule->ucIPSourceAddressLength); ucLoopIndex++) { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "Src Ip Address Mask:0x%x PacketIp:0x%x and Classification:0x%x", (UINT)pstClassifierRule->stSrcIpAddress.ulIpv4Mask[ucLoopIndex], (UINT)ulSrcIP, (UINT)pstClassifierRule->stSrcIpAddress.ulIpv6Addr[ucLoopIndex]); if ((pstClassifierRule->stSrcIpAddress.ulIpv4Mask[ucLoopIndex] & ulSrcIP) == (pstClassifierRule->stSrcIpAddress.ulIpv4Addr[ucLoopIndex] & pstClassifierRule->stSrcIpAddress.ulIpv4Mask[ucLoopIndex])) - { return TRUE; - } } BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "Src Ip Address Not Matched"); return false; @@ -68,13 +65,10 @@ static bool MatchDestIpAddress(struct bcm_classifier_rule *pstClassifierRule, UL return TRUE; BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "Destination Ip Address 0x%x 0x%x 0x%x ", (UINT)ulDestIP, (UINT)pstClassifierRule->stDestIpAddress.ulIpv4Mask[ucLoopIndex], (UINT)pstClassifierRule->stDestIpAddress.ulIpv4Addr[ucLoopIndex]); - for (ucLoopIndex = 0; ucLoopIndex < (pstClassifierRule->ucIPDestinationAddressLength); ucLoopIndex++) - { + for (ucLoopIndex = 0; ucLoopIndex < (pstClassifierRule->ucIPDestinationAddressLength); ucLoopIndex++) { if ((pstClassifierRule->stDestIpAddress.ulIpv4Mask[ucLoopIndex] & ulDestIP) == (pstClassifierRule->stDestIpAddress.ulIpv4Addr[ucLoopIndex] & pstClassifierRule->stDestIpAddress.ulIpv4Mask[ucLoopIndex])) - { return TRUE; - } } BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "Destination Ip Address Not Matched"); return false; @@ -99,9 +93,8 @@ static bool MatchTos(struct bcm_classifier_rule *pstClassifierRule, UCHAR ucType return TRUE; if (((pstClassifierRule->ucTosMask & ucTypeOfService) <= pstClassifierRule->ucTosHigh) && ((pstClassifierRule->ucTosMask & ucTypeOfService) >= pstClassifierRule->ucTosLow)) - { return TRUE; - } + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "Type Of Service Not Matched"); return false; } @@ -123,13 +116,10 @@ bool MatchProtocol(struct bcm_classifier_rule *pstClassifierRule, UCHAR ucProtoc struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev); if (0 == pstClassifierRule->ucProtocolLength) return TRUE; - for (ucLoopIndex = 0; ucLoopIndex < pstClassifierRule->ucProtocolLength; ucLoopIndex++) - { + for (ucLoopIndex = 0; ucLoopIndex < pstClassifierRule->ucProtocolLength; ucLoopIndex++) { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "Protocol:0x%X Classification Protocol:0x%X", ucProtocol, pstClassifierRule->ucProtocol[ucLoopIndex]); if (pstClassifierRule->ucProtocol[ucLoopIndex] == ucProtocol) - { return TRUE; - } } BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "Protocol Not Matched"); return false; @@ -155,13 +145,10 @@ bool MatchSrcPort(struct bcm_classifier_rule *pstClassifierRule, USHORT ushSrcPo if (0 == pstClassifierRule->ucSrcPortRangeLength) return TRUE; - for (ucLoopIndex = 0; ucLoopIndex < pstClassifierRule->ucSrcPortRangeLength; ucLoopIndex++) - { + for (ucLoopIndex = 0; ucLoopIndex < pstClassifierRule->ucSrcPortRangeLength; ucLoopIndex++) { if (ushSrcPort <= pstClassifierRule->usSrcPortRangeHi[ucLoopIndex] && ushSrcPort >= pstClassifierRule->usSrcPortRangeLo[ucLoopIndex]) - { return TRUE; - } } BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "Src Port: %x Not Matched ", ushSrcPort); return false; @@ -186,15 +173,12 @@ bool MatchDestPort(struct bcm_classifier_rule *pstClassifierRule, USHORT ushDest if (0 == pstClassifierRule->ucDestPortRangeLength) return TRUE; - for (ucLoopIndex = 0; ucLoopIndex < pstClassifierRule->ucDestPortRangeLength; ucLoopIndex++) - { + for (ucLoopIndex = 0; ucLoopIndex < pstClassifierRule->ucDestPortRangeLength; ucLoopIndex++) { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "Matching Port:0x%X 0x%X 0x%X", ushDestPort, pstClassifierRule->usDestPortRangeLo[ucLoopIndex], pstClassifierRule->usDestPortRangeHi[ucLoopIndex]); if (ushDestPort <= pstClassifierRule->usDestPortRangeHi[ucLoopIndex] && ushDestPort >= pstClassifierRule->usDestPortRangeLo[ucLoopIndex]) - { return TRUE; - } } BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "Dest Port: %x Not Matched", ushDestPort); return false; @@ -273,21 +257,13 @@ static USHORT IpVersion4(struct bcm_mini_adapter *Adapter, bClassificationSucceed = TRUE; } while (0); - if (TRUE == bClassificationSucceed) - { + if (TRUE == bClassificationSucceed) { INT iMatchedSFQueueIndex = 0; iMatchedSFQueueIndex = SearchSfid(Adapter, pstClassifierRule->ulSFID); if (iMatchedSFQueueIndex >= NO_OF_QUEUES) - { bClassificationSucceed = false; - } - else - { - if (false == Adapter->PackInfo[iMatchedSFQueueIndex].bActive) - { - bClassificationSucceed = false; - } - } + else if (false == Adapter->PackInfo[iMatchedSFQueueIndex].bActive) + bClassificationSucceed = false; } BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "IpVersion4 <=========="); @@ -299,8 +275,7 @@ VOID PruneQueueAllSF(struct bcm_mini_adapter *Adapter) { UINT iIndex = 0; - for (iIndex = 0; iIndex < HiPriority; iIndex++) - { + for (iIndex = 0; iIndex < HiPriority; iIndex++) { if (!Adapter->PackInfo[iIndex].bValid) continue; @@ -334,10 +309,10 @@ static VOID PruneQueue(struct bcm_mini_adapter *Adapter, INT iIndex) spin_lock_bh(&Adapter->PackInfo[iIndex].SFQueueLock); - while (1) + while (1) { // while((UINT)Adapter->PackInfo[iIndex].uiCurrentPacketsOnHost > -// SF_MAX_ALLOWED_PACKETS_TO_BACKUP) - { +// SF_MAX_ALLOWED_PACKETS_TO_BACKUP) { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, PRUNE_QUEUE, DBG_LVL_ALL, "uiCurrentBytesOnHost:%x uiMaxBucketSize :%x", Adapter->PackInfo[iIndex].uiCurrentBytesOnHost, Adapter->PackInfo[iIndex].uiMaxBucketSize); @@ -350,8 +325,7 @@ static VOID PruneQueue(struct bcm_mini_adapter *Adapter, INT iIndex) ((1000*(jiffies - *((B_UINT32 *)(PacketToDrop->cb)+SKB_CB_LATENCY_OFFSET))/HZ) <= Adapter->PackInfo[iIndex].uiMaxLatency)) break; - if (PacketToDrop) - { + if (PacketToDrop) { if (netif_msg_tx_err(Adapter)) pr_info(PFX "%s: tx queue %d overlimit\n", Adapter->dev->name, iIndex); @@ -394,20 +368,16 @@ VOID flush_all_queues(struct bcm_mini_adapter *Adapter) BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "=====>"); // down(&Adapter->data_packet_queue_lock); - for (iQIndex = LowPriority; iQIndex < HiPriority; iQIndex++) - { + for (iQIndex = LowPriority; iQIndex < HiPriority; iQIndex++) { struct net_device_stats *netstats = &Adapter->dev->stats; spin_lock_bh(&Adapter->PackInfo[iQIndex].SFQueueLock); - while (Adapter->PackInfo[iQIndex].FirstTxQueue) - { + while (Adapter->PackInfo[iQIndex].FirstTxQueue) { PacketToDrop = Adapter->PackInfo[iQIndex].FirstTxQueue; - if (PacketToDrop) - { + if (PacketToDrop) { uiTotalPacketLength = PacketToDrop->len; netstats->tx_dropped++; - } - else + } else uiTotalPacketLength = 0; DEQUEUEPACKET(Adapter->PackInfo[iQIndex].FirstTxQueue, @@ -455,58 +425,42 @@ USHORT ClassifyPacket(struct bcm_mini_adapter *Adapter, struct sk_buff* skb) *((UINT32*) (skb->cb) +SKB_CB_TCPACK_OFFSET) = 0; EThCSGetPktInfo(Adapter, pvEThPayload, &stEthCsPktInfo); - switch (stEthCsPktInfo.eNwpktEthFrameType) - { + switch (stEthCsPktInfo.eNwpktEthFrameType) { case eEth802LLCFrame: - { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "ClassifyPacket : 802LLCFrame\n"); pIpHeader = pvEThPayload + sizeof(struct bcm_eth_llc_frame); break; - } - case eEth802LLCSNAPFrame: - { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "ClassifyPacket : 802LLC SNAP Frame\n"); pIpHeader = pvEThPayload + sizeof(struct bcm_eth_llc_snap_frame); break; - } case eEth802QVLANFrame: - { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "ClassifyPacket : 802.1Q VLANFrame\n"); pIpHeader = pvEThPayload + sizeof(struct bcm_eth_q_frame); break; - } case eEthOtherFrame: - { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "ClassifyPacket : ETH Other Frame\n"); pIpHeader = pvEThPayload + sizeof(struct bcm_ethernet2_frame); break; - } default: - { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "ClassifyPacket : Unrecognized ETH Frame\n"); pIpHeader = pvEThPayload + sizeof(struct bcm_ethernet2_frame); break; - } } - if (stEthCsPktInfo.eNwpktIPFrameType == eIPv4Packet) - { + if (stEthCsPktInfo.eNwpktIPFrameType == eIPv4Packet) { usCurrFragment = (ntohs(pIpHeader->frag_off) & IP_OFFSET); if ((ntohs(pIpHeader->frag_off) & IP_MF) || usCurrFragment) bFragmentedPkt = TRUE; - if (bFragmentedPkt) - { + if (bFragmentedPkt) { //Fragmented Packet. Get Frag Classifier Entry. pstClassifierRule = GetFragIPClsEntry(Adapter, pIpHeader->id, pIpHeader->saddr); - if (pstClassifierRule) - { + if (pstClassifierRule) { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "It is next Fragmented pkt"); bClassificationSucceed = TRUE; } - if (!(ntohs(pIpHeader->frag_off) & IP_MF)) - { + if (!(ntohs(pIpHeader->frag_off) & IP_MF)) { //Fragmented Last packet . Remove Frag Classifier Entry BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "This is the last fragmented Pkt"); DelFragIPClsEntry(Adapter, pIpHeader->id, pIpHeader->saddr); @@ -514,23 +468,19 @@ USHORT ClassifyPacket(struct bcm_mini_adapter *Adapter, struct sk_buff* skb) } } - for (uiLoopIndex = MAX_CLASSIFIERS - 1; uiLoopIndex >= 0; uiLoopIndex--) - { + for (uiLoopIndex = MAX_CLASSIFIERS - 1; uiLoopIndex >= 0; uiLoopIndex--) { if (bClassificationSucceed) break; //Iterate through all classifiers which are already in order of priority //to classify the packet until match found - do - { - if (false == Adapter->astClassifierTable[uiLoopIndex].bUsed) - { + do { + if (false == Adapter->astClassifierTable[uiLoopIndex].bUsed) { bClassificationSucceed = false; break; } BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "Adapter->PackInfo[%d].bvalid=True\n", uiLoopIndex); - if (0 == Adapter->astClassifierTable[uiLoopIndex].ucDirection) - { + if (0 == Adapter->astClassifierTable[uiLoopIndex].ucDirection) { bClassificationSucceed = false;//cannot be processed for classification. break; // it is a down link connection } @@ -543,11 +493,9 @@ USHORT ClassifyPacket(struct bcm_mini_adapter *Adapter, struct sk_buff* skb) break; } - if (Adapter->PackInfo[uiSfIndex].bEthCSSupport) - { + if (Adapter->PackInfo[uiSfIndex].bEthCSSupport) { - if (eEthUnsupportedFrame == stEthCsPktInfo.eNwpktEthFrameType) - { + if (eEthUnsupportedFrame == stEthCsPktInfo.eNwpktEthFrameType) { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, " ClassifyPacket : Packet Not a Valid Supported Ethernet Frame\n"); bClassificationSucceed = false; break; @@ -558,17 +506,12 @@ USHORT ClassifyPacket(struct bcm_mini_adapter *Adapter, struct sk_buff* skb) BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "Performing ETH CS Classification on Classifier Rule ID : %x Service Flow ID : %lx\n", pstClassifierRule->uiClassifierRuleIndex, Adapter->PackInfo[uiSfIndex].ulSFID); bClassificationSucceed = EThCSClassifyPkt(Adapter, skb, &stEthCsPktInfo, pstClassifierRule, Adapter->PackInfo[uiSfIndex].bEthCSSupport); - if (!bClassificationSucceed) - { + if (!bClassificationSucceed) { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "ClassifyPacket : Ethernet CS Classification Failed\n"); break; } - } - - else // No ETH Supported on this SF - { - if (eEthOtherFrame != stEthCsPktInfo.eNwpktEthFrameType) - { + } else { // No ETH Supported on this SF + if (eEthOtherFrame != stEthCsPktInfo.eNwpktEthFrameType) { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, " ClassifyPacket : Packet Not a 802.3 Ethernet Frame... hence not allowed over non-ETH CS SF\n"); bClassificationSucceed = false; break; @@ -577,11 +520,9 @@ USHORT ClassifyPacket(struct bcm_mini_adapter *Adapter, struct sk_buff* skb) BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "Proceeding to IP CS Clasification"); - if (Adapter->PackInfo[uiSfIndex].bIPCSSupport) - { + if (Adapter->PackInfo[uiSfIndex].bIPCSSupport) { - if (stEthCsPktInfo.eNwpktIPFrameType == eNonIPPacket) - { + if (stEthCsPktInfo.eNwpktIPFrameType == eNonIPPacket) { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, " ClassifyPacket : Packet is Not an IP Packet\n"); bClassificationSucceed = false; break; @@ -598,31 +539,26 @@ USHORT ClassifyPacket(struct bcm_mini_adapter *Adapter, struct sk_buff* skb) } while (0); } - if (bClassificationSucceed == TRUE) - { + if (bClassificationSucceed == TRUE) { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "CF id : %d, SF ID is =%lu", pstClassifierRule->uiClassifierRuleIndex, pstClassifierRule->ulSFID); //Store The matched Classifier in SKB *((UINT32*)(skb->cb)+SKB_CB_CLASSIFICATION_OFFSET) = pstClassifierRule->uiClassifierRuleIndex; - if ((TCP == pIpHeader->protocol) && !bFragmentedPkt && (ETH_AND_IP_HEADER_LEN + TCP_HEADER_LEN <= skb->len)) - { + if ((TCP == pIpHeader->protocol) && !bFragmentedPkt && (ETH_AND_IP_HEADER_LEN + TCP_HEADER_LEN <= skb->len)) { IpHeaderLength = pIpHeader->ihl; pTcpHeader = (struct bcm_tcp_header *)(((PUCHAR)pIpHeader)+(IpHeaderLength*4)); TcpHeaderLength = GET_TCP_HEADER_LEN(pTcpHeader->HeaderLength); if ((pTcpHeader->ucFlags & TCP_ACK) && (ntohs(pIpHeader->tot_len) == (IpHeaderLength*4)+(TcpHeaderLength*4))) - { *((UINT32*) (skb->cb) + SKB_CB_TCPACK_OFFSET) = TCP_ACK; - } } usIndex = SearchSfid(Adapter, pstClassifierRule->ulSFID); BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "index is =%d", usIndex); //If this is the first fragment of a Fragmented pkt, add this CF. Only This CF should be used for all other fragment of this Pkt. - if (bFragmentedPkt && (usCurrFragment == 0)) - { + if (bFragmentedPkt && (usCurrFragment == 0)) { //First Fragment of Fragmented Packet. Create Frag CLS Entry struct bcm_fragmented_packet_info stFragPktInfo; stFragPktInfo.bUsed = TRUE; @@ -649,8 +585,7 @@ static bool EthCSMatchSrcMACAddress(struct bcm_classifier_rule *pstClassifierRul if (pstClassifierRule->ucEthCSSrcMACLen == 0) return TRUE; BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "%s\n", __FUNCTION__); - for (i = 0; i < MAC_ADDRESS_SIZE; i++) - { + for (i = 0; i < MAC_ADDRESS_SIZE; i++) { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "SRC MAC[%x] = %x ClassifierRuleSrcMAC = %x Mask : %x\n", i, Mac[i], pstClassifierRule->au8EThCSSrcMAC[i], pstClassifierRule->au8EThCSSrcMACMask[i]); if ((pstClassifierRule->au8EThCSSrcMAC[i] & pstClassifierRule->au8EThCSSrcMACMask[i]) != (Mac[i] & pstClassifierRule->au8EThCSSrcMACMask[i])) @@ -666,8 +601,7 @@ static bool EthCSMatchDestMACAddress(struct bcm_classifier_rule *pstClassifierRu if (pstClassifierRule->ucEthCSDestMACLen == 0) return TRUE; BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "%s\n", __FUNCTION__); - for (i = 0; i < MAC_ADDRESS_SIZE; i++) - { + for (i = 0; i < MAC_ADDRESS_SIZE; i++) { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "SRC MAC[%x] = %x ClassifierRuleSrcMAC = %x Mask : %x\n", i, Mac[i], pstClassifierRule->au8EThCSDestMAC[i], pstClassifierRule->au8EThCSDestMACMask[i]); if ((pstClassifierRule->au8EThCSDestMAC[i] & pstClassifierRule->au8EThCSDestMACMask[i]) != (Mac[i] & pstClassifierRule->au8EThCSDestMACMask[i])) @@ -684,8 +618,7 @@ static bool EthCSMatchEThTypeSAP(struct bcm_classifier_rule *pstClassifierRule, return TRUE; BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "%s SrcEtherType:%x CLS EtherType[0]:%x\n", __FUNCTION__, pstEthCsPktInfo->usEtherType, pstClassifierRule->au8EthCSEtherType[0]); - if (pstClassifierRule->au8EthCSEtherType[0] == 1) - { + if (pstClassifierRule->au8EthCSEtherType[0] == 1) { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "%s CLS EtherType[1]:%x EtherType[2]:%x\n", __FUNCTION__, pstClassifierRule->au8EthCSEtherType[1], pstClassifierRule->au8EthCSEtherType[2]); if (memcmp(&pstEthCsPktInfo->usEtherType, &pstClassifierRule->au8EthCSEtherType[1], 2) == 0) @@ -694,8 +627,7 @@ static bool EthCSMatchEThTypeSAP(struct bcm_classifier_rule *pstClassifierRule, return false; } - if (pstClassifierRule->au8EthCSEtherType[0] == 2) - { + if (pstClassifierRule->au8EthCSEtherType[0] == 2) { if (eEth802LLCFrame != pstEthCsPktInfo->eNwpktEthFrameType) return false; @@ -721,8 +653,7 @@ static bool EthCSMatchVLANRules(struct bcm_classifier_rule *pstClassifierRule, s BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "%s CLS UserPrio:%x CLS VLANID:%x\n", __FUNCTION__, ntohs(*((USHORT *)pstClassifierRule->usUserPriority)), pstClassifierRule->usVLANID); /* In case FW didn't receive the TLV, the priority field should be ignored */ - if (pstClassifierRule->usValidityBitMap & (1<usValidityBitMap & (1<eNwpktEthFrameType != eEth802QVLANFrame) return false; @@ -739,8 +670,7 @@ static bool EthCSMatchVLANRules(struct bcm_classifier_rule *pstClassifierRule, s bClassificationSucceed = false; - if (pstClassifierRule->usValidityBitMap & (1<usValidityBitMap & (1<eNwpktEthFrameType != eEth802QVLANFrame) return false; @@ -800,32 +730,24 @@ static void EThCSGetPktInfo(struct bcm_mini_adapter *Adapter, PVOID pvEthPayload USHORT u16Etype = ntohs(((struct bcm_eth_header *)pvEthPayload)->u16Etype); BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "EthCSGetPktInfo : Eth Hdr Type : %X\n", u16Etype); - if (u16Etype > 0x5dc) - { + if (u16Etype > 0x5dc) { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "EthCSGetPktInfo : ETH2 Frame\n"); //ETH2 Frame - if (u16Etype == ETHERNET_FRAMETYPE_802QVLAN) - { + if (u16Etype == ETHERNET_FRAMETYPE_802QVLAN) { //802.1Q VLAN Header pstEthCsPktInfo->eNwpktEthFrameType = eEth802QVLANFrame; u16Etype = ((struct bcm_eth_q_frame *)pvEthPayload)->EthType; //((ETH_CS_802_Q_FRAME*)pvEthPayload)->UserPriority - } - else - { + } else { pstEthCsPktInfo->eNwpktEthFrameType = eEthOtherFrame; u16Etype = ntohs(u16Etype); } - - } - else - { + } else { //802.2 LLC BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "802.2 LLC Frame\n"); pstEthCsPktInfo->eNwpktEthFrameType = eEth802LLCFrame; pstEthCsPktInfo->ucDSAP = ((struct bcm_eth_llc_frame *)pvEthPayload)->DSAP; - if (pstEthCsPktInfo->ucDSAP == 0xAA && ((struct bcm_eth_llc_frame *)pvEthPayload)->SSAP == 0xAA) - { + if (pstEthCsPktInfo->ucDSAP == 0xAA && ((struct bcm_eth_llc_frame *)pvEthPayload)->SSAP == 0xAA) { //SNAP Frame pstEthCsPktInfo->eNwpktEthFrameType = eEth802LLCSNAPFrame; u16Etype = ((struct bcm_eth_llc_snap_frame *)pvEthPayload)->usEtherType; -- cgit v1.2.3 From 9f9e1e0ff3980b73da94b1b3b12779581a2ae580 Mon Sep 17 00:00:00 2001 From: Joel Porquet Date: Wed, 9 Apr 2014 20:09:45 +0200 Subject: staging: iio: fix coding style As suggested by checkpatch.pl, use dev_info() instead of printk(KERN_INFO ...) to print message. Signed-off-by: Joel Porquet Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/trigger/iio-trig-periodic-rtc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/staging/iio/trigger/iio-trig-periodic-rtc.c b/drivers/staging/iio/trigger/iio-trig-periodic-rtc.c index 48a6afa84088..38ecb4bb6e4c 100644 --- a/drivers/staging/iio/trigger/iio-trig-periodic-rtc.c +++ b/drivers/staging/iio/trigger/iio-trig-periodic-rtc.c @@ -33,7 +33,8 @@ static int iio_trig_periodic_rtc_set_state(struct iio_trigger *trig, bool state) struct iio_prtc_trigger_info *trig_info = iio_trigger_get_drvdata(trig); if (trig_info->frequency == 0) return -EINVAL; - printk(KERN_INFO "trigger frequency is %d\n", trig_info->frequency); + dev_info(&trig_info->rtc->dev, "trigger frequency is %d\n", + trig_info->frequency); return rtc_irq_set_state(trig_info->rtc, &trig_info->task, state); } -- cgit v1.2.3 From 8f2150dd8e6f0eb39b739e64949e98a72755599b Mon Sep 17 00:00:00 2001 From: Michael Welling Date: Wed, 9 Apr 2014 21:26:43 -0500 Subject: Staging: iio: Removes unwanted space before semicolon Signed-off-by: Michael Welling Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/light/tsl2583.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/iio/light/tsl2583.c b/drivers/staging/iio/light/tsl2583.c index 0a60def92735..77c7f65c3762 100644 --- a/drivers/staging/iio/light/tsl2583.c +++ b/drivers/staging/iio/light/tsl2583.c @@ -211,7 +211,7 @@ static int taos_get_lux(struct iio_dev *indio_dev) if (chip->taos_chip_status != TSL258X_CHIP_WORKING) { /* device is not enabled */ dev_err(&chip->client->dev, "taos_get_lux device is not enabled\n"); - ret = -EBUSY ; + ret = -EBUSY; goto out_unlock; } -- cgit v1.2.3 From b47b894c6002d36ac93e4cc82139c7e7157a0f19 Mon Sep 17 00:00:00 2001 From: Michael Welling Date: Wed, 9 Apr 2014 21:26:44 -0500 Subject: Staging: iio: Remove quoted string split across lines warnings Signed-off-by: Michael Welling Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/light/tsl2583.c | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/drivers/staging/iio/light/tsl2583.c b/drivers/staging/iio/light/tsl2583.c index 77c7f65c3762..f015fb4c09a8 100644 --- a/drivers/staging/iio/light/tsl2583.c +++ b/drivers/staging/iio/light/tsl2583.c @@ -165,8 +165,9 @@ taos_i2c_read(struct i2c_client *client, u8 reg, u8 *val, unsigned int len) /* select register to write */ ret = i2c_smbus_write_byte(client, (TSL258X_CMD_REG | reg)); if (ret < 0) { - dev_err(&client->dev, "taos_i2c_read failed to write" - " register %x\n", reg); + dev_err(&client->dev, + "taos_i2c_read failed to write register %x\n", + reg); return ret; } /* read the data */ @@ -231,8 +232,9 @@ static int taos_get_lux(struct iio_dev *indio_dev) int reg = TSL258X_CMD_REG | (TSL258X_ALS_CHAN0LO + i); ret = taos_i2c_read(chip->client, reg, &buf[i], 1); if (ret < 0) { - dev_err(&chip->client->dev, "taos_get_lux failed to read" - " register %x\n", reg); + dev_err(&chip->client->dev, + "taos_get_lux failed to read register %x\n", + reg); goto out_unlock; } } @@ -809,9 +811,7 @@ static int taos_probe(struct i2c_client *clientp, if (!i2c_check_functionality(clientp->adapter, I2C_FUNC_SMBUS_BYTE_DATA)) { - dev_err(&clientp->dev, - "taos_probe() - i2c smbus byte data " - "functions unsupported\n"); + dev_err(&clientp->dev, "taos_probe() - i2c smbus byte data func unsupported\n"); return -EOPNOTSUPP; } @@ -830,30 +830,32 @@ static int taos_probe(struct i2c_client *clientp, ret = i2c_smbus_write_byte(clientp, (TSL258X_CMD_REG | (TSL258X_CNTRL + i))); if (ret < 0) { - dev_err(&clientp->dev, "i2c_smbus_write_bytes() to cmd " - "reg failed in taos_probe(), err = %d\n", ret); + dev_err(&clientp->dev, + "i2c_smbus_write_byte to cmd reg failed in taos_probe(), err = %d\n", + ret); return ret; } ret = i2c_smbus_read_byte(clientp); if (ret < 0) { - dev_err(&clientp->dev, "i2c_smbus_read_byte from " - "reg failed in taos_probe(), err = %d\n", ret); - + dev_err(&clientp->dev, + "i2c_smbus_read_byte from reg failed in taos_probe(), err = %d\n", + ret); return ret; } buf[i] = ret; } if (!taos_tsl258x_device(buf)) { - dev_info(&clientp->dev, "i2c device found but does not match " - "expected id in taos_probe()\n"); + dev_info(&clientp->dev, + "i2c device found but does not match expected id in taos_probe()\n"); return -EINVAL; } ret = i2c_smbus_write_byte(clientp, (TSL258X_CMD_REG | TSL258X_CNTRL)); if (ret < 0) { - dev_err(&clientp->dev, "i2c_smbus_write_byte() to cmd reg " - "failed in taos_probe(), err = %d\n", ret); + dev_err(&clientp->dev, + "i2c_smbus_write_byte() to cmd reg failed in taos_probe(), err = %d\n", + ret); return ret; } -- cgit v1.2.3 From 7fe704ce6af8f5996ebde436afdb9fa2599a7384 Mon Sep 17 00:00:00 2001 From: Michael Welling Date: Wed, 9 Apr 2014 21:26:45 -0500 Subject: Staging: iio: Switch from msleep to usleep range per timers-howto.txt Signed-off-by: Michael Welling Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/light/tsl2583.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/iio/light/tsl2583.c b/drivers/staging/iio/light/tsl2583.c index f015fb4c09a8..fa9649879662 100644 --- a/drivers/staging/iio/light/tsl2583.c +++ b/drivers/staging/iio/light/tsl2583.c @@ -451,7 +451,7 @@ static int taos_chip_on(struct iio_dev *indio_dev) } } - msleep(3); + usleep_range(3000, 3500); /* NOW enable the ADC * initialize the desired mode of operation */ utmp = TSL258X_CNTL_PWR_ON | TSL258X_CNTL_ADC_ENBL; -- cgit v1.2.3 From dab3775c6cf8cb47d8cb7af273c375e0ebde523f Mon Sep 17 00:00:00 2001 From: Mark Einon Date: Thu, 10 Apr 2014 13:34:58 +0100 Subject: staging: rtl8821ae: Fix whitespace in rtl8821ae/hw.h Fix checkpatch warnings, lines over 80 chars using tabs where possible. Signed-off-by: Mark Einon Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8821ae/rtl8821ae/hw.h | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/drivers/staging/rtl8821ae/rtl8821ae/hw.h b/drivers/staging/rtl8821ae/rtl8821ae/hw.h index 4fb6bf0d1da2..3f2068175345 100644 --- a/drivers/staging/rtl8821ae/rtl8821ae/hw.h +++ b/drivers/staging/rtl8821ae/rtl8821ae/hw.h @@ -34,42 +34,43 @@ void rtl8821ae_get_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val); void rtl8821ae_read_eeprom_info(struct ieee80211_hw *hw); void rtl8821ae_interrupt_recognized(struct ieee80211_hw *hw, - u32 *p_inta, u32 *p_intb); + u32 *p_inta, u32 *p_intb); int rtl8821ae_hw_init(struct ieee80211_hw *hw); void rtl8821ae_card_disable(struct ieee80211_hw *hw); void rtl8821ae_enable_interrupt(struct ieee80211_hw *hw); void rtl8821ae_disable_interrupt(struct ieee80211_hw *hw); -int rtl8821ae_set_network_type(struct ieee80211_hw *hw, enum nl80211_iftype type); +int rtl8821ae_set_network_type(struct ieee80211_hw *hw, + enum nl80211_iftype type); void rtl8821ae_set_check_bssid(struct ieee80211_hw *hw, bool check_bssid); void rtl8821ae_set_qos(struct ieee80211_hw *hw, int aci); void rtl8821ae_set_beacon_related_registers(struct ieee80211_hw *hw); void rtl8821ae_set_beacon_interval(struct ieee80211_hw *hw); void rtl8821ae_update_interrupt_mask(struct ieee80211_hw *hw, - u32 add_msr, u32 rm_msr); + u32 add_msr, u32 rm_msr); void rtl8821ae_set_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val); void rtl8821ae_update_hal_rate_tbl(struct ieee80211_hw *hw, - struct ieee80211_sta *sta, - u8 rssi_level); + struct ieee80211_sta *sta, + u8 rssi_level); void rtl8821ae_update_channel_access_setting(struct ieee80211_hw *hw); bool rtl8821ae_gpio_radio_on_off_checking(struct ieee80211_hw *hw, u8 *valid); void rtl8821ae_enable_hw_security_config(struct ieee80211_hw *hw); void rtl8821ae_set_key(struct ieee80211_hw *hw, u32 key_index, - u8 *p_macaddr, bool is_group, u8 enc_algo, - bool is_wepkey, bool clear_all); + u8 *p_macaddr, bool is_group, u8 enc_algo, + bool is_wepkey, bool clear_all); void rtl8821ae_read_bt_coexist_info_from_hwpg(struct ieee80211_hw *hw, - bool autoload_fail, - u8* hwinfo); + bool autoload_fail, + u8* hwinfo); void rtl8812ae_read_bt_coexist_info_from_hwpg(struct ieee80211_hw *hw, - bool autoload_fail, - u8* hwinfo); + bool autoload_fail, + u8* hwinfo); void rtl8821ae_bt_reg_init(struct ieee80211_hw* hw); void rtl8821ae_bt_hw_init(struct ieee80211_hw* hw); void rtl8821ae_suspend(struct ieee80211_hw *hw); void rtl8821ae_resume(struct ieee80211_hw *hw); void rtl8821ae_allow_all_destaddr(struct ieee80211_hw *hw, - bool allow_all_da, - bool write_into_reg); + bool allow_all_da, + bool write_into_reg); void _rtl8821ae_stop_tx_beacon(struct ieee80211_hw *hw); void _rtl8821ae_resume_tx_beacon(struct ieee80211_hw *hw); #endif -- cgit v1.2.3 From f6d49cb0ffd57fa8068e1f5607cf9d2dcd8118d0 Mon Sep 17 00:00:00 2001 From: Mark Einon Date: Thu, 10 Apr 2014 13:34:59 +0100 Subject: staging: rtl8821ae: Remove FSF mailing address from rtl8821ae/hw.h header Fix checkpatch check: CHECK: Do not include the paragraph about writing to the Free Software Foundation's mailing address from the sample GPL notice. The FSF has changed addresses in the past, and may do so again. Linux already includes a copy of the GPL. Signed-off-by: Mark Einon Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8821ae/rtl8821ae/hw.h | 4 ---- 1 file changed, 4 deletions(-) diff --git a/drivers/staging/rtl8821ae/rtl8821ae/hw.h b/drivers/staging/rtl8821ae/rtl8821ae/hw.h index 3f2068175345..335d4ab5e39f 100644 --- a/drivers/staging/rtl8821ae/rtl8821ae/hw.h +++ b/drivers/staging/rtl8821ae/rtl8821ae/hw.h @@ -11,10 +11,6 @@ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * more details. * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * * The full GNU General Public License is included in this distribution in the * file called LICENSE. * -- cgit v1.2.3 From bd2715f6e7023aa9ba9779e92e1baf2a48292383 Mon Sep 17 00:00:00 2001 From: Mark Einon Date: Thu, 10 Apr 2014 13:35:00 +0100 Subject: staging: rtl8821ae: Fix rtl8821ae/hw.h pointer declaration style Fix all occurences of the checkpatch error: ERROR: "foo* bar" should be "foo *bar" Signed-off-by: Mark Einon Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8821ae/rtl8821ae/hw.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/rtl8821ae/rtl8821ae/hw.h b/drivers/staging/rtl8821ae/rtl8821ae/hw.h index 335d4ab5e39f..256e514f424a 100644 --- a/drivers/staging/rtl8821ae/rtl8821ae/hw.h +++ b/drivers/staging/rtl8821ae/rtl8821ae/hw.h @@ -56,12 +56,12 @@ void rtl8821ae_set_key(struct ieee80211_hw *hw, u32 key_index, void rtl8821ae_read_bt_coexist_info_from_hwpg(struct ieee80211_hw *hw, bool autoload_fail, - u8* hwinfo); + u8 *hwinfo); void rtl8812ae_read_bt_coexist_info_from_hwpg(struct ieee80211_hw *hw, bool autoload_fail, - u8* hwinfo); -void rtl8821ae_bt_reg_init(struct ieee80211_hw* hw); -void rtl8821ae_bt_hw_init(struct ieee80211_hw* hw); + u8 *hwinfo); +void rtl8821ae_bt_reg_init(struct ieee80211_hw *hw); +void rtl8821ae_bt_hw_init(struct ieee80211_hw *hw); void rtl8821ae_suspend(struct ieee80211_hw *hw); void rtl8821ae_resume(struct ieee80211_hw *hw); void rtl8821ae_allow_all_destaddr(struct ieee80211_hw *hw, -- cgit v1.2.3 From 2c44ef7526b8f0fe16e461065539076c538d36ac Mon Sep 17 00:00:00 2001 From: Mark Hounschell Date: Fri, 21 Mar 2014 10:41:10 -0400 Subject: staging: dgap: Remove some unused code in dgap.c This patch removes some unused code in dgap.c. Signed-off-by: Mark Hounschell Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgap/dgap.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/drivers/staging/dgap/dgap.c b/drivers/staging/dgap/dgap.c index a5fc3c75ed4e..ea66c9f8db5d 100644 --- a/drivers/staging/dgap/dgap.c +++ b/drivers/staging/dgap/dgap.c @@ -78,10 +78,6 @@ #include "dgap.h" -#define init_MUTEX(sem) sema_init(sem, 1) -#define DECLARE_MUTEX(name) \ - struct semaphore name = __SEMAPHORE_INITIALIZER(name, 1) - MODULE_LICENSE("GPL"); MODULE_AUTHOR("Digi International, http://www.digi.com"); MODULE_DESCRIPTION("Driver for the Digi International EPCA PCI based product line"); @@ -245,9 +241,7 @@ static struct board_t *dgap_Board[MAXBOARDS]; static ulong dgap_poll_counter; static char *dgap_config_buf; static int dgap_driver_state = DRIVER_INITIALIZED; -DEFINE_SPINLOCK(dgap_dl_lock); static wait_queue_head_t dgap_dl_wait; -static int dgap_dl_action; static int dgap_poll_tick = 20; /* Poll interval - 20 ms */ /* @@ -1197,7 +1191,6 @@ static void dgap_init_globals(void) init_timer(&dgap_poll_timer); init_waitqueue_head(&dgap_dl_wait); - dgap_dl_action = 0; } /************************************************************************ -- cgit v1.2.3 From 35ed972362fba5253846d5353c31670b428c3fc7 Mon Sep 17 00:00:00 2001 From: Mark Hounschell Date: Fri, 21 Mar 2014 10:41:11 -0400 Subject: staging: dgap: Remove some unneeded comments This patch removes some unneeded comments from dgap.c Signed-off-by: Mark Hounschell Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgap/dgap.c | 29 ----------------------------- 1 file changed, 29 deletions(-) diff --git a/drivers/staging/dgap/dgap.c b/drivers/staging/dgap/dgap.c index ea66c9f8db5d..ea920e41dc0a 100644 --- a/drivers/staging/dgap/dgap.c +++ b/drivers/staging/dgap/dgap.c @@ -12,21 +12,6 @@ * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * - * NOTE TO LINUX KERNEL HACKERS: DO NOT REFORMAT THIS CODE! - * - * This is shared code between Digi's CVS archive and the - * Linux Kernel sources. - * Changing the source just for reformatting needlessly breaks - * our CVS diff history. - * - * Send any bug fixes/changes to: Eng.Linux at digi dot com. - * Thank you. - * */ /* @@ -83,12 +68,6 @@ MODULE_AUTHOR("Digi International, http://www.digi.com"); MODULE_DESCRIPTION("Driver for the Digi International EPCA PCI based product line"); MODULE_SUPPORTED_DEVICE("dgap"); -/************************************************************************** - * - * protos for this file - * - */ - static int dgap_start(void); static void dgap_init_globals(void); static int dgap_found_board(struct pci_dev *pdev, int id); @@ -101,7 +80,6 @@ static int dgap_probe1(struct pci_dev *pdev, int card_type); static int dgap_do_remap(struct board_t *brd); static irqreturn_t dgap_intr(int irq, void *voidbrd); -/* Our function prototypes */ static int dgap_tty_open(struct tty_struct *tty, struct file *file); static void dgap_tty_close(struct tty_struct *tty, struct file *file); static int dgap_block_til_ready(struct tty_struct *tty, struct file *file, @@ -221,7 +199,6 @@ static int dgap_do_wait_for_fep(struct board_t *brd); static int dgap_tty_register_ports(struct board_t *brd); static int dgap_firmware_load(struct pci_dev *pdev, int card_type); -/* Driver unload function */ static void dgap_cleanup_module(void); module_exit(dgap_cleanup_module); @@ -233,9 +210,6 @@ static const struct file_operations DgapBoardFops = { .owner = THIS_MODULE, }; -/* - * Globals - */ static uint dgap_NumBoards; static struct board_t *dgap_Board[MAXBOARDS]; static ulong dgap_poll_counter; @@ -244,9 +218,6 @@ static int dgap_driver_state = DRIVER_INITIALIZED; static wait_queue_head_t dgap_dl_wait; static int dgap_poll_tick = 20; /* Poll interval - 20 ms */ -/* - * Static vars. - */ static struct class *dgap_class; static struct board_t *dgap_BoardsByMajor[256]; -- cgit v1.2.3 From 084eb9d75b9f3bc0f8c8eb0c4010fbfb6f7b89c6 Mon Sep 17 00:00:00 2001 From: Mark Hounschell Date: Fri, 21 Mar 2014 10:41:12 -0400 Subject: staging: dgap: fix some whitespace warnings in dgap.h This patch fixes some whitespace warnings as reported by checkpatch in dgap.h. Signed-off-by: Mark Hounschell Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgap/dgap.h | 47 +++++++++++++++++++++++---------------------- 1 file changed, 24 insertions(+), 23 deletions(-) diff --git a/drivers/staging/dgap/dgap.h b/drivers/staging/dgap/dgap.h index 6b8f5f858327..1466901ca02f 100644 --- a/drivers/staging/dgap/dgap.h +++ b/drivers/staging/dgap/dgap.h @@ -61,7 +61,7 @@ typedef unsigned char uchar; /* * defines from dgap_pci.h - */ + */ #define PCIMAX 32 /* maximum number of PCI boards */ #define DIGI_VID 0x114F @@ -209,7 +209,8 @@ typedef unsigned char uchar; #define FEP5_PLUS 0x0E40 /* ASCII '5' and ASCII 'A' is here */ #define ECS_SEG 0x0E44 /* Segment of the extended channel structure */ #define LINE_SPEED 0x10 /* Offset into ECS_SEG for line speed */ - /* if the fep has extended capabilities */ + /* if the fep has extended */ + /* capabilities */ /* BIOS MAGIC SPOTS */ #define ERROR 0x0C14L /* BIOS error code */ @@ -362,13 +363,13 @@ typedef unsigned char uchar; #define MC8E8K 36 #define AVANFS 42 /* start of Avanstar family definitions */ -#define A8P 42 +#define A8P 42 #define A16P 43 #define AVANFE 43 /* end of Avanstar family definitions */ #define DA2000FS 44 /* start of AccelePort 2000 family definitions */ -#define DA22 44 /* AccelePort 2002 */ -#define DA24 45 /* AccelePort 2004 */ +#define DA22 44 /* AccelePort 2002 */ +#define DA24 45 /* AccelePort 2004 */ #define DA28 46 /* AccelePort 2008 */ #define DA216 47 /* AccelePort 2016 */ #define DAR4 48 /* AccelePort RAS 4 port */ @@ -578,7 +579,7 @@ struct board_t { ulong membase; /* Start of base memory of the card */ ulong membase_end; /* End of base memory of the card */ - uchar *re_map_port; /* Remapped io port of the card */ + uchar *re_map_port; /* Remapped io port of the card */ uchar *re_map_membase;/* Remapped memory of the card */ uchar runwait; /* # Processes waiting for FEP */ @@ -737,26 +738,26 @@ struct un_t { /* Adapter Memory */ #define DIGI_GETFLOW (('e'<<8) | 99) /* Get startc/stopc flow */ - /* control characters */ -#define DIGI_SETFLOW (('e'<<8) | 100) /* Set startc/stopc flow */ + /* control characters */ +#define DIGI_SETFLOW (('e'<<8) | 100) /* Set startc/stopc flow */ /* control characters */ -#define DIGI_GETAFLOW (('e'<<8) | 101) /* Get Aux. startc/stopc */ - /* flow control chars */ -#define DIGI_SETAFLOW (('e'<<8) | 102) /* Set Aux. startc/stopc */ +#define DIGI_GETAFLOW (('e'<<8) | 101) /* Get Aux. startc/stopc */ + /* flow control chars */ +#define DIGI_SETAFLOW (('e'<<8) | 102) /* Set Aux. startc/stopc */ /* flow control chars */ -#define DIGI_GEDELAY (('d'<<8) | 246) /* Get edelay */ -#define DIGI_SEDELAY (('d'<<8) | 247) /* Set edelay */ +#define DIGI_GEDELAY (('d'<<8) | 246) /* Get edelay */ +#define DIGI_SEDELAY (('d'<<8) | 247) /* Set edelay */ struct digiflow_t { - unsigned char startc; /* flow cntl start char */ - unsigned char stopc; /* flow cntl stop char */ + unsigned char startc; /* flow cntl start char */ + unsigned char stopc; /* flow cntl stop char */ }; #ifdef FLOW_2200 -#define F2200_GETA (('e'<<8) | 104) /* Get 2x36 flow cntl flags */ -#define F2200_SETAW (('e'<<8) | 105) /* Set 2x36 flow cntl flags */ +#define F2200_GETA (('e'<<8) | 104) /* Get 2x36 flow cntl flags */ +#define F2200_SETAW (('e'<<8) | 105) /* Set 2x36 flow cntl flags */ #define F2200_MASK 0x03 /* 2200 flow cntl bit mask */ #define FCNTL_2200 0x01 /* 2x36 terminal flow cntl */ #define PCNTL_2200 0x02 /* 2x36 printer flow cntl */ @@ -873,7 +874,7 @@ struct shrink_buf_struct { xxinit call. */ unsigned char shrink_buf_anports; /* Number of async ports */ - unsigned char shrink_buf_snports; /* Number of sync ports */ + unsigned char shrink_buf_snports; /* Number of sync ports */ unsigned char shrink_buf_type; /* Board type 1 = PC/Xi, 2 = PC/Xm, 3 = PC/Xe @@ -936,9 +937,9 @@ struct digi_stat { struct digi_ch { unsigned long info_bdnum; /* Board number (0 based) */ unsigned long info_channel; /* Channel index number */ - unsigned long info_ch_cflag; /* Channel cflag */ - unsigned long info_ch_iflag; /* Channel iflag */ - unsigned long info_ch_oflag; /* Channel oflag */ + unsigned long info_ch_cflag; /* Channel cflag */ + unsigned long info_ch_iflag; /* Channel iflag */ + unsigned long info_ch_oflag; /* Channel oflag */ unsigned long info_chsize; /* Channel structure size */ unsigned long info_sleep_stat; /* sleep status */ dev_t info_dev; /* device number */ @@ -1208,7 +1209,7 @@ struct bs_t { volatile unsigned char stopc; /* W Xoff character */ volatile unsigned char vnextc; /* W Vnext character */ volatile unsigned char hflow; /* C Software flow control */ - + volatile unsigned char fillc; /* U Delay Fill character */ volatile unsigned char ochar; /* U Saved output character */ volatile unsigned char omask; /* U Output character mask */ @@ -1225,7 +1226,7 @@ struct cnode { union { struct { - char type; /* Board Type */ + char type; /* Board Type */ long port; /* I/O Address */ char *portstr; /* I/O Address in string */ long addr; /* Memory Address */ -- cgit v1.2.3 From d68dcfc18034c8ff8a8a8e054e776211a7dafdb2 Mon Sep 17 00:00:00 2001 From: Mark Hounschell Date: Fri, 21 Mar 2014 10:41:13 -0400 Subject: staging: dgap: Fix several 80+ line warnings in dgap.h This patch fixes several 80+ char line warnings as reported by checkpatch in dgap.h Signed-off-by: Mark Hounschell Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgap/dgap.h | 244 +++++++++++++++++++++++--------------------- 1 file changed, 129 insertions(+), 115 deletions(-) diff --git a/drivers/staging/dgap/dgap.h b/drivers/staging/dgap/dgap.h index 1466901ca02f..2913f6e3def5 100644 --- a/drivers/staging/dgap/dgap.h +++ b/drivers/staging/dgap/dgap.h @@ -207,9 +207,10 @@ typedef unsigned char uchar; #define EVSTART 0x0800L /* Start of event buffer */ #define EVMAX 0x0c00L /* End of event buffer */ #define FEP5_PLUS 0x0E40 /* ASCII '5' and ASCII 'A' is here */ -#define ECS_SEG 0x0E44 /* Segment of the extended channel structure */ -#define LINE_SPEED 0x10 /* Offset into ECS_SEG for line speed */ - /* if the fep has extended */ +#define ECS_SEG 0x0E44 /* Segment of the extended */ + /* channel structure */ +#define LINE_SPEED 0x10 /* Offset into ECS_SEG for line */ + /* speed if the fep has extended */ /* capabilities */ /* BIOS MAGIC SPOTS */ @@ -248,12 +249,12 @@ typedef unsigned char uchar; #define FEPTIMEOUT 200000 -#define ENABLE_INTR 0x0e04 /* Enable interrupts flag */ -#define FEPPOLL_MIN 1 /* minimum of 1 millisecond */ -#define FEPPOLL_MAX 20 /* maximum of 20 milliseconds */ -#define FEPPOLL 0x0c26 /* Fep event poll interval */ +#define ENABLE_INTR 0x0e04 /* Enable interrupts flag */ +#define FEPPOLL_MIN 1 /* minimum of 1 millisecond */ +#define FEPPOLL_MAX 20 /* maximum of 20 milliseconds */ +#define FEPPOLL 0x0c26 /* Fep event poll interval */ -#define IALTPIN 0x0080 /* Input flag to swap DSR <-> DCD */ +#define IALTPIN 0x0080 /* Input flag to swap DSR <-> DCD */ /************************************************************************ * FEP supported functions @@ -367,7 +368,7 @@ typedef unsigned char uchar; #define A16P 43 #define AVANFE 43 /* end of Avanstar family definitions */ -#define DA2000FS 44 /* start of AccelePort 2000 family definitions */ +#define DA2000FS 44 /* start of AccelePort 2000 family definitions */ #define DA22 44 /* AccelePort 2002 */ #define DA24 45 /* AccelePort 2004 */ #define DA28 46 /* AccelePort 2008 */ @@ -572,7 +573,8 @@ struct board_t { ulong irq; /* Interrupt request number */ ulong intr_count; /* Count of interrupts */ u32 intr_used; /* Non-zero if using interrupts */ - u32 intr_running; /* Non-zero if FEP knows its doing interrupts */ + u32 intr_running; /* Non-zero if FEP knows its doing */ + /* interrupts */ ulong port; /* Start of base io port of the card */ ulong port_end; /* End of base io port of the card */ @@ -583,9 +585,10 @@ struct board_t { uchar *re_map_membase;/* Remapped memory of the card */ uchar runwait; /* # Processes waiting for FEP */ - uchar inhibit_poller; /* Tells the poller to leave us alone */ + uchar inhibit_poller; /* Tells the poller to leave us alone */ - struct channel_t *channels[MAXPORTS]; /* array of pointers to our channels. */ + struct channel_t *channels[MAXPORTS]; /* array of pointers to our */ + /* channels. */ struct tty_driver *SerialDriver; struct tty_port *SerialPorts; @@ -600,16 +603,21 @@ struct board_t { u32 dgap_Serial_Major; u32 dgap_TransparentPrint_Major; - struct bs_t *bd_bs; /* Base structure pointer */ + struct bs_t *bd_bs; /* Base structure pointer */ - char *flipbuf; /* Our flip buffer, alloced if board is found */ - char *flipflagbuf; /* Our flip flag buffer, alloced if board is found */ + char *flipbuf; /* Our flip buffer, alloced if */ + /* board is found */ + char *flipflagbuf; /* Our flip flag buffer, alloced */ + /* if board is found */ - u16 dpatype; /* The board "type", as defined by DPA */ - u16 dpastatus; /* The board "status", as defined by DPA */ - wait_queue_head_t kme_wait; /* Needed for DPA support */ + u16 dpatype; /* The board "type", as defined */ + /* by DPA */ + u16 dpastatus; /* The board "status", as defined */ + /* by DPA */ + wait_queue_head_t kme_wait; /* Needed for DPA support */ - u32 conc_dl_status; /* Status of any pending conc download */ + u32 conc_dl_status; /* Status of any pending conc */ + /* download */ }; @@ -690,8 +698,8 @@ struct un_t { #if !defined(TIOCMODG) -#define TIOCMODG (('d'<<8) | 250) /* get modem ctrl state */ -#define TIOCMODS (('d'<<8) | 251) /* set modem ctrl state */ +#define TIOCMODG (('d'<<8) | 250) /* get modem ctrl state */ +#define TIOCMODS (('d'<<8) | 251) /* set modem ctrl state */ #ifndef TIOCM_LE #define TIOCM_LE 0x01 /* line enable */ @@ -710,13 +718,13 @@ struct un_t { #endif #if !defined(TIOCMSET) -#define TIOCMSET (('d'<<8) | 252) /* set modem ctrl state */ -#define TIOCMGET (('d'<<8) | 253) /* set modem ctrl state */ +#define TIOCMSET (('d'<<8) | 252) /* set modem ctrl state */ +#define TIOCMGET (('d'<<8) | 253) /* set modem ctrl state */ #endif #if !defined(TIOCMBIC) -#define TIOCMBIC (('d'<<8) | 254) /* set modem ctrl state */ -#define TIOCMBIS (('d'<<8) | 255) /* set modem ctrl state */ +#define TIOCMBIC (('d'<<8) | 254) /* set modem ctrl state */ +#define TIOCMBIS (('d'<<8) | 255) /* set modem ctrl state */ #endif @@ -853,9 +861,9 @@ struct shrink_buf_struct { unsigned long shrink_buf_vaddr; /* Virtual address of board */ unsigned long shrink_buf_phys; /* Physical address of board */ unsigned long shrink_buf_bseg; /* Amount of board memory */ - unsigned long shrink_buf_hseg; /* '186 Beginning of Dual-Port */ + unsigned long shrink_buf_hseg; /* 186 Beginning of Dual-Port */ - unsigned long shrink_buf_lseg; /* '186 Beginning of freed memory */ + unsigned long shrink_buf_lseg; /* 186 Beginning of freed mem */ unsigned long shrink_buf_mseg; /* Linear address from start of dual-port were freed memory begins, host viewpoint. */ @@ -893,7 +901,7 @@ struct digi_dinfo { char dinfo_version[16]; /* driver version */ }; -#define DIGI_GETDD (('d'<<8) | 248) /* get driver info */ +#define DIGI_GETDD (('d'<<8) | 248) /* get driver info */ /************************************************************************ * Structure used with ioctl commands for per-board information @@ -913,7 +921,7 @@ struct digi_info { char info_reserved[7]; /* for future expansion */ }; -#define DIGI_GETBD (('d'<<8) | 249) /* get board info */ +#define DIGI_GETBD (('d'<<8) | 249) /* get board info */ struct digi_stat { unsigned int info_chan; /* Channel number (0 based) */ @@ -928,7 +936,7 @@ struct digi_stat { unsigned long info_reserved[8]; /* for future expansion */ }; -#define DIGI_GETSTAT (('d'<<8) | 244) /* get board info */ +#define DIGI_GETSTAT (('d'<<8) | 244) /* get board info */ /************************************************************************ * * Structure used with ioctl commands for per-channel information @@ -971,7 +979,7 @@ struct digi_cmd { #define INFO_CH_WLOW 0x0020 #define INFO_XXBUF_BUSY 0x0040 -#define DIGI_GETCH (('d'<<8) | 245) /* get board info */ +#define DIGI_GETCH (('d'<<8) | 245) /* get board info */ /* Board type definitions */ @@ -1016,12 +1024,13 @@ struct digi_cmd { #define BD_TRIBOOT 0x8 #define BD_BADKME 0x80 -#define DIGI_LOOPBACK (('d'<<8) | 252) /* Enable/disable UART internal loopback */ -#define DIGI_SPOLL (('d'<<8) | 254) /* change poller rate */ +#define DIGI_LOOPBACK (('d'<<8) | 252) /* Enable/disable UART */ + /* internal loopback */ +#define DIGI_SPOLL (('d'<<8) | 254) /* change poller rate */ -#define DIGI_SETCUSTOMBAUD _IOW('e', 106, int) /* Set integer baud rate */ -#define DIGI_GETCUSTOMBAUD _IOR('e', 107, int) /* Get integer baud rate */ -#define DIGI_RESET_PORT (('e'<<8) | 93) /* Reset port */ +#define DIGI_SETCUSTOMBAUD _IOW('e', 106, int) /* Set integer baud rate */ +#define DIGI_GETCUSTOMBAUD _IOR('e', 107, int) /* Get integer baud rate */ +#define DIGI_RESET_PORT (('e'<<8) | 93) /* Reset port */ /************************************************************************ * Channel information structure. @@ -1049,7 +1058,8 @@ struct channel_t { u32 ch_flags; /* Channel flags */ - u32 ch_close_delay; /* How long we should drop RTS/DTR for */ + u32 ch_close_delay; /* How long we should drop */ + /* RTS/DTR for */ u32 ch_cpstime; /* Time for CPS calculations */ @@ -1058,7 +1068,7 @@ struct channel_t { tcflag_t ch_c_oflag; /* channel oflags */ tcflag_t ch_c_lflag; /* channel lflags */ - u16 ch_fepiflag; /* FEP tty iflags */ + u16 ch_fepiflag; /* FEP tty iflags */ u16 ch_fepcflag; /* FEP tty cflags */ u16 ch_fepoflag; /* FEP tty oflags */ u16 ch_wopen; /* Waiting for open process cnt */ @@ -1094,11 +1104,11 @@ struct channel_t { uchar ch_tx_win; /* channel tx buffer window */ uchar ch_rx_win; /* channel rx buffer window */ uint ch_custom_speed; /* Custom baud, if set */ - uint ch_baud_info; /* Current baud info for /proc output */ - ulong ch_rxcount; /* total of data received so far */ - ulong ch_txcount; /* total of data transmitted so far */ - ulong ch_err_parity; /* Count of parity errors on channel */ - ulong ch_err_frame; /* Count of framing errors on channel */ + uint ch_baud_info; /* Current baud info for /proc output */ + ulong ch_rxcount; /* total of data received so far */ + ulong ch_txcount; /* total of data transmitted so far */ + ulong ch_err_parity; /* Count of parity errors on channel */ + ulong ch_err_frame; /* Count of framing errors on channel */ ulong ch_err_break; /* Count of breaks on channel */ ulong ch_err_overrun; /* Count of overruns on channel */ @@ -1113,20 +1123,20 @@ struct channel_t { * Command structure definition. ************************************************************************/ struct cm_t { - volatile unsigned short cm_head; /* Command buffer head offset */ - volatile unsigned short cm_tail; /* Command buffer tail offset */ - volatile unsigned short cm_start; /* start offset of buffer */ - volatile unsigned short cm_max; /* last offset of buffer */ + volatile unsigned short cm_head; /* Command buffer head offset */ + volatile unsigned short cm_tail; /* Command buffer tail offset */ + volatile unsigned short cm_start; /* start offset of buffer */ + volatile unsigned short cm_max; /* last offset of buffer */ }; /************************************************************************ * Event structure definition. ************************************************************************/ struct ev_t { - volatile unsigned short ev_head; /* Command buffer head offset */ - volatile unsigned short ev_tail; /* Command buffer tail offset */ - volatile unsigned short ev_start; /* start offset of buffer */ - volatile unsigned short ev_max; /* last offset of buffer */ + volatile unsigned short ev_head; /* Command buffer head offset */ + volatile unsigned short ev_tail; /* Command buffer tail offset */ + volatile unsigned short ev_start; /* start offset of buffer */ + volatile unsigned short ev_max; /* last offset of buffer */ }; /************************************************************************ @@ -1153,70 +1163,74 @@ struct downld_t { * U = unknown (may be changed w/o notice) * ************************************************************************/ struct bs_t { - volatile unsigned short tp_jmp; /* Transmit poll jump */ - volatile unsigned short tc_jmp; /* Cooked procedure jump */ - volatile unsigned short ri_jmp; /* Not currently used */ - volatile unsigned short rp_jmp; /* Receive poll jump */ - - volatile unsigned short tx_seg; /* W Tx segment */ - volatile unsigned short tx_head; /* W Tx buffer head offset */ - volatile unsigned short tx_tail; /* R Tx buffer tail offset */ - volatile unsigned short tx_max; /* W Tx buffer size - 1 */ - - volatile unsigned short rx_seg; /* W Rx segment */ - volatile unsigned short rx_head; /* W Rx buffer head offset */ - volatile unsigned short rx_tail; /* R Rx buffer tail offset */ - volatile unsigned short rx_max; /* W Rx buffer size - 1 */ - - volatile unsigned short tx_lw; /* W Tx buffer low water mark */ - volatile unsigned short rx_lw; /* W Rx buffer low water mark */ - volatile unsigned short rx_hw; /* W Rx buffer high water mark */ - volatile unsigned short incr; /* W Increment to next channel */ - - volatile unsigned short fepdev; /* U SCC device base address */ - volatile unsigned short edelay; /* W Exception delay */ - volatile unsigned short blen; /* W Break length */ - volatile unsigned short btime; /* U Break complete time */ - - volatile unsigned short iflag; /* C UNIX input flags */ - volatile unsigned short oflag; /* C UNIX output flags */ - volatile unsigned short cflag; /* C UNIX control flags */ - volatile unsigned short wfill[13]; /* U Reserved for expansion */ - - volatile unsigned char num; /* U Channel number */ - volatile unsigned char ract; /* U Receiver active counter */ - volatile unsigned char bstat; /* U Break status bits */ - volatile unsigned char tbusy; /* W Transmit busy */ - volatile unsigned char iempty; /* W Transmit empty event enable */ - volatile unsigned char ilow; /* W Transmit low-water event enable */ - volatile unsigned char idata; /* W Receive data interrupt enable */ - volatile unsigned char eflag; /* U Host event flags */ - - volatile unsigned char tflag; /* U Transmit flags */ - volatile unsigned char rflag; /* U Receive flags */ - volatile unsigned char xmask; /* U Transmit ready flags */ - volatile unsigned char xval; /* U Transmit ready value */ - volatile unsigned char m_stat; /* RC Modem status bits */ - volatile unsigned char m_change; /* U Modem bits which changed */ - volatile unsigned char m_int; /* W Modem interrupt enable bits */ - volatile unsigned char m_last; /* U Last modem status */ - - volatile unsigned char mtran; /* C Unreported modem trans */ - volatile unsigned char orun; /* C Buffer overrun occurred */ - volatile unsigned char astartc; /* W Auxiliary Xon char */ - volatile unsigned char astopc; /* W Auxiliary Xoff char */ - volatile unsigned char startc; /* W Xon character */ - volatile unsigned char stopc; /* W Xoff character */ - volatile unsigned char vnextc; /* W Vnext character */ - volatile unsigned char hflow; /* C Software flow control */ - - volatile unsigned char fillc; /* U Delay Fill character */ - volatile unsigned char ochar; /* U Saved output character */ - volatile unsigned char omask; /* U Output character mask */ - - volatile unsigned char bfill[13]; /* U Reserved for expansion */ - - volatile unsigned char scc[16]; /* U SCC registers */ + volatile unsigned short tp_jmp; /* Transmit poll jump */ + volatile unsigned short tc_jmp; /* Cooked procedure jump */ + volatile unsigned short ri_jmp; /* Not currently used */ + volatile unsigned short rp_jmp; /* Receive poll jump */ + + volatile unsigned short tx_seg; /* W Tx segment */ + volatile unsigned short tx_head; /* W Tx buffer head offset */ + volatile unsigned short tx_tail; /* R Tx buffer tail offset */ + volatile unsigned short tx_max; /* W Tx buffer size - 1 */ + + volatile unsigned short rx_seg; /* W Rx segment */ + volatile unsigned short rx_head; /* W Rx buffer head offset */ + volatile unsigned short rx_tail; /* R Rx buffer tail offset */ + volatile unsigned short rx_max; /* W Rx buffer size - 1 */ + + volatile unsigned short tx_lw; /* W Tx buffer low water mark */ + volatile unsigned short rx_lw; /* W Rx buffer low water mark */ + volatile unsigned short rx_hw; /* W Rx buffer high water mark*/ + volatile unsigned short incr; /* W Increment to next channel*/ + + volatile unsigned short fepdev; /* U SCC device base address */ + volatile unsigned short edelay; /* W Exception delay */ + volatile unsigned short blen; /* W Break length */ + volatile unsigned short btime; /* U Break complete time */ + + volatile unsigned short iflag; /* C UNIX input flags */ + volatile unsigned short oflag; /* C UNIX output flags */ + volatile unsigned short cflag; /* C UNIX control flags */ + volatile unsigned short wfill[13]; /* U Reserved for expansion */ + + volatile unsigned char num; /* U Channel number */ + volatile unsigned char ract; /* U Receiver active counter */ + volatile unsigned char bstat; /* U Break status bits */ + volatile unsigned char tbusy; /* W Transmit busy */ + volatile unsigned char iempty; /* W Transmit empty event */ + /* enable */ + volatile unsigned char ilow; /* W Transmit low-water event */ + /* enable */ + volatile unsigned char idata; /* W Receive data interrupt */ + /* enable */ + volatile unsigned char eflag; /* U Host event flags */ + + volatile unsigned char tflag; /* U Transmit flags */ + volatile unsigned char rflag; /* U Receive flags */ + volatile unsigned char xmask; /* U Transmit ready flags */ + volatile unsigned char xval; /* U Transmit ready value */ + volatile unsigned char m_stat; /* RC Modem status bits */ + volatile unsigned char m_change; /* U Modem bits which changed */ + volatile unsigned char m_int; /* W Modem interrupt enable */ + /* bits */ + volatile unsigned char m_last; /* U Last modem status */ + + volatile unsigned char mtran; /* C Unreported modem trans */ + volatile unsigned char orun; /* C Buffer overrun occurred */ + volatile unsigned char astartc; /* W Auxiliary Xon char */ + volatile unsigned char astopc; /* W Auxiliary Xoff char */ + volatile unsigned char startc; /* W Xon character */ + volatile unsigned char stopc; /* W Xoff character */ + volatile unsigned char vnextc; /* W Vnext character */ + volatile unsigned char hflow; /* C Software flow control */ + + volatile unsigned char fillc; /* U Delay Fill character */ + volatile unsigned char ochar; /* U Saved output character */ + volatile unsigned char omask; /* U Output character mask */ + + volatile unsigned char bfill[13]; /* U Reserved for expansion */ + + volatile unsigned char scc[16]; /* U SCC registers */ }; struct cnode { -- cgit v1.2.3 From cb873994a723a6026c72e5f21fef46268bf70fba Mon Sep 17 00:00:00 2001 From: Mark Hounschell Date: Fri, 21 Mar 2014 10:41:14 -0400 Subject: staging: dgap: remove some unused code in dgap.h This patch removes some unused code in dgap.h Signed-off-by: Mark Hounschell Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgap/dgap.h | 53 --------------------------------------------- 1 file changed, 53 deletions(-) diff --git a/drivers/staging/dgap/dgap.h b/drivers/staging/dgap/dgap.h index 2913f6e3def5..979ad404e2f7 100644 --- a/drivers/staging/dgap/dgap.h +++ b/drivers/staging/dgap/dgap.h @@ -839,59 +839,6 @@ struct rw_t { unsigned char rw_data[128]; /* Data to read/write */ }; -/*********************************************************************** - * Shrink Buffer and Board Information definitions and structures. - - ************************************************************************/ - /* Board type return codes */ -#define PCXI_TYPE 1 /* Board type at the designated port is a PC/Xi */ -#define PCXM_TYPE 2 /* Board type at the designated port is a PC/Xm */ -#define PCXE_TYPE 3 /* Board type at the designated port is a PC/Xe */ -#define MCXI_TYPE 4 /* Board type at the designated port is a MC/Xi */ -#define COMXI_TYPE 5 /* Board type at the designated port is a COM/Xi */ - - /* Non-Zero Result codes. */ -#define RESULT_NOBDFND 1 /* A Digi product at that port is not config installed */ -#define RESULT_NODESCT 2 /* A memory descriptor was not obtainable */ -#define RESULT_NOOSSIG 3 /* FEP/OS signature was not detected on the board */ -#define RESULT_TOOSML 4 /* Too small an area to shrink. */ -#define RESULT_NOCHAN 5 /* Channel structure for the board was not found */ - -struct shrink_buf_struct { - unsigned long shrink_buf_vaddr; /* Virtual address of board */ - unsigned long shrink_buf_phys; /* Physical address of board */ - unsigned long shrink_buf_bseg; /* Amount of board memory */ - unsigned long shrink_buf_hseg; /* 186 Beginning of Dual-Port */ - - unsigned long shrink_buf_lseg; /* 186 Beginning of freed mem */ - unsigned long shrink_buf_mseg; /* Linear address from start of - dual-port were freed memory - begins, host viewpoint. */ - - unsigned long shrink_buf_bdparam; /* Parameter for xxmemon and - xxmemoff */ - - unsigned long shrink_buf_reserva; /* Reserved */ - unsigned long shrink_buf_reservb; /* Reserved */ - unsigned long shrink_buf_reservc; /* Reserved */ - unsigned long shrink_buf_reservd; /* Reserved */ - - unsigned char shrink_buf_result; /* Reason for call failing - Zero is Good return */ - unsigned char shrink_buf_init; /* Non-Zero if it caused an - xxinit call. */ - - unsigned char shrink_buf_anports; /* Number of async ports */ - unsigned char shrink_buf_snports; /* Number of sync ports */ - unsigned char shrink_buf_type; /* Board type 1 = PC/Xi, - 2 = PC/Xm, - 3 = PC/Xe - 4 = MC/Xi - 5 = COMX/i */ - unsigned char shrink_buf_card; /* Card number */ - -}; - /************************************************************************ * Structure to get driver status information ************************************************************************/ -- cgit v1.2.3 From 559edcb73a13af63066aee0e9a322383fef7cae2 Mon Sep 17 00:00:00 2001 From: Mark Hounschell Date: Tue, 25 Mar 2014 16:38:13 -0400 Subject: staging: dgap: Removes excessive empty lines from dgap.h This patch removes excessive empty lines from dgap.h not previously caught. Signed-off-by: Mark Hounschell Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgap/dgap.h | 26 -------------------------- 1 file changed, 26 deletions(-) diff --git a/drivers/staging/dgap/dgap.h b/drivers/staging/dgap/dgap.h index 979ad404e2f7..64156807a333 100644 --- a/drivers/staging/dgap/dgap.h +++ b/drivers/staging/dgap/dgap.h @@ -282,14 +282,12 @@ typedef unsigned char uchar; #define SPINTFC 0xfc /* Reserved */ #define SCOMMODE 0xfd /* Set RS232/422 mode */ - /************************************************************************ * Modes for SCOMMODE ************************************************************************/ #define MODE_232 0x00 #define MODE_422 0x01 - /************************************************************************ * Event flags. ************************************************************************/ @@ -494,8 +492,6 @@ enum { REQUESTED_CONCENTRATOR }; - - /* * Modem line constants are defined as macros because DSR and * DCD are swapable using the ditty altpin option. @@ -507,14 +503,12 @@ enum { #define D_RI(ch) DM_RI /* Ring indicator */ #define D_DTR(ch) DM_DTR /* Data terminal ready */ - /************************************************************************* * * Structures and closely related defines. * *************************************************************************/ - /* * A structure to hold a statistics counter. We also * compute moving averages for this counter. @@ -526,7 +520,6 @@ struct macounter { ulong ema; /* Exponential moving average */ }; - /************************************************************************ * Device flag definitions for bd_flags. ************************************************************************/ @@ -620,8 +613,6 @@ struct board_t { /* download */ }; - - /************************************************************************ * Unit flag definitions for un_flags. ************************************************************************/ @@ -659,7 +650,6 @@ struct un_t { struct device *un_sysfs; }; - /************************************************************************ * Device flag definitions for ch_flags. ************************************************************************/ @@ -686,7 +676,6 @@ struct un_t { #define SNIFF_WAIT_DATA 0x2 #define SNIFF_WAIT_SPACE 0x4 - /************************************************************************ *** Definitions for Digi ditty(1) command. ************************************************************************/ @@ -727,7 +716,6 @@ struct un_t { #define TIOCMBIS (('d'<<8) | 255) /* set modem ctrl state */ #endif - #if !defined(TIOCSDTR) #define TIOCSDTR (('e'<<8) | 0) /* set DTR */ #define TIOCCDTR (('e'<<8) | 1) /* clear DTR */ @@ -762,7 +750,6 @@ struct digiflow_t { unsigned char stopc; /* flow cntl stop char */ }; - #ifdef FLOW_2200 #define F2200_GETA (('e'<<8) | 104) /* Get 2x36 flow cntl flags */ #define F2200_SETAW (('e'<<8) | 105) /* Set 2x36 flow cntl flags */ @@ -1004,7 +991,6 @@ struct channel_t { u32 ch_open_count; /* open count */ u32 ch_flags; /* Channel flags */ - u32 ch_close_delay; /* How long we should drop */ /* RTS/DTR for */ @@ -1256,29 +1242,17 @@ struct cnode { } module; char *ttyname; - char *cuname; - char *printname; - long majornumber; - long altpin; - long ttysize; - long chsize; - long bssize; - long unsize; - long f2size; - long vpixsize; - long useintr; } u; }; - #endif -- cgit v1.2.3 From 9e84401638143184cb16a2d5c5326476c13467e8 Mon Sep 17 00:00:00 2001 From: Mark Hounschell Date: Tue, 25 Mar 2014 16:38:14 -0400 Subject: staging: dgap: Only read config file dgap.conf once The config file is currently read for each board found. It only needs to be read one time. The buffer it is read into can now be freed immediately after it is parsed instead of at driver unload time. Signed-off-by: Mark Hounschell Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgap/dgap.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/staging/dgap/dgap.c b/drivers/staging/dgap/dgap.c index ea920e41dc0a..07fcb8df6a60 100644 --- a/drivers/staging/dgap/dgap.c +++ b/drivers/staging/dgap/dgap.c @@ -620,8 +620,6 @@ static void dgap_cleanup_module(void) class_destroy(dgap_class); unregister_chrdev(DIGI_DGAP_MAJOR, "dgap"); - kfree(dgap_config_buf); - for (i = 0; i < dgap_NumBoards; ++i) { dgap_remove_ports_sysfiles(dgap_Board[i]); dgap_tty_uninit(dgap_Board[i]); @@ -828,7 +826,7 @@ static int dgap_firmware_load(struct pci_dev *pdev, int card_type) dgap_get_vpd(brd); dgap_do_reset_board(brd); - if (fw_info[card_type].conf_name) { + if ((fw_info[card_type].conf_name) && !dgap_config_buf) { ret = request_firmware(&fw, fw_info[card_type].conf_name, &pdev->dev); if (ret) { @@ -836,20 +834,22 @@ static int dgap_firmware_load(struct pci_dev *pdev, int card_type) fw_info[card_type].conf_name); return ret; } + + dgap_config_buf = kmalloc(fw->size + 1, GFP_KERNEL); if (!dgap_config_buf) { - dgap_config_buf = kmalloc(fw->size + 1, GFP_ATOMIC); - if (!dgap_config_buf) { - release_firmware(fw); - return -ENOMEM; - } + release_firmware(fw); + return -ENOMEM; } memcpy(dgap_config_buf, fw->data, fw->size); release_firmware(fw); dgap_config_buf[fw->size + 1] = '\0'; - if (dgap_parsefile(&dgap_config_buf, TRUE) != 0) + if (dgap_parsefile(&dgap_config_buf, TRUE) != 0) { + kfree(dgap_config_buf); return -EINVAL; + } + kfree(dgap_config_buf); } ret = dgap_after_config_loaded(brd->boardnum); -- cgit v1.2.3 From 77c9976fa6a70cf62c8d5eb606d5353b8713ce1e Mon Sep 17 00:00:00 2001 From: Mark Hounschell Date: Tue, 25 Mar 2014 16:38:15 -0400 Subject: staging: dgap: Macros with complex values should be enclosed in parenthesis This patch fixes a checkpatch warning "Macros with complex values should be enclosed in parenthesis" Signed-off-by: Mark Hounschell Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgap/dgap.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/dgap/dgap.h b/drivers/staging/dgap/dgap.h index 64156807a333..01eb56fd9ada 100644 --- a/drivers/staging/dgap/dgap.h +++ b/drivers/staging/dgap/dgap.h @@ -186,7 +186,7 @@ typedef unsigned char uchar; ECHOCTL | ECHOKE | IEXTEN) #ifndef _POSIX_VDISABLE -#define _POSIX_VDISABLE '\0' +#define _POSIX_VDISABLE ('\0') #endif #define SNIFF_MAX 65536 /* Sniff buffer size (2^n) */ -- cgit v1.2.3 From 70dc23361daca50801e8e2e08d2a7681d886e390 Mon Sep 17 00:00:00 2001 From: Mark Hounschell Date: Tue, 25 Mar 2014 16:38:16 -0400 Subject: staging: dgap: remove volatiles from dgap.h This patch fixes checkpatch warnings about using volatiles in dgap.h Signed-off-by: Mark Hounschell Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgap/dgap.h | 152 ++++++++++++++++++++++---------------------- 1 file changed, 76 insertions(+), 76 deletions(-) diff --git a/drivers/staging/dgap/dgap.h b/drivers/staging/dgap/dgap.h index 01eb56fd9ada..2fce41c31cf7 100644 --- a/drivers/staging/dgap/dgap.h +++ b/drivers/staging/dgap/dgap.h @@ -1056,20 +1056,20 @@ struct channel_t { * Command structure definition. ************************************************************************/ struct cm_t { - volatile unsigned short cm_head; /* Command buffer head offset */ - volatile unsigned short cm_tail; /* Command buffer tail offset */ - volatile unsigned short cm_start; /* start offset of buffer */ - volatile unsigned short cm_max; /* last offset of buffer */ + unsigned short cm_head; /* Command buffer head offset */ + unsigned short cm_tail; /* Command buffer tail offset */ + unsigned short cm_start; /* start offset of buffer */ + unsigned short cm_max; /* last offset of buffer */ }; /************************************************************************ * Event structure definition. ************************************************************************/ struct ev_t { - volatile unsigned short ev_head; /* Command buffer head offset */ - volatile unsigned short ev_tail; /* Command buffer tail offset */ - volatile unsigned short ev_start; /* start offset of buffer */ - volatile unsigned short ev_max; /* last offset of buffer */ + unsigned short ev_head; /* Command buffer head offset */ + unsigned short ev_tail; /* Command buffer tail offset */ + unsigned short ev_start; /* start offset of buffer */ + unsigned short ev_max; /* last offset of buffer */ }; /************************************************************************ @@ -1096,74 +1096,74 @@ struct downld_t { * U = unknown (may be changed w/o notice) * ************************************************************************/ struct bs_t { - volatile unsigned short tp_jmp; /* Transmit poll jump */ - volatile unsigned short tc_jmp; /* Cooked procedure jump */ - volatile unsigned short ri_jmp; /* Not currently used */ - volatile unsigned short rp_jmp; /* Receive poll jump */ - - volatile unsigned short tx_seg; /* W Tx segment */ - volatile unsigned short tx_head; /* W Tx buffer head offset */ - volatile unsigned short tx_tail; /* R Tx buffer tail offset */ - volatile unsigned short tx_max; /* W Tx buffer size - 1 */ - - volatile unsigned short rx_seg; /* W Rx segment */ - volatile unsigned short rx_head; /* W Rx buffer head offset */ - volatile unsigned short rx_tail; /* R Rx buffer tail offset */ - volatile unsigned short rx_max; /* W Rx buffer size - 1 */ - - volatile unsigned short tx_lw; /* W Tx buffer low water mark */ - volatile unsigned short rx_lw; /* W Rx buffer low water mark */ - volatile unsigned short rx_hw; /* W Rx buffer high water mark*/ - volatile unsigned short incr; /* W Increment to next channel*/ - - volatile unsigned short fepdev; /* U SCC device base address */ - volatile unsigned short edelay; /* W Exception delay */ - volatile unsigned short blen; /* W Break length */ - volatile unsigned short btime; /* U Break complete time */ - - volatile unsigned short iflag; /* C UNIX input flags */ - volatile unsigned short oflag; /* C UNIX output flags */ - volatile unsigned short cflag; /* C UNIX control flags */ - volatile unsigned short wfill[13]; /* U Reserved for expansion */ - - volatile unsigned char num; /* U Channel number */ - volatile unsigned char ract; /* U Receiver active counter */ - volatile unsigned char bstat; /* U Break status bits */ - volatile unsigned char tbusy; /* W Transmit busy */ - volatile unsigned char iempty; /* W Transmit empty event */ - /* enable */ - volatile unsigned char ilow; /* W Transmit low-water event */ - /* enable */ - volatile unsigned char idata; /* W Receive data interrupt */ - /* enable */ - volatile unsigned char eflag; /* U Host event flags */ - - volatile unsigned char tflag; /* U Transmit flags */ - volatile unsigned char rflag; /* U Receive flags */ - volatile unsigned char xmask; /* U Transmit ready flags */ - volatile unsigned char xval; /* U Transmit ready value */ - volatile unsigned char m_stat; /* RC Modem status bits */ - volatile unsigned char m_change; /* U Modem bits which changed */ - volatile unsigned char m_int; /* W Modem interrupt enable */ - /* bits */ - volatile unsigned char m_last; /* U Last modem status */ - - volatile unsigned char mtran; /* C Unreported modem trans */ - volatile unsigned char orun; /* C Buffer overrun occurred */ - volatile unsigned char astartc; /* W Auxiliary Xon char */ - volatile unsigned char astopc; /* W Auxiliary Xoff char */ - volatile unsigned char startc; /* W Xon character */ - volatile unsigned char stopc; /* W Xoff character */ - volatile unsigned char vnextc; /* W Vnext character */ - volatile unsigned char hflow; /* C Software flow control */ - - volatile unsigned char fillc; /* U Delay Fill character */ - volatile unsigned char ochar; /* U Saved output character */ - volatile unsigned char omask; /* U Output character mask */ - - volatile unsigned char bfill[13]; /* U Reserved for expansion */ - - volatile unsigned char scc[16]; /* U SCC registers */ + unsigned short tp_jmp; /* Transmit poll jump */ + unsigned short tc_jmp; /* Cooked procedure jump */ + unsigned short ri_jmp; /* Not currently used */ + unsigned short rp_jmp; /* Receive poll jump */ + + unsigned short tx_seg; /* W Tx segment */ + unsigned short tx_head; /* W Tx buffer head offset */ + unsigned short tx_tail; /* R Tx buffer tail offset */ + unsigned short tx_max; /* W Tx buffer size - 1 */ + + unsigned short rx_seg; /* W Rx segment */ + unsigned short rx_head; /* W Rx buffer head offset */ + unsigned short rx_tail; /* R Rx buffer tail offset */ + unsigned short rx_max; /* W Rx buffer size - 1 */ + + unsigned short tx_lw; /* W Tx buffer low water mark */ + unsigned short rx_lw; /* W Rx buffer low water mark */ + unsigned short rx_hw; /* W Rx buffer high water mark*/ + unsigned short incr; /* W Increment to next channel*/ + + unsigned short fepdev; /* U SCC device base address */ + unsigned short edelay; /* W Exception delay */ + unsigned short blen; /* W Break length */ + unsigned short btime; /* U Break complete time */ + + unsigned short iflag; /* C UNIX input flags */ + unsigned short oflag; /* C UNIX output flags */ + unsigned short cflag; /* C UNIX control flags */ + unsigned short wfill[13]; /* U Reserved for expansion */ + + unsigned char num; /* U Channel number */ + unsigned char ract; /* U Receiver active counter */ + unsigned char bstat; /* U Break status bits */ + unsigned char tbusy; /* W Transmit busy */ + unsigned char iempty; /* W Transmit empty event */ + /* enable */ + unsigned char ilow; /* W Transmit low-water event */ + /* enable */ + unsigned char idata; /* W Receive data interrupt */ + /* enable */ + unsigned char eflag; /* U Host event flags */ + + unsigned char tflag; /* U Transmit flags */ + unsigned char rflag; /* U Receive flags */ + unsigned char xmask; /* U Transmit ready flags */ + unsigned char xval; /* U Transmit ready value */ + unsigned char m_stat; /* RC Modem status bits */ + unsigned char m_change; /* U Modem bits which changed */ + unsigned char m_int; /* W Modem interrupt enable */ + /* bits */ + unsigned char m_last; /* U Last modem status */ + + unsigned char mtran; /* C Unreported modem trans */ + unsigned char orun; /* C Buffer overrun occurred */ + unsigned char astartc; /* W Auxiliary Xon char */ + unsigned char astopc; /* W Auxiliary Xoff char */ + unsigned char startc; /* W Xon character */ + unsigned char stopc; /* W Xoff character */ + unsigned char vnextc; /* W Vnext character */ + unsigned char hflow; /* C Software flow control */ + + unsigned char fillc; /* U Delay Fill character */ + unsigned char ochar; /* U Saved output character */ + unsigned char omask; /* U Output character mask */ + + unsigned char bfill[13]; /* U Reserved for expansion */ + + unsigned char scc[16]; /* U SCC registers */ }; struct cnode { -- cgit v1.2.3 From 20fe4ae19d58766a87af6f74a97027a2eb0c85c3 Mon Sep 17 00:00:00 2001 From: Mark Hounschell Date: Tue, 25 Mar 2014 16:38:17 -0400 Subject: staging: dgap: fix/change a pr_info This patch just fixes a pr_info. brd->state is not proper at this point in time. Signed-off-by: Mark Hounschell Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgap/dgap.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/staging/dgap/dgap.c b/drivers/staging/dgap/dgap.c index 07fcb8df6a60..4bbedae22d49 100644 --- a/drivers/staging/dgap/dgap.c +++ b/drivers/staging/dgap/dgap.c @@ -782,9 +782,8 @@ static int dgap_found_board(struct pci_dev *pdev, int id) if (i) brd->state = BOARD_FAILED; - pr_info("dgap: board %d: %s (rev %d), irq %ld, %s\n", - dgap_NumBoards, brd->name, brd->rev, brd->irq, - brd->state ? "NOT READY\0" : "READY\0"); + pr_info("dgap: board %d: %s (rev %d), irq %ld\n", + dgap_NumBoards, brd->name, brd->rev, brd->irq); return 0; } -- cgit v1.2.3 From c9a129966227b39ec5f03abd4e24c8c08ee010ac Mon Sep 17 00:00:00 2001 From: Mark Hounschell Date: Fri, 28 Mar 2014 09:30:15 -0400 Subject: staging: dgap: rename and fixup dgap_wait_for_xxx functions This patch renames and changes the dgap_wait_for_bios and dgap_wait_for_fep functions from boolean functions to return zero on success and a negative error code on error. Signed-off-by: Mark Hounschell Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgap/dgap.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/drivers/staging/dgap/dgap.c b/drivers/staging/dgap/dgap.c index 4bbedae22d49..34693dc5d8c4 100644 --- a/drivers/staging/dgap/dgap.c +++ b/drivers/staging/dgap/dgap.c @@ -194,8 +194,8 @@ static int dgap_finalize_board_init(struct board_t *brd); static void dgap_get_vpd(struct board_t *brd); static void dgap_do_reset_board(struct board_t *brd); -static int dgap_do_wait_for_bios(struct board_t *brd); -static int dgap_do_wait_for_fep(struct board_t *brd); +static int dgap_test_bios(struct board_t *brd); +static int dgap_test_fep(struct board_t *brd); static int dgap_tty_register_ports(struct board_t *brd); static int dgap_firmware_load(struct pci_dev *pdev, int card_type); @@ -890,8 +890,9 @@ static int dgap_firmware_load(struct pci_dev *pdev, int card_type) release_firmware(fw); /* Wait for BIOS to test board... */ - if (!dgap_do_wait_for_bios(brd)) - return -ENXIO; + ret = dgap_test_bios(brd); + if (ret) + return ret; } if (fw_info[card_type].fep_name) { @@ -906,8 +907,9 @@ static int dgap_firmware_load(struct pci_dev *pdev, int card_type) release_firmware(fw); /* Wait for FEP to load on board... */ - if (!dgap_do_wait_for_fep(brd)) - return -ENXIO; + ret = dgap_test_fep(brd); + if (ret) + return ret; } #ifdef DIGI_CONCENTRATORS_SUPPORTED @@ -4332,16 +4334,15 @@ static void dgap_do_bios_load(struct board_t *brd, const uchar *ubios, int len) /* * Checks to see if the BIOS completed running on the card. */ -static int dgap_do_wait_for_bios(struct board_t *brd) +static int dgap_test_bios(struct board_t *brd) { uchar *addr; u16 word; u16 err1; u16 err2; - int ret = 0; if (!brd || (brd->magic != DGAP_BOARD_MAGIC) || !brd->re_map_membase) - return ret; + return -EINVAL; addr = brd->re_map_membase; word = readw(addr + POSTAREA); @@ -4355,7 +4356,7 @@ static int dgap_do_wait_for_bios(struct board_t *brd) while (brd->wait_for_bios < 1000) { /* Check to see if BIOS thinks board is good. (GD). */ if (word == *(u16 *) "GD") - return 1; + return 0; msleep_interruptible(10); brd->wait_for_bios++; word = readw(addr + POSTAREA); @@ -4369,7 +4370,7 @@ static int dgap_do_wait_for_bios(struct board_t *brd) brd->state = BOARD_FAILED; brd->dpastatus = BD_NOBIOS; - return ret; + return -EIO; } /* @@ -4420,16 +4421,15 @@ static void dgap_do_fep_load(struct board_t *brd, const uchar *ufep, int len) /* * Waits for the FEP to report thats its ready for us to use. */ -static int dgap_do_wait_for_fep(struct board_t *brd) +static int dgap_test_fep(struct board_t *brd) { uchar *addr; u16 word; u16 err1; u16 err2; - int ret = 0; if (!brd || (brd->magic != DGAP_BOARD_MAGIC) || !brd->re_map_membase) - return ret; + return -EINVAL; addr = brd->re_map_membase; word = readw(addr + FEPSTAT); @@ -4449,7 +4449,7 @@ static int dgap_do_wait_for_fep(struct board_t *brd) if (word == *(u16 *) "5A") brd->bd_flags |= BD_FEP5PLUS; - return 1; + return 0; } msleep_interruptible(10); brd->wait_for_fep++; @@ -4464,7 +4464,7 @@ static int dgap_do_wait_for_fep(struct board_t *brd) brd->state = BOARD_FAILED; brd->dpastatus = BD_NOFEP; - return ret; + return -EIO; } /* -- cgit v1.2.3 From 4aa8c0694c731e03eb660b92a3afe14859142381 Mon Sep 17 00:00:00 2001 From: Xiubo Li Date: Wed, 2 Apr 2014 18:09:07 +0800 Subject: regmap: implement LE formatting/parsing for 16/32-bit values. Allow busses to request little endianness formatting and parsing for 16- and 32-bit values. This will be useful to support regmap-mmio. For the following the scenarios using the regmap-mmio, for example: Index CPU Device Endianess flag for values ---------------------------------------------------------- 1 LE LE REGMAP_ENDIAN_DEFAULT/NATIVE 2 LE BE REGMAP_ENDIAN_BIG 3 BE BE REGMAP_ENDIAN_DEFAULT/NATIVE 4 BE LE REGMAP_ENDIAN_LITTLE For one device driver, which will support all the cases above, needs two boolean properties in DT node like: 'big-endian' for case 2 and 'little-endian' for case 4, and for cases 1 and 3 they all will be absent. Signed-off-by: Xiubo Li Signed-off-by: Mark Brown --- drivers/base/regmap/regmap.c | 52 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c index 63e30ef096e2..a1beffb4b066 100644 --- a/drivers/base/regmap/regmap.c +++ b/drivers/base/regmap/regmap.c @@ -192,6 +192,13 @@ static void regmap_format_16_be(void *buf, unsigned int val, unsigned int shift) b[0] = cpu_to_be16(val << shift); } +static void regmap_format_16_le(void *buf, unsigned int val, unsigned int shift) +{ + __le16 *b = buf; + + b[0] = cpu_to_le16(val << shift); +} + static void regmap_format_16_native(void *buf, unsigned int val, unsigned int shift) { @@ -216,6 +223,13 @@ static void regmap_format_32_be(void *buf, unsigned int val, unsigned int shift) b[0] = cpu_to_be32(val << shift); } +static void regmap_format_32_le(void *buf, unsigned int val, unsigned int shift) +{ + __le32 *b = buf; + + b[0] = cpu_to_le32(val << shift); +} + static void regmap_format_32_native(void *buf, unsigned int val, unsigned int shift) { @@ -240,6 +254,13 @@ static unsigned int regmap_parse_16_be(const void *buf) return be16_to_cpu(b[0]); } +static unsigned int regmap_parse_16_le(const void *buf) +{ + const __le16 *b = buf; + + return le16_to_cpu(b[0]); +} + static void regmap_parse_16_be_inplace(void *buf) { __be16 *b = buf; @@ -247,6 +268,13 @@ static void regmap_parse_16_be_inplace(void *buf) b[0] = be16_to_cpu(b[0]); } +static void regmap_parse_16_le_inplace(void *buf) +{ + __le16 *b = buf; + + b[0] = le16_to_cpu(b[0]); +} + static unsigned int regmap_parse_16_native(const void *buf) { return *(u16 *)buf; @@ -269,6 +297,13 @@ static unsigned int regmap_parse_32_be(const void *buf) return be32_to_cpu(b[0]); } +static unsigned int regmap_parse_32_le(const void *buf) +{ + const __le32 *b = buf; + + return le32_to_cpu(b[0]); +} + static void regmap_parse_32_be_inplace(void *buf) { __be32 *b = buf; @@ -276,6 +311,13 @@ static void regmap_parse_32_be_inplace(void *buf) b[0] = be32_to_cpu(b[0]); } +static void regmap_parse_32_le_inplace(void *buf) +{ + __le32 *b = buf; + + b[0] = le32_to_cpu(b[0]); +} + static unsigned int regmap_parse_32_native(const void *buf) { return *(u32 *)buf; @@ -608,6 +650,11 @@ struct regmap *regmap_init(struct device *dev, map->format.parse_val = regmap_parse_16_be; map->format.parse_inplace = regmap_parse_16_be_inplace; break; + case REGMAP_ENDIAN_LITTLE: + map->format.format_val = regmap_format_16_le; + map->format.parse_val = regmap_parse_16_le; + map->format.parse_inplace = regmap_parse_16_le_inplace; + break; case REGMAP_ENDIAN_NATIVE: map->format.format_val = regmap_format_16_native; map->format.parse_val = regmap_parse_16_native; @@ -629,6 +676,11 @@ struct regmap *regmap_init(struct device *dev, map->format.parse_val = regmap_parse_32_be; map->format.parse_inplace = regmap_parse_32_be_inplace; break; + case REGMAP_ENDIAN_LITTLE: + map->format.format_val = regmap_format_32_le; + map->format.parse_val = regmap_parse_32_le; + map->format.parse_inplace = regmap_parse_32_le_inplace; + break; case REGMAP_ENDIAN_NATIVE: map->format.format_val = regmap_format_32_native; map->format.parse_val = regmap_parse_32_native; -- cgit v1.2.3 From 88cb32c657ed13dc29561d0f4aa154e0fd25759f Mon Sep 17 00:00:00 2001 From: Xiubo Li Date: Wed, 2 Apr 2014 10:20:17 +0800 Subject: regmap: mmio: Fix the bug of 'offset' value parsing. 'offset = *(u32 *)reg;' This will be okey for 32/64-bits register device, but for 8/16-bits register ones, the 'offset' value will overflow, for example: The IMX2 Watchdog, whose registers and values are all 16-bits: If the IO base virtual address is ctx->regs = 0x888c0000, and the now doing the 0x00 register accessing: Using 'offset = *(u32 *)reg' the offset value will possiblly be 0x77310000, Using 'offset = *(u16 *)reg' the offset value will be 0x0000. In the regmap_mmio_gather_write(), ctx->regs + 0x7731000 will be 0xffbd0000, but actually it should be ctx->regs + 0x0000 = 0x888c0000. Signed-off-by: Xiubo Li Signed-off-by: Mark Brown --- drivers/base/regmap/regmap-mmio.c | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/drivers/base/regmap/regmap-mmio.c b/drivers/base/regmap/regmap-mmio.c index 1e03e7f8bacb..dff32c6b2474 100644 --- a/drivers/base/regmap/regmap-mmio.c +++ b/drivers/base/regmap/regmap-mmio.c @@ -66,12 +66,31 @@ static inline void regmap_mmio_count_check(size_t count) BUG_ON(count % 2 != 0); } +static inline unsigned int +regmap_mmio_get_offset(const void *reg, size_t reg_size) +{ + switch (reg_size) { + case 1: + return *(u8 *)reg; + case 2: + return *(u16 *)reg; + case 4: + return *(u32 *)reg; +#ifdef CONFIG_64BIT + case 8: + return *(u64 *)reg; +#endif + default: + BUG(); + } +} + static int regmap_mmio_gather_write(void *context, const void *reg, size_t reg_size, const void *val, size_t val_size) { struct regmap_mmio_context *ctx = context; - u32 offset; + unsigned int offset; int ret; regmap_mmio_regsize_check(reg_size); @@ -82,7 +101,7 @@ static int regmap_mmio_gather_write(void *context, return ret; } - offset = *(u32 *)reg; + offset = regmap_mmio_get_offset(reg, reg_size); while (val_size) { switch (ctx->val_bytes) { @@ -118,7 +137,7 @@ static int regmap_mmio_gather_write(void *context, static int regmap_mmio_write(void *context, const void *data, size_t count) { struct regmap_mmio_context *ctx = context; - u32 offset = ctx->reg_bytes + ctx->pad_bytes; + unsigned int offset = ctx->reg_bytes + ctx->pad_bytes; regmap_mmio_count_check(count); @@ -131,7 +150,7 @@ static int regmap_mmio_read(void *context, void *val, size_t val_size) { struct regmap_mmio_context *ctx = context; - u32 offset; + unsigned int offset; int ret; regmap_mmio_regsize_check(reg_size); @@ -142,7 +161,7 @@ static int regmap_mmio_read(void *context, return ret; } - offset = *(u32 *)reg; + offset = regmap_mmio_get_offset(reg, reg_size); while (val_size) { switch (ctx->val_bytes) { -- cgit v1.2.3 From 70d383b7fefc40179da3eadbeb79c222d21987df Mon Sep 17 00:00:00 2001 From: Jean-Christophe PINCE Date: Tue, 1 Apr 2014 13:26:48 -0700 Subject: regmap: rbtree: improve 64bits memory alignment Change regcache_rbtree_node strcuture fields order to align the pointers on 64bits architectures. Signed-off-by: Jean-Christophe PINCE Signed-off-by: David Cohen Signed-off-by: Mark Brown --- drivers/base/regmap/regcache-rbtree.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/base/regmap/regcache-rbtree.c b/drivers/base/regmap/regcache-rbtree.c index 930cad4e5df8..6a7e4fa12854 100644 --- a/drivers/base/regmap/regcache-rbtree.c +++ b/drivers/base/regmap/regcache-rbtree.c @@ -23,16 +23,16 @@ static int regcache_rbtree_write(struct regmap *map, unsigned int reg, static int regcache_rbtree_exit(struct regmap *map); struct regcache_rbtree_node { - /* the actual rbtree node holding this block */ - struct rb_node node; - /* base register handled by this block */ - unsigned int base_reg; /* block of adjacent registers */ void *block; /* Which registers are present */ long *cache_present; + /* base register handled by this block */ + unsigned int base_reg; /* number of registers available in the block */ unsigned int blklen; + /* the actual rbtree node holding this block */ + struct rb_node node; } __attribute__ ((packed)); struct regcache_rbtree_ctx { -- cgit v1.2.3 From dfe7a1b058bbb29fa524ca7cf05aa13ff52983f4 Mon Sep 17 00:00:00 2001 From: Carlo Caione Date: Fri, 11 Apr 2014 11:38:10 +0200 Subject: regulator: AXP20x: Add support for regulators subsystem AXP202 and AXP209 come with two synchronous step-down DC-DCs and five LDOs. This patch introduces basic support for those regulators. Signed-off-by: Carlo Caione Signed-off-by: Mark Brown --- drivers/regulator/Kconfig | 7 + drivers/regulator/Makefile | 1 + drivers/regulator/axp20x-regulator.c | 285 +++++++++++++++++++++++++++++++++++ 3 files changed, 293 insertions(+) create mode 100644 drivers/regulator/axp20x-regulator.c diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig index 903eb37f047a..65e5d7d1b35a 100644 --- a/drivers/regulator/Kconfig +++ b/drivers/regulator/Kconfig @@ -139,6 +139,13 @@ config REGULATOR_AS3722 AS3722 PMIC. This will enable support for all the software controllable DCDC/LDO regulators. +config REGULATOR_AXP20X + tristate "X-POWERS AXP20X PMIC Regulators" + depends on MFD_AXP20X + help + This driver provides support for the voltage regulators on the + AXP20X PMIC. + config REGULATOR_BCM590XX tristate "Broadcom BCM590xx PMU Regulators" depends on MFD_BCM590XX diff --git a/drivers/regulator/Makefile b/drivers/regulator/Makefile index 12ef277a48b4..c14696b290c0 100644 --- a/drivers/regulator/Makefile +++ b/drivers/regulator/Makefile @@ -20,6 +20,7 @@ obj-$(CONFIG_REGULATOR_ANATOP) += anatop-regulator.o obj-$(CONFIG_REGULATOR_ARIZONA) += arizona-micsupp.o arizona-ldo1.o obj-$(CONFIG_REGULATOR_AS3711) += as3711-regulator.o obj-$(CONFIG_REGULATOR_AS3722) += as3722-regulator.o +obj-$(CONFIG_REGULATOR_AXP20X) += axp20x-regulator.o obj-$(CONFIG_REGULATOR_BCM590XX) += bcm590xx-regulator.o obj-$(CONFIG_REGULATOR_DA903X) += da903x.o obj-$(CONFIG_REGULATOR_DA9052) += da9052-regulator.o diff --git a/drivers/regulator/axp20x-regulator.c b/drivers/regulator/axp20x-regulator.c new file mode 100644 index 000000000000..78a29e60f53a --- /dev/null +++ b/drivers/regulator/axp20x-regulator.c @@ -0,0 +1,285 @@ +/* + * AXP20x regulators driver. + * + * Copyright (C) 2013 Carlo Caione + * + * This file is subject to the terms and conditions of the GNU General + * Public License. See the file "COPYING" in the main directory of this + * archive for more details. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define AXP20X_IO_ENABLED 0x03 +#define AXP20X_IO_DISABLED 0x07 + +#define AXP20X_WORKMODE_DCDC2_MASK BIT(2) +#define AXP20X_WORKMODE_DCDC3_MASK BIT(1) + +#define AXP20X_FREQ_DCDC_MASK 0x0f + +#define AXP20X_DESC_IO(_id, _supply, _min, _max, _step, _vreg, _vmask, _ereg, \ + _emask, _enable_val, _disable_val) \ + [AXP20X_##_id] = { \ + .name = #_id, \ + .supply_name = (_supply), \ + .type = REGULATOR_VOLTAGE, \ + .id = AXP20X_##_id, \ + .n_voltages = (((_max) - (_min)) / (_step) + 1), \ + .owner = THIS_MODULE, \ + .min_uV = (_min) * 1000, \ + .uV_step = (_step) * 1000, \ + .vsel_reg = (_vreg), \ + .vsel_mask = (_vmask), \ + .enable_reg = (_ereg), \ + .enable_mask = (_emask), \ + .enable_val = (_enable_val), \ + .disable_val = (_disable_val), \ + .ops = &axp20x_ops, \ + } + +#define AXP20X_DESC(_id, _supply, _min, _max, _step, _vreg, _vmask, _ereg, \ + _emask) \ + [AXP20X_##_id] = { \ + .name = #_id, \ + .supply_name = (_supply), \ + .type = REGULATOR_VOLTAGE, \ + .id = AXP20X_##_id, \ + .n_voltages = (((_max) - (_min)) / (_step) + 1), \ + .owner = THIS_MODULE, \ + .min_uV = (_min) * 1000, \ + .uV_step = (_step) * 1000, \ + .vsel_reg = (_vreg), \ + .vsel_mask = (_vmask), \ + .enable_reg = (_ereg), \ + .enable_mask = (_emask), \ + .ops = &axp20x_ops, \ + } + +#define AXP20X_DESC_FIXED(_id, _supply, _volt) \ + [AXP20X_##_id] = { \ + .name = #_id, \ + .supply_name = (_supply), \ + .type = REGULATOR_VOLTAGE, \ + .id = AXP20X_##_id, \ + .n_voltages = 1, \ + .owner = THIS_MODULE, \ + .min_uV = (_volt) * 1000, \ + .ops = &axp20x_ops_fixed \ + } + +#define AXP20X_DESC_TABLE(_id, _supply, _table, _vreg, _vmask, _ereg, _emask) \ + [AXP20X_##_id] = { \ + .name = #_id, \ + .supply_name = (_supply), \ + .type = REGULATOR_VOLTAGE, \ + .id = AXP20X_##_id, \ + .n_voltages = ARRAY_SIZE(_table), \ + .owner = THIS_MODULE, \ + .vsel_reg = (_vreg), \ + .vsel_mask = (_vmask), \ + .enable_reg = (_ereg), \ + .enable_mask = (_emask), \ + .volt_table = (_table), \ + .ops = &axp20x_ops_table, \ + } + +static const int axp20x_ldo4_data[] = { 1250000, 1300000, 1400000, 1500000, 1600000, + 1700000, 1800000, 1900000, 2000000, 2500000, + 2700000, 2800000, 3000000, 3100000, 3200000, + 3300000 }; + +static struct regulator_ops axp20x_ops_fixed = { + .list_voltage = regulator_list_voltage_linear, +}; + +static struct regulator_ops axp20x_ops_table = { + .set_voltage_sel = regulator_set_voltage_sel_regmap, + .get_voltage_sel = regulator_get_voltage_sel_regmap, + .list_voltage = regulator_list_voltage_table, + .enable = regulator_enable_regmap, + .disable = regulator_disable_regmap, + .is_enabled = regulator_is_enabled_regmap, +}; + +static struct regulator_ops axp20x_ops = { + .set_voltage_sel = regulator_set_voltage_sel_regmap, + .get_voltage_sel = regulator_get_voltage_sel_regmap, + .list_voltage = regulator_list_voltage_linear, + .enable = regulator_enable_regmap, + .disable = regulator_disable_regmap, + .is_enabled = regulator_is_enabled_regmap, +}; + +static const struct regulator_desc axp20x_regulators[] = { + AXP20X_DESC(DCDC2, "vin2", 700, 2275, 25, AXP20X_DCDC2_V_OUT, 0x3f, + AXP20X_PWR_OUT_CTRL, 0x10), + AXP20X_DESC(DCDC3, "vin3", 700, 3500, 25, AXP20X_DCDC3_V_OUT, 0x7f, + AXP20X_PWR_OUT_CTRL, 0x02), + AXP20X_DESC_FIXED(LDO1, "acin", 1300), + AXP20X_DESC(LDO2, "ldo24in", 1800, 3300, 100, AXP20X_LDO24_V_OUT, 0xf0, + AXP20X_PWR_OUT_CTRL, 0x04), + AXP20X_DESC(LDO3, "ldo3in", 700, 3500, 25, AXP20X_LDO3_V_OUT, 0x7f, + AXP20X_PWR_OUT_CTRL, 0x40), + AXP20X_DESC_TABLE(LDO4, "ldo24in", axp20x_ldo4_data, AXP20X_LDO24_V_OUT, 0x0f, + AXP20X_PWR_OUT_CTRL, 0x08), + AXP20X_DESC_IO(LDO5, "ldo5in", 1800, 3300, 100, AXP20X_LDO5_V_OUT, 0xf0, + AXP20X_GPIO0_CTRL, 0x07, AXP20X_IO_ENABLED, + AXP20X_IO_DISABLED), +}; + +#define AXP_MATCH(_name, _id) \ + [AXP20X_##_id] = { \ + .name = #_name, \ + .driver_data = (void *) &axp20x_regulators[AXP20X_##_id], \ + } + +static struct of_regulator_match axp20x_matches[] = { + AXP_MATCH(dcdc2, DCDC2), + AXP_MATCH(dcdc3, DCDC3), + AXP_MATCH(ldo1, LDO1), + AXP_MATCH(ldo2, LDO2), + AXP_MATCH(ldo3, LDO3), + AXP_MATCH(ldo4, LDO4), + AXP_MATCH(ldo5, LDO5), +}; + +static int axp20x_set_dcdc_freq(struct platform_device *pdev, u32 dcdcfreq) +{ + struct axp20x_dev *axp20x = dev_get_drvdata(pdev->dev.parent); + + if (dcdcfreq < 750) { + dcdcfreq = 750; + dev_warn(&pdev->dev, "DCDC frequency too low. Set to 750kHz\n"); + } + + if (dcdcfreq > 1875) { + dcdcfreq = 1875; + dev_warn(&pdev->dev, "DCDC frequency too high. Set to 1875kHz\n"); + } + + dcdcfreq = (dcdcfreq - 750) / 75; + + return regmap_update_bits(axp20x->regmap, AXP20X_DCDC_FREQ, + AXP20X_FREQ_DCDC_MASK, dcdcfreq); +} + +static int axp20x_regulator_parse_dt(struct platform_device *pdev) +{ + struct device_node *np, *regulators; + int ret; + u32 dcdcfreq; + + np = of_node_get(pdev->dev.parent->of_node); + if (!np) + return 0; + + regulators = of_find_node_by_name(np, "regulators"); + if (!regulators) { + dev_warn(&pdev->dev, "regulators node not found\n"); + } else { + ret = of_regulator_match(&pdev->dev, regulators, axp20x_matches, + ARRAY_SIZE(axp20x_matches)); + if (ret < 0) { + dev_err(&pdev->dev, "Error parsing regulator init data: %d\n", ret); + return ret; + } + + dcdcfreq = 1500; + of_property_read_u32(regulators, "x-powers,dcdc-freq", &dcdcfreq); + ret = axp20x_set_dcdc_freq(pdev, dcdcfreq); + if (ret < 0) { + dev_err(&pdev->dev, "Error setting dcdc frequency: %d\n", ret); + return ret; + } + + of_node_put(regulators); + } + + return 0; +} + +static int axp20x_set_dcdc_workmode(struct regulator_dev *rdev, int id, u32 workmode) +{ + unsigned int mask = AXP20X_WORKMODE_DCDC2_MASK; + + if ((id != AXP20X_DCDC2) && (id != AXP20X_DCDC3)) + return -EINVAL; + + if (id == AXP20X_DCDC3) + mask = AXP20X_WORKMODE_DCDC3_MASK; + + workmode <<= ffs(mask) - 1; + + return regmap_update_bits(rdev->regmap, AXP20X_DCDC_MODE, mask, workmode); +} + +static int axp20x_regulator_probe(struct platform_device *pdev) +{ + struct regulator_dev *rdev; + struct axp20x_dev *axp20x = dev_get_drvdata(pdev->dev.parent); + struct regulator_config config = { }; + struct regulator_init_data *init_data; + int ret, i; + u32 workmode; + + ret = axp20x_regulator_parse_dt(pdev); + if (ret) + return ret; + + for (i = 0; i < AXP20X_REG_ID_MAX; i++) { + init_data = axp20x_matches[i].init_data; + + config.dev = &pdev->dev; + config.init_data = init_data; + config.regmap = axp20x->regmap; + config.of_node = axp20x_matches[i].of_node; + + rdev = devm_regulator_register(&pdev->dev, &axp20x_regulators[i], + &config); + if (IS_ERR(rdev)) { + dev_err(&pdev->dev, "Failed to register %s\n", + axp20x_regulators[i].name); + + return PTR_ERR(rdev); + } + + ret = of_property_read_u32(axp20x_matches[i].of_node, "x-powers,dcdc-workmode", + &workmode); + if (!ret) { + if (axp20x_set_dcdc_workmode(rdev, i, workmode)) + dev_err(&pdev->dev, "Failed to set workmode on %s\n", + axp20x_regulators[i].name); + } + } + + return 0; +} + +static struct platform_driver axp20x_regulator_driver = { + .probe = axp20x_regulator_probe, + .driver = { + .name = "axp20x-regulator", + .owner = THIS_MODULE, + }, +}; + +module_platform_driver(axp20x_regulator_driver); + +MODULE_LICENSE("GPL v2"); +MODULE_AUTHOR("Carlo Caione "); +MODULE_DESCRIPTION("Regulator Driver for AXP20X PMIC"); -- cgit v1.2.3 From bd0dda744cdfb93a1907091c4540764593a28fa2 Mon Sep 17 00:00:00 2001 From: Charles Keepax Date: Thu, 3 Apr 2014 15:32:15 +0100 Subject: regulator: core: Add of_node_get to of_regulator_match Currently, of_regulator_match does not increment the reference count of the of_nodes it takes new references to. This could cause the node pointer held to be invalid, by the time it is passed to the regulator core. This patchs adds an of_node_get when we copy each of_node pointer into the match structure. Signed-off-by: Charles Keepax Signed-off-by: Mark Brown --- drivers/regulator/of_regulator.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/regulator/of_regulator.c b/drivers/regulator/of_regulator.c index ea4f36f2cbe2..c58c8d178948 100644 --- a/drivers/regulator/of_regulator.c +++ b/drivers/regulator/of_regulator.c @@ -119,7 +119,8 @@ EXPORT_SYMBOL_GPL(of_get_regulator_init_data); * regulator. The data parsed from a child node will be matched to a regulator * based on either the deprecated property regulator-compatible if present, * or otherwise the child node's name. Note that the match table is modified - * in place. + * in place and an additional of_node reference is taken for each matched + * regulator. * * Returns the number of matches found or a negative error code on failure. */ @@ -162,7 +163,7 @@ int of_regulator_match(struct device *dev, struct device_node *node, child->name); return -EINVAL; } - match->of_node = child; + match->of_node = of_node_get(child); count++; break; } -- cgit v1.2.3 From 3764806440149ea9024dff039497d1e45d6ed027 Mon Sep 17 00:00:00 2001 From: Charles Keepax Date: Thu, 3 Apr 2014 15:32:16 +0100 Subject: regulator: core: Add helper to put of_nodes from matches As of_regulator_match will take an of_node reference to each matched regulator, it makes sense to provide a helper to put all those references. This patch does that. Signed-off-by: Charles Keepax Signed-off-by: Mark Brown --- drivers/regulator/of_regulator.c | 21 +++++++++++++++++++++ include/linux/regulator/of_regulator.h | 7 +++++++ 2 files changed, 28 insertions(+) diff --git a/drivers/regulator/of_regulator.c b/drivers/regulator/of_regulator.c index c58c8d178948..188e0cb10d03 100644 --- a/drivers/regulator/of_regulator.c +++ b/drivers/regulator/of_regulator.c @@ -172,3 +172,24 @@ int of_regulator_match(struct device *dev, struct device_node *node, return count; } EXPORT_SYMBOL_GPL(of_regulator_match); + +/** + * of_regulator_put_match - put the of_node references from an + * of_regulator_match structure + * @matches: match table for the regulators + * @num_matches: number of entries in match table + * + * This function goes through a match table and calls of_node_put on each + * of_node. + */ +int of_regulator_put_match(struct of_regulator_match *matches, + unsigned int num_matches) +{ + int i; + + for (i = 0; i < num_matches; i++) + of_node_put(matches[i].of_node); + + return 0; +} +EXPORT_SYMBOL_GPL(of_regulator_put_match); diff --git a/include/linux/regulator/of_regulator.h b/include/linux/regulator/of_regulator.h index f9217965aaa3..06528516aa15 100644 --- a/include/linux/regulator/of_regulator.h +++ b/include/linux/regulator/of_regulator.h @@ -20,6 +20,8 @@ extern struct regulator_init_data extern int of_regulator_match(struct device *dev, struct device_node *node, struct of_regulator_match *matches, unsigned int num_matches); +extern int of_regulator_put_match(struct of_regulator_match *matches, + unsigned int num_matches); #else static inline struct regulator_init_data *of_get_regulator_init_data(struct device *dev, @@ -35,6 +37,11 @@ static inline int of_regulator_match(struct device *dev, { return 0; } +static inline int of_regulator_put_match(struct of_regulator_match *matches, + unsigned int num_matches); +{ + return 0; +} #endif /* CONFIG_OF */ #endif /* __LINUX_OF_REG_H */ -- cgit v1.2.3 From 63c7c9e16c8e92cc069854f2babdf82d2d38e4c7 Mon Sep 17 00:00:00 2001 From: Charles Keepax Date: Thu, 3 Apr 2014 15:32:17 +0100 Subject: regulator: core: Get and put regulator of_node Currently the regulator core does not take an additional reference to the of_node it is passed. This means that the caller must ensure that the of_node is valid for the duration of the regulator's existance. It is reasonable for the framework to assume it is passed a valid of_node but seems onerous for it to assume the caller will keep the node valid for the life-time of the regulator, especially when devm_regulator_register is used and there will likely be no code in the driver called at the point it would be safe to put the of_node. This patch adds an additional of_node_get when the regulator is registered and an of_node_put when it is unregistered in the core. This means individual drivers are free to put their of_node references at the end of probe letting the regulator core handling it from there. This simplifies code on the driver side. Signed-off-by: Charles Keepax Signed-off-by: Mark Brown --- drivers/regulator/core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index 9a09f3cdbabb..b97ffd2365d3 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -3447,7 +3447,7 @@ regulator_register(const struct regulator_desc *regulator_desc, /* register with sysfs */ rdev->dev.class = ®ulator_class; - rdev->dev.of_node = config->of_node; + rdev->dev.of_node = of_node_get(config->of_node); rdev->dev.parent = dev; dev_set_name(&rdev->dev, "regulator.%d", atomic_inc_return(®ulator_no) - 1); @@ -3589,6 +3589,7 @@ void regulator_unregister(struct regulator_dev *rdev) list_del(&rdev->list); kfree(rdev->constraints); regulator_ena_gpio_free(rdev); + of_node_put(rdev->dev.of_node); device_unregister(&rdev->dev); mutex_unlock(®ulator_list_mutex); } -- cgit v1.2.3 From 5efe144681c183e1ca7b0053ad1113667aa7fde2 Mon Sep 17 00:00:00 2001 From: Charles Keepax Date: Fri, 4 Apr 2014 09:29:58 +0100 Subject: regulator: core: Fix typo in of_regulator.h Fix a typo from my patch adding of_regulator_put_match in the patch: regulator: core: Add helper to put of_nodes from matches Signed-off-by: Charles Keepax Signed-off-by: Mark Brown --- include/linux/regulator/of_regulator.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/regulator/of_regulator.h b/include/linux/regulator/of_regulator.h index 06528516aa15..a5abd8334003 100644 --- a/include/linux/regulator/of_regulator.h +++ b/include/linux/regulator/of_regulator.h @@ -38,7 +38,7 @@ static inline int of_regulator_match(struct device *dev, return 0; } static inline int of_regulator_put_match(struct of_regulator_match *matches, - unsigned int num_matches); + unsigned int num_matches) { return 0; } -- cgit v1.2.3 From e80fb721cac4202253939451678c873a222be2fa Mon Sep 17 00:00:00 2001 From: Krzysztof Kozlowski Date: Mon, 7 Apr 2014 14:15:24 +0200 Subject: regulator: s5m8767: Remove regulator_dev pointer from state container Don't store pointer to regulator_dev returned by devm_regulator_register() in state container. It isn't used anywhere outside of probe. Signed-off-by: Krzysztof Kozlowski Signed-off-by: Mark Brown --- drivers/regulator/s5m8767.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/drivers/regulator/s5m8767.c b/drivers/regulator/s5m8767.c index 92f19a005dc3..5daa06626f16 100644 --- a/drivers/regulator/s5m8767.c +++ b/drivers/regulator/s5m8767.c @@ -28,7 +28,6 @@ struct s5m8767_info { struct device *dev; struct sec_pmic_dev *iodev; int num_regulators; - struct regulator_dev **rdev; struct sec_opmode_data *opmode; int ramp_delay; @@ -695,7 +694,6 @@ static int s5m8767_pmic_probe(struct platform_device *pdev) struct sec_pmic_dev *iodev = dev_get_drvdata(pdev->dev.parent); struct sec_platform_data *pdata = iodev->pdata; struct regulator_config config = { }; - struct regulator_dev **rdev; struct s5m8767_info *s5m8767; int i, ret, size, buck_init; @@ -737,11 +735,7 @@ static int s5m8767_pmic_probe(struct platform_device *pdev) return -ENOMEM; size = sizeof(struct regulator_dev *) * (S5M8767_REG_MAX - 2); - s5m8767->rdev = devm_kzalloc(&pdev->dev, size, GFP_KERNEL); - if (!s5m8767->rdev) - return -ENOMEM; - rdev = s5m8767->rdev; s5m8767->dev = &pdev->dev; s5m8767->iodev = iodev; s5m8767->num_regulators = pdata->num_regulators; @@ -938,6 +932,7 @@ static int s5m8767_pmic_probe(struct platform_device *pdev) const struct sec_voltage_desc *desc; int id = pdata->regulators[i].id; int enable_reg, enable_val; + struct regulator_dev *rdev; desc = reg_voltage_map[id]; if (desc) { @@ -969,21 +964,21 @@ static int s5m8767_pmic_probe(struct platform_device *pdev) s5m8767_regulator_config_ext_control(s5m8767, &pdata->regulators[i], &config); - rdev[i] = devm_regulator_register(&pdev->dev, ®ulators[id], + rdev = devm_regulator_register(&pdev->dev, ®ulators[id], &config); - if (IS_ERR(rdev[i])) { - ret = PTR_ERR(rdev[i]); + if (IS_ERR(rdev)) { + ret = PTR_ERR(rdev); dev_err(s5m8767->dev, "regulator init failed for %d\n", id); return ret; } if (pdata->regulators[i].ext_control_gpio) { - ret = s5m8767_enable_ext_control(s5m8767, rdev[i]); + ret = s5m8767_enable_ext_control(s5m8767, rdev); if (ret < 0) { dev_err(s5m8767->dev, "failed to enable gpio control over %s: %d\n", - rdev[i]->desc->name, ret); + rdev->desc->name, ret); return ret; } } -- cgit v1.2.3 From 0c3b97487d15a452f1fa7bfd9b6f1bd1a31d538d Mon Sep 17 00:00:00 2001 From: Axel Lin Date: Thu, 27 Mar 2014 09:26:38 +0800 Subject: spi: atmel: Make current_remaining_bytes to be int Don't use unsigned for current_remaining_bytes so we can check current_remaining_bytes < 0 case. Use int is enough for current_remaining_bytes. Signed-off-by: Axel Lin Signed-off-by: Wenyou Yang Signed-off-by: Mark Brown --- drivers/spi/spi-atmel.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/spi/spi-atmel.c b/drivers/spi/spi-atmel.c index 8005f9869481..485e6cce94bf 100644 --- a/drivers/spi/spi-atmel.c +++ b/drivers/spi/spi-atmel.c @@ -224,7 +224,7 @@ struct atmel_spi { struct platform_device *pdev; struct spi_transfer *current_transfer; - unsigned long current_remaining_bytes; + int current_remaining_bytes; int done_status; struct completion xfer_completion; @@ -1110,6 +1110,8 @@ static int atmel_spi_one_transfer(struct spi_master *master, atmel_spi_next_xfer_pio(master, xfer); } else { as->current_remaining_bytes -= len; + if (as->current_remaining_bytes < 0) + as->current_remaining_bytes = 0; } } else { atmel_spi_next_xfer_pio(master, xfer); -- cgit v1.2.3 From eee668a92bc775030178c8a7f0d0abe9cce441d7 Mon Sep 17 00:00:00 2001 From: Harini Katakam Date: Fri, 11 Apr 2014 12:06:28 +0530 Subject: spi: core: Increase timeout value The existing timeout value in wait_for_completion_timeout is calculated from the transfer length and speed with tolerance of 10msec. This is too low because this is used for error conditions such as hardware hang etc. The xfer->speed_hz considered may not be the actual speed set because the best clock divisor is chosen from a limited set such that the actual speed <= requested speed. This will lead to timeout being less than actual transfer time. Considering acceptable latencies, this timeout can be set to a value double the expected transfer plus 100 msecs. This patch adds the same in the core. Signed-off-by: Harini Katakam Signed-off-by: Mark Brown --- drivers/spi/spi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index 4eb9bf02996c..f01cbb41e6ca 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c @@ -775,7 +775,7 @@ static int spi_transfer_one_message(struct spi_master *master, if (ret > 0) { ret = 0; ms = xfer->len * 8 * 1000 / xfer->speed_hz; - ms += 10; /* some tolerance */ + ms += ms + 100; /* some tolerance */ ms = wait_for_completion_timeout(&master->xfer_completion, msecs_to_jiffies(ms)); -- cgit v1.2.3 From cd6339e6ced387ad67b5551dd2931cfd7e8b970b Mon Sep 17 00:00:00 2001 From: Zhao Qiang Date: Tue, 1 Apr 2014 17:10:50 +0800 Subject: spi: add "spi-lsb-first" to devicetree add optional property devicetree for SPI slave nodes into devicetree so that LSB mode can be enabled by devicetree. Signed-off-by: Zhao Qiang Signed-off-by: Mark Brown --- Documentation/devicetree/bindings/spi/spi-bus.txt | 2 ++ drivers/spi/spi.c | 2 ++ 2 files changed, 4 insertions(+) diff --git a/Documentation/devicetree/bindings/spi/spi-bus.txt b/Documentation/devicetree/bindings/spi/spi-bus.txt index e5a4d1b4acfe..22d57404fdc3 100644 --- a/Documentation/devicetree/bindings/spi/spi-bus.txt +++ b/Documentation/devicetree/bindings/spi/spi-bus.txt @@ -55,6 +55,8 @@ contain the following properties. chip select active high - spi-3wire - (optional) Empty property indicating device requires 3-wire mode. +- spi-lsb-first - (optional) Empty property indicating device requires + LSB first mode. - spi-tx-bus-width - (optional) The bus width(number of data wires) that used for MOSI. Defaults to 1 if not present. - spi-rx-bus-width - (optional) The bus width(number of data wires) that diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index 4eb9bf02996c..214045c04705 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c @@ -1234,6 +1234,8 @@ static void of_register_spi_devices(struct spi_master *master) spi->mode |= SPI_CS_HIGH; if (of_find_property(nc, "spi-3wire", NULL)) spi->mode |= SPI_3WIRE; + if (of_find_property(nc, "spi-lsb-first", NULL)) + spi->mode |= SPI_LSB_FIRST; /* Device DUAL/QUAD mode */ if (!of_property_read_u32(nc, "spi-tx-bus-width", &value)) { -- cgit v1.2.3 From abcadeb255074d1351d110ef696b647859fa3d5b Mon Sep 17 00:00:00 2001 From: Axel Lin Date: Sun, 30 Mar 2014 16:43:23 +0800 Subject: spi: fsl: Kill mpc8xxx_spi_cleanup and convert fsl_espi_setup to use devm_kzalloc In current code, master->cleanup and master->setup are not set in the same function. This makes it hard to read and not good for code maintain. One example is in fsl-spi.c, master->cleanup is overrided in mpc8xxx_spi_probe() which leads to a memory leak. This patch removes mpc8xxx_spi_cleanup() and converts fsl_espi_setup to use devm_kzalloc so we don't need to take care of freeing memory. Signed-off-by: Axel Lin Signed-off-by: Mark Brown --- drivers/spi/spi-fsl-espi.c | 2 +- drivers/spi/spi-fsl-lib.c | 6 ------ drivers/spi/spi-fsl-lib.h | 1 - 3 files changed, 1 insertion(+), 8 deletions(-) diff --git a/drivers/spi/spi-fsl-espi.c b/drivers/spi/spi-fsl-espi.c index e767f5831b9c..3cf7d65bc739 100644 --- a/drivers/spi/spi-fsl-espi.c +++ b/drivers/spi/spi-fsl-espi.c @@ -458,7 +458,7 @@ static int fsl_espi_setup(struct spi_device *spi) return -EINVAL; if (!cs) { - cs = kzalloc(sizeof *cs, GFP_KERNEL); + cs = devm_kzalloc(&spi->dev, sizeof(*cs), GFP_KERNEL); if (!cs) return -ENOMEM; spi->controller_state = cs; diff --git a/drivers/spi/spi-fsl-lib.c b/drivers/spi/spi-fsl-lib.c index e5d45fca3551..95212ea96c8d 100644 --- a/drivers/spi/spi-fsl-lib.c +++ b/drivers/spi/spi-fsl-lib.c @@ -99,11 +99,6 @@ int mpc8xxx_spi_transfer(struct spi_device *spi, return 0; } -void mpc8xxx_spi_cleanup(struct spi_device *spi) -{ - kfree(spi->controller_state); -} - const char *mpc8xxx_spi_strmode(unsigned int flags) { if (flags & SPI_QE_CPU_MODE) { @@ -134,7 +129,6 @@ int mpc8xxx_spi_probe(struct device *dev, struct resource *mem, | SPI_LSB_FIRST | SPI_LOOP; master->transfer = mpc8xxx_spi_transfer; - master->cleanup = mpc8xxx_spi_cleanup; master->dev.of_node = dev->of_node; mpc8xxx_spi = spi_master_get_devdata(master); diff --git a/drivers/spi/spi-fsl-lib.h b/drivers/spi/spi-fsl-lib.h index 52db6936778e..2fcbfd01d109 100644 --- a/drivers/spi/spi-fsl-lib.h +++ b/drivers/spi/spi-fsl-lib.h @@ -124,7 +124,6 @@ extern struct mpc8xxx_spi_probe_info *to_of_pinfo( extern int mpc8xxx_spi_bufs(struct mpc8xxx_spi *mspi, struct spi_transfer *t, unsigned int len); extern int mpc8xxx_spi_transfer(struct spi_device *spi, struct spi_message *m); -extern void mpc8xxx_spi_cleanup(struct spi_device *spi); extern const char *mpc8xxx_spi_strmode(unsigned int flags); extern int mpc8xxx_spi_probe(struct device *dev, struct resource *mem, unsigned int irq); -- cgit v1.2.3 From 7a40054361162d2f78f332aa868fed137beb7901 Mon Sep 17 00:00:00 2001 From: Axel Lin Date: Sun, 30 Mar 2014 16:42:57 +0800 Subject: spi: fsl-spi: Fix memory leak mpc8xxx_spi_probe() has set master->cleanup = mpc8xxx_spi_cleanup, however current code overrides the setting in fsl_spi_probe() and set master->cleanup = fsl_spi_cleanup. Thus the memory allocated for cs is not freed anywhere. Convert to use devm_kzalloc to fix the memory leak. Signed-off-by: Axel Lin Signed-off-by: Mark Brown --- drivers/spi/spi-fsl-spi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/spi/spi-fsl-spi.c b/drivers/spi/spi-fsl-spi.c index b3e7775034db..98ccd231bf00 100644 --- a/drivers/spi/spi-fsl-spi.c +++ b/drivers/spi/spi-fsl-spi.c @@ -431,7 +431,7 @@ static int fsl_spi_setup(struct spi_device *spi) return -EINVAL; if (!cs) { - cs = kzalloc(sizeof *cs, GFP_KERNEL); + cs = devm_kzalloc(&spi->dev, sizeof(*cs), GFP_KERNEL); if (!cs) return -ENOMEM; spi->controller_state = cs; -- cgit v1.2.3 From c586feba880d78cab1882e1faee0395bba2b884f Mon Sep 17 00:00:00 2001 From: Axel Lin Date: Mon, 31 Mar 2014 11:37:29 +0800 Subject: spi: s3c24xx: Convert to use devm_kzalloc Simplify the cleanup code. Signed-off-by: Axel Lin Reviewed-by: Jingoo Han Signed-off-by: Mark Brown --- drivers/spi/spi-s3c24xx.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/drivers/spi/spi-s3c24xx.c b/drivers/spi/spi-s3c24xx.c index bed23384dfab..6db14e53af17 100644 --- a/drivers/spi/spi-s3c24xx.c +++ b/drivers/spi/spi-s3c24xx.c @@ -183,7 +183,9 @@ static int s3c24xx_spi_setup(struct spi_device *spi) /* allocate settings on the first call */ if (!cs) { - cs = kzalloc(sizeof(struct s3c24xx_spi_devstate), GFP_KERNEL); + cs = devm_kzalloc(&spi->dev, + sizeof(struct s3c24xx_spi_devstate), + GFP_KERNEL); if (!cs) { dev_err(&spi->dev, "no memory for controller state\n"); return -ENOMEM; @@ -209,11 +211,6 @@ static int s3c24xx_spi_setup(struct spi_device *spi) return 0; } -static void s3c24xx_spi_cleanup(struct spi_device *spi) -{ - kfree(spi->controller_state); -} - static inline unsigned int hw_txbyte(struct s3c24xx_spi *hw, int count) { return hw->tx ? hw->tx[count] : 0; @@ -543,7 +540,6 @@ static int s3c24xx_spi_probe(struct platform_device *pdev) hw->bitbang.txrx_bufs = s3c24xx_spi_txrx; hw->master->setup = s3c24xx_spi_setup; - hw->master->cleanup = s3c24xx_spi_cleanup; dev_dbg(hw->dev, "bitbang at %p\n", &hw->bitbang); -- cgit v1.2.3 From e4745fef5595df7405ea24d6b21ba0e65332bb8e Mon Sep 17 00:00:00 2001 From: Axel Lin Date: Fri, 28 Mar 2014 11:05:55 +0800 Subject: spi: Remove unneeded include of linux/workqueue.h Signed-off-by: Axel Lin Signed-off-by: Mark Brown --- drivers/spi/spi-ath79.c | 1 - drivers/spi/spi-bcm63xx-hsspi.c | 1 - drivers/spi/spi-bcm63xx.c | 1 - drivers/spi/spi-falcon.c | 1 - drivers/spi/spi-nuc900.c | 1 - drivers/spi/spi-omap-uwire.c | 1 - drivers/spi/spi-pxa2xx.c | 1 - drivers/spi/spi-s3c24xx.c | 1 - drivers/spi/spi-s3c64xx.c | 1 - drivers/spi/spi-sh-sci.c | 1 - drivers/spi/spi-sun4i.c | 1 - drivers/spi/spi-sun6i.c | 1 - 12 files changed, 12 deletions(-) diff --git a/drivers/spi/spi-ath79.c b/drivers/spi/spi-ath79.c index 3898b0b9ee77..058db0fe8dc7 100644 --- a/drivers/spi/spi-ath79.c +++ b/drivers/spi/spi-ath79.c @@ -16,7 +16,6 @@ #include #include #include -#include #include #include #include diff --git a/drivers/spi/spi-bcm63xx-hsspi.c b/drivers/spi/spi-bcm63xx-hsspi.c index 5a211e98383b..86f5a98aa7a2 100644 --- a/drivers/spi/spi-bcm63xx-hsspi.c +++ b/drivers/spi/spi-bcm63xx-hsspi.c @@ -18,7 +18,6 @@ #include #include #include -#include #include #define HSSPI_GLOBAL_CTRL_REG 0x0 diff --git a/drivers/spi/spi-bcm63xx.c b/drivers/spi/spi-bcm63xx.c index 0250fa721cea..8510400e7867 100644 --- a/drivers/spi/spi-bcm63xx.c +++ b/drivers/spi/spi-bcm63xx.c @@ -29,7 +29,6 @@ #include #include #include -#include #include #include diff --git a/drivers/spi/spi-falcon.c b/drivers/spi/spi-falcon.c index 09965f069a1c..ba441ad9a007 100644 --- a/drivers/spi/spi-falcon.c +++ b/drivers/spi/spi-falcon.c @@ -11,7 +11,6 @@ #include #include #include -#include #include #include diff --git a/drivers/spi/spi-nuc900.c b/drivers/spi/spi-nuc900.c index 16e30de650b0..73e91d5a43df 100644 --- a/drivers/spi/spi-nuc900.c +++ b/drivers/spi/spi-nuc900.c @@ -10,7 +10,6 @@ #include #include -#include #include #include #include diff --git a/drivers/spi/spi-omap-uwire.c b/drivers/spi/spi-omap-uwire.c index be2a2e108e2f..0f5a0aa3b871 100644 --- a/drivers/spi/spi-omap-uwire.c +++ b/drivers/spi/spi-omap-uwire.c @@ -37,7 +37,6 @@ #include #include #include -#include #include #include #include diff --git a/drivers/spi/spi-pxa2xx.c b/drivers/spi/spi-pxa2xx.c index 41185d0557fa..d0fc8e06bf43 100644 --- a/drivers/spi/spi-pxa2xx.c +++ b/drivers/spi/spi-pxa2xx.c @@ -27,7 +27,6 @@ #include #include #include -#include #include #include #include diff --git a/drivers/spi/spi-s3c24xx.c b/drivers/spi/spi-s3c24xx.c index bed23384dfab..1f3ef978c1d3 100644 --- a/drivers/spi/spi-s3c24xx.c +++ b/drivers/spi/spi-s3c24xx.c @@ -10,7 +10,6 @@ */ #include -#include #include #include #include diff --git a/drivers/spi/spi-s3c64xx.c b/drivers/spi/spi-s3c64xx.c index f19cd97855e8..153b4bec21c1 100644 --- a/drivers/spi/spi-s3c64xx.c +++ b/drivers/spi/spi-s3c64xx.c @@ -19,7 +19,6 @@ #include #include -#include #include #include #include diff --git a/drivers/spi/spi-sh-sci.c b/drivers/spi/spi-sh-sci.c index 8b44b71f5024..1f56ef651d1a 100644 --- a/drivers/spi/spi-sh-sci.c +++ b/drivers/spi/spi-sh-sci.c @@ -16,7 +16,6 @@ #include #include #include -#include #include #include diff --git a/drivers/spi/spi-sun4i.c b/drivers/spi/spi-sun4i.c index d266a8702067..85204c93f3d3 100644 --- a/drivers/spi/spi-sun4i.c +++ b/drivers/spi/spi-sun4i.c @@ -19,7 +19,6 @@ #include #include #include -#include #include diff --git a/drivers/spi/spi-sun6i.c b/drivers/spi/spi-sun6i.c index b3e3498a7e6f..bd24093f4038 100644 --- a/drivers/spi/spi-sun6i.c +++ b/drivers/spi/spi-sun6i.c @@ -20,7 +20,6 @@ #include #include #include -#include #include -- cgit v1.2.3 From 9374f375ab8b91a394487ef0707d827dcdeb8139 Mon Sep 17 00:00:00 2001 From: Charles Keepax Date: Sat, 5 Apr 2014 12:11:48 +0100 Subject: ASoC: wm5110: Add in OSR controls for OUT5/6 There are no OSR controls on outputs 1-4 on wm5110, however when these were removed the ones on output 5 and 6 were also accidentally removed, but those actually exist. This patch adds these controls back in. Signed-off-by: Charles Keepax Signed-off-by: Mark Brown --- sound/soc/codecs/wm5110.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/sound/soc/codecs/wm5110.c b/sound/soc/codecs/wm5110.c index df5a38dd8328..83a7e2f91ece 100644 --- a/sound/soc/codecs/wm5110.c +++ b/sound/soc/codecs/wm5110.c @@ -367,6 +367,11 @@ SOC_SINGLE("HPOUT2 SC Protect Switch", ARIZONA_HP2_SHORT_CIRCUIT_CTRL, SOC_SINGLE("HPOUT3 SC Protect Switch", ARIZONA_HP3_SHORT_CIRCUIT_CTRL, ARIZONA_HP3_SC_ENA_SHIFT, 1, 0), +SOC_SINGLE("SPKDAT1 High Performance Switch", ARIZONA_OUTPUT_PATH_CONFIG_5L, + ARIZONA_OUT5_OSR_SHIFT, 1, 0), +SOC_SINGLE("SPKDAT2 High Performance Switch", ARIZONA_OUTPUT_PATH_CONFIG_6L, + ARIZONA_OUT6_OSR_SHIFT, 1, 0), + SOC_DOUBLE_R("HPOUT1 Digital Switch", ARIZONA_DAC_DIGITAL_VOLUME_1L, ARIZONA_DAC_DIGITAL_VOLUME_1R, ARIZONA_OUT1L_MUTE_SHIFT, 1, 1), SOC_DOUBLE_R("HPOUT2 Digital Switch", ARIZONA_DAC_DIGITAL_VOLUME_2L, -- cgit v1.2.3 From a39f75f7907fa3a708751dc283e3ab3e7da526b8 Mon Sep 17 00:00:00 2001 From: Xiubo Li Date: Wed, 26 Mar 2014 13:40:23 +0800 Subject: ASoC: core: Move the default regmap I/O setting to snd_soc_register_codec() Add the default regmap I/O setting to snd_soc_register_codec() while the CODEC is initialising, which will be called by CODEC driver device probe(), and then we can make XXX_set_cache_io() go away entirely from each CODEC ASoC probe. Signed-off-by: Xiubo Li Signed-off-by: Mark Brown --- include/sound/soc.h | 1 + sound/soc/soc-core.c | 28 ++++++++++++++++++---------- sound/soc/soc-io.c | 9 +++------ 3 files changed, 22 insertions(+), 16 deletions(-) diff --git a/include/sound/soc.h b/include/sound/soc.h index 0b83168d8ff4..2f62436026d2 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h @@ -754,6 +754,7 @@ struct snd_soc_codec_driver { unsigned int freq_in, unsigned int freq_out); /* codec IO */ + struct regmap *(*get_regmap)(struct device *); unsigned int (*read)(struct snd_soc_codec *, unsigned int); int (*write)(struct snd_soc_codec *, unsigned int, unsigned int); int (*display_register)(struct snd_soc_codec *, char *, diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 051c006281f5..5071a3a0ac83 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -1137,16 +1137,6 @@ static int soc_probe_codec(struct snd_soc_card *card, codec->dapm.idle_bias_off = driver->idle_bias_off; - if (!codec->write && dev_get_regmap(codec->dev, NULL)) { - /* Set the default I/O up try regmap */ - ret = snd_soc_codec_set_cache_io(codec, NULL); - if (ret < 0) { - dev_err(codec->dev, - "Failed to set cache I/O: %d\n", ret); - goto err_probe; - } - } - if (driver->probe) { ret = driver->probe(codec); if (ret < 0) { @@ -4263,6 +4253,7 @@ int snd_soc_register_codec(struct device *dev, int num_dai) { struct snd_soc_codec *codec; + struct regmap *regmap; int ret, i; dev_dbg(dev, "codec register %s\n", dev_name(dev)); @@ -4294,6 +4285,23 @@ int snd_soc_register_codec(struct device *dev, codec->num_dai = num_dai; mutex_init(&codec->mutex); + if (!codec->write) { + if (codec_drv->get_regmap) + regmap = codec_drv->get_regmap(dev); + else + regmap = dev_get_regmap(dev, NULL); + + if (regmap) { + ret = snd_soc_codec_set_cache_io(codec, regmap); + if (ret && ret != -ENOTSUPP) { + dev_err(codec->dev, + "Failed to set cache I/O:%d\n", + ret); + return ret; + } + } + } + for (i = 0; i < num_dai; i++) { fixup_codec_formats(&dai_drv[i].playback); fixup_codec_formats(&dai_drv[i].capture); diff --git a/sound/soc/soc-io.c b/sound/soc/soc-io.c index 260efc8466fc..6480e8f29310 100644 --- a/sound/soc/soc-io.c +++ b/sound/soc/soc-io.c @@ -60,14 +60,11 @@ int snd_soc_codec_set_cache_io(struct snd_soc_codec *codec, { int ret; - /* Device has made its own regmap arrangements */ if (!regmap) - codec->control_data = dev_get_regmap(codec->dev, NULL); - else - codec->control_data = regmap; + return -EINVAL; - if (IS_ERR(codec->control_data)) - return PTR_ERR(codec->control_data); + /* Device has made its own regmap arrangements */ + codec->control_data = regmap; codec->write = hw_write; codec->read = hw_read; -- cgit v1.2.3 From bbc0bd7fd3f671096625b5cbde97e12e3e2dba8f Mon Sep 17 00:00:00 2001 From: Xiubo Li Date: Wed, 26 Mar 2014 13:40:24 +0800 Subject: ASoC: 88pm860x: Remove the set_cache_io() entirely from ASoC probe. As we can set the CODEC I/O while snd_soc_register_codec(), so the calling of set_cache_io() from CODEC ASoC probe could be removed entirely. And then we can set the CODEC I/O in the device probe instead of CODEC ASoC probe as earily as possible. Signed-off-by: Xiubo Li Signed-off-by: Mark Brown --- sound/soc/codecs/88pm860x-codec.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/sound/soc/codecs/88pm860x-codec.c b/sound/soc/codecs/88pm860x-codec.c index b07e17160f94..dc9e6b94e645 100644 --- a/sound/soc/codecs/88pm860x-codec.c +++ b/sound/soc/codecs/88pm860x-codec.c @@ -1327,10 +1327,6 @@ static int pm860x_probe(struct snd_soc_codec *codec) pm860x->codec = codec; - ret = snd_soc_codec_set_cache_io(codec, pm860x->regmap); - if (ret) - return ret; - for (i = 0; i < 4; i++) { ret = request_threaded_irq(pm860x->irq[i], NULL, pm860x_codec_handler, IRQF_ONESHOT, @@ -1362,10 +1358,18 @@ static int pm860x_remove(struct snd_soc_codec *codec) return 0; } +struct regmap *pm860x_get_regmap(struct device *dev) +{ + struct pm860x_priv *pm860x = dev_get_drvdata(dev); + + return pm860x->regmap; +} + static struct snd_soc_codec_driver soc_codec_dev_pm860x = { .probe = pm860x_probe, .remove = pm860x_remove, .set_bias_level = pm860x_set_bias_level, + .get_regmap = pm860x_get_regmap, .controls = pm860x_snd_controls, .num_controls = ARRAY_SIZE(pm860x_snd_controls), -- cgit v1.2.3 From 49101a25acd69cf36192888392c518a299c091af Mon Sep 17 00:00:00 2001 From: Xiubo Li Date: Wed, 26 Mar 2014 13:40:25 +0800 Subject: ASoC: cq93vc: Remove the set_cache_io() entirely from ASoC probe. As we can set the CODEC I/O while snd_soc_register_codec(), so the calling of set_cache_io() from CODEC ASoC probe could be removed entirely. And then we can set the CODEC I/O in the device probe instead of CODEC ASoC probe as earily as possible. Signed-off-by: Xiubo Li Signed-off-by: Mark Brown --- sound/soc/codecs/cq93vc.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/sound/soc/codecs/cq93vc.c b/sound/soc/codecs/cq93vc.c index 1e25c7af853b..5e5518d20311 100644 --- a/sound/soc/codecs/cq93vc.c +++ b/sound/soc/codecs/cq93vc.c @@ -139,8 +139,6 @@ static int cq93vc_probe(struct snd_soc_codec *codec) davinci_vc->cq93vc.codec = codec; - snd_soc_codec_set_cache_io(codec, davinci_vc->regmap); - /* Off, with power on */ cq93vc_set_bias_level(codec, SND_SOC_BIAS_STANDBY); @@ -154,11 +152,19 @@ static int cq93vc_remove(struct snd_soc_codec *codec) return 0; } +struct regmap *cq93vc_get_regmap(struct device *dev) +{ + struct davinci_vc *davinci_vc = codec->dev->platform_data; + + return davinci_vc->regmap; +} + static struct snd_soc_codec_driver soc_codec_dev_cq93vc = { .set_bias_level = cq93vc_set_bias_level, .probe = cq93vc_probe, .remove = cq93vc_remove, .resume = cq93vc_resume, + .get_regmap = cq93vc_get_regmap, .controls = cq93vc_snd_controls, .num_controls = ARRAY_SIZE(cq93vc_snd_controls), }; -- cgit v1.2.3 From d957f1651ed2976e18c75c5644a92ed471c3ae9e Mon Sep 17 00:00:00 2001 From: Xiubo Li Date: Wed, 26 Mar 2014 13:40:26 +0800 Subject: ASoC: mc13783: Remove the set_cache_io() entirely from ASoC probe. As we can set the CODEC I/O while snd_soc_register_codec(), so the calling of set_cache_io() from CODEC ASoC probe could be removed entirely. And then we can set the CODEC I/O in the device probe instead of CODEC ASoC probe as earily as possible. Signed-off-by: Xiubo Li Signed-off-by: Mark Brown --- sound/soc/codecs/mc13783.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/sound/soc/codecs/mc13783.c b/sound/soc/codecs/mc13783.c index 2c59b1fb69dc..8c0cec392dec 100644 --- a/sound/soc/codecs/mc13783.c +++ b/sound/soc/codecs/mc13783.c @@ -608,14 +608,6 @@ static struct snd_kcontrol_new mc13783_control_list[] = { static int mc13783_probe(struct snd_soc_codec *codec) { struct mc13783_priv *priv = snd_soc_codec_get_drvdata(codec); - int ret; - - ret = snd_soc_codec_set_cache_io(codec, - dev_get_regmap(codec->dev->parent, NULL)); - if (ret != 0) { - dev_err(codec->dev, "Failed to set cache I/O: %d\n", ret); - return ret; - } /* these are the reset values */ mc13xxx_reg_write(priv->mc13xxx, MC13783_AUDIO_RX0, 0x25893); @@ -735,9 +727,15 @@ static struct snd_soc_dai_driver mc13783_dai_sync[] = { } }; +struct regmap *mc13783_get_regmap(struct device *dev) +{ + return dev_get_regmap(dev->parent, NULL); +} + static struct snd_soc_codec_driver soc_codec_dev_mc13783 = { .probe = mc13783_probe, .remove = mc13783_remove, + .get_regmap = mc13783_get_regmap, .controls = mc13783_control_list, .num_controls = ARRAY_SIZE(mc13783_control_list), .dapm_widgets = mc13783_dapm_widgets, -- cgit v1.2.3 From 83905ef3cbd0025830e9db65bf5ce7db721e39a7 Mon Sep 17 00:00:00 2001 From: Xiubo Li Date: Wed, 26 Mar 2014 13:40:27 +0800 Subject: ASoC: si476x: Remove the set_cache_io() entirely from ASoC probe. As we can set the CODEC I/O while snd_soc_register_codec(), so the calling of set_cache_io() from CODEC ASoC probe could be removed entirely. And then we can set the CODEC I/O in the device probe instead of CODEC ASoC probe as earily as possible. Signed-off-by: Xiubo Li Acked-by: Andrey Smirnov Signed-off-by: Mark Brown --- sound/soc/codecs/si476x.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/sound/soc/codecs/si476x.c b/sound/soc/codecs/si476x.c index 244c097cd905..961b7e8ac0da 100644 --- a/sound/soc/codecs/si476x.c +++ b/sound/soc/codecs/si476x.c @@ -208,13 +208,6 @@ out: return err; } -static int si476x_codec_probe(struct snd_soc_codec *codec) -{ - struct regmap *regmap = dev_get_regmap(codec->dev->parent, NULL); - - return snd_soc_codec_set_cache_io(codec, regmap); -} - static struct snd_soc_dai_ops si476x_dai_ops = { .hw_params = si476x_codec_hw_params, .set_fmt = si476x_codec_set_dai_fmt, @@ -238,8 +231,13 @@ static struct snd_soc_dai_driver si476x_dai = { .ops = &si476x_dai_ops, }; +struct regmap *si476x_get_regmap(struct device *dev) +{ + return dev_get_regmap(dev->parent, NULL); +} + static struct snd_soc_codec_driver soc_codec_dev_si476x = { - .probe = si476x_codec_probe, + .get_regmap = si476x_get_regmap, .dapm_widgets = si476x_dapm_widgets, .num_dapm_widgets = ARRAY_SIZE(si476x_dapm_widgets), .dapm_routes = si476x_dapm_routes, -- cgit v1.2.3 From c8b02acd45e4b30aef2a86526e6844071cfd41bf Mon Sep 17 00:00:00 2001 From: Xiubo Li Date: Wed, 26 Mar 2014 13:40:28 +0800 Subject: ASoC: wm5102: Remove the set_cache_io() entirely from ASoC probe. As we can set the CODEC I/O while snd_soc_register_codec(), so the calling of set_cache_io() from CODEC ASoC probe could be removed entirely. And then we can set the CODEC I/O in the device probe instead of CODEC ASoC probe as earily as possible. Signed-off-by: Xiubo Li Acked-by: Charles Keepax Signed-off-by: Mark Brown --- sound/soc/codecs/wm5102.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/sound/soc/codecs/wm5102.c b/sound/soc/codecs/wm5102.c index dcf1d12cfef8..aa60ba23b017 100644 --- a/sound/soc/codecs/wm5102.c +++ b/sound/soc/codecs/wm5102.c @@ -1760,10 +1760,6 @@ static int wm5102_codec_probe(struct snd_soc_codec *codec) struct wm5102_priv *priv = snd_soc_codec_get_drvdata(codec); int ret; - ret = snd_soc_codec_set_cache_io(codec, priv->core.arizona->regmap); - if (ret != 0) - return ret; - ret = snd_soc_add_codec_controls(codec, wm_adsp2_fw_controls, 2); if (ret != 0) return ret; @@ -1802,9 +1798,17 @@ static unsigned int wm5102_digital_vu[] = { ARIZONA_DAC_DIGITAL_VOLUME_5R, }; +struct regmap *wm5102_get_regmap(struct device *dev) +{ + struct wm5102_priv *priv = dev_get_drvdata(dev); + + return priv->core.arizona->regmap; +} + static struct snd_soc_codec_driver soc_codec_dev_wm5102 = { .probe = wm5102_codec_probe, .remove = wm5102_codec_remove, + .get_regmap = wm5102_get_regmap, .idle_bias_off = true, -- cgit v1.2.3 From 6e4842d30c2eea928b6df6adfe9db49ec971f32d Mon Sep 17 00:00:00 2001 From: Xiubo Li Date: Wed, 26 Mar 2014 13:40:29 +0800 Subject: ASoC: wm5110: Remove the set_cache_io() entirely from ASoC probe. As we can set the CODEC I/O while snd_soc_register_codec(), so the calling of set_cache_io() from CODEC ASoC probe could be removed entirely. And then we can set the CODEC I/O in the device probe instead of CODEC ASoC probe as earily as possible. Signed-off-by: Xiubo Li Acked-by: Charles Keepax Signed-off-by: Mark Brown --- sound/soc/codecs/wm5110.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/sound/soc/codecs/wm5110.c b/sound/soc/codecs/wm5110.c index df5a38dd8328..4be5f990a9d6 100644 --- a/sound/soc/codecs/wm5110.c +++ b/sound/soc/codecs/wm5110.c @@ -1589,10 +1589,6 @@ static int wm5110_codec_probe(struct snd_soc_codec *codec) priv->core.arizona->dapm = &codec->dapm; - ret = snd_soc_codec_set_cache_io(codec, priv->core.arizona->regmap); - if (ret != 0) - return ret; - arizona_init_spk(codec); arizona_init_gpio(codec); @@ -1633,9 +1629,17 @@ static unsigned int wm5110_digital_vu[] = { ARIZONA_DAC_DIGITAL_VOLUME_6R, }; +struct regmap *wm5110_get_regmap(struct device *dev) +{ + struct wm5110_priv *priv = dev_get_drvdata(dev); + + return priv->core.arizona->regmap; +} + static struct snd_soc_codec_driver soc_codec_dev_wm5110 = { .probe = wm5110_codec_probe, .remove = wm5110_codec_remove, + .get_regmap = wm5110_get_regmap, .idle_bias_off = true, -- cgit v1.2.3 From aec0eb50e5f71f6c28cc0a4739b34ec109fe1a56 Mon Sep 17 00:00:00 2001 From: Xiubo Li Date: Wed, 26 Mar 2014 13:40:30 +0800 Subject: ASoC: wm8350: Remove the set_cache_io() entirely from ASoC probe. As we can set the CODEC I/O while snd_soc_register_codec(), so the calling of set_cache_io() from CODEC ASoC probe could be removed entirely. And then we can set the CODEC I/O in the device probe instead of CODEC ASoC probe as earily as possible. Signed-off-by: Xiubo Li Acked-by: Charles Keepax Signed-off-by: Mark Brown --- sound/soc/codecs/wm8350.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/sound/soc/codecs/wm8350.c b/sound/soc/codecs/wm8350.c index 757256bf7672..6b31a9f83137 100644 --- a/sound/soc/codecs/wm8350.c +++ b/sound/soc/codecs/wm8350.c @@ -1505,8 +1505,6 @@ static int wm8350_codec_probe(struct snd_soc_codec *codec) if (ret != 0) return ret; - snd_soc_codec_set_cache_io(codec, wm8350->regmap); - /* Put the codec into reset if it wasn't already */ wm8350_clear_bits(wm8350, WM8350_POWER_MGMT_5, WM8350_CODEC_ENA); @@ -1608,11 +1606,19 @@ static int wm8350_codec_remove(struct snd_soc_codec *codec) return 0; } +struct regmap *wm8350_get_regmap(struct device *dev) +{ + struct wm8350 *wm8350 = dev_get_platdata(dev); + + return wm8350->regmap; +} + static struct snd_soc_codec_driver soc_codec_dev_wm8350 = { .probe = wm8350_codec_probe, .remove = wm8350_codec_remove, .suspend = wm8350_suspend, .resume = wm8350_resume, + .get_regmap = wm8350_get_regmap, .set_bias_level = wm8350_set_bias_level, .controls = wm8350_snd_controls, -- cgit v1.2.3 From 4504badea3a3edd0d114b51a866cd98b4ff626b0 Mon Sep 17 00:00:00 2001 From: Xiubo Li Date: Wed, 26 Mar 2014 13:40:31 +0800 Subject: ASoC: wm8400: Remove the set_cache_io() entirely from ASoC probe. As we can set the CODEC I/O while snd_soc_register_codec(), so the calling of set_cache_io() from CODEC ASoC probe could be removed entirely. And then we can set the CODEC I/O in the device probe instead of CODEC ASoC probe as earily as possible. Signed-off-by: Xiubo Li Acked-by: Charles Keepax Signed-off-by: Mark Brown --- sound/soc/codecs/wm8400.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/sound/soc/codecs/wm8400.c b/sound/soc/codecs/wm8400.c index 146564feaea0..e6410f2e8cac 100644 --- a/sound/soc/codecs/wm8400.c +++ b/sound/soc/codecs/wm8400.c @@ -1318,8 +1318,6 @@ static int wm8400_codec_probe(struct snd_soc_codec *codec) priv->wm8400 = wm8400; priv->codec = codec; - snd_soc_codec_set_cache_io(codec, wm8400->regmap); - ret = devm_regulator_bulk_get(wm8400->dev, ARRAY_SIZE(power), &power[0]); if (ret != 0) { @@ -1361,11 +1359,19 @@ static int wm8400_codec_remove(struct snd_soc_codec *codec) return 0; } +struct regmap *wm8400_get_regmap(struct device *dev) +{ + struct wm8400 *wm8400 = dev_get_platdata(dev); + + return wm8400->regmap; +} + static struct snd_soc_codec_driver soc_codec_dev_wm8400 = { .probe = wm8400_codec_probe, .remove = wm8400_codec_remove, .suspend = wm8400_suspend, .resume = wm8400_resume, + .get_regmap = wm8400_get_regmap, .set_bias_level = wm8400_set_bias_level, .controls = wm8400_snd_controls, -- cgit v1.2.3 From c0b6f59b7036c0cb7e0d03240fcb095104855ab9 Mon Sep 17 00:00:00 2001 From: Xiubo Li Date: Wed, 26 Mar 2014 13:40:32 +0800 Subject: ASoC: wm8994: Remove the set_cache_io() entirely from ASoC probe. As we can set the CODEC I/O while snd_soc_register_codec(), so the calling of set_cache_io() from CODEC ASoC probe could be removed entirely. And then we can set the CODEC I/O in the device probe instead of CODEC ASoC probe as earily as possible. Signed-off-by: Xiubo Li Acked-by: Charles Keepax Signed-off-by: Mark Brown --- sound/soc/codecs/wm8994.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/sound/soc/codecs/wm8994.c b/sound/soc/codecs/wm8994.c index 6303537f54c6..daa4edcfe14a 100644 --- a/sound/soc/codecs/wm8994.c +++ b/sound/soc/codecs/wm8994.c @@ -3999,8 +3999,6 @@ static int wm8994_codec_probe(struct snd_soc_codec *codec) wm8994->hubs.codec = codec; - snd_soc_codec_set_cache_io(codec, control->regmap); - mutex_init(&wm8994->accdet_lock); INIT_DELAYED_WORK(&wm8994->jackdet_bootstrap, wm1811_jackdet_bootstrap); @@ -4434,11 +4432,19 @@ static int wm8994_codec_remove(struct snd_soc_codec *codec) return 0; } +struct regmap *wm8994_get_regmap(struct device *dev) +{ + struct wm8994 *control = dev_get_drvdata(dev->parent); + + return control->regmap; +} + static struct snd_soc_codec_driver soc_codec_dev_wm8994 = { .probe = wm8994_codec_probe, .remove = wm8994_codec_remove, .suspend = wm8994_codec_suspend, .resume = wm8994_codec_resume, + .get_regmap = wm8994_get_regmap, .set_bias_level = wm8994_set_bias_level, }; -- cgit v1.2.3 From 964eafb1d59b7c270982d144882c64b93c67eb03 Mon Sep 17 00:00:00 2001 From: Xiubo Li Date: Wed, 26 Mar 2014 13:40:33 +0800 Subject: ASoC: wm8997: Remove the set_cache_io() entirely from ASoC probe. As we can set the CODEC I/O while snd_soc_register_codec(), so the calling of set_cache_io() from CODEC ASoC probe could be removed entirely. And then we can set the CODEC I/O in the device probe instead of CODEC ASoC probe as earily as possible. Signed-off-by: Xiubo Li Acked-by: Charles Keepax Signed-off-by: Mark Brown --- sound/soc/codecs/wm8997.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/sound/soc/codecs/wm8997.c b/sound/soc/codecs/wm8997.c index 004186b6bd48..3d50621b070c 100644 --- a/sound/soc/codecs/wm8997.c +++ b/sound/soc/codecs/wm8997.c @@ -1051,11 +1051,6 @@ static struct snd_soc_dai_driver wm8997_dai[] = { static int wm8997_codec_probe(struct snd_soc_codec *codec) { struct wm8997_priv *priv = snd_soc_codec_get_drvdata(codec); - int ret; - - ret = snd_soc_codec_set_cache_io(codec, priv->core.arizona->regmap); - if (ret != 0) - return ret; arizona_init_spk(codec); @@ -1086,9 +1081,17 @@ static unsigned int wm8997_digital_vu[] = { ARIZONA_DAC_DIGITAL_VOLUME_5R, }; +struct regmap *wm8997_get_regmap(struct device *dev) +{ + struct wm8997_priv *priv = dev_get_drvdata(dev); + + return priv->core.arizona->regmap; +} + static struct snd_soc_codec_driver soc_codec_dev_wm8997 = { .probe = wm8997_codec_probe, .remove = wm8997_codec_remove, + .get_regmap = wm8997_get_regmap, .idle_bias_off = true, -- cgit v1.2.3 From 7a34b1c1dff720dd8dcf63e2b0e5fc15a8f7208f Mon Sep 17 00:00:00 2001 From: Xiubo Li Date: Thu, 3 Apr 2014 07:53:59 +0800 Subject: ASoC: codec: fix the sparse check warnings. Some thing Likes: reproduce: make C=1 CF=-D__CHECK_ENDIAN__ sparse warnings: (new ones prefixed by >>) >> sound/soc/codecs/wm8997.c:1084:15: sparse: symbol \ 'wm8997_get_regmap' was not declared. Should it be static? Signed-off-by: Xiubo Li Signed-off-by: Mark Brown --- sound/soc/codecs/88pm860x-codec.c | 2 +- sound/soc/codecs/cq93vc.c | 2 +- sound/soc/codecs/mc13783.c | 2 +- sound/soc/codecs/si476x.c | 2 +- sound/soc/codecs/wm5102.c | 2 +- sound/soc/codecs/wm5110.c | 2 +- sound/soc/codecs/wm8350.c | 2 +- sound/soc/codecs/wm8400.c | 2 +- sound/soc/codecs/wm8994.c | 2 +- sound/soc/codecs/wm8997.c | 2 +- 10 files changed, 10 insertions(+), 10 deletions(-) diff --git a/sound/soc/codecs/88pm860x-codec.c b/sound/soc/codecs/88pm860x-codec.c index dc9e6b94e645..f073b6feac94 100644 --- a/sound/soc/codecs/88pm860x-codec.c +++ b/sound/soc/codecs/88pm860x-codec.c @@ -1358,7 +1358,7 @@ static int pm860x_remove(struct snd_soc_codec *codec) return 0; } -struct regmap *pm860x_get_regmap(struct device *dev) +static struct regmap *pm860x_get_regmap(struct device *dev) { struct pm860x_priv *pm860x = dev_get_drvdata(dev); diff --git a/sound/soc/codecs/cq93vc.c b/sound/soc/codecs/cq93vc.c index 5e5518d20311..5ee48c8e4849 100644 --- a/sound/soc/codecs/cq93vc.c +++ b/sound/soc/codecs/cq93vc.c @@ -152,7 +152,7 @@ static int cq93vc_remove(struct snd_soc_codec *codec) return 0; } -struct regmap *cq93vc_get_regmap(struct device *dev) +static struct regmap *cq93vc_get_regmap(struct device *dev) { struct davinci_vc *davinci_vc = codec->dev->platform_data; diff --git a/sound/soc/codecs/mc13783.c b/sound/soc/codecs/mc13783.c index 8c0cec392dec..9029e20514e1 100644 --- a/sound/soc/codecs/mc13783.c +++ b/sound/soc/codecs/mc13783.c @@ -727,7 +727,7 @@ static struct snd_soc_dai_driver mc13783_dai_sync[] = { } }; -struct regmap *mc13783_get_regmap(struct device *dev) +static struct regmap *mc13783_get_regmap(struct device *dev) { return dev_get_regmap(dev->parent, NULL); } diff --git a/sound/soc/codecs/si476x.c b/sound/soc/codecs/si476x.c index 961b7e8ac0da..f26befb0c297 100644 --- a/sound/soc/codecs/si476x.c +++ b/sound/soc/codecs/si476x.c @@ -231,7 +231,7 @@ static struct snd_soc_dai_driver si476x_dai = { .ops = &si476x_dai_ops, }; -struct regmap *si476x_get_regmap(struct device *dev) +static struct regmap *si476x_get_regmap(struct device *dev) { return dev_get_regmap(dev->parent, NULL); } diff --git a/sound/soc/codecs/wm5102.c b/sound/soc/codecs/wm5102.c index aa60ba23b017..7a046536ea68 100644 --- a/sound/soc/codecs/wm5102.c +++ b/sound/soc/codecs/wm5102.c @@ -1798,7 +1798,7 @@ static unsigned int wm5102_digital_vu[] = { ARIZONA_DAC_DIGITAL_VOLUME_5R, }; -struct regmap *wm5102_get_regmap(struct device *dev) +static struct regmap *wm5102_get_regmap(struct device *dev) { struct wm5102_priv *priv = dev_get_drvdata(dev); diff --git a/sound/soc/codecs/wm5110.c b/sound/soc/codecs/wm5110.c index 4be5f990a9d6..97eb1bc5bea7 100644 --- a/sound/soc/codecs/wm5110.c +++ b/sound/soc/codecs/wm5110.c @@ -1629,7 +1629,7 @@ static unsigned int wm5110_digital_vu[] = { ARIZONA_DAC_DIGITAL_VOLUME_6R, }; -struct regmap *wm5110_get_regmap(struct device *dev) +static struct regmap *wm5110_get_regmap(struct device *dev) { struct wm5110_priv *priv = dev_get_drvdata(dev); diff --git a/sound/soc/codecs/wm8350.c b/sound/soc/codecs/wm8350.c index 6b31a9f83137..1bd14b64a6c0 100644 --- a/sound/soc/codecs/wm8350.c +++ b/sound/soc/codecs/wm8350.c @@ -1606,7 +1606,7 @@ static int wm8350_codec_remove(struct snd_soc_codec *codec) return 0; } -struct regmap *wm8350_get_regmap(struct device *dev) +static struct regmap *wm8350_get_regmap(struct device *dev) { struct wm8350 *wm8350 = dev_get_platdata(dev); diff --git a/sound/soc/codecs/wm8400.c b/sound/soc/codecs/wm8400.c index e6410f2e8cac..5880d223e161 100644 --- a/sound/soc/codecs/wm8400.c +++ b/sound/soc/codecs/wm8400.c @@ -1359,7 +1359,7 @@ static int wm8400_codec_remove(struct snd_soc_codec *codec) return 0; } -struct regmap *wm8400_get_regmap(struct device *dev) +static struct regmap *wm8400_get_regmap(struct device *dev) { struct wm8400 *wm8400 = dev_get_platdata(dev); diff --git a/sound/soc/codecs/wm8994.c b/sound/soc/codecs/wm8994.c index daa4edcfe14a..6f336da856c5 100644 --- a/sound/soc/codecs/wm8994.c +++ b/sound/soc/codecs/wm8994.c @@ -4432,7 +4432,7 @@ static int wm8994_codec_remove(struct snd_soc_codec *codec) return 0; } -struct regmap *wm8994_get_regmap(struct device *dev) +static struct regmap *wm8994_get_regmap(struct device *dev) { struct wm8994 *control = dev_get_drvdata(dev->parent); diff --git a/sound/soc/codecs/wm8997.c b/sound/soc/codecs/wm8997.c index 3d50621b070c..09c4150840a3 100644 --- a/sound/soc/codecs/wm8997.c +++ b/sound/soc/codecs/wm8997.c @@ -1081,7 +1081,7 @@ static unsigned int wm8997_digital_vu[] = { ARIZONA_DAC_DIGITAL_VOLUME_5R, }; -struct regmap *wm8997_get_regmap(struct device *dev) +static struct regmap *wm8997_get_regmap(struct device *dev) { struct wm8997_priv *priv = dev_get_drvdata(dev); -- cgit v1.2.3 From ea53bf77d147e7e560ac007fdaa30fb98c37c712 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Tue, 18 Mar 2014 09:02:04 +0100 Subject: ASoC: Add snd_soc_kcontrol_codec() helper function For CODEC controls snd_kcontrol_chip() currently returns a pointer to the CODEC that registered the control. With the upcoming consolidation of platform and CODEC controls this will change. Prepare for this by introducing the snd_soc_kcontrol_codec() helper function that will hide the implementation details of how the CODEC for a control can be obtained. This will allow us to change this easily in the future. The patch also updates all CODEC drivers to use the new helper function. Signed-off-by: Lars-Peter Clausen Acked-by: Charles Keepax Signed-off-by: Mark Brown --- include/sound/soc.h | 14 ++++++++++++++ sound/soc/codecs/88pm860x-codec.c | 8 ++++---- sound/soc/codecs/ab8500-codec.c | 12 ++++++------ sound/soc/codecs/adav80x.c | 4 ++-- sound/soc/codecs/ak4641.c | 4 ++-- sound/soc/codecs/cs4270.c | 2 +- sound/soc/codecs/cs4271.c | 4 ++-- sound/soc/codecs/cs42l51.c | 4 ++-- sound/soc/codecs/da7210.c | 4 ++-- sound/soc/codecs/da7213.c | 4 ++-- sound/soc/codecs/da732x.c | 4 ++-- sound/soc/codecs/da9055.c | 2 +- sound/soc/codecs/lm4857.c | 4 ++-- sound/soc/codecs/max9768.c | 4 ++-- sound/soc/codecs/max98088.c | 12 ++++++------ sound/soc/codecs/max98090.c | 4 ++-- sound/soc/codecs/max98095.c | 16 ++++++++-------- sound/soc/codecs/pcm1681.c | 4 ++-- sound/soc/codecs/rt5631.c | 4 ++-- sound/soc/codecs/sgtl5000.c | 4 ++-- sound/soc/codecs/sta32x.c | 4 ++-- sound/soc/codecs/tas5086.c | 4 ++-- sound/soc/codecs/tlv320aic23.c | 4 ++-- sound/soc/codecs/tlv320dac33.c | 4 ++-- sound/soc/codecs/twl4030.c | 10 +++++----- sound/soc/codecs/twl6040.c | 8 ++++---- sound/soc/codecs/wl1273.c | 12 ++++++------ sound/soc/codecs/wm2000.c | 8 ++++---- sound/soc/codecs/wm8350.c | 4 ++-- sound/soc/codecs/wm8400.c | 2 +- sound/soc/codecs/wm8580.c | 2 +- sound/soc/codecs/wm8731.c | 4 ++-- sound/soc/codecs/wm8753.c | 4 ++-- sound/soc/codecs/wm8804.c | 4 ++-- sound/soc/codecs/wm8903.c | 4 ++-- sound/soc/codecs/wm8904.c | 14 +++++++------- sound/soc/codecs/wm8955.c | 4 ++-- sound/soc/codecs/wm8958-dsp2.c | 32 ++++++++++++++++---------------- sound/soc/codecs/wm8960.c | 4 ++-- sound/soc/codecs/wm8962.c | 8 ++++---- sound/soc/codecs/wm8983.c | 4 ++-- sound/soc/codecs/wm8985.c | 4 ++-- sound/soc/codecs/wm8990.c | 2 +- sound/soc/codecs/wm8991.c | 2 +- sound/soc/codecs/wm8994.c | 10 +++++----- sound/soc/codecs/wm8996.c | 4 ++-- sound/soc/codecs/wm9081.c | 4 ++-- sound/soc/codecs/wm_adsp.c | 4 ++-- sound/soc/codecs/wm_hubs.c | 2 +- 49 files changed, 154 insertions(+), 140 deletions(-) diff --git a/include/sound/soc.h b/include/sound/soc.h index 0b83168d8ff4..e150030b754d 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h @@ -1228,6 +1228,20 @@ static inline bool snd_soc_codec_is_active(struct snd_soc_codec *codec) return snd_soc_component_is_active(&codec->component); } +/** + * snd_soc_kcontrol_codec() - Returns the CODEC that registered the control + * @kcontrol: The control for which to get the CODEC + * + * Note: This function will only work correctly if the control has been + * registered with snd_soc_add_codec_controls() or via table based setup of + * snd_soc_codec_driver. Otherwise the behavior is undefined. + */ +static inline struct snd_soc_codec *snd_soc_kcontrol_codec( + struct snd_kcontrol *kcontrol) +{ + return snd_kcontrol_chip(kcontrol); +} + int snd_soc_util_init(void); void snd_soc_util_exit(void); diff --git a/sound/soc/codecs/88pm860x-codec.c b/sound/soc/codecs/88pm860x-codec.c index b07e17160f94..b18cafa5a858 100644 --- a/sound/soc/codecs/88pm860x-codec.c +++ b/sound/soc/codecs/88pm860x-codec.c @@ -276,7 +276,7 @@ static int snd_soc_get_volsw_2r_st(struct snd_kcontrol *kcontrol, { struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value; - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); unsigned int reg = mc->reg; unsigned int reg2 = mc->rreg; int val[2], val2[2], i; @@ -300,7 +300,7 @@ static int snd_soc_put_volsw_2r_st(struct snd_kcontrol *kcontrol, { struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value; - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); unsigned int reg = mc->reg; unsigned int reg2 = mc->rreg; int err; @@ -333,7 +333,7 @@ static int snd_soc_get_volsw_2r_out(struct snd_kcontrol *kcontrol, { struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value; - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); unsigned int reg = mc->reg; unsigned int reg2 = mc->rreg; unsigned int shift = mc->shift; @@ -353,7 +353,7 @@ static int snd_soc_put_volsw_2r_out(struct snd_kcontrol *kcontrol, { struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value; - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); unsigned int reg = mc->reg; unsigned int reg2 = mc->rreg; unsigned int shift = mc->shift; diff --git a/sound/soc/codecs/ab8500-codec.c b/sound/soc/codecs/ab8500-codec.c index 1ad92cbf0b24..1fb4402bf72d 100644 --- a/sound/soc/codecs/ab8500-codec.c +++ b/sound/soc/codecs/ab8500-codec.c @@ -1139,7 +1139,7 @@ static void anc_configure(struct snd_soc_codec *codec, static int sid_status_control_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct ab8500_codec_drvdata *drvdata = dev_get_drvdata(codec->dev); mutex_lock(&codec->mutex); @@ -1153,7 +1153,7 @@ static int sid_status_control_get(struct snd_kcontrol *kcontrol, static int sid_status_control_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct ab8500_codec_drvdata *drvdata = dev_get_drvdata(codec->dev); unsigned int param, sidconf, val; int status = 1; @@ -1208,7 +1208,7 @@ out: static int anc_status_control_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct ab8500_codec_drvdata *drvdata = dev_get_drvdata(codec->dev); mutex_lock(&codec->mutex); @@ -1221,7 +1221,7 @@ static int anc_status_control_get(struct snd_kcontrol *kcontrol, static int anc_status_control_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct ab8500_codec_drvdata *drvdata = dev_get_drvdata(codec->dev); struct device *dev = codec->dev; bool apply_fir, apply_iir; @@ -1306,7 +1306,7 @@ static int filter_control_info(struct snd_kcontrol *kcontrol, static int filter_control_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct filter_control *fc = (struct filter_control *)kcontrol->private_value; unsigned int i; @@ -1322,7 +1322,7 @@ static int filter_control_get(struct snd_kcontrol *kcontrol, static int filter_control_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct filter_control *fc = (struct filter_control *)kcontrol->private_value; unsigned int i; diff --git a/sound/soc/codecs/adav80x.c b/sound/soc/codecs/adav80x.c index 5062e34ee8dc..cf170b5ef426 100644 --- a/sound/soc/codecs/adav80x.c +++ b/sound/soc/codecs/adav80x.c @@ -315,7 +315,7 @@ static int adav80x_set_deemph(struct snd_soc_codec *codec) static int adav80x_put_deemph(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct adav80x *adav80x = snd_soc_codec_get_drvdata(codec); unsigned int deemph = ucontrol->value.enumerated.item[0]; @@ -330,7 +330,7 @@ static int adav80x_put_deemph(struct snd_kcontrol *kcontrol, static int adav80x_get_deemph(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct adav80x *adav80x = snd_soc_codec_get_drvdata(codec); ucontrol->value.enumerated.item[0] = adav80x->deemph; diff --git a/sound/soc/codecs/ak4641.c b/sound/soc/codecs/ak4641.c index 868c0e2da1ec..7afe8f482088 100644 --- a/sound/soc/codecs/ak4641.c +++ b/sound/soc/codecs/ak4641.c @@ -74,7 +74,7 @@ static int ak4641_set_deemph(struct snd_soc_codec *codec) static int ak4641_put_deemph(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct ak4641_priv *ak4641 = snd_soc_codec_get_drvdata(codec); int deemph = ucontrol->value.enumerated.item[0]; @@ -89,7 +89,7 @@ static int ak4641_put_deemph(struct snd_kcontrol *kcontrol, static int ak4641_get_deemph(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct ak4641_priv *ak4641 = snd_soc_codec_get_drvdata(codec); ucontrol->value.enumerated.item[0] = ak4641->deemph; diff --git a/sound/soc/codecs/cs4270.c b/sound/soc/codecs/cs4270.c index 3920e6264948..9947a9583679 100644 --- a/sound/soc/codecs/cs4270.c +++ b/sound/soc/codecs/cs4270.c @@ -438,7 +438,7 @@ static int cs4270_dai_mute(struct snd_soc_dai *dai, int mute) static int cs4270_soc_put_mute(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct cs4270_private *cs4270 = snd_soc_codec_get_drvdata(codec); int left = !ucontrol->value.integer.value[0]; int right = !ucontrol->value.integer.value[1]; diff --git a/sound/soc/codecs/cs4271.c b/sound/soc/codecs/cs4271.c index aef4965750c7..93cec52f4733 100644 --- a/sound/soc/codecs/cs4271.c +++ b/sound/soc/codecs/cs4271.c @@ -284,7 +284,7 @@ static int cs4271_set_deemph(struct snd_soc_codec *codec) static int cs4271_get_deemph(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct cs4271_private *cs4271 = snd_soc_codec_get_drvdata(codec); ucontrol->value.enumerated.item[0] = cs4271->deemph; @@ -294,7 +294,7 @@ static int cs4271_get_deemph(struct snd_kcontrol *kcontrol, static int cs4271_put_deemph(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct cs4271_private *cs4271 = snd_soc_codec_get_drvdata(codec); cs4271->deemph = ucontrol->value.enumerated.item[0]; diff --git a/sound/soc/codecs/cs42l51.c b/sound/soc/codecs/cs42l51.c index 6c0da2baa154..23acaa0263dc 100644 --- a/sound/soc/codecs/cs42l51.c +++ b/sound/soc/codecs/cs42l51.c @@ -55,7 +55,7 @@ struct cs42l51_private { static int cs42l51_get_chan_mix(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); unsigned long value = snd_soc_read(codec, CS42L51_PCM_MIXER)&3; switch (value) { @@ -83,7 +83,7 @@ static int cs42l51_get_chan_mix(struct snd_kcontrol *kcontrol, static int cs42l51_set_chan_mix(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); unsigned char val; switch (ucontrol->value.integer.value[0]) { diff --git a/sound/soc/codecs/da7210.c b/sound/soc/codecs/da7210.c index 137e8ebc092c..21810e5f3321 100644 --- a/sound/soc/codecs/da7210.c +++ b/sound/soc/codecs/da7210.c @@ -335,7 +335,7 @@ static SOC_ENUM_SINGLE_DECL(da7210_hp_mode_sel, static int da7210_put_alc_sw(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); if (ucontrol->value.integer.value[0]) { /* Check if noise suppression is enabled */ @@ -358,7 +358,7 @@ static int da7210_put_alc_sw(struct snd_kcontrol *kcontrol, static int da7210_put_noise_sup_sw(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); u8 val; if (ucontrol->value.integer.value[0]) { diff --git a/sound/soc/codecs/da7213.c b/sound/soc/codecs/da7213.c index 738fa18a50d2..9ec577f0edb4 100644 --- a/sound/soc/codecs/da7213.c +++ b/sound/soc/codecs/da7213.c @@ -345,7 +345,7 @@ static void da7213_alc_calib(struct snd_soc_codec *codec) static int da7213_put_mixin_gain(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct da7213_priv *da7213 = snd_soc_codec_get_drvdata(codec); int ret; @@ -361,7 +361,7 @@ static int da7213_put_mixin_gain(struct snd_kcontrol *kcontrol, static int da7213_put_alc_sw(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct da7213_priv *da7213 = snd_soc_codec_get_drvdata(codec); /* Force ALC offset calibration if enabling ALC */ diff --git a/sound/soc/codecs/da732x.c b/sound/soc/codecs/da732x.c index 48f3fef68484..2fae31cb0067 100644 --- a/sound/soc/codecs/da732x.c +++ b/sound/soc/codecs/da732x.c @@ -332,7 +332,7 @@ static SOC_ENUM_SINGLE_DECL(da732x_adc2_voice_filter_enum, static int da732x_hpf_set(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct soc_enum *enum_ctrl = (struct soc_enum *)kcontrol->private_value; unsigned int reg = enum_ctrl->reg; unsigned int sel = ucontrol->value.integer.value[0]; @@ -360,7 +360,7 @@ static int da732x_hpf_set(struct snd_kcontrol *kcontrol, static int da732x_hpf_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct soc_enum *enum_ctrl = (struct soc_enum *)kcontrol->private_value; unsigned int reg = enum_ctrl->reg; int val; diff --git a/sound/soc/codecs/da9055.c b/sound/soc/codecs/da9055.c index 4ff06b50fbba..ad19cc56702b 100644 --- a/sound/soc/codecs/da9055.c +++ b/sound/soc/codecs/da9055.c @@ -484,7 +484,7 @@ static int da9055_get_alc_data(struct snd_soc_codec *codec, u8 reg_val) static int da9055_put_alc_sw(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); u8 reg_val, adc_left, adc_right, mic_left, mic_right; int avg_left_data, avg_right_data, offset_l, offset_r; diff --git a/sound/soc/codecs/lm4857.c b/sound/soc/codecs/lm4857.c index 4f048db9f55f..a924bb9d7886 100644 --- a/sound/soc/codecs/lm4857.c +++ b/sound/soc/codecs/lm4857.c @@ -49,7 +49,7 @@ static const struct reg_default lm4857_default_regs[] = { static int lm4857_get_mode(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct lm4857 *lm4857 = snd_soc_codec_get_drvdata(codec); ucontrol->value.integer.value[0] = lm4857->mode; @@ -60,7 +60,7 @@ static int lm4857_get_mode(struct snd_kcontrol *kcontrol, static int lm4857_set_mode(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct lm4857 *lm4857 = snd_soc_codec_get_drvdata(codec); uint8_t value = ucontrol->value.integer.value[0]; diff --git a/sound/soc/codecs/max9768.c b/sound/soc/codecs/max9768.c index ec481fc428c7..e1c196a41930 100644 --- a/sound/soc/codecs/max9768.c +++ b/sound/soc/codecs/max9768.c @@ -43,7 +43,7 @@ static struct reg_default max9768_default_regs[] = { static int max9768_get_gpio(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct max9768 *max9768 = snd_soc_codec_get_drvdata(codec); int val = gpio_get_value_cansleep(max9768->mute_gpio); @@ -55,7 +55,7 @@ static int max9768_get_gpio(struct snd_kcontrol *kcontrol, static int max9768_set_gpio(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct max9768 *max9768 = snd_soc_codec_get_drvdata(codec); gpio_set_value_cansleep(max9768->mute_gpio, !ucontrol->value.integer.value[0]); diff --git a/sound/soc/codecs/max98088.c b/sound/soc/codecs/max98088.c index ef7cf89f5623..9134982807b5 100644 --- a/sound/soc/codecs/max98088.c +++ b/sound/soc/codecs/max98088.c @@ -635,7 +635,7 @@ static SOC_ENUM_SINGLE_DECL(max98088_dai1_adc_filter_enum, static int max98088_mic1pre_set(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct max98088_priv *max98088 = snd_soc_codec_get_drvdata(codec); unsigned int sel = ucontrol->value.integer.value[0]; @@ -649,7 +649,7 @@ static int max98088_mic1pre_set(struct snd_kcontrol *kcontrol, static int max98088_mic1pre_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct max98088_priv *max98088 = snd_soc_codec_get_drvdata(codec); ucontrol->value.integer.value[0] = max98088->mic1pre; @@ -659,7 +659,7 @@ static int max98088_mic1pre_get(struct snd_kcontrol *kcontrol, static int max98088_mic2pre_set(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct max98088_priv *max98088 = snd_soc_codec_get_drvdata(codec); unsigned int sel = ucontrol->value.integer.value[0]; @@ -673,7 +673,7 @@ static int max98088_mic2pre_set(struct snd_kcontrol *kcontrol, static int max98088_mic2pre_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct max98088_priv *max98088 = snd_soc_codec_get_drvdata(codec); ucontrol->value.integer.value[0] = max98088->mic2pre; @@ -1750,7 +1750,7 @@ static void max98088_setup_eq2(struct snd_soc_codec *codec) static int max98088_put_eq_enum(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct max98088_priv *max98088 = snd_soc_codec_get_drvdata(codec); struct max98088_pdata *pdata = max98088->pdata; int channel = max98088_get_channel(codec, kcontrol->id.name); @@ -1782,7 +1782,7 @@ static int max98088_put_eq_enum(struct snd_kcontrol *kcontrol, static int max98088_get_eq_enum(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct max98088_priv *max98088 = snd_soc_codec_get_drvdata(codec); int channel = max98088_get_channel(codec, kcontrol->id.name); struct max98088_cdata *cdata; diff --git a/sound/soc/codecs/max98090.c b/sound/soc/codecs/max98090.c index f7b0b37aa858..49d12387ac2f 100644 --- a/sound/soc/codecs/max98090.c +++ b/sound/soc/codecs/max98090.c @@ -426,7 +426,7 @@ static const unsigned int max98090_rcv_lout_tlv[] = { static int max98090_get_enab_tlv(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct max98090_priv *max98090 = snd_soc_codec_get_drvdata(codec); struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value; @@ -466,7 +466,7 @@ static int max98090_get_enab_tlv(struct snd_kcontrol *kcontrol, static int max98090_put_enab_tlv(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct max98090_priv *max98090 = snd_soc_codec_get_drvdata(codec); struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value; diff --git a/sound/soc/codecs/max98095.c b/sound/soc/codecs/max98095.c index 03f0536e6f61..5d4c621dbf99 100644 --- a/sound/soc/codecs/max98095.c +++ b/sound/soc/codecs/max98095.c @@ -612,7 +612,7 @@ static SOC_ENUM_SINGLE_DECL(max98095_dai3_dac_filter_enum, static int max98095_mic1pre_set(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct max98095_priv *max98095 = snd_soc_codec_get_drvdata(codec); unsigned int sel = ucontrol->value.integer.value[0]; @@ -626,7 +626,7 @@ static int max98095_mic1pre_set(struct snd_kcontrol *kcontrol, static int max98095_mic1pre_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct max98095_priv *max98095 = snd_soc_codec_get_drvdata(codec); ucontrol->value.integer.value[0] = max98095->mic1pre; @@ -636,7 +636,7 @@ static int max98095_mic1pre_get(struct snd_kcontrol *kcontrol, static int max98095_mic2pre_set(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct max98095_priv *max98095 = snd_soc_codec_get_drvdata(codec); unsigned int sel = ucontrol->value.integer.value[0]; @@ -650,7 +650,7 @@ static int max98095_mic2pre_set(struct snd_kcontrol *kcontrol, static int max98095_mic2pre_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct max98095_priv *max98095 = snd_soc_codec_get_drvdata(codec); ucontrol->value.integer.value[0] = max98095->mic2pre; @@ -1737,7 +1737,7 @@ static int max98095_get_eq_channel(const char *name) static int max98095_put_eq_enum(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct max98095_priv *max98095 = snd_soc_codec_get_drvdata(codec); struct max98095_pdata *pdata = max98095->pdata; int channel = max98095_get_eq_channel(kcontrol->id.name); @@ -1801,7 +1801,7 @@ static int max98095_put_eq_enum(struct snd_kcontrol *kcontrol, static int max98095_get_eq_enum(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct max98095_priv *max98095 = snd_soc_codec_get_drvdata(codec); int channel = max98095_get_eq_channel(kcontrol->id.name); struct max98095_cdata *cdata; @@ -1891,7 +1891,7 @@ static int max98095_get_bq_channel(struct snd_soc_codec *codec, static int max98095_put_bq_enum(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct max98095_priv *max98095 = snd_soc_codec_get_drvdata(codec); struct max98095_pdata *pdata = max98095->pdata; int channel = max98095_get_bq_channel(codec, kcontrol->id.name); @@ -1952,7 +1952,7 @@ static int max98095_put_bq_enum(struct snd_kcontrol *kcontrol, static int max98095_get_bq_enum(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct max98095_priv *max98095 = snd_soc_codec_get_drvdata(codec); int channel = max98095_get_bq_channel(codec, kcontrol->id.name); struct max98095_cdata *cdata; diff --git a/sound/soc/codecs/pcm1681.c b/sound/soc/codecs/pcm1681.c index e427544183d7..a722a023c262 100644 --- a/sound/soc/codecs/pcm1681.c +++ b/sound/soc/codecs/pcm1681.c @@ -115,7 +115,7 @@ static int pcm1681_set_deemph(struct snd_soc_codec *codec) static int pcm1681_get_deemph(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct pcm1681_private *priv = snd_soc_codec_get_drvdata(codec); ucontrol->value.enumerated.item[0] = priv->deemph; @@ -126,7 +126,7 @@ static int pcm1681_get_deemph(struct snd_kcontrol *kcontrol, static int pcm1681_put_deemph(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct pcm1681_private *priv = snd_soc_codec_get_drvdata(codec); priv->deemph = ucontrol->value.enumerated.item[0]; diff --git a/sound/soc/codecs/rt5631.c b/sound/soc/codecs/rt5631.c index d4c229f0233f..30e234708579 100644 --- a/sound/soc/codecs/rt5631.c +++ b/sound/soc/codecs/rt5631.c @@ -188,7 +188,7 @@ static unsigned int mic_bst_tlv[] = { static int rt5631_dmic_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct rt5631_priv *rt5631 = snd_soc_codec_get_drvdata(codec); ucontrol->value.integer.value[0] = rt5631->dmic_used_flag; @@ -199,7 +199,7 @@ static int rt5631_dmic_get(struct snd_kcontrol *kcontrol, static int rt5631_dmic_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct rt5631_priv *rt5631 = snd_soc_codec_get_drvdata(codec); rt5631->dmic_used_flag = ucontrol->value.integer.value[0]; diff --git a/sound/soc/codecs/sgtl5000.c b/sound/soc/codecs/sgtl5000.c index d3ed1be5a186..b56caefcf664 100644 --- a/sound/soc/codecs/sgtl5000.c +++ b/sound/soc/codecs/sgtl5000.c @@ -296,7 +296,7 @@ static int dac_info_volsw(struct snd_kcontrol *kcontrol, static int dac_get_volsw(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); int reg; int l; int r; @@ -349,7 +349,7 @@ static int dac_get_volsw(struct snd_kcontrol *kcontrol, static int dac_put_volsw(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); int reg; int l; int r; diff --git a/sound/soc/codecs/sta32x.c b/sound/soc/codecs/sta32x.c index 12577749b17b..0579d187135b 100644 --- a/sound/soc/codecs/sta32x.c +++ b/sound/soc/codecs/sta32x.c @@ -243,7 +243,7 @@ static int sta32x_coefficient_info(struct snd_kcontrol *kcontrol, static int sta32x_coefficient_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); int numcoef = kcontrol->private_value >> 16; int index = kcontrol->private_value & 0xffff; unsigned int cfud; @@ -272,7 +272,7 @@ static int sta32x_coefficient_get(struct snd_kcontrol *kcontrol, static int sta32x_coefficient_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct sta32x_priv *sta32x = snd_soc_codec_get_drvdata(codec); int numcoef = kcontrol->private_value >> 16; int index = kcontrol->private_value & 0xffff; diff --git a/sound/soc/codecs/tas5086.c b/sound/soc/codecs/tas5086.c index a895a5e4bdf2..d48491a4a19d 100644 --- a/sound/soc/codecs/tas5086.c +++ b/sound/soc/codecs/tas5086.c @@ -272,7 +272,7 @@ static int tas5086_set_deemph(struct snd_soc_codec *codec) static int tas5086_get_deemph(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct tas5086_private *priv = snd_soc_codec_get_drvdata(codec); ucontrol->value.enumerated.item[0] = priv->deemph; @@ -283,7 +283,7 @@ static int tas5086_get_deemph(struct snd_kcontrol *kcontrol, static int tas5086_put_deemph(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct tas5086_private *priv = snd_soc_codec_get_drvdata(codec); priv->deemph = ucontrol->value.enumerated.item[0]; diff --git a/sound/soc/codecs/tlv320aic23.c b/sound/soc/codecs/tlv320aic23.c index 20864ee8793b..686b8b85b956 100644 --- a/sound/soc/codecs/tlv320aic23.c +++ b/sound/soc/codecs/tlv320aic23.c @@ -82,7 +82,7 @@ static const DECLARE_TLV_DB_SCALE(sidetone_vol_tlv, -1800, 300, 0); static int snd_soc_tlv320aic23_put_volsw(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); u16 val, reg; val = (ucontrol->value.integer.value[0] & 0x07); @@ -105,7 +105,7 @@ static int snd_soc_tlv320aic23_put_volsw(struct snd_kcontrol *kcontrol, static int snd_soc_tlv320aic23_get_volsw(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); u16 val; val = snd_soc_read(codec, TLV320AIC23_ANLG) & (0x1C0); diff --git a/sound/soc/codecs/tlv320dac33.c b/sound/soc/codecs/tlv320dac33.c index 6bfc8a17331b..517055ab65ef 100644 --- a/sound/soc/codecs/tlv320dac33.c +++ b/sound/soc/codecs/tlv320dac33.c @@ -442,7 +442,7 @@ static int dac33_playback_event(struct snd_soc_dapm_widget *w, static int dac33_get_fifo_mode(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct tlv320dac33_priv *dac33 = snd_soc_codec_get_drvdata(codec); ucontrol->value.integer.value[0] = dac33->fifo_mode; @@ -453,7 +453,7 @@ static int dac33_get_fifo_mode(struct snd_kcontrol *kcontrol, static int dac33_set_fifo_mode(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct tlv320dac33_priv *dac33 = snd_soc_codec_get_drvdata(codec); int ret = 0; diff --git a/sound/soc/codecs/twl4030.c b/sound/soc/codecs/twl4030.c index 975e0f760ac1..69e12a311ba2 100644 --- a/sound/soc/codecs/twl4030.c +++ b/sound/soc/codecs/twl4030.c @@ -830,7 +830,7 @@ static int snd_soc_get_volsw_twl4030(struct snd_kcontrol *kcontrol, { struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value; - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); unsigned int reg = mc->reg; unsigned int shift = mc->shift; unsigned int rshift = mc->rshift; @@ -859,7 +859,7 @@ static int snd_soc_put_volsw_twl4030(struct snd_kcontrol *kcontrol, { struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value; - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); unsigned int reg = mc->reg; unsigned int shift = mc->shift; unsigned int rshift = mc->rshift; @@ -888,7 +888,7 @@ static int snd_soc_get_volsw_r2_twl4030(struct snd_kcontrol *kcontrol, { struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value; - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); unsigned int reg = mc->reg; unsigned int reg2 = mc->rreg; unsigned int shift = mc->shift; @@ -915,7 +915,7 @@ static int snd_soc_put_volsw_r2_twl4030(struct snd_kcontrol *kcontrol, { struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value; - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); unsigned int reg = mc->reg; unsigned int reg2 = mc->rreg; unsigned int shift = mc->shift; @@ -956,7 +956,7 @@ static SOC_ENUM_SINGLE_DECL(twl4030_op_modes_enum, static int snd_soc_put_twl4030_opmode_enum_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct twl4030_priv *twl4030 = snd_soc_codec_get_drvdata(codec); if (twl4030->configured) { diff --git a/sound/soc/codecs/twl6040.c b/sound/soc/codecs/twl6040.c index bd3a20647fdf..0f6067f04e29 100644 --- a/sound/soc/codecs/twl6040.c +++ b/sound/soc/codecs/twl6040.c @@ -484,7 +484,7 @@ static SOC_ENUM_SINGLE_EXT_DECL(twl6040_power_mode_enum, static int twl6040_headset_power_get_enum(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct twl6040_data *priv = snd_soc_codec_get_drvdata(codec); ucontrol->value.enumerated.item[0] = priv->hs_power_mode; @@ -495,7 +495,7 @@ static int twl6040_headset_power_get_enum(struct snd_kcontrol *kcontrol, static int twl6040_headset_power_put_enum(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct twl6040_data *priv = snd_soc_codec_get_drvdata(codec); int high_perf = ucontrol->value.enumerated.item[0]; int ret = 0; @@ -512,7 +512,7 @@ static int twl6040_headset_power_put_enum(struct snd_kcontrol *kcontrol, static int twl6040_pll_get_enum(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct twl6040_data *priv = snd_soc_codec_get_drvdata(codec); ucontrol->value.enumerated.item[0] = priv->pll_power_mode; @@ -523,7 +523,7 @@ static int twl6040_pll_get_enum(struct snd_kcontrol *kcontrol, static int twl6040_pll_put_enum(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct twl6040_data *priv = snd_soc_codec_get_drvdata(codec); priv->pll_power_mode = ucontrol->value.enumerated.item[0]; diff --git a/sound/soc/codecs/wl1273.c b/sound/soc/codecs/wl1273.c index 6be5f80b65f1..4ead0dc02b87 100644 --- a/sound/soc/codecs/wl1273.c +++ b/sound/soc/codecs/wl1273.c @@ -172,7 +172,7 @@ out: static int snd_wl1273_get_audio_route(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct wl1273_priv *wl1273 = snd_soc_codec_get_drvdata(codec); ucontrol->value.integer.value[0] = wl1273->mode; @@ -190,7 +190,7 @@ static const char * const wl1273_audio_route[] = { "Bt", "FmRx", "FmTx" }; static int snd_wl1273_set_audio_route(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct wl1273_priv *wl1273 = snd_soc_codec_get_drvdata(codec); if (wl1273->mode == ucontrol->value.integer.value[0]) @@ -214,7 +214,7 @@ static SOC_ENUM_SINGLE_EXT_DECL(wl1273_enum, wl1273_audio_route); static int snd_wl1273_fm_audio_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct wl1273_priv *wl1273 = snd_soc_codec_get_drvdata(codec); dev_dbg(codec->dev, "%s: enter.\n", __func__); @@ -227,7 +227,7 @@ static int snd_wl1273_fm_audio_get(struct snd_kcontrol *kcontrol, static int snd_wl1273_fm_audio_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct wl1273_priv *wl1273 = snd_soc_codec_get_drvdata(codec); int val, r = 0; @@ -251,7 +251,7 @@ static SOC_ENUM_SINGLE_EXT_DECL(wl1273_audio_enum, wl1273_audio_strings); static int snd_wl1273_fm_volume_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct wl1273_priv *wl1273 = snd_soc_codec_get_drvdata(codec); dev_dbg(codec->dev, "%s: enter.\n", __func__); @@ -264,7 +264,7 @@ static int snd_wl1273_fm_volume_get(struct snd_kcontrol *kcontrol, static int snd_wl1273_fm_volume_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct wl1273_priv *wl1273 = snd_soc_codec_get_drvdata(codec); int r; diff --git a/sound/soc/codecs/wm2000.c b/sound/soc/codecs/wm2000.c index 83a2c872925c..a4c352cc3464 100644 --- a/sound/soc/codecs/wm2000.c +++ b/sound/soc/codecs/wm2000.c @@ -607,7 +607,7 @@ static int wm2000_anc_set_mode(struct wm2000_priv *wm2000) static int wm2000_anc_mode_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct wm2000_priv *wm2000 = dev_get_drvdata(codec->dev); ucontrol->value.enumerated.item[0] = wm2000->anc_active; @@ -618,7 +618,7 @@ static int wm2000_anc_mode_get(struct snd_kcontrol *kcontrol, static int wm2000_anc_mode_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct wm2000_priv *wm2000 = dev_get_drvdata(codec->dev); int anc_active = ucontrol->value.enumerated.item[0]; int ret; @@ -640,7 +640,7 @@ static int wm2000_anc_mode_put(struct snd_kcontrol *kcontrol, static int wm2000_speaker_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct wm2000_priv *wm2000 = dev_get_drvdata(codec->dev); ucontrol->value.enumerated.item[0] = wm2000->spk_ena; @@ -651,7 +651,7 @@ static int wm2000_speaker_get(struct snd_kcontrol *kcontrol, static int wm2000_speaker_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct wm2000_priv *wm2000 = dev_get_drvdata(codec->dev); int val = ucontrol->value.enumerated.item[0]; int ret; diff --git a/sound/soc/codecs/wm8350.c b/sound/soc/codecs/wm8350.c index 757256bf7672..42a72b2404d5 100644 --- a/sound/soc/codecs/wm8350.c +++ b/sound/soc/codecs/wm8350.c @@ -302,7 +302,7 @@ static int pga_event(struct snd_soc_dapm_widget *w, static int wm8350_put_volsw_2r_vu(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct wm8350_data *wm8350_priv = snd_soc_codec_get_drvdata(codec); struct wm8350_output *out = NULL; struct soc_mixer_control *mc = @@ -345,7 +345,7 @@ static int wm8350_put_volsw_2r_vu(struct snd_kcontrol *kcontrol, static int wm8350_get_volsw_2r(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct wm8350_data *wm8350_priv = snd_soc_codec_get_drvdata(codec); struct wm8350_output *out1 = &wm8350_priv->out1; struct wm8350_output *out2 = &wm8350_priv->out2; diff --git a/sound/soc/codecs/wm8400.c b/sound/soc/codecs/wm8400.c index 146564feaea0..edfdbcd9d316 100644 --- a/sound/soc/codecs/wm8400.c +++ b/sound/soc/codecs/wm8400.c @@ -93,7 +93,7 @@ static const DECLARE_TLV_DB_SCALE(out_sidetone_tlv, -3600, 0, 0); static int wm8400_outpga_put_volsw_vu(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value; int reg = mc->reg; diff --git a/sound/soc/codecs/wm8580.c b/sound/soc/codecs/wm8580.c index af7ed8b5d4e1..7665ff6aea6d 100644 --- a/sound/soc/codecs/wm8580.c +++ b/sound/soc/codecs/wm8580.c @@ -252,7 +252,7 @@ static int wm8580_out_vu(struct snd_kcontrol *kcontrol, { struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value; - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct wm8580_priv *wm8580 = snd_soc_codec_get_drvdata(codec); unsigned int reg = mc->reg; unsigned int reg2 = mc->rreg; diff --git a/sound/soc/codecs/wm8731.c b/sound/soc/codecs/wm8731.c index d74f43975b90..763b265d9528 100644 --- a/sound/soc/codecs/wm8731.c +++ b/sound/soc/codecs/wm8731.c @@ -119,7 +119,7 @@ static int wm8731_set_deemph(struct snd_soc_codec *codec) static int wm8731_get_deemph(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct wm8731_priv *wm8731 = snd_soc_codec_get_drvdata(codec); ucontrol->value.enumerated.item[0] = wm8731->deemph; @@ -130,7 +130,7 @@ static int wm8731_get_deemph(struct snd_kcontrol *kcontrol, static int wm8731_put_deemph(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct wm8731_priv *wm8731 = snd_soc_codec_get_drvdata(codec); int deemph = ucontrol->value.enumerated.item[0]; int ret = 0; diff --git a/sound/soc/codecs/wm8753.c b/sound/soc/codecs/wm8753.c index cbb8d55052a4..53e57b4049a8 100644 --- a/sound/soc/codecs/wm8753.c +++ b/sound/soc/codecs/wm8753.c @@ -234,7 +234,7 @@ SOC_ENUM_SINGLE(WM8753_OUTCTL, 2, 2, wm8753_rout2_phase), static int wm8753_get_dai(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct wm8753_priv *wm8753 = snd_soc_codec_get_drvdata(codec); ucontrol->value.integer.value[0] = wm8753->dai_func; @@ -244,7 +244,7 @@ static int wm8753_get_dai(struct snd_kcontrol *kcontrol, static int wm8753_set_dai(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct wm8753_priv *wm8753 = snd_soc_codec_get_drvdata(codec); u16 ioctl; diff --git a/sound/soc/codecs/wm8804.c b/sound/soc/codecs/wm8804.c index ee76f0fb4299..589455c3bfcd 100644 --- a/sound/soc/codecs/wm8804.c +++ b/sound/soc/codecs/wm8804.c @@ -106,7 +106,7 @@ static int txsrc_get(struct snd_kcontrol *kcontrol, struct snd_soc_codec *codec; unsigned int src; - codec = snd_kcontrol_chip(kcontrol); + codec = snd_soc_kcontrol_codec(kcontrol); src = snd_soc_read(codec, WM8804_SPDTX4); if (src & 0x40) ucontrol->value.integer.value[0] = 1; @@ -122,7 +122,7 @@ static int txsrc_put(struct snd_kcontrol *kcontrol, struct snd_soc_codec *codec; unsigned int src, txpwr; - codec = snd_kcontrol_chip(kcontrol); + codec = snd_soc_kcontrol_codec(kcontrol); if (ucontrol->value.integer.value[0] != 0 && ucontrol->value.integer.value[0] != 1) diff --git a/sound/soc/codecs/wm8903.c b/sound/soc/codecs/wm8903.c index b0084a127d18..b84940c359a1 100644 --- a/sound/soc/codecs/wm8903.c +++ b/sound/soc/codecs/wm8903.c @@ -439,7 +439,7 @@ static int wm8903_set_deemph(struct snd_soc_codec *codec) static int wm8903_get_deemph(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct wm8903_priv *wm8903 = snd_soc_codec_get_drvdata(codec); ucontrol->value.enumerated.item[0] = wm8903->deemph; @@ -450,7 +450,7 @@ static int wm8903_get_deemph(struct snd_kcontrol *kcontrol, static int wm8903_put_deemph(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct wm8903_priv *wm8903 = snd_soc_codec_get_drvdata(codec); int deemph = ucontrol->value.enumerated.item[0]; int ret = 0; diff --git a/sound/soc/codecs/wm8904.c b/sound/soc/codecs/wm8904.c index 49c35c36935e..f7c549949c54 100644 --- a/sound/soc/codecs/wm8904.c +++ b/sound/soc/codecs/wm8904.c @@ -391,7 +391,7 @@ static void wm8904_set_drc(struct snd_soc_codec *codec) static int wm8904_put_drc_enum(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct wm8904_priv *wm8904 = snd_soc_codec_get_drvdata(codec); struct wm8904_pdata *pdata = wm8904->pdata; int value = ucontrol->value.integer.value[0]; @@ -409,7 +409,7 @@ static int wm8904_put_drc_enum(struct snd_kcontrol *kcontrol, static int wm8904_get_drc_enum(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct wm8904_priv *wm8904 = snd_soc_codec_get_drvdata(codec); ucontrol->value.enumerated.item[0] = wm8904->drc_cfg; @@ -462,7 +462,7 @@ static void wm8904_set_retune_mobile(struct snd_soc_codec *codec) static int wm8904_put_retune_mobile_enum(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct wm8904_priv *wm8904 = snd_soc_codec_get_drvdata(codec); struct wm8904_pdata *pdata = wm8904->pdata; int value = ucontrol->value.integer.value[0]; @@ -480,7 +480,7 @@ static int wm8904_put_retune_mobile_enum(struct snd_kcontrol *kcontrol, static int wm8904_get_retune_mobile_enum(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct wm8904_priv *wm8904 = snd_soc_codec_get_drvdata(codec); ucontrol->value.enumerated.item[0] = wm8904->retune_mobile_cfg; @@ -520,7 +520,7 @@ static int wm8904_set_deemph(struct snd_soc_codec *codec) static int wm8904_get_deemph(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct wm8904_priv *wm8904 = snd_soc_codec_get_drvdata(codec); ucontrol->value.enumerated.item[0] = wm8904->deemph; @@ -530,7 +530,7 @@ static int wm8904_get_deemph(struct snd_kcontrol *kcontrol, static int wm8904_put_deemph(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct wm8904_priv *wm8904 = snd_soc_codec_get_drvdata(codec); int deemph = ucontrol->value.enumerated.item[0]; @@ -570,7 +570,7 @@ static SOC_ENUM_SINGLE_DECL(hpf_mode, WM8904_ADC_DIGITAL_0, 5, static int wm8904_adc_osr_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); unsigned int val; int ret; diff --git a/sound/soc/codecs/wm8955.c b/sound/soc/codecs/wm8955.c index fecd4e4f4c57..7e443c4f6f85 100644 --- a/sound/soc/codecs/wm8955.c +++ b/sound/soc/codecs/wm8955.c @@ -390,7 +390,7 @@ static int wm8955_set_deemph(struct snd_soc_codec *codec) static int wm8955_get_deemph(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct wm8955_priv *wm8955 = snd_soc_codec_get_drvdata(codec); ucontrol->value.enumerated.item[0] = wm8955->deemph; @@ -400,7 +400,7 @@ static int wm8955_get_deemph(struct snd_kcontrol *kcontrol, static int wm8955_put_deemph(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct wm8955_priv *wm8955 = snd_soc_codec_get_drvdata(codec); int deemph = ucontrol->value.enumerated.item[0]; diff --git a/sound/soc/codecs/wm8958-dsp2.c b/sound/soc/codecs/wm8958-dsp2.c index 7ac2e511403c..b2ebb104d879 100644 --- a/sound/soc/codecs/wm8958-dsp2.c +++ b/sound/soc/codecs/wm8958-dsp2.c @@ -456,7 +456,7 @@ static int wm8958_dsp2_busy(struct wm8994_priv *wm8994, int aif) static int wm8958_put_mbc_enum(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); struct wm8994 *control = wm8994->wm8994; int value = ucontrol->value.integer.value[0]; @@ -478,7 +478,7 @@ static int wm8958_put_mbc_enum(struct snd_kcontrol *kcontrol, static int wm8958_get_mbc_enum(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); ucontrol->value.enumerated.item[0] = wm8994->mbc_cfg; @@ -500,7 +500,7 @@ static int wm8958_mbc_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { int mbc = kcontrol->private_value; - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); ucontrol->value.integer.value[0] = wm8994->mbc_ena[mbc]; @@ -512,7 +512,7 @@ static int wm8958_mbc_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { int mbc = kcontrol->private_value; - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); if (wm8994->mbc_ena[mbc] == ucontrol->value.integer.value[0]) @@ -546,7 +546,7 @@ static int wm8958_mbc_put(struct snd_kcontrol *kcontrol, static int wm8958_put_vss_enum(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); struct wm8994 *control = wm8994->wm8994; int value = ucontrol->value.integer.value[0]; @@ -568,7 +568,7 @@ static int wm8958_put_vss_enum(struct snd_kcontrol *kcontrol, static int wm8958_get_vss_enum(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); ucontrol->value.enumerated.item[0] = wm8994->vss_cfg; @@ -579,7 +579,7 @@ static int wm8958_get_vss_enum(struct snd_kcontrol *kcontrol, static int wm8958_put_vss_hpf_enum(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); struct wm8994 *control = wm8994->wm8994; int value = ucontrol->value.integer.value[0]; @@ -601,7 +601,7 @@ static int wm8958_put_vss_hpf_enum(struct snd_kcontrol *kcontrol, static int wm8958_get_vss_hpf_enum(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); ucontrol->value.enumerated.item[0] = wm8994->vss_hpf_cfg; @@ -623,7 +623,7 @@ static int wm8958_vss_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { int vss = kcontrol->private_value; - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); ucontrol->value.integer.value[0] = wm8994->vss_ena[vss]; @@ -635,7 +635,7 @@ static int wm8958_vss_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { int vss = kcontrol->private_value; - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); if (wm8994->vss_ena[vss] == ucontrol->value.integer.value[0]) @@ -684,7 +684,7 @@ static int wm8958_hpf_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { int hpf = kcontrol->private_value; - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); if (hpf < 3) @@ -699,7 +699,7 @@ static int wm8958_hpf_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { int hpf = kcontrol->private_value; - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); if (hpf < 3) { @@ -746,7 +746,7 @@ static int wm8958_hpf_put(struct snd_kcontrol *kcontrol, static int wm8958_put_enh_eq_enum(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); struct wm8994 *control = wm8994->wm8994; int value = ucontrol->value.integer.value[0]; @@ -768,7 +768,7 @@ static int wm8958_put_enh_eq_enum(struct snd_kcontrol *kcontrol, static int wm8958_get_enh_eq_enum(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); ucontrol->value.enumerated.item[0] = wm8994->enh_eq_cfg; @@ -790,7 +790,7 @@ static int wm8958_enh_eq_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { int eq = kcontrol->private_value; - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); ucontrol->value.integer.value[0] = wm8994->enh_eq_ena[eq]; @@ -802,7 +802,7 @@ static int wm8958_enh_eq_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { int eq = kcontrol->private_value; - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); if (wm8994->enh_eq_ena[eq] == ucontrol->value.integer.value[0]) diff --git a/sound/soc/codecs/wm8960.c b/sound/soc/codecs/wm8960.c index d04e9cad445c..a145d0431b63 100644 --- a/sound/soc/codecs/wm8960.c +++ b/sound/soc/codecs/wm8960.c @@ -178,7 +178,7 @@ static int wm8960_set_deemph(struct snd_soc_codec *codec) static int wm8960_get_deemph(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct wm8960_priv *wm8960 = snd_soc_codec_get_drvdata(codec); ucontrol->value.enumerated.item[0] = wm8960->deemph; @@ -188,7 +188,7 @@ static int wm8960_get_deemph(struct snd_kcontrol *kcontrol, static int wm8960_put_deemph(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct wm8960_priv *wm8960 = snd_soc_codec_get_drvdata(codec); int deemph = ucontrol->value.enumerated.item[0]; diff --git a/sound/soc/codecs/wm8962.c b/sound/soc/codecs/wm8962.c index 5522d2566c67..37986c84cbff 100644 --- a/sound/soc/codecs/wm8962.c +++ b/sound/soc/codecs/wm8962.c @@ -1552,7 +1552,7 @@ static int wm8962_dsp2_ena_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { int shift = kcontrol->private_value; - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec); ucontrol->value.integer.value[0] = !!(wm8962->dsp2_ena & 1 << shift); @@ -1564,7 +1564,7 @@ static int wm8962_dsp2_ena_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { int shift = kcontrol->private_value; - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec); int old = wm8962->dsp2_ena; int ret = 0; @@ -1602,7 +1602,7 @@ out: static int wm8962_put_hp_sw(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); int ret; /* Apply the update (if any) */ @@ -1632,7 +1632,7 @@ static int wm8962_put_hp_sw(struct snd_kcontrol *kcontrol, static int wm8962_put_spk_sw(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); int ret; /* Apply the update (if any) */ diff --git a/sound/soc/codecs/wm8983.c b/sound/soc/codecs/wm8983.c index 2b9bfa53efbf..19d5baa38f5c 100644 --- a/sound/soc/codecs/wm8983.c +++ b/sound/soc/codecs/wm8983.c @@ -552,7 +552,7 @@ static const struct snd_soc_dapm_route wm8983_audio_map[] = { static int eqmode_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); unsigned int reg; reg = snd_soc_read(codec, WM8983_EQ1_LOW_SHELF); @@ -567,7 +567,7 @@ static int eqmode_get(struct snd_kcontrol *kcontrol, static int eqmode_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); unsigned int regpwr2, regpwr3; unsigned int reg_eq; diff --git a/sound/soc/codecs/wm8985.c b/sound/soc/codecs/wm8985.c index 5473dc969585..ad23ffb8346c 100644 --- a/sound/soc/codecs/wm8985.c +++ b/sound/soc/codecs/wm8985.c @@ -526,7 +526,7 @@ static const struct snd_soc_dapm_route wm8985_dapm_routes[] = { static int eqmode_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); unsigned int reg; reg = snd_soc_read(codec, WM8985_EQ1_LOW_SHELF); @@ -541,7 +541,7 @@ static int eqmode_get(struct snd_kcontrol *kcontrol, static int eqmode_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); unsigned int regpwr2, regpwr3; unsigned int reg_eq; diff --git a/sound/soc/codecs/wm8990.c b/sound/soc/codecs/wm8990.c index c413c1991453..b5c1f0f07058 100644 --- a/sound/soc/codecs/wm8990.c +++ b/sound/soc/codecs/wm8990.c @@ -132,7 +132,7 @@ static const DECLARE_TLV_DB_SCALE(out_sidetone_tlv, -3600, 0, 0); static int wm899x_outpga_put_volsw_vu(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value; int reg = mc->reg; diff --git a/sound/soc/codecs/wm8991.c b/sound/soc/codecs/wm8991.c index 844cc4a60d66..b8fd284fc0c0 100644 --- a/sound/soc/codecs/wm8991.c +++ b/sound/soc/codecs/wm8991.c @@ -154,7 +154,7 @@ static const unsigned int out_sidetone_tlv[] = { static int wm899x_outpga_put_volsw_vu(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); int reg = kcontrol->private_value & 0xff; int ret; u16 val; diff --git a/sound/soc/codecs/wm8994.c b/sound/soc/codecs/wm8994.c index 6303537f54c6..3eb390be7dee 100644 --- a/sound/soc/codecs/wm8994.c +++ b/sound/soc/codecs/wm8994.c @@ -298,7 +298,7 @@ static int wm8994_put_drc_sw(struct snd_kcontrol *kcontrol, { struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value; - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); int mask, ret; /* Can't enable both ADC and DAC paths simultaneously */ @@ -355,7 +355,7 @@ static int wm8994_get_drc(const char *name) static int wm8994_put_drc_enum(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); struct wm8994 *control = wm8994->wm8994; struct wm8994_pdata *pdata = &control->pdata; @@ -378,7 +378,7 @@ static int wm8994_put_drc_enum(struct snd_kcontrol *kcontrol, static int wm8994_get_drc_enum(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); int drc = wm8994_get_drc(kcontrol->id.name); @@ -462,7 +462,7 @@ static int wm8994_get_retune_mobile_block(const char *name) static int wm8994_put_retune_mobile_enum(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); struct wm8994 *control = wm8994->wm8994; struct wm8994_pdata *pdata = &control->pdata; @@ -485,7 +485,7 @@ static int wm8994_put_retune_mobile_enum(struct snd_kcontrol *kcontrol, static int wm8994_get_retune_mobile_enum(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); int block = wm8994_get_retune_mobile_block(kcontrol->id.name); diff --git a/sound/soc/codecs/wm8996.c b/sound/soc/codecs/wm8996.c index c6cbb3b8ace9..69266332760e 100644 --- a/sound/soc/codecs/wm8996.c +++ b/sound/soc/codecs/wm8996.c @@ -412,7 +412,7 @@ static int wm8996_get_retune_mobile_block(const char *name) static int wm8996_put_retune_mobile_enum(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct wm8996_priv *wm8996 = snd_soc_codec_get_drvdata(codec); struct wm8996_pdata *pdata = &wm8996->pdata; int block = wm8996_get_retune_mobile_block(kcontrol->id.name); @@ -434,7 +434,7 @@ static int wm8996_put_retune_mobile_enum(struct snd_kcontrol *kcontrol, static int wm8996_get_retune_mobile_enum(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct wm8996_priv *wm8996 = snd_soc_codec_get_drvdata(codec); int block = wm8996_get_retune_mobile_block(kcontrol->id.name); diff --git a/sound/soc/codecs/wm9081.c b/sound/soc/codecs/wm9081.c index d18eff31fbbc..185eb97769e7 100644 --- a/sound/soc/codecs/wm9081.c +++ b/sound/soc/codecs/wm9081.c @@ -340,7 +340,7 @@ static SOC_ENUM_SINGLE_DECL(speaker_mode, WM9081_ANALOGUE_SPEAKER_2, 6, static int speaker_mode_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); unsigned int reg; reg = snd_soc_read(codec, WM9081_ANALOGUE_SPEAKER_2); @@ -361,7 +361,7 @@ static int speaker_mode_get(struct snd_kcontrol *kcontrol, static int speaker_mode_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); unsigned int reg_pwr = snd_soc_read(codec, WM9081_POWER_MANAGEMENT); unsigned int reg2 = snd_soc_read(codec, WM9081_ANALOGUE_SPEAKER_2); diff --git a/sound/soc/codecs/wm_adsp.c b/sound/soc/codecs/wm_adsp.c index bb5f7b4e3ebb..d9686dcd024c 100644 --- a/sound/soc/codecs/wm_adsp.c +++ b/sound/soc/codecs/wm_adsp.c @@ -242,7 +242,7 @@ struct wm_coeff_ctl { static int wm_adsp_fw_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; struct wm_adsp *adsp = snd_soc_codec_get_drvdata(codec); @@ -254,7 +254,7 @@ static int wm_adsp_fw_get(struct snd_kcontrol *kcontrol, static int wm_adsp_fw_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; struct wm_adsp *adsp = snd_soc_codec_get_drvdata(codec); diff --git a/sound/soc/codecs/wm_hubs.c b/sound/soc/codecs/wm_hubs.c index b6209662ab13..916817fe6632 100644 --- a/sound/soc/codecs/wm_hubs.c +++ b/sound/soc/codecs/wm_hubs.c @@ -337,7 +337,7 @@ static void enable_dc_servo(struct snd_soc_codec *codec) static int wm8993_put_dc_servo(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct wm_hubs_data *hubs = snd_soc_codec_get_drvdata(codec); int ret; -- cgit v1.2.3 From f6272ff8a5f42c614f4a338013f5323979121e0f Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Tue, 18 Mar 2014 09:02:05 +0100 Subject: ASoC: Add snd_soc_kcontrol_platform() helper function For platform controls snd_kcontrol_chip() currently returns a pointer to the platform that registered the control. With the upcoming consolidation of platform and CODEC controls this will change. Prepare for this by introducing the snd_soc_kcontrol_platform() helper function that will hide the implementation details of how the platform for a control can be obtained. This will allow us to change this easily in the future. The patch also updates all platforms to use this new helper function. Signed-off-by: Lars-Peter Clausen Signed-off-by: Mark Brown --- include/sound/soc.h | 14 ++++++++++++++ sound/soc/intel/sst-haswell-pcm.c | 8 ++++---- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/include/sound/soc.h b/include/sound/soc.h index e150030b754d..14e7457e2347 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h @@ -1242,6 +1242,20 @@ static inline struct snd_soc_codec *snd_soc_kcontrol_codec( return snd_kcontrol_chip(kcontrol); } +/** + * snd_soc_kcontrol_platform() - Returns the platform that registerd the control + * @kcontrol: The control for which to get the platform + * + * Note: This function will only work correctly if the control has been + * registered with snd_soc_add_platform_controls() or via table based setup of + * a snd_soc_platform_driver. Otherwise the behavior is undefined. + */ +static inline struct snd_soc_codec *snd_soc_kcontrol_platform( + struct snd_kcontrol *kcontrol) +{ + return snd_kcontrol_chip(kcontrol); +} + int snd_soc_util_init(void); void snd_soc_util_exit(void); diff --git a/sound/soc/intel/sst-haswell-pcm.c b/sound/soc/intel/sst-haswell-pcm.c index 0a32dd13a23d..67a5eb3c6196 100644 --- a/sound/soc/intel/sst-haswell-pcm.c +++ b/sound/soc/intel/sst-haswell-pcm.c @@ -136,7 +136,7 @@ static inline unsigned int hsw_ipc_to_mixer(u32 value) static int hsw_stream_volume_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_platform *platform = snd_kcontrol_chip(kcontrol); + struct snd_soc_platform *platform = snd_soc_kcontrol_platform(kcontrol); struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value; struct hsw_priv_data *pdata = @@ -174,7 +174,7 @@ static int hsw_stream_volume_put(struct snd_kcontrol *kcontrol, static int hsw_stream_volume_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_platform *platform = snd_kcontrol_chip(kcontrol); + struct snd_soc_platform *platform = snd_soc_kcontrol_platform(kcontrol); struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value; struct hsw_priv_data *pdata = @@ -206,7 +206,7 @@ static int hsw_stream_volume_get(struct snd_kcontrol *kcontrol, static int hsw_volume_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_platform *platform = snd_kcontrol_chip(kcontrol); + struct snd_soc_platform *platform = snd_soc_kcontrol_platform(kcontrol); struct hsw_priv_data *pdata = snd_soc_platform_get_drvdata(platform); struct sst_hsw *hsw = pdata->hsw; u32 volume; @@ -231,7 +231,7 @@ static int hsw_volume_put(struct snd_kcontrol *kcontrol, static int hsw_volume_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_platform *platform = snd_kcontrol_chip(kcontrol); + struct snd_soc_platform *platform = snd_soc_kcontrol_platform(kcontrol); struct hsw_priv_data *pdata = snd_soc_platform_get_drvdata(platform); struct sst_hsw *hsw = pdata->hsw; unsigned int volume = 0; -- cgit v1.2.3 From 6137a5ca326dac848b35bcbdc44b2ff890273375 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Tue, 18 Mar 2014 09:02:06 +0100 Subject: ASoC: Prepare SOC_SINGLE_XR_SX controls for regmap SOC_SINGLE_XR_SX controls currently only work with CODECs that set the 'reg_word_size' field in their snd_soc_codec_driver struct. Going forward support for ASoC level IO will eventually be removed and all drivers will be converted to regmap. Preparing for the transition this patch adds support for CODECs using regmap for IO to the SOC_SINGLE_XR_SX control. We already have the val_bytes field in the CODEC struct which holds the number of bytes per word, but it is only initialized when regmap is used. Also initialize it for drivers still using legacy IO and update the SOC_SINGLE_XR_SX handlers to use it. Signed-off-by: Lars-Peter Clausen Signed-off-by: Mark Brown --- sound/soc/soc-core.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 051c006281f5..935c59418b19 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -3343,7 +3343,7 @@ int snd_soc_get_xr_sx(struct snd_kcontrol *kcontrol, struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); unsigned int regbase = mc->regbase; unsigned int regcount = mc->regcount; - unsigned int regwshift = codec->driver->reg_word_size * BITS_PER_BYTE; + unsigned int regwshift = codec->val_bytes * BITS_PER_BYTE; unsigned int regwmask = (1<invert; unsigned long mask = (1UL<nbits)-1; @@ -3389,7 +3389,7 @@ int snd_soc_put_xr_sx(struct snd_kcontrol *kcontrol, struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); unsigned int regbase = mc->regbase; unsigned int regcount = mc->regcount; - unsigned int regwshift = codec->driver->reg_word_size * BITS_PER_BYTE; + unsigned int regwshift = codec->val_bytes * BITS_PER_BYTE; unsigned int regwmask = (1<invert; unsigned long mask = (1UL<nbits)-1; @@ -4292,6 +4292,7 @@ int snd_soc_register_codec(struct device *dev, codec->dev = dev; codec->driver = codec_drv; codec->num_dai = num_dai; + codec->val_bytes = codec_drv->reg_word_size; mutex_init(&codec->mutex); for (i = 0; i < num_dai; i++) { -- cgit v1.2.3 From 96241c83293de346037b9a85e321f52ace210926 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Tue, 18 Mar 2014 09:02:07 +0100 Subject: ASoC: Move IO functions to soc-io.c soc-core.c is getting quite crowded. Move all IO related functions that are still in soc-core.c to soc-io.c Signed-off-by: Lars-Peter Clausen Signed-off-by: Mark Brown --- sound/soc/soc-core.c | 144 --------------------------------------------------- sound/soc/soc-io.c | 144 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 144 insertions(+), 144 deletions(-) diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 935c59418b19..5c0ed3931285 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -2033,38 +2033,6 @@ int snd_soc_codec_writable_register(struct snd_soc_codec *codec, } EXPORT_SYMBOL_GPL(snd_soc_codec_writable_register); -int snd_soc_platform_read(struct snd_soc_platform *platform, - unsigned int reg) -{ - unsigned int ret; - - if (!platform->driver->read) { - dev_err(platform->dev, "ASoC: platform has no read back\n"); - return -1; - } - - ret = platform->driver->read(platform, reg); - dev_dbg(platform->dev, "read %x => %x\n", reg, ret); - trace_snd_soc_preg_read(platform, reg, ret); - - return ret; -} -EXPORT_SYMBOL_GPL(snd_soc_platform_read); - -int snd_soc_platform_write(struct snd_soc_platform *platform, - unsigned int reg, unsigned int val) -{ - if (!platform->driver->write) { - dev_err(platform->dev, "ASoC: platform has no write back\n"); - return -1; - } - - dev_dbg(platform->dev, "write %x = %x\n", reg, val); - trace_snd_soc_preg_write(platform, reg, val); - return platform->driver->write(platform, reg, val); -} -EXPORT_SYMBOL_GPL(snd_soc_platform_write); - /** * snd_soc_new_ac97_codec - initailise AC97 device * @codec: audio codec @@ -2283,118 +2251,6 @@ void snd_soc_free_ac97_codec(struct snd_soc_codec *codec) } EXPORT_SYMBOL_GPL(snd_soc_free_ac97_codec); -unsigned int snd_soc_read(struct snd_soc_codec *codec, unsigned int reg) -{ - unsigned int ret; - - ret = codec->read(codec, reg); - dev_dbg(codec->dev, "read %x => %x\n", reg, ret); - trace_snd_soc_reg_read(codec, reg, ret); - - return ret; -} -EXPORT_SYMBOL_GPL(snd_soc_read); - -unsigned int snd_soc_write(struct snd_soc_codec *codec, - unsigned int reg, unsigned int val) -{ - dev_dbg(codec->dev, "write %x = %x\n", reg, val); - trace_snd_soc_reg_write(codec, reg, val); - return codec->write(codec, reg, val); -} -EXPORT_SYMBOL_GPL(snd_soc_write); - -/** - * snd_soc_update_bits - update codec register bits - * @codec: audio codec - * @reg: codec register - * @mask: register mask - * @value: new value - * - * Writes new register value. - * - * Returns 1 for change, 0 for no change, or negative error code. - */ -int snd_soc_update_bits(struct snd_soc_codec *codec, unsigned short reg, - unsigned int mask, unsigned int value) -{ - bool change; - unsigned int old, new; - int ret; - - if (codec->using_regmap) { - ret = regmap_update_bits_check(codec->control_data, reg, - mask, value, &change); - } else { - ret = snd_soc_read(codec, reg); - if (ret < 0) - return ret; - - old = ret; - new = (old & ~mask) | (value & mask); - change = old != new; - if (change) - ret = snd_soc_write(codec, reg, new); - } - - if (ret < 0) - return ret; - - return change; -} -EXPORT_SYMBOL_GPL(snd_soc_update_bits); - -/** - * snd_soc_update_bits_locked - update codec register bits - * @codec: audio codec - * @reg: codec register - * @mask: register mask - * @value: new value - * - * Writes new register value, and takes the codec mutex. - * - * Returns 1 for change else 0. - */ -int snd_soc_update_bits_locked(struct snd_soc_codec *codec, - unsigned short reg, unsigned int mask, - unsigned int value) -{ - int change; - - mutex_lock(&codec->mutex); - change = snd_soc_update_bits(codec, reg, mask, value); - mutex_unlock(&codec->mutex); - - return change; -} -EXPORT_SYMBOL_GPL(snd_soc_update_bits_locked); - -/** - * snd_soc_test_bits - test register for change - * @codec: audio codec - * @reg: codec register - * @mask: register mask - * @value: new value - * - * Tests a register with a new value and checks if the new value is - * different from the old value. - * - * Returns 1 for change else 0. - */ -int snd_soc_test_bits(struct snd_soc_codec *codec, unsigned short reg, - unsigned int mask, unsigned int value) -{ - int change; - unsigned int old, new; - - old = snd_soc_read(codec, reg); - new = (old & ~mask) | value; - change = old != new; - - return change; -} -EXPORT_SYMBOL_GPL(snd_soc_test_bits); - /** * snd_soc_cnew - create new control * @_template: control template diff --git a/sound/soc/soc-io.c b/sound/soc/soc-io.c index 260efc8466fc..bfd7206c178f 100644 --- a/sound/soc/soc-io.c +++ b/sound/soc/soc-io.c @@ -19,6 +19,150 @@ #include +unsigned int snd_soc_read(struct snd_soc_codec *codec, unsigned int reg) +{ + unsigned int ret; + + ret = codec->read(codec, reg); + dev_dbg(codec->dev, "read %x => %x\n", reg, ret); + trace_snd_soc_reg_read(codec, reg, ret); + + return ret; +} +EXPORT_SYMBOL_GPL(snd_soc_read); + +unsigned int snd_soc_write(struct snd_soc_codec *codec, + unsigned int reg, unsigned int val) +{ + dev_dbg(codec->dev, "write %x = %x\n", reg, val); + trace_snd_soc_reg_write(codec, reg, val); + return codec->write(codec, reg, val); +} +EXPORT_SYMBOL_GPL(snd_soc_write); + +/** + * snd_soc_update_bits - update codec register bits + * @codec: audio codec + * @reg: codec register + * @mask: register mask + * @value: new value + * + * Writes new register value. + * + * Returns 1 for change, 0 for no change, or negative error code. + */ +int snd_soc_update_bits(struct snd_soc_codec *codec, unsigned short reg, + unsigned int mask, unsigned int value) +{ + bool change; + unsigned int old, new; + int ret; + + if (codec->using_regmap) { + ret = regmap_update_bits_check(codec->control_data, reg, + mask, value, &change); + } else { + ret = snd_soc_read(codec, reg); + if (ret < 0) + return ret; + + old = ret; + new = (old & ~mask) | (value & mask); + change = old != new; + if (change) + ret = snd_soc_write(codec, reg, new); + } + + if (ret < 0) + return ret; + + return change; +} +EXPORT_SYMBOL_GPL(snd_soc_update_bits); + +/** + * snd_soc_update_bits_locked - update codec register bits + * @codec: audio codec + * @reg: codec register + * @mask: register mask + * @value: new value + * + * Writes new register value, and takes the codec mutex. + * + * Returns 1 for change else 0. + */ +int snd_soc_update_bits_locked(struct snd_soc_codec *codec, + unsigned short reg, unsigned int mask, + unsigned int value) +{ + int change; + + mutex_lock(&codec->mutex); + change = snd_soc_update_bits(codec, reg, mask, value); + mutex_unlock(&codec->mutex); + + return change; +} +EXPORT_SYMBOL_GPL(snd_soc_update_bits_locked); + +/** + * snd_soc_test_bits - test register for change + * @codec: audio codec + * @reg: codec register + * @mask: register mask + * @value: new value + * + * Tests a register with a new value and checks if the new value is + * different from the old value. + * + * Returns 1 for change else 0. + */ +int snd_soc_test_bits(struct snd_soc_codec *codec, unsigned short reg, + unsigned int mask, unsigned int value) +{ + int change; + unsigned int old, new; + + old = snd_soc_read(codec, reg); + new = (old & ~mask) | value; + change = old != new; + + return change; +} +EXPORT_SYMBOL_GPL(snd_soc_test_bits); + +int snd_soc_platform_read(struct snd_soc_platform *platform, + unsigned int reg) +{ + unsigned int ret; + + if (!platform->driver->read) { + dev_err(platform->dev, "ASoC: platform has no read back\n"); + return -1; + } + + ret = platform->driver->read(platform, reg); + dev_dbg(platform->dev, "read %x => %x\n", reg, ret); + trace_snd_soc_preg_read(platform, reg, ret); + + return ret; +} +EXPORT_SYMBOL_GPL(snd_soc_platform_read); + +int snd_soc_platform_write(struct snd_soc_platform *platform, + unsigned int reg, unsigned int val) +{ + if (!platform->driver->write) { + dev_err(platform->dev, "ASoC: platform has no write back\n"); + return -1; + } + + dev_dbg(platform->dev, "write %x = %x\n", reg, val); + trace_snd_soc_preg_write(platform, reg, val); + return platform->driver->write(platform, reg, val); +} +EXPORT_SYMBOL_GPL(snd_soc_platform_write); + #ifdef CONFIG_REGMAP static int hw_write(struct snd_soc_codec *codec, unsigned int reg, unsigned int value) -- cgit v1.2.3 From 20a0ec27ea11af0251ffeb5ee2b96cc5c72cb517 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Tue, 18 Mar 2014 09:02:09 +0100 Subject: ASoC: Remove IO register modifier callbacks There are no ASoC drivers left that use them and new drivers are supposed to use regmap for this. Signed-off-by: Lars-Peter Clausen Signed-off-by: Mark Brown --- include/sound/soc.h | 14 --------- sound/soc/soc-cache.c | 2 -- sound/soc/soc-core.c | 80 ++++++--------------------------------------------- 3 files changed, 8 insertions(+), 88 deletions(-) diff --git a/include/sound/soc.h b/include/sound/soc.h index 14e7457e2347..a355d0f9a6f9 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h @@ -393,12 +393,6 @@ int devm_snd_soc_register_component(struct device *dev, const struct snd_soc_component_driver *cmpnt_drv, struct snd_soc_dai_driver *dai_drv, int num_dai); void snd_soc_unregister_component(struct device *dev); -int snd_soc_codec_volatile_register(struct snd_soc_codec *codec, - unsigned int reg); -int snd_soc_codec_readable_register(struct snd_soc_codec *codec, - unsigned int reg); -int snd_soc_codec_writable_register(struct snd_soc_codec *codec, - unsigned int reg); int snd_soc_codec_set_cache_io(struct snd_soc_codec *codec, struct regmap *regmap); int snd_soc_cache_sync(struct snd_soc_codec *codec); @@ -692,9 +686,6 @@ struct snd_soc_codec { struct list_head list; struct list_head card_list; int num_dai; - int (*volatile_register)(struct snd_soc_codec *, unsigned int); - int (*readable_register)(struct snd_soc_codec *, unsigned int); - int (*writable_register)(struct snd_soc_codec *, unsigned int); /* runtime */ struct snd_ac97 *ac97; /* for ad-hoc ac97 devices */ @@ -756,11 +747,6 @@ struct snd_soc_codec_driver { /* codec IO */ unsigned int (*read)(struct snd_soc_codec *, unsigned int); int (*write)(struct snd_soc_codec *, unsigned int, unsigned int); - int (*display_register)(struct snd_soc_codec *, char *, - size_t, unsigned int); - int (*volatile_register)(struct snd_soc_codec *, unsigned int); - int (*readable_register)(struct snd_soc_codec *, unsigned int); - int (*writable_register)(struct snd_soc_codec *, unsigned int); unsigned int reg_cache_size; short reg_cache_step; short reg_word_size; diff --git a/sound/soc/soc-cache.c b/sound/soc/soc-cache.c index bfed3e4c45ff..3fa77d5f9b75 100644 --- a/sound/soc/soc-cache.c +++ b/sound/soc/soc-cache.c @@ -162,8 +162,6 @@ static int snd_soc_flat_cache_sync(struct snd_soc_codec *codec) i, codec_drv->reg_word_size) == val) continue; - WARN_ON(!snd_soc_codec_writable_register(codec, i)); - ret = snd_soc_write(codec, i, val); if (ret) return ret; diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 5c0ed3931285..41bd24348520 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -154,22 +154,15 @@ static ssize_t soc_codec_reg_show(struct snd_soc_codec *codec, char *buf, step = codec->driver->reg_cache_step; for (i = 0; i < codec->driver->reg_cache_size; i += step) { - if (!snd_soc_codec_readable_register(codec, i)) - continue; - if (codec->driver->display_register) { - count += codec->driver->display_register(codec, buf + count, - PAGE_SIZE - count, i); - } else { - /* only support larger than PAGE_SIZE bytes debugfs - * entries for the default case */ - if (p >= pos) { - if (total + len >= count - 1) - break; - format_register_str(codec, i, buf + total, len); - total += len; - } - p += len; + /* only support larger than PAGE_SIZE bytes debugfs + * entries for the default case */ + if (p >= pos) { + if (total + len >= count - 1) + break; + format_register_str(codec, i, buf + total, len); + total += len; } + p += len; } total = min(total, count - 1); @@ -1979,60 +1972,6 @@ static struct platform_driver soc_driver = { .remove = soc_remove, }; -/** - * snd_soc_codec_volatile_register: Report if a register is volatile. - * - * @codec: CODEC to query. - * @reg: Register to query. - * - * Boolean function indiciating if a CODEC register is volatile. - */ -int snd_soc_codec_volatile_register(struct snd_soc_codec *codec, - unsigned int reg) -{ - if (codec->volatile_register) - return codec->volatile_register(codec, reg); - else - return 0; -} -EXPORT_SYMBOL_GPL(snd_soc_codec_volatile_register); - -/** - * snd_soc_codec_readable_register: Report if a register is readable. - * - * @codec: CODEC to query. - * @reg: Register to query. - * - * Boolean function indicating if a CODEC register is readable. - */ -int snd_soc_codec_readable_register(struct snd_soc_codec *codec, - unsigned int reg) -{ - if (codec->readable_register) - return codec->readable_register(codec, reg); - else - return 1; -} -EXPORT_SYMBOL_GPL(snd_soc_codec_readable_register); - -/** - * snd_soc_codec_writable_register: Report if a register is writable. - * - * @codec: CODEC to query. - * @reg: Register to query. - * - * Boolean function indicating if a CODEC register is writable. - */ -int snd_soc_codec_writable_register(struct snd_soc_codec *codec, - unsigned int reg) -{ - if (codec->writable_register) - return codec->writable_register(codec, reg); - else - return 1; -} -EXPORT_SYMBOL_GPL(snd_soc_codec_writable_register); - /** * snd_soc_new_ac97_codec - initailise AC97 device * @codec: audio codec @@ -4136,9 +4075,6 @@ int snd_soc_register_codec(struct device *dev, codec->write = codec_drv->write; codec->read = codec_drv->read; - codec->volatile_register = codec_drv->volatile_register; - codec->readable_register = codec_drv->readable_register; - codec->writable_register = codec_drv->writable_register; codec->component.ignore_pmdown_time = codec_drv->ignore_pmdown_time; codec->dapm.bias_level = SND_SOC_BIAS_OFF; codec->dapm.dev = dev; -- cgit v1.2.3 From 98e639fb8a3ed1bf2bd512626c3cfc2992a57113 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Tue, 18 Mar 2014 09:02:11 +0100 Subject: ASoC: Track which components have been registered with snd_soc_register_component() snd_soc_unregister_component() takes the parent device of the component as a parameter and then looks up the component based on this. This is a problem if multiple components are registered for the same parent device. Currently drivers do not do this, but some drivers register a CPU DAI component and a platform for the same parent device. This will become a problem once platforms are also made components. To make sure that snd_soc_unregister_component() will not accidentally unregister the platform in such a case only consider components that were registered with snd_soc_register_component(). This is only meant as short term stopgap solution to be able to continue componentisation. Long term we'll need something different. Signed-off-by: Lars-Peter Clausen Signed-off-by: Mark Brown --- include/sound/soc.h | 1 + sound/soc/soc-core.c | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/include/sound/soc.h b/include/sound/soc.h index a355d0f9a6f9..f8a79c17628e 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h @@ -662,6 +662,7 @@ struct snd_soc_component { unsigned int active; unsigned int ignore_pmdown_time:1; /* pmdown_time is ignored at stop */ + unsigned int registered_as_component:1; struct list_head list; diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 41bd24348520..3314efb365e3 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -3879,6 +3879,7 @@ int snd_soc_register_component(struct device *dev, } cmpnt->ignore_pmdown_time = true; + cmpnt->registered_as_component = true; return __snd_soc_register_component(dev, cmpnt, cmpnt_drv, NULL, dai_drv, num_dai, true); @@ -3894,7 +3895,7 @@ void snd_soc_unregister_component(struct device *dev) struct snd_soc_component *cmpnt; list_for_each_entry(cmpnt, &component_list, list) { - if (dev == cmpnt->dev) + if (dev == cmpnt->dev && cmpnt->registered_as_component) goto found; } return; -- cgit v1.2.3 From b37f1d123c69c0d7730704d65b83eaac780c0e3b Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Tue, 18 Mar 2014 09:02:12 +0100 Subject: ASoC: Let snd_soc_platform subclass snd_soc_component There is an increasing amount of code that is very similar between platforms, CODECS and other components. Making platforms a component will allow us to share this code. For now the patch just adds component and component_driver fields to the platform and platform_driver structs and registers the platform as a component. Followup patches will be used to consolidate code between the different types of components. Signed-off-by: Lars-Peter Clausen Signed-off-by: Mark Brown --- include/sound/soc.h | 16 ++++++++++++++++ sound/soc/soc-core.c | 14 ++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/include/sound/soc.h b/include/sound/soc.h index f8a79c17628e..94a2dc20ad6e 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h @@ -778,6 +778,7 @@ struct snd_soc_platform_driver { int (*remove)(struct snd_soc_platform *); int (*suspend)(struct snd_soc_dai *dai); int (*resume)(struct snd_soc_dai *dai); + struct snd_soc_component_driver component_driver; /* pcm creation and destruction */ int (*pcm_new)(struct snd_soc_pcm_runtime *); @@ -831,6 +832,8 @@ struct snd_soc_platform { struct list_head list; struct list_head card_list; + struct snd_soc_component component; + struct snd_soc_dapm_context dapm; #ifdef CONFIG_DEBUG_FS @@ -1107,6 +1110,19 @@ static inline struct snd_soc_codec *snd_soc_component_to_codec( return container_of(component, struct snd_soc_codec, component); } +/** + * snd_soc_component_to_platform() - Casts a component to the platform it is embedded in + * @component: The component to cast to a platform + * + * This function must only be used on components that are known to be platforms. + * Otherwise the behavior is undefined. + */ +static inline struct snd_soc_platform *snd_soc_component_to_platform( + struct snd_soc_component *component) +{ + return container_of(component, struct snd_soc_platform, component); +} + /* codec IO */ unsigned int snd_soc_read(struct snd_soc_codec *codec, unsigned int reg); unsigned int snd_soc_write(struct snd_soc_codec *codec, diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 3314efb365e3..a95c7e524dfc 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -3921,6 +3921,8 @@ EXPORT_SYMBOL_GPL(snd_soc_unregister_component); int snd_soc_add_platform(struct device *dev, struct snd_soc_platform *platform, const struct snd_soc_platform_driver *platform_drv) { + int ret; + /* create platform component name */ platform->name = fmt_single_name(dev, &platform->id); if (platform->name == NULL) @@ -3933,6 +3935,16 @@ int snd_soc_add_platform(struct device *dev, struct snd_soc_platform *platform, platform->dapm.stream_event = platform_drv->stream_event; mutex_init(&platform->mutex); + /* register component */ + ret = __snd_soc_register_component(dev, &platform->component, + &platform_drv->component_driver, + NULL, NULL, 0, false); + if (ret < 0) { + dev_err(platform->component.dev, + "ASoC: Failed to register component: %d\n", ret); + return ret; + } + mutex_lock(&client_mutex); list_add(&platform->list, &platform_list); mutex_unlock(&client_mutex); @@ -3974,6 +3986,8 @@ EXPORT_SYMBOL_GPL(snd_soc_register_platform); */ void snd_soc_remove_platform(struct snd_soc_platform *platform) { + snd_soc_unregister_component(platform->dev); + mutex_lock(&client_mutex); list_del(&platform->list); mutex_unlock(&client_mutex); -- cgit v1.2.3 From 261edc7013a7435e40fd5ebb3682eac6fc3c15ea Mon Sep 17 00:00:00 2001 From: Nariman Poushin Date: Mon, 31 Mar 2014 15:47:12 +0100 Subject: ASoC: core: Fail probe if we fail to add dai widgets Signed-off-by: Nariman Poushin Signed-off-by: Mark Brown --- sound/soc/soc-core.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 051c006281f5..d5710fc79b49 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -1132,8 +1132,15 @@ static int soc_probe_codec(struct snd_soc_card *card, driver->num_dapm_widgets); /* Create DAPM widgets for each DAI stream */ - list_for_each_entry(dai, &codec->component.dai_list, list) - snd_soc_dapm_new_dai_widgets(&codec->dapm, dai); + list_for_each_entry(dai, &codec->component.dai_list, list) { + ret = snd_soc_dapm_new_dai_widgets(&codec->dapm, dai); + + if (ret != 0) { + dev_err(codec->dev, + "Failed to create DAI widgets %d\n", ret); + goto err_probe; + } + } codec->dapm.idle_bias_off = driver->idle_bias_off; -- cgit v1.2.3 From b318ad503698160183fe5e0752b9a1bb3e558026 Mon Sep 17 00:00:00 2001 From: Nariman Poushin Date: Tue, 1 Apr 2014 13:59:33 +0100 Subject: ASoC: core: Fail codec probe if we fail to add controls Signed-off-by: Nariman Poushin Signed-off-by: Mark Brown --- sound/soc/soc-core.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index d5710fc79b49..777453158347 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -1127,9 +1127,17 @@ static int soc_probe_codec(struct snd_soc_card *card, soc_init_codec_debugfs(codec); - if (driver->dapm_widgets) - snd_soc_dapm_new_controls(&codec->dapm, driver->dapm_widgets, - driver->num_dapm_widgets); + if (driver->dapm_widgets) { + ret = snd_soc_dapm_new_controls(&codec->dapm, + driver->dapm_widgets, + driver->num_dapm_widgets); + + if (ret != 0) { + dev_err(codec->dev, + "Failed to create new controls %d\n", ret); + goto err_probe; + } + } /* Create DAPM widgets for each DAI stream */ list_for_each_entry(dai, &codec->component.dai_list, list) { -- cgit v1.2.3 From 1a39019e939f620f39a1b914231ab6ba9013b208 Mon Sep 17 00:00:00 2001 From: Bard Liao Date: Tue, 8 Apr 2014 11:18:10 +0800 Subject: ASoC: core: Allow snd_soc_update_bits use 32 bits register Change reg's type from unsigned short to unsigned int. So that we can use 32 bits reg value in snd_soc_update_bits. Signed-off-by: Bard Liao Signed-off-by: Mark Brown --- include/sound/soc.h | 6 +++--- sound/soc/soc-core.c | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/include/sound/soc.h b/include/sound/soc.h index 0b83168d8ff4..4ed706bf11d1 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h @@ -469,12 +469,12 @@ static inline void snd_soc_jack_free_gpios(struct snd_soc_jack *jack, int count, #endif /* codec register bit access */ -int snd_soc_update_bits(struct snd_soc_codec *codec, unsigned short reg, +int snd_soc_update_bits(struct snd_soc_codec *codec, unsigned int reg, unsigned int mask, unsigned int value); int snd_soc_update_bits_locked(struct snd_soc_codec *codec, - unsigned short reg, unsigned int mask, + unsigned int reg, unsigned int mask, unsigned int value); -int snd_soc_test_bits(struct snd_soc_codec *codec, unsigned short reg, +int snd_soc_test_bits(struct snd_soc_codec *codec, unsigned int reg, unsigned int mask, unsigned int value); int snd_soc_new_ac97_codec(struct snd_soc_codec *codec, diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 777453158347..7f0a9297e420 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -2330,7 +2330,7 @@ EXPORT_SYMBOL_GPL(snd_soc_write); * * Returns 1 for change, 0 for no change, or negative error code. */ -int snd_soc_update_bits(struct snd_soc_codec *codec, unsigned short reg, +int snd_soc_update_bits(struct snd_soc_codec *codec, unsigned int reg, unsigned int mask, unsigned int value) { bool change; @@ -2371,7 +2371,7 @@ EXPORT_SYMBOL_GPL(snd_soc_update_bits); * Returns 1 for change else 0. */ int snd_soc_update_bits_locked(struct snd_soc_codec *codec, - unsigned short reg, unsigned int mask, + unsigned int reg, unsigned int mask, unsigned int value) { int change; @@ -2396,7 +2396,7 @@ EXPORT_SYMBOL_GPL(snd_soc_update_bits_locked); * * Returns 1 for change else 0. */ -int snd_soc_test_bits(struct snd_soc_codec *codec, unsigned short reg, +int snd_soc_test_bits(struct snd_soc_codec *codec, unsigned int reg, unsigned int mask, unsigned int value) { int change; @@ -2911,7 +2911,7 @@ int snd_soc_put_volsw_sx(struct snd_kcontrol *kcontrol, int min = mc->min; int mask = (1 << (fls(min + max) - 1)) - 1; int err = 0; - unsigned short val, val_mask, val2 = 0; + unsigned int val, val_mask, val2 = 0; val_mask = mask << shift; val = (ucontrol->value.integer.value[0] + min) & mask; -- cgit v1.2.3 From 1a95d8d09ef7e40563afd587cce52868e3d076a0 Mon Sep 17 00:00:00 2001 From: Peter Ujfalusi Date: Tue, 18 Mar 2014 15:20:37 +0200 Subject: ASoC: davinci-pcm: Add empty functions for !CONFIG_SND_DAVINCI_SOC builds To save drivers using davinci-pcm and edma-pcm the need to fiddle with !CONFIG_SND_DAVINCI_SOC in their code. Signed-off-by: Peter Ujfalusi Signed-off-by: Mark Brown --- sound/soc/davinci/davinci-pcm.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/sound/soc/davinci/davinci-pcm.h b/sound/soc/davinci/davinci-pcm.h index fbb710c76c08..5fd4737ab398 100644 --- a/sound/soc/davinci/davinci-pcm.h +++ b/sound/soc/davinci/davinci-pcm.h @@ -29,7 +29,17 @@ struct davinci_pcm_dma_params { unsigned int fifo_level; }; +#if IS_ENABLED(CONFIG_SND_DAVINCI_SOC) int davinci_soc_platform_register(struct device *dev); void davinci_soc_platform_unregister(struct device *dev); +#else +static inline int davinci_soc_platform_register(struct device *dev) +{ + return 0; +} +static inline void davinci_soc_platform_unregister(struct device *dev) +{ +} +#endif /* CONFIG_SND_DAVINCI_SOC */ #endif -- cgit v1.2.3 From d5902f693698076e5bda44cbfa999e9c02bb83ab Mon Sep 17 00:00:00 2001 From: Peter Ujfalusi Date: Tue, 1 Apr 2014 15:55:07 +0300 Subject: ASoC: davinci-mcasp: Assign the dma_data earlier in dai_probe callback Set up the playback_dma_data/capture_dma_data for the dai at probe time since the generic dmaengine PCM stack needs to have access to this information early. Signed-off-by: Peter Ujfalusi Signed-off-by: Mark Brown --- sound/soc/davinci/davinci-mcasp.c | 36 +++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/sound/soc/davinci/davinci-mcasp.c b/sound/soc/davinci/davinci-mcasp.c index 4f75cac462d1..b4c5cf58b030 100644 --- a/sound/soc/davinci/davinci-mcasp.c +++ b/sound/soc/davinci/davinci-mcasp.c @@ -716,22 +716,7 @@ static int davinci_mcasp_trigger(struct snd_pcm_substream *substream, return ret; } -static int davinci_mcasp_startup(struct snd_pcm_substream *substream, - struct snd_soc_dai *dai) -{ - struct davinci_mcasp *mcasp = snd_soc_dai_get_drvdata(dai); - - if (mcasp->version == MCASP_VERSION_4) - snd_soc_dai_set_dma_data(dai, substream, - &mcasp->dma_data[substream->stream]); - else - snd_soc_dai_set_dma_data(dai, substream, mcasp->dma_params); - - return 0; -} - static const struct snd_soc_dai_ops davinci_mcasp_dai_ops = { - .startup = davinci_mcasp_startup, .trigger = davinci_mcasp_trigger, .hw_params = davinci_mcasp_hw_params, .set_fmt = davinci_mcasp_set_dai_fmt, @@ -739,6 +724,25 @@ static const struct snd_soc_dai_ops davinci_mcasp_dai_ops = { .set_sysclk = davinci_mcasp_set_sysclk, }; +static int davinci_mcasp_dai_probe(struct snd_soc_dai *dai) +{ + struct davinci_mcasp *mcasp = snd_soc_dai_get_drvdata(dai); + + if (mcasp->version == MCASP_VERSION_4) { + /* Using dmaengine PCM */ + dai->playback_dma_data = + &mcasp->dma_data[SNDRV_PCM_STREAM_PLAYBACK]; + dai->capture_dma_data = + &mcasp->dma_data[SNDRV_PCM_STREAM_CAPTURE]; + } else { + /* Using davinci-pcm */ + dai->playback_dma_data = mcasp->dma_params; + dai->capture_dma_data = mcasp->dma_params; + } + + return 0; +} + #ifdef CONFIG_PM_SLEEP static int davinci_mcasp_suspend(struct snd_soc_dai *dai) { @@ -792,6 +796,7 @@ static int davinci_mcasp_resume(struct snd_soc_dai *dai) static struct snd_soc_dai_driver davinci_mcasp_dai[] = { { .name = "davinci-mcasp.0", + .probe = davinci_mcasp_dai_probe, .suspend = davinci_mcasp_suspend, .resume = davinci_mcasp_resume, .playback = { @@ -811,6 +816,7 @@ static struct snd_soc_dai_driver davinci_mcasp_dai[] = { }, { .name = "davinci-mcasp.1", + .probe = davinci_mcasp_dai_probe, .playback = { .channels_min = 1, .channels_max = 384, -- cgit v1.2.3 From f5b02b4a2cb7eaa223ddaba8e4338b31bcdaf369 Mon Sep 17 00:00:00 2001 From: Peter Ujfalusi Date: Tue, 1 Apr 2014 15:55:08 +0300 Subject: ASoC: davinci-mcasp: Fix debug typo in davinci_mcasp_hw_params() requred -> required Signed-off-by: Peter Ujfalusi Signed-off-by: Mark Brown --- sound/soc/davinci/davinci-mcasp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/soc/davinci/davinci-mcasp.c b/sound/soc/davinci/davinci-mcasp.c index b4c5cf58b030..eb46dc69248f 100644 --- a/sound/soc/davinci/davinci-mcasp.c +++ b/sound/soc/davinci/davinci-mcasp.c @@ -620,7 +620,7 @@ static int davinci_mcasp_hw_params(struct snd_pcm_substream *substream, if (mcasp->bclk_master) { unsigned int bclk_freq = snd_soc_params_to_bclk(params); if (mcasp->sysclk_freq % bclk_freq != 0) { - dev_err(mcasp->dev, "Can't produce requred BCLK\n"); + dev_err(mcasp->dev, "Can't produce required BCLK\n"); return -EINVAL; } davinci_mcasp_set_clkdiv( -- cgit v1.2.3 From 0bf0e8aeceaf4b12524559fce9c6b91a90b63381 Mon Sep 17 00:00:00 2001 From: Peter Ujfalusi Date: Tue, 1 Apr 2014 15:55:09 +0300 Subject: ASoC: davinci-mcasp: Simplify and clean up the AFIFO configuration code We can have more linear code flow by using variables in mcasp_common_hw_param() related to the AFIFO configuration. Signed-off-by: Peter Ujfalusi Signed-off-by: Mark Brown --- sound/soc/davinci/davinci-mcasp.c | 48 +++++++++++++++++++-------------------- sound/soc/davinci/davinci-mcasp.h | 1 + 2 files changed, 25 insertions(+), 24 deletions(-) diff --git a/sound/soc/davinci/davinci-mcasp.c b/sound/soc/davinci/davinci-mcasp.c index eb46dc69248f..aa063a4e7b0c 100644 --- a/sound/soc/davinci/davinci-mcasp.c +++ b/sound/soc/davinci/davinci-mcasp.c @@ -37,6 +37,8 @@ #include "davinci-pcm.h" #include "davinci-mcasp.h" +#define MCASP_MAX_AFIFO_DEPTH 64 + struct davinci_mcasp_context { u32 txfmtctl; u32 rxfmtctl; @@ -469,9 +471,9 @@ static int mcasp_common_hw_param(struct davinci_mcasp *mcasp, int stream, int i; u8 tx_ser = 0; u8 rx_ser = 0; - u8 ser; u8 slots = mcasp->tdm_slots; u8 max_active_serializers = (channels + slots - 1) / slots; + u8 active_serializers, numevt; u32 reg; /* Default configuration */ if (mcasp->version != MCASP_VERSION_4) @@ -505,36 +507,34 @@ static int mcasp_common_hw_param(struct davinci_mcasp *mcasp, int stream, } } - if (stream == SNDRV_PCM_STREAM_PLAYBACK) - ser = tx_ser; - else - ser = rx_ser; + if (stream == SNDRV_PCM_STREAM_PLAYBACK) { + active_serializers = tx_ser; + numevt = mcasp->txnumevt; + reg = mcasp->fifo_base + MCASP_WFIFOCTL_OFFSET; + } else { + active_serializers = rx_ser; + numevt = mcasp->rxnumevt; + reg = mcasp->fifo_base + MCASP_RFIFOCTL_OFFSET; + } - if (ser < max_active_serializers) { + if (active_serializers < max_active_serializers) { dev_warn(mcasp->dev, "stream has more channels (%d) than are " - "enabled in mcasp (%d)\n", channels, ser * slots); + "enabled in mcasp (%d)\n", channels, + active_serializers * slots); return -EINVAL; } - if (mcasp->txnumevt && stream == SNDRV_PCM_STREAM_PLAYBACK) { - if (mcasp->txnumevt * tx_ser > 64) - mcasp->txnumevt = 1; - - reg = mcasp->fifo_base + MCASP_WFIFOCTL_OFFSET; - mcasp_mod_bits(mcasp, reg, tx_ser, NUMDMA_MASK); - mcasp_mod_bits(mcasp, reg, ((mcasp->txnumevt * tx_ser) << 8), - NUMEVT_MASK); - } + /* AFIFO is not in use */ + if (!numevt) + return 0; - if (mcasp->rxnumevt && stream == SNDRV_PCM_STREAM_CAPTURE) { - if (mcasp->rxnumevt * rx_ser > 64) - mcasp->rxnumevt = 1; + if (numevt * active_serializers > MCASP_MAX_AFIFO_DEPTH) + numevt = active_serializers; - reg = mcasp->fifo_base + MCASP_RFIFOCTL_OFFSET; - mcasp_mod_bits(mcasp, reg, rx_ser, NUMDMA_MASK); - mcasp_mod_bits(mcasp, reg, ((mcasp->rxnumevt * rx_ser) << 8), - NUMEVT_MASK); - } + /* Configure the AFIFO */ + numevt *= active_serializers; + mcasp_mod_bits(mcasp, reg, active_serializers, NUMDMA_MASK); + mcasp_mod_bits(mcasp, reg, NUMEVT(numevt), NUMEVT_MASK); return 0; } diff --git a/sound/soc/davinci/davinci-mcasp.h b/sound/soc/davinci/davinci-mcasp.h index 8fed757d6087..98fbc451892a 100644 --- a/sound/soc/davinci/davinci-mcasp.h +++ b/sound/soc/davinci/davinci-mcasp.h @@ -283,6 +283,7 @@ */ #define FIFO_ENABLE BIT(16) #define NUMEVT_MASK (0xFF << 8) +#define NUMEVT(x) (((x) & 0xFF) << 8) #define NUMDMA_MASK (0xFF) #endif /* DAVINCI_MCASP_H */ -- cgit v1.2.3 From 5f04c603a52d4951e6f6b2f059049e7c5ee93db7 Mon Sep 17 00:00:00 2001 From: Peter Ujfalusi Date: Tue, 1 Apr 2014 15:55:10 +0300 Subject: ASoC: davinci-mcasp: Configure the AFIFO and DMA burst size at the same place Move the dma_params->fifo_level and dma_data->maxburst configuration to the mcasp_common_hw_param() function where we configure the AFIFO registers. It makes the code regarding to AFIFO and DMA configuration more easy to follow since it is now clear how the AFIFO and how the DMA is going to be configured. Previously this has been done in two functions using a bit different calculation form - which ended up with the same result in both case at the end, but it was confusing. Signed-off-by: Peter Ujfalusi Signed-off-by: Mark Brown --- sound/soc/davinci/davinci-mcasp.c | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/sound/soc/davinci/davinci-mcasp.c b/sound/soc/davinci/davinci-mcasp.c index aa063a4e7b0c..ab4fa1291795 100644 --- a/sound/soc/davinci/davinci-mcasp.c +++ b/sound/soc/davinci/davinci-mcasp.c @@ -468,6 +468,8 @@ static int davinci_config_channel_size(struct davinci_mcasp *mcasp, static int mcasp_common_hw_param(struct davinci_mcasp *mcasp, int stream, int channels) { + struct davinci_pcm_dma_params *dma_params = &mcasp->dma_params[stream]; + struct snd_dmaengine_dai_dma_data *dma_data = &mcasp->dma_data[stream]; int i; u8 tx_ser = 0; u8 rx_ser = 0; @@ -524,9 +526,14 @@ static int mcasp_common_hw_param(struct davinci_mcasp *mcasp, int stream, return -EINVAL; } + /* AFIFO is not in use */ - if (!numevt) + if (!numevt) { + /* Configure the burst size for platform drivers */ + dma_params->fifo_level = 0; + dma_data->maxburst = 0; return 0; + } if (numevt * active_serializers > MCASP_MAX_AFIFO_DEPTH) numevt = active_serializers; @@ -536,6 +543,10 @@ static int mcasp_common_hw_param(struct davinci_mcasp *mcasp, int stream, mcasp_mod_bits(mcasp, reg, active_serializers, NUMDMA_MASK); mcasp_mod_bits(mcasp, reg, NUMEVT(numevt), NUMEVT_MASK); + /* Configure the burst size for platform drivers */ + dma_params->fifo_level = numevt; + dma_data->maxburst = numevt; + return 0; } @@ -607,12 +618,7 @@ static int davinci_mcasp_hw_params(struct snd_pcm_substream *substream, struct davinci_mcasp *mcasp = snd_soc_dai_get_drvdata(cpu_dai); struct davinci_pcm_dma_params *dma_params = &mcasp->dma_params[substream->stream]; - struct snd_dmaengine_dai_dma_data *dma_data = - &mcasp->dma_data[substream->stream]; int word_length; - u8 fifo_level; - u8 slots = mcasp->tdm_slots; - u8 active_serializers; int channels = params_channels(params); int ret; @@ -671,21 +677,11 @@ static int davinci_mcasp_hw_params(struct snd_pcm_substream *substream, return -EINVAL; } - /* Calculate FIFO level */ - active_serializers = (channels + slots - 1) / slots; - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) - fifo_level = mcasp->txnumevt * active_serializers; - else - fifo_level = mcasp->rxnumevt * active_serializers; - - if (mcasp->version == MCASP_VERSION_2 && !fifo_level) + if (mcasp->version == MCASP_VERSION_2 && !dma_params->fifo_level) dma_params->acnt = 4; else dma_params->acnt = dma_params->data_type; - dma_params->fifo_level = fifo_level; - dma_data->maxburst = fifo_level; - davinci_config_channel_size(mcasp, word_length); return 0; -- cgit v1.2.3 From dd093a0f1962fb71e8852411f03fec7290027a90 Mon Sep 17 00:00:00 2001 From: Peter Ujfalusi Date: Tue, 1 Apr 2014 15:55:11 +0300 Subject: ASoC: davinic-mcasp: Adopt the AFIFO/DMA configuration to the stream (dynamic depth) Configure the AFIFO numevt parameter based on the requested tx/rx_numevt, active serializers and period size in words. In this way McASP can adopt it's (and the DMA) configuration runtime and can pick the most optimal setup which satisfy the parameters. This way we do not need to place any constraint on the stream itself, allowing application greater freedom on how they want to set up ALSA. Signed-off-by: Peter Ujfalusi Signed-off-by: Mark Brown --- sound/soc/davinci/davinci-mcasp.c | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/sound/soc/davinci/davinci-mcasp.c b/sound/soc/davinci/davinci-mcasp.c index ab4fa1291795..9454d123f4bb 100644 --- a/sound/soc/davinci/davinci-mcasp.c +++ b/sound/soc/davinci/davinci-mcasp.c @@ -466,7 +466,7 @@ static int davinci_config_channel_size(struct davinci_mcasp *mcasp, } static int mcasp_common_hw_param(struct davinci_mcasp *mcasp, int stream, - int channels) + int period_words, int channels) { struct davinci_pcm_dma_params *dma_params = &mcasp->dma_params[stream]; struct snd_dmaengine_dai_dma_data *dma_data = &mcasp->dma_data[stream]; @@ -475,7 +475,7 @@ static int mcasp_common_hw_param(struct davinci_mcasp *mcasp, int stream, u8 rx_ser = 0; u8 slots = mcasp->tdm_slots; u8 max_active_serializers = (channels + slots - 1) / slots; - u8 active_serializers, numevt; + int active_serializers, numevt, n; u32 reg; /* Default configuration */ if (mcasp->version != MCASP_VERSION_4) @@ -526,7 +526,6 @@ static int mcasp_common_hw_param(struct davinci_mcasp *mcasp, int stream, return -EINVAL; } - /* AFIFO is not in use */ if (!numevt) { /* Configure the burst size for platform drivers */ @@ -535,11 +534,26 @@ static int mcasp_common_hw_param(struct davinci_mcasp *mcasp, int stream, return 0; } - if (numevt * active_serializers > MCASP_MAX_AFIFO_DEPTH) + if (period_words % active_serializers) { + dev_err(mcasp->dev, "Invalid combination of period words and " + "active serializers: %d, %d\n", period_words, + active_serializers); + return -EINVAL; + } + + /* + * Calculate the optimal AFIFO depth for platform side: + * The number of words for numevt need to be in steps of active + * serializers. + */ + n = numevt % active_serializers; + if (n) + numevt += (active_serializers - n); + while (period_words % numevt && numevt > 0) + numevt -= active_serializers; + if (numevt <= 0) numevt = active_serializers; - /* Configure the AFIFO */ - numevt *= active_serializers; mcasp_mod_bits(mcasp, reg, active_serializers, NUMDMA_MASK); mcasp_mod_bits(mcasp, reg, NUMEVT(numevt), NUMEVT_MASK); @@ -620,6 +634,7 @@ static int davinci_mcasp_hw_params(struct snd_pcm_substream *substream, &mcasp->dma_params[substream->stream]; int word_length; int channels = params_channels(params); + int period_size = params_period_size(params); int ret; /* If mcasp is BCLK master we need to set BCLK divider */ @@ -633,7 +648,8 @@ static int davinci_mcasp_hw_params(struct snd_pcm_substream *substream, cpu_dai, 1, mcasp->sysclk_freq / bclk_freq); } - ret = mcasp_common_hw_param(mcasp, substream->stream, channels); + ret = mcasp_common_hw_param(mcasp, substream->stream, + period_size * channels, channels); if (ret) return ret; -- cgit v1.2.3 From 33445643c3146fa43af3e9aa1cce08da9fe03157 Mon Sep 17 00:00:00 2001 From: Peter Ujfalusi Date: Tue, 1 Apr 2014 15:55:12 +0300 Subject: ASoC: davinci-mcasp: Fine tune and correct the DMA burst configuration When the AFIFO is not enabled but more than one serializers are used the DMA need to transfer number of words equal to active serializers when a DMA request is generated. When configuring the burst for the DMA avoid using value '1' for the burst since it is going to enable additional logic in the DMA drivers. Burst '1' means that the DMA should send/receive one word per DMA requests. Signed-off-by: Peter Ujfalusi Signed-off-by: Mark Brown --- sound/soc/davinci/davinci-mcasp.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/sound/soc/davinci/davinci-mcasp.c b/sound/soc/davinci/davinci-mcasp.c index 9454d123f4bb..196158f2d1c4 100644 --- a/sound/soc/davinci/davinci-mcasp.c +++ b/sound/soc/davinci/davinci-mcasp.c @@ -529,8 +529,19 @@ static int mcasp_common_hw_param(struct davinci_mcasp *mcasp, int stream, /* AFIFO is not in use */ if (!numevt) { /* Configure the burst size for platform drivers */ - dma_params->fifo_level = 0; - dma_data->maxburst = 0; + if (active_serializers > 1) { + /* + * If more than one serializers are in use we have one + * DMA request to provide data for all serializers. + * For example if three serializers are enabled the DMA + * need to transfer three words per DMA request. + */ + dma_params->fifo_level = active_serializers; + dma_data->maxburst = active_serializers; + } else { + dma_params->fifo_level = 0; + dma_data->maxburst = 0; + } return 0; } @@ -558,6 +569,8 @@ static int mcasp_common_hw_param(struct davinci_mcasp *mcasp, int stream, mcasp_mod_bits(mcasp, reg, NUMEVT(numevt), NUMEVT_MASK); /* Configure the burst size for platform drivers */ + if (numevt == 1) + numevt = 0; dma_params->fifo_level = numevt; dma_data->maxburst = numevt; -- cgit v1.2.3 From 6dfa9a4e6aacba70bff24c47871ac9aba3e76020 Mon Sep 17 00:00:00 2001 From: Peter Ujfalusi Date: Fri, 4 Apr 2014 14:31:42 +0300 Subject: ASoC: davinci-mcasp: Format data delay configuration enhancement Use intermediate variable for the data delay needed for the specific format and write the register after the format configuration at once. This will help to control the number of lines as support for more formats going to be added. Also fixes a case when we switch between two formats with different delay requirements. Signed-off-by: Peter Ujfalusi Signed-off-by: Mark Brown --- sound/soc/davinci/davinci-mcasp.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/sound/soc/davinci/davinci-mcasp.c b/sound/soc/davinci/davinci-mcasp.c index 196158f2d1c4..f0c98653bfe7 100644 --- a/sound/soc/davinci/davinci-mcasp.c +++ b/sound/soc/davinci/davinci-mcasp.c @@ -271,6 +271,7 @@ static int davinci_mcasp_set_dai_fmt(struct snd_soc_dai *cpu_dai, { struct davinci_mcasp *mcasp = snd_soc_dai_get_drvdata(cpu_dai); int ret = 0; + u32 data_delay; pm_runtime_get_sync(mcasp->dev); switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { @@ -278,18 +279,25 @@ static int davinci_mcasp_set_dai_fmt(struct snd_soc_dai *cpu_dai, case SND_SOC_DAIFMT_AC97: mcasp_clr_bits(mcasp, DAVINCI_MCASP_TXFMCTL_REG, FSXDUR); mcasp_clr_bits(mcasp, DAVINCI_MCASP_RXFMCTL_REG, FSRDUR); + + /* No delay after FS */ + data_delay = 0; break; default: /* configure a full-word SYNC pulse (LRCLK) */ mcasp_set_bits(mcasp, DAVINCI_MCASP_TXFMCTL_REG, FSXDUR); mcasp_set_bits(mcasp, DAVINCI_MCASP_RXFMCTL_REG, FSRDUR); - /* make 1st data bit occur one ACLK cycle after the frame sync */ - mcasp_set_bits(mcasp, DAVINCI_MCASP_TXFMT_REG, FSXDLY(1)); - mcasp_set_bits(mcasp, DAVINCI_MCASP_RXFMT_REG, FSRDLY(1)); + /* 1st data bit occur one ACLK cycle after the frame sync */ + data_delay = 1; break; } + mcasp_mod_bits(mcasp, DAVINCI_MCASP_TXFMT_REG, FSXDLY(data_delay), + FSXDLY(3)); + mcasp_mod_bits(mcasp, DAVINCI_MCASP_RXFMT_REG, FSRDLY(data_delay), + FSRDLY(3)); + switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { case SND_SOC_DAIFMT_CBS_CFS: /* codec is clock and frame slave */ -- cgit v1.2.3 From 188edc59c297fcd971d6a4ae5f5f5dacff7b315b Mon Sep 17 00:00:00 2001 From: Peter Ujfalusi Date: Fri, 4 Apr 2014 14:31:43 +0300 Subject: ASoC: davinci-mcasp: Support for DSP_A format DSP_A is like DSP_B mode but with one bit delay after the FS. Signed-off-by: Peter Ujfalusi Signed-off-by: Mark Brown --- sound/soc/davinci/davinci-mcasp.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/sound/soc/davinci/davinci-mcasp.c b/sound/soc/davinci/davinci-mcasp.c index f0c98653bfe7..58b6d47cc8f8 100644 --- a/sound/soc/davinci/davinci-mcasp.c +++ b/sound/soc/davinci/davinci-mcasp.c @@ -275,6 +275,13 @@ static int davinci_mcasp_set_dai_fmt(struct snd_soc_dai *cpu_dai, pm_runtime_get_sync(mcasp->dev); switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { + case SND_SOC_DAIFMT_DSP_A: + mcasp_clr_bits(mcasp, DAVINCI_MCASP_TXFMCTL_REG, FSXDUR); + mcasp_clr_bits(mcasp, DAVINCI_MCASP_RXFMCTL_REG, FSRDUR); + + /* 1st data bit occur one ACLK cycle after the frame sync */ + data_delay = 1; + break; case SND_SOC_DAIFMT_DSP_B: case SND_SOC_DAIFMT_AC97: mcasp_clr_bits(mcasp, DAVINCI_MCASP_TXFMCTL_REG, FSXDUR); -- cgit v1.2.3 From 83f12503bd1fb18d3fd460871660b34faf671918 Mon Sep 17 00:00:00 2001 From: Peter Ujfalusi Date: Fri, 4 Apr 2014 14:31:44 +0300 Subject: ASoC: davinci-mcasp: Move the FS polarity change out from the switch case FS polarity can be either rising or falling edge in McASP. Instead of accessing the registers in every switch/case set a flag and write the registers after the switch for the invert configuration. This change will help when adding support for more formats also. Signed-off-by: Peter Ujfalusi Signed-off-by: Mark Brown --- sound/soc/davinci/davinci-mcasp.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/sound/soc/davinci/davinci-mcasp.c b/sound/soc/davinci/davinci-mcasp.c index 58b6d47cc8f8..113e74c9479f 100644 --- a/sound/soc/davinci/davinci-mcasp.c +++ b/sound/soc/davinci/davinci-mcasp.c @@ -272,6 +272,7 @@ static int davinci_mcasp_set_dai_fmt(struct snd_soc_dai *cpu_dai, struct davinci_mcasp *mcasp = snd_soc_dai_get_drvdata(cpu_dai); int ret = 0; u32 data_delay; + bool fs_pol_rising; pm_runtime_get_sync(mcasp->dev); switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { @@ -351,39 +352,39 @@ static int davinci_mcasp_set_dai_fmt(struct snd_soc_dai *cpu_dai, switch (fmt & SND_SOC_DAIFMT_INV_MASK) { case SND_SOC_DAIFMT_IB_NF: mcasp_clr_bits(mcasp, DAVINCI_MCASP_ACLKXCTL_REG, ACLKXPOL); - mcasp_clr_bits(mcasp, DAVINCI_MCASP_TXFMCTL_REG, FSXPOL); - mcasp_clr_bits(mcasp, DAVINCI_MCASP_ACLKRCTL_REG, ACLKRPOL); - mcasp_clr_bits(mcasp, DAVINCI_MCASP_RXFMCTL_REG, FSRPOL); + fs_pol_rising = true; break; case SND_SOC_DAIFMT_NB_IF: mcasp_set_bits(mcasp, DAVINCI_MCASP_ACLKXCTL_REG, ACLKXPOL); - mcasp_set_bits(mcasp, DAVINCI_MCASP_TXFMCTL_REG, FSXPOL); - mcasp_set_bits(mcasp, DAVINCI_MCASP_ACLKRCTL_REG, ACLKRPOL); - mcasp_set_bits(mcasp, DAVINCI_MCASP_RXFMCTL_REG, FSRPOL); + fs_pol_rising = false; break; case SND_SOC_DAIFMT_IB_IF: mcasp_clr_bits(mcasp, DAVINCI_MCASP_ACLKXCTL_REG, ACLKXPOL); - mcasp_set_bits(mcasp, DAVINCI_MCASP_TXFMCTL_REG, FSXPOL); - mcasp_clr_bits(mcasp, DAVINCI_MCASP_ACLKRCTL_REG, ACLKRPOL); - mcasp_set_bits(mcasp, DAVINCI_MCASP_RXFMCTL_REG, FSRPOL); + fs_pol_rising = false; break; case SND_SOC_DAIFMT_NB_NF: mcasp_set_bits(mcasp, DAVINCI_MCASP_ACLKXCTL_REG, ACLKXPOL); - mcasp_clr_bits(mcasp, DAVINCI_MCASP_TXFMCTL_REG, FSXPOL); - mcasp_set_bits(mcasp, DAVINCI_MCASP_ACLKRCTL_REG, ACLKRPOL); - mcasp_clr_bits(mcasp, DAVINCI_MCASP_RXFMCTL_REG, FSRPOL); + fs_pol_rising = true; break; default: ret = -EINVAL; - break; + goto out; + } + + if (fs_pol_rising) { + mcasp_clr_bits(mcasp, DAVINCI_MCASP_TXFMCTL_REG, FSXPOL); + mcasp_clr_bits(mcasp, DAVINCI_MCASP_RXFMCTL_REG, FSRPOL); + } else { + mcasp_set_bits(mcasp, DAVINCI_MCASP_TXFMCTL_REG, FSXPOL); + mcasp_set_bits(mcasp, DAVINCI_MCASP_RXFMCTL_REG, FSRPOL); } out: pm_runtime_put_sync(mcasp->dev); -- cgit v1.2.3 From ffd950f75dd71f13194b5d5c8ec67926a1996102 Mon Sep 17 00:00:00 2001 From: Peter Ujfalusi Date: Fri, 4 Apr 2014 14:31:45 +0300 Subject: ASoC: davinci-mcasp: Add support for I2S format The FS needs to be inverted in McASP compared to other supported formats. Use a flag to indicate if the FS needs to be inverted. At the same time fail when non supported format is asked since the default case was anyways configuring McASP to a not valid format. Signed-off-by: Peter Ujfalusi Signed-off-by: Mark Brown --- sound/soc/davinci/davinci-mcasp.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/sound/soc/davinci/davinci-mcasp.c b/sound/soc/davinci/davinci-mcasp.c index 113e74c9479f..d4d640004bed 100644 --- a/sound/soc/davinci/davinci-mcasp.c +++ b/sound/soc/davinci/davinci-mcasp.c @@ -273,6 +273,7 @@ static int davinci_mcasp_set_dai_fmt(struct snd_soc_dai *cpu_dai, int ret = 0; u32 data_delay; bool fs_pol_rising; + bool inv_fs = false; pm_runtime_get_sync(mcasp->dev); switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { @@ -291,14 +292,19 @@ static int davinci_mcasp_set_dai_fmt(struct snd_soc_dai *cpu_dai, /* No delay after FS */ data_delay = 0; break; - default: + case SND_SOC_DAIFMT_I2S: /* configure a full-word SYNC pulse (LRCLK) */ mcasp_set_bits(mcasp, DAVINCI_MCASP_TXFMCTL_REG, FSXDUR); mcasp_set_bits(mcasp, DAVINCI_MCASP_RXFMCTL_REG, FSRDUR); /* 1st data bit occur one ACLK cycle after the frame sync */ data_delay = 1; + /* FS need to be inverted */ + inv_fs = true; break; + default: + ret = -EINVAL; + goto out; } mcasp_mod_bits(mcasp, DAVINCI_MCASP_TXFMT_REG, FSXDLY(data_delay), @@ -379,6 +385,9 @@ static int davinci_mcasp_set_dai_fmt(struct snd_soc_dai *cpu_dai, goto out; } + if (inv_fs) + fs_pol_rising = !fs_pol_rising; + if (fs_pol_rising) { mcasp_clr_bits(mcasp, DAVINCI_MCASP_TXFMCTL_REG, FSXPOL); mcasp_clr_bits(mcasp, DAVINCI_MCASP_RXFMCTL_REG, FSRPOL); -- cgit v1.2.3 From 423761e0cab39c98f0fd9387ea44b98c2a4ca6fa Mon Sep 17 00:00:00 2001 From: Peter Ujfalusi Date: Fri, 4 Apr 2014 14:31:46 +0300 Subject: ASoC: davinci-mcasp: Support for LEFT_J format Configuration for LEFT_J format. Signed-off-by: Peter Ujfalusi Signed-off-by: Mark Brown --- sound/soc/davinci/davinci-mcasp.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/sound/soc/davinci/davinci-mcasp.c b/sound/soc/davinci/davinci-mcasp.c index d4d640004bed..2b6722024fbd 100644 --- a/sound/soc/davinci/davinci-mcasp.c +++ b/sound/soc/davinci/davinci-mcasp.c @@ -302,6 +302,13 @@ static int davinci_mcasp_set_dai_fmt(struct snd_soc_dai *cpu_dai, /* FS need to be inverted */ inv_fs = true; break; + case SND_SOC_DAIFMT_LEFT_J: + /* configure a full-word SYNC pulse (LRCLK) */ + mcasp_set_bits(mcasp, DAVINCI_MCASP_TXFMCTL_REG, FSXDUR); + mcasp_set_bits(mcasp, DAVINCI_MCASP_RXFMCTL_REG, FSRDUR); + /* No delay after FS */ + data_delay = 0; + break; default: ret = -EINVAL; goto out; -- cgit v1.2.3 From 3c25f916d378da6f06874abfc5c18e5a40e2d8c0 Mon Sep 17 00:00:00 2001 From: Peter Ujfalusi Date: Fri, 4 Apr 2014 14:31:47 +0300 Subject: ASoC: davinci-mcasp: Remove excess empty lines from davinci_mcasp_set_dai_fmt() To make the code look uniform. Signed-off-by: Peter Ujfalusi Signed-off-by: Mark Brown --- sound/soc/davinci/davinci-mcasp.c | 8 -------- 1 file changed, 8 deletions(-) diff --git a/sound/soc/davinci/davinci-mcasp.c b/sound/soc/davinci/davinci-mcasp.c index 2b6722024fbd..8007fcf428d9 100644 --- a/sound/soc/davinci/davinci-mcasp.c +++ b/sound/soc/davinci/davinci-mcasp.c @@ -280,7 +280,6 @@ static int davinci_mcasp_set_dai_fmt(struct snd_soc_dai *cpu_dai, case SND_SOC_DAIFMT_DSP_A: mcasp_clr_bits(mcasp, DAVINCI_MCASP_TXFMCTL_REG, FSXDUR); mcasp_clr_bits(mcasp, DAVINCI_MCASP_RXFMCTL_REG, FSRDUR); - /* 1st data bit occur one ACLK cycle after the frame sync */ data_delay = 1; break; @@ -288,7 +287,6 @@ static int davinci_mcasp_set_dai_fmt(struct snd_soc_dai *cpu_dai, case SND_SOC_DAIFMT_AC97: mcasp_clr_bits(mcasp, DAVINCI_MCASP_TXFMCTL_REG, FSXDUR); mcasp_clr_bits(mcasp, DAVINCI_MCASP_RXFMCTL_REG, FSRDUR); - /* No delay after FS */ data_delay = 0; break; @@ -296,7 +294,6 @@ static int davinci_mcasp_set_dai_fmt(struct snd_soc_dai *cpu_dai, /* configure a full-word SYNC pulse (LRCLK) */ mcasp_set_bits(mcasp, DAVINCI_MCASP_TXFMCTL_REG, FSXDUR); mcasp_set_bits(mcasp, DAVINCI_MCASP_RXFMCTL_REG, FSRDUR); - /* 1st data bit occur one ACLK cycle after the frame sync */ data_delay = 1; /* FS need to be inverted */ @@ -356,7 +353,6 @@ static int davinci_mcasp_set_dai_fmt(struct snd_soc_dai *cpu_dai, ACLKX | AHCLKX | AFSX | ACLKR | AHCLKR | AFSR); mcasp->bclk_master = 0; break; - default: ret = -EINVAL; goto out; @@ -368,25 +364,21 @@ static int davinci_mcasp_set_dai_fmt(struct snd_soc_dai *cpu_dai, mcasp_clr_bits(mcasp, DAVINCI_MCASP_ACLKRCTL_REG, ACLKRPOL); fs_pol_rising = true; break; - case SND_SOC_DAIFMT_NB_IF: mcasp_set_bits(mcasp, DAVINCI_MCASP_ACLKXCTL_REG, ACLKXPOL); mcasp_set_bits(mcasp, DAVINCI_MCASP_ACLKRCTL_REG, ACLKRPOL); fs_pol_rising = false; break; - case SND_SOC_DAIFMT_IB_IF: mcasp_clr_bits(mcasp, DAVINCI_MCASP_ACLKXCTL_REG, ACLKXPOL); mcasp_clr_bits(mcasp, DAVINCI_MCASP_ACLKRCTL_REG, ACLKRPOL); fs_pol_rising = false; break; - case SND_SOC_DAIFMT_NB_NF: mcasp_set_bits(mcasp, DAVINCI_MCASP_ACLKXCTL_REG, ACLKXPOL); mcasp_set_bits(mcasp, DAVINCI_MCASP_ACLKRCTL_REG, ACLKRPOL); fs_pol_rising = true; break; - default: ret = -EINVAL; goto out; -- cgit v1.2.3 From eba9e06f0ceb2ea3342e72577b244d8b02645396 Mon Sep 17 00:00:00 2001 From: Alexander Shiyan Date: Sun, 16 Mar 2014 08:21:34 +0400 Subject: ASoC: fsl: Separation of the main audio options and boards This patch provide separation of the main audio options and boards. Signed-off-by: Alexander Shiyan Signed-off-by: Mark Brown --- sound/soc/fsl/Kconfig | 36 ++++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/sound/soc/fsl/Kconfig b/sound/soc/fsl/Kconfig index 338a91642471..0b4315d5af77 100644 --- a/sound/soc/fsl/Kconfig +++ b/sound/soc/fsl/Kconfig @@ -1,3 +1,5 @@ +menu "SoC Audio for Freescale CPUs" + config SND_SOC_FSL_SAI tristate select REGMAP_MMIO @@ -18,13 +20,27 @@ config SND_SOC_FSL_ESAI config SND_SOC_FSL_UTILS tristate -menuconfig SND_POWERPC_SOC +config SND_SOC_IMX_PCM_DMA + tristate + select SND_SOC_GENERIC_DMAENGINE_PCM + +config SND_SOC_IMX_AUDMUX + tristate + +config SND_POWERPC_SOC tristate "SoC Audio for Freescale PowerPC CPUs" depends on FSL_SOC || PPC_MPC52xx help Say Y or M if you want to add support for codecs attached to the PowerPC CPUs. +config SND_IMX_SOC + tristate "SoC Audio for Freescale i.MX CPUs" + depends on ARCH_MXC || COMPILE_TEST + help + Say Y or M if you want to add support for codecs attached to + the i.MX CPUs. + if SND_POWERPC_SOC config SND_MPC52xx_DMA @@ -33,6 +49,8 @@ config SND_MPC52xx_DMA config SND_SOC_POWERPC_DMA tristate +comment "SoC Audio support for Freescale PPC boards:" + config SND_SOC_MPC8610_HPCD tristate "ALSA SoC support for the Freescale MPC8610 HPCD board" # I2C is necessary for the CS4270 driver @@ -110,13 +128,6 @@ config SND_MPC52xx_SOC_EFIKA endif # SND_POWERPC_SOC -menuconfig SND_IMX_SOC - tristate "SoC Audio for Freescale i.MX CPUs" - depends on ARCH_MXC || COMPILE_TEST - help - Say Y or M if you want to add support for codecs attached to - the i.MX CPUs. - if SND_IMX_SOC config SND_SOC_IMX_SSI @@ -127,12 +138,7 @@ config SND_SOC_IMX_PCM_FIQ tristate select FIQ -config SND_SOC_IMX_PCM_DMA - tristate - select SND_SOC_GENERIC_DMAENGINE_PCM - -config SND_SOC_IMX_AUDMUX - tristate +comment "SoC Audio support for Freescale i.MX boards:" config SND_MXC_SOC_WM1133_EV1 tristate "Audio on the i.MX31ADS with WM1133-EV1 fitted" @@ -225,3 +231,5 @@ config SND_SOC_IMX_MC13783 select SND_SOC_IMX_PCM_DMA endif # SND_IMX_SOC + +endmenu -- cgit v1.2.3 From 204dec93eaaba3a7afdc09aa3c3f6d08c773a367 Mon Sep 17 00:00:00 2001 From: Alexander Shiyan Date: Sun, 16 Mar 2014 08:21:35 +0400 Subject: ASoC: fsl: Allow to select individual common options This patch allow to select individual common sound options and as a result allow using sound cards/codecs based on DT description. Signed-off-by: Alexander Shiyan Signed-off-by: Mark Brown --- sound/soc/fsl/Kconfig | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/sound/soc/fsl/Kconfig b/sound/soc/fsl/Kconfig index 0b4315d5af77..7a7eaf32158f 100644 --- a/sound/soc/fsl/Kconfig +++ b/sound/soc/fsl/Kconfig @@ -1,16 +1,28 @@ menu "SoC Audio for Freescale CPUs" +comment "Common SoC Audio options for Freescale CPUs:" + config SND_SOC_FSL_SAI tristate select REGMAP_MMIO select SND_SOC_GENERIC_DMAENGINE_PCM config SND_SOC_FSL_SSI - tristate + tristate "Synchronous Serial Interface module support" + help + Say Y if you want to add Synchronous Serial Interface (SSI) + support for the Freescale CPUs. + This option is only useful for out-of-tree drivers since + in-tree drivers select it automatically. config SND_SOC_FSL_SPDIF - tristate + tristate "Sony/Philips Digital Interface module support" select REGMAP_MMIO + help + Say Y if you want to add Sony/Philips Digital Interface (SPDIF) + support for the Freescale CPUs. + This option is only useful for out-of-tree drivers since + in-tree drivers select it automatically. config SND_SOC_FSL_ESAI tristate @@ -25,7 +37,12 @@ config SND_SOC_IMX_PCM_DMA select SND_SOC_GENERIC_DMAENGINE_PCM config SND_SOC_IMX_AUDMUX - tristate + tristate "Digital Audio Mux module support" + help + Say Y if you want to add Digital Audio Mux (AUDMUX) support + for the ARM i.MX CPUs. + This option is only useful for out-of-tree drivers since + in-tree drivers select it automatically. config SND_POWERPC_SOC tristate "SoC Audio for Freescale PowerPC CPUs" -- cgit v1.2.3 From 413312aa17ceefe7003ad690778ab72f023128f0 Mon Sep 17 00:00:00 2001 From: Nicolin Chen Date: Fri, 28 Mar 2014 19:39:25 +0800 Subject: ASoC: fsl_sai: Improve fsl_sai_isr() This patch improves fsl_sai_isr() in these ways: 1, Add comment for mask fetching code. 2, Return IRQ_NONE if the IRQ is not for the device. 3, Use regmap_write() instead of regmap_update_bits(). Signed-off-by: Nicolin Chen Signed-off-by: Mark Brown --- sound/soc/fsl/fsl_sai.c | 64 ++++++++++++++++++++++++++++++++++--------------- 1 file changed, 45 insertions(+), 19 deletions(-) diff --git a/sound/soc/fsl/fsl_sai.c b/sound/soc/fsl/fsl_sai.c index 56da8c8c5960..7194d9280020 100644 --- a/sound/soc/fsl/fsl_sai.c +++ b/sound/soc/fsl/fsl_sai.c @@ -30,62 +30,88 @@ static irqreturn_t fsl_sai_isr(int irq, void *devid) { struct fsl_sai *sai = (struct fsl_sai *)devid; struct device *dev = &sai->pdev->dev; - u32 xcsr, mask; + u32 flags, xcsr, mask; + bool irq_none = true; - /* Only handle those what we enabled */ + /* + * Both IRQ status bits and IRQ mask bits are in the xCSR but + * different shifts. And we here create a mask only for those + * IRQs that we activated. + */ mask = (FSL_SAI_FLAGS >> FSL_SAI_CSR_xIE_SHIFT) << FSL_SAI_CSR_xF_SHIFT; /* Tx IRQ */ regmap_read(sai->regmap, FSL_SAI_TCSR, &xcsr); - xcsr &= mask; + flags = xcsr & mask; - if (xcsr & FSL_SAI_CSR_WSF) + if (flags) + irq_none = false; + else + goto irq_rx; + + if (flags & FSL_SAI_CSR_WSF) dev_dbg(dev, "isr: Start of Tx word detected\n"); - if (xcsr & FSL_SAI_CSR_SEF) + if (flags & FSL_SAI_CSR_SEF) dev_warn(dev, "isr: Tx Frame sync error detected\n"); - if (xcsr & FSL_SAI_CSR_FEF) { + if (flags & FSL_SAI_CSR_FEF) { dev_warn(dev, "isr: Transmit underrun detected\n"); /* FIFO reset for safety */ xcsr |= FSL_SAI_CSR_FR; } - if (xcsr & FSL_SAI_CSR_FWF) + if (flags & FSL_SAI_CSR_FWF) dev_dbg(dev, "isr: Enabled transmit FIFO is empty\n"); - if (xcsr & FSL_SAI_CSR_FRF) + if (flags & FSL_SAI_CSR_FRF) dev_dbg(dev, "isr: Transmit FIFO watermark has been reached\n"); - regmap_update_bits(sai->regmap, FSL_SAI_TCSR, - FSL_SAI_CSR_xF_W_MASK | FSL_SAI_CSR_FR, xcsr); + flags &= FSL_SAI_CSR_xF_W_MASK; + xcsr &= ~FSL_SAI_CSR_xF_MASK; + + if (flags) + regmap_write(sai->regmap, FSL_SAI_TCSR, flags | xcsr); +irq_rx: /* Rx IRQ */ regmap_read(sai->regmap, FSL_SAI_RCSR, &xcsr); - xcsr &= mask; + flags = xcsr & mask; - if (xcsr & FSL_SAI_CSR_WSF) + if (flags) + irq_none = false; + else + goto out; + + if (flags & FSL_SAI_CSR_WSF) dev_dbg(dev, "isr: Start of Rx word detected\n"); - if (xcsr & FSL_SAI_CSR_SEF) + if (flags & FSL_SAI_CSR_SEF) dev_warn(dev, "isr: Rx Frame sync error detected\n"); - if (xcsr & FSL_SAI_CSR_FEF) { + if (flags & FSL_SAI_CSR_FEF) { dev_warn(dev, "isr: Receive overflow detected\n"); /* FIFO reset for safety */ xcsr |= FSL_SAI_CSR_FR; } - if (xcsr & FSL_SAI_CSR_FWF) + if (flags & FSL_SAI_CSR_FWF) dev_dbg(dev, "isr: Enabled receive FIFO is full\n"); - if (xcsr & FSL_SAI_CSR_FRF) + if (flags & FSL_SAI_CSR_FRF) dev_dbg(dev, "isr: Receive FIFO watermark has been reached\n"); - regmap_update_bits(sai->regmap, FSL_SAI_RCSR, - FSL_SAI_CSR_xF_W_MASK | FSL_SAI_CSR_FR, xcsr); + flags &= FSL_SAI_CSR_xF_W_MASK; + xcsr &= ~FSL_SAI_CSR_xF_MASK; - return IRQ_HANDLED; + if (flags) + regmap_write(sai->regmap, FSL_SAI_TCSR, flags | xcsr); + +out: + if (irq_none) + return IRQ_NONE; + else + return IRQ_HANDLED; } static int fsl_sai_set_dai_sysclk_tr(struct snd_soc_dai *cpu_dai, -- cgit v1.2.3 From e6b398465821fb8e08d208bd4ef2b5b73ce87b58 Mon Sep 17 00:00:00 2001 From: Nicolin Chen Date: Tue, 1 Apr 2014 11:17:06 +0800 Subject: ASoC: fsl_sai: Fix buggy configurations in trigger() The current trigger() has two crucial problems: 1) The DMA request enabling operations (FSL_SAI_CSR_FRDE) for Tx and Rx are now totally exclusive: It would fail to run simultaneous Tx-Rx cases. 2) The TERE disabling operation depends on an incorrect condition -- active reference count that only gets increased in snd_pcm_open() and decreased in snd_pcm_close(): The TERE would never get cleared. So this patch overwrites the trigger function by following these rules: A) We continue to support tx-async-while-rx-sync-to-tx case alone, which's originally limited by this fsl_sai driver, but we make the code easy to modify for the further support of the opposite case. B) We enable both TE and RE for PLAYBACK stream or CAPTURE stream but only enabling the DMA request bit (FSL_SAI_CSR_FRDE) of the current direction due to the requirement of SAI -- For tx-async-while-rx-sync-to-tx case, the receiver is enabled only when both the transmitter and receiver are enabled. Tested cases: a) aplay test.wav -d5 b) arecord -r44100 -c2 -fS16_LE test.wav -d5 c) arecord -r44100 -c2 -fS16_LE -d5 | aplay d) (aplay test2.wav &); sleep 1; arecord -r44100 -c2 -fS16_LE test.wav -d1 e) (arecord -r44100 -c2 -fS16_LE test.wav -d5 &); sleep 1; aplay test.wav -d1 Signed-off-by: Nicolin Chen Acked-by: Xiubo Li Signed-off-by: Mark Brown --- sound/soc/fsl/fsl_sai.c | 35 +++++++++++++++++------------------ sound/soc/fsl/fsl_sai.h | 10 ++++++++++ 2 files changed, 27 insertions(+), 18 deletions(-) diff --git a/sound/soc/fsl/fsl_sai.c b/sound/soc/fsl/fsl_sai.c index 7194d9280020..80cca7bb2a11 100644 --- a/sound/soc/fsl/fsl_sai.c +++ b/sound/soc/fsl/fsl_sai.c @@ -365,6 +365,7 @@ static int fsl_sai_trigger(struct snd_pcm_substream *substream, int cmd, struct snd_soc_dai *cpu_dai) { struct fsl_sai *sai = snd_soc_dai_get_drvdata(cpu_dai); + bool tx = substream->stream == SNDRV_PCM_STREAM_PLAYBACK; u32 tcsr, rcsr; /* @@ -379,14 +380,6 @@ static int fsl_sai_trigger(struct snd_pcm_substream *substream, int cmd, regmap_read(sai->regmap, FSL_SAI_TCSR, &tcsr); regmap_read(sai->regmap, FSL_SAI_RCSR, &rcsr); - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { - tcsr |= FSL_SAI_CSR_FRDE; - rcsr &= ~FSL_SAI_CSR_FRDE; - } else { - rcsr |= FSL_SAI_CSR_FRDE; - tcsr &= ~FSL_SAI_CSR_FRDE; - } - /* * It is recommended that the transmitter is the last enabled * and the first disabled. @@ -395,22 +388,28 @@ static int fsl_sai_trigger(struct snd_pcm_substream *substream, int cmd, case SNDRV_PCM_TRIGGER_START: case SNDRV_PCM_TRIGGER_RESUME: case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: - tcsr |= FSL_SAI_CSR_TERE; - rcsr |= FSL_SAI_CSR_TERE; + if (!(tcsr & FSL_SAI_CSR_FRDE || rcsr & FSL_SAI_CSR_FRDE)) { + regmap_update_bits(sai->regmap, FSL_SAI_RCSR, + FSL_SAI_CSR_TERE, FSL_SAI_CSR_TERE); + regmap_update_bits(sai->regmap, FSL_SAI_TCSR, + FSL_SAI_CSR_TERE, FSL_SAI_CSR_TERE); + } - regmap_write(sai->regmap, FSL_SAI_RCSR, rcsr); - regmap_write(sai->regmap, FSL_SAI_TCSR, tcsr); + regmap_update_bits(sai->regmap, FSL_SAI_xCSR(tx), + FSL_SAI_CSR_FRDE, FSL_SAI_CSR_FRDE); break; case SNDRV_PCM_TRIGGER_STOP: case SNDRV_PCM_TRIGGER_SUSPEND: case SNDRV_PCM_TRIGGER_PAUSE_PUSH: - if (!(cpu_dai->playback_active || cpu_dai->capture_active)) { - tcsr &= ~FSL_SAI_CSR_TERE; - rcsr &= ~FSL_SAI_CSR_TERE; + regmap_update_bits(sai->regmap, FSL_SAI_xCSR(tx), + FSL_SAI_CSR_FRDE, 0); + + if (!(tcsr & FSL_SAI_CSR_FRDE || rcsr & FSL_SAI_CSR_FRDE)) { + regmap_update_bits(sai->regmap, FSL_SAI_TCSR, + FSL_SAI_CSR_TERE, 0); + regmap_update_bits(sai->regmap, FSL_SAI_RCSR, + FSL_SAI_CSR_TERE, 0); } - - regmap_write(sai->regmap, FSL_SAI_TCSR, tcsr); - regmap_write(sai->regmap, FSL_SAI_RCSR, rcsr); break; default: return -EINVAL; diff --git a/sound/soc/fsl/fsl_sai.h b/sound/soc/fsl/fsl_sai.h index a264185c7138..64b6fe72cd08 100644 --- a/sound/soc/fsl/fsl_sai.h +++ b/sound/soc/fsl/fsl_sai.h @@ -35,6 +35,16 @@ #define FSL_SAI_RFR 0xc0 /* SAI Receive FIFO */ #define FSL_SAI_RMR 0xe0 /* SAI Receive Mask */ +#define FSL_SAI_xCSR(tx) (tx ? FSL_SAI_TCSR : FSL_SAI_RCSR) +#define FSL_SAI_xCR1(tx) (tx ? FSL_SAI_TCR1 : FSL_SAI_RCR1) +#define FSL_SAI_xCR2(tx) (tx ? FSL_SAI_TCR2 : FSL_SAI_RCR2) +#define FSL_SAI_xCR3(tx) (tx ? FSL_SAI_TCR3 : FSL_SAI_RCR3) +#define FSL_SAI_xCR4(tx) (tx ? FSL_SAI_TCR4 : FSL_SAI_RCR4) +#define FSL_SAI_xCR5(tx) (tx ? FSL_SAI_TCR5 : FSL_SAI_RCR5) +#define FSL_SAI_xDR(tx) (tx ? FSL_SAI_TDR : FSL_SAI_RDR) +#define FSL_SAI_xFR(tx) (tx ? FSL_SAI_TFR : FSL_SAI_RFR) +#define FSL_SAI_xMR(tx) (tx ? FSL_SAI_TMR : FSL_SAI_RMR) + /* SAI Transmit/Recieve Control Register */ #define FSL_SAI_CSR_TERE BIT(31) #define FSL_SAI_CSR_FR BIT(25) -- cgit v1.2.3 From 8abba5d64835c636d97ac0009ab7430ed832cb93 Mon Sep 17 00:00:00 2001 From: Nicolin Chen Date: Tue, 1 Apr 2014 11:17:07 +0800 Subject: ASoC: fsl_sai: Separately enable interrupts for Tx and Rx streams We only enable one side interrupt for each stream since over/underrun on the opposite stream would be resulted from what we previously did, enabling TERE but remaining FRDE disabled, even though the xrun on the opposite direction will not break the current stream. Signed-off-by: Nicolin Chen Acked-by: Xiubo Li Signed-off-by: Mark Brown --- sound/soc/fsl/fsl_sai.c | 8 ++++++-- sound/soc/fsl/fsl_sai.h | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/sound/soc/fsl/fsl_sai.c b/sound/soc/fsl/fsl_sai.c index 80cca7bb2a11..21de5bd1c9c5 100644 --- a/sound/soc/fsl/fsl_sai.c +++ b/sound/soc/fsl/fsl_sai.c @@ -395,6 +395,8 @@ static int fsl_sai_trigger(struct snd_pcm_substream *substream, int cmd, FSL_SAI_CSR_TERE, FSL_SAI_CSR_TERE); } + regmap_update_bits(sai->regmap, FSL_SAI_xCSR(tx), + FSL_SAI_CSR_xIE_MASK, FSL_SAI_FLAGS); regmap_update_bits(sai->regmap, FSL_SAI_xCSR(tx), FSL_SAI_CSR_FRDE, FSL_SAI_CSR_FRDE); break; @@ -403,6 +405,8 @@ static int fsl_sai_trigger(struct snd_pcm_substream *substream, int cmd, case SNDRV_PCM_TRIGGER_PAUSE_PUSH: regmap_update_bits(sai->regmap, FSL_SAI_xCSR(tx), FSL_SAI_CSR_FRDE, 0); + regmap_update_bits(sai->regmap, FSL_SAI_xCSR(tx), + FSL_SAI_CSR_xIE_MASK, 0); if (!(tcsr & FSL_SAI_CSR_FRDE || rcsr & FSL_SAI_CSR_FRDE)) { regmap_update_bits(sai->regmap, FSL_SAI_TCSR, @@ -463,8 +467,8 @@ static int fsl_sai_dai_probe(struct snd_soc_dai *cpu_dai) { struct fsl_sai *sai = dev_get_drvdata(cpu_dai->dev); - regmap_update_bits(sai->regmap, FSL_SAI_TCSR, 0xffffffff, FSL_SAI_FLAGS); - regmap_update_bits(sai->regmap, FSL_SAI_RCSR, 0xffffffff, FSL_SAI_FLAGS); + regmap_update_bits(sai->regmap, FSL_SAI_TCSR, 0xffffffff, 0x0); + regmap_update_bits(sai->regmap, FSL_SAI_RCSR, 0xffffffff, 0x0); regmap_update_bits(sai->regmap, FSL_SAI_TCR1, FSL_SAI_CR1_RFW_MASK, FSL_SAI_MAXBURST_TX * 2); regmap_update_bits(sai->regmap, FSL_SAI_RCR1, FSL_SAI_CR1_RFW_MASK, diff --git a/sound/soc/fsl/fsl_sai.h b/sound/soc/fsl/fsl_sai.h index 64b6fe72cd08..be26d46ee737 100644 --- a/sound/soc/fsl/fsl_sai.h +++ b/sound/soc/fsl/fsl_sai.h @@ -58,6 +58,7 @@ #define FSL_SAI_CSR_FWF BIT(17) #define FSL_SAI_CSR_FRF BIT(16) #define FSL_SAI_CSR_xIE_SHIFT 8 +#define FSL_SAI_CSR_xIE_MASK (0x1f << FSL_SAI_CSR_xIE_SHIFT) #define FSL_SAI_CSR_WSIE BIT(12) #define FSL_SAI_CSR_SEIE BIT(11) #define FSL_SAI_CSR_FEIE BIT(10) -- cgit v1.2.3 From c754064453e0d48043bd6a111f5c1f8ef1b75f7e Mon Sep 17 00:00:00 2001 From: Nicolin Chen Date: Tue, 1 Apr 2014 19:34:09 +0800 Subject: ASoC: fsl_sai: Add imx6sx platform support The next coming i.MX6 Solo X SoC also contains SAI module while we use imp_pcm_init() for i.MX platform. So this patch adds one compatible route for imx6sx and updates the DT doc accordingly. Signed-off-by: Nicolin Chen Signed-off-by: Mark Brown --- Documentation/devicetree/bindings/sound/fsl-sai.txt | 2 +- sound/soc/fsl/fsl_sai.c | 12 ++++++++++-- sound/soc/fsl/fsl_sai.h | 1 + 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/Documentation/devicetree/bindings/sound/fsl-sai.txt b/Documentation/devicetree/bindings/sound/fsl-sai.txt index 98611a6761c0..35c09fe5847a 100644 --- a/Documentation/devicetree/bindings/sound/fsl-sai.txt +++ b/Documentation/devicetree/bindings/sound/fsl-sai.txt @@ -7,7 +7,7 @@ codec/DSP interfaces. Required properties: -- compatible: Compatible list, contains "fsl,vf610-sai". +- compatible: Compatible list, contains "fsl,vf610-sai" or "fsl,imx6sx-sai". - reg: Offset and length of the register set for the device. - clocks: Must contain an entry for each entry in clock-names. - clock-names : Must include the "sai" entry. diff --git a/sound/soc/fsl/fsl_sai.c b/sound/soc/fsl/fsl_sai.c index 21de5bd1c9c5..dde084273c64 100644 --- a/sound/soc/fsl/fsl_sai.c +++ b/sound/soc/fsl/fsl_sai.c @@ -22,6 +22,7 @@ #include #include "fsl_sai.h" +#include "imx-pcm.h" #define FSL_SAI_FLAGS (FSL_SAI_CSR_SEIE |\ FSL_SAI_CSR_FEIE) @@ -592,6 +593,9 @@ static int fsl_sai_probe(struct platform_device *pdev) sai->pdev = pdev; + if (of_device_is_compatible(pdev->dev.of_node, "fsl,imx6sx-sai")) + sai->sai_on_imx = true; + sai->big_endian_regs = of_property_read_bool(np, "big-endian-regs"); if (sai->big_endian_regs) fsl_sai_regmap_config.val_format_endian = REGMAP_ENDIAN_BIG; @@ -634,12 +638,16 @@ static int fsl_sai_probe(struct platform_device *pdev) if (ret) return ret; - return devm_snd_dmaengine_pcm_register(&pdev->dev, NULL, - SND_DMAENGINE_PCM_FLAG_NO_RESIDUE); + if (sai->sai_on_imx) + return imx_pcm_dma_init(pdev); + else + return devm_snd_dmaengine_pcm_register(&pdev->dev, NULL, + SND_DMAENGINE_PCM_FLAG_NO_RESIDUE); } static const struct of_device_id fsl_sai_ids[] = { { .compatible = "fsl,vf610-sai", }, + { .compatible = "fsl,imx6sx-sai", }, { /* sentinel */ } }; diff --git a/sound/soc/fsl/fsl_sai.h b/sound/soc/fsl/fsl_sai.h index be26d46ee737..677670d62fcd 100644 --- a/sound/soc/fsl/fsl_sai.h +++ b/sound/soc/fsl/fsl_sai.h @@ -130,6 +130,7 @@ struct fsl_sai { bool big_endian_regs; bool big_endian_data; bool is_dsp_mode; + bool sai_on_imx; struct snd_dmaengine_dai_dma_data dma_params_rx; struct snd_dmaengine_dai_dma_data dma_params_tx; -- cgit v1.2.3 From ca3e35c7a37cb59b12a1839d03c621cf8fa9a3d9 Mon Sep 17 00:00:00 2001 From: Nicolin Chen Date: Thu, 10 Apr 2014 23:26:15 +0800 Subject: ASoC: fsl_sai: Add clock controls for SAI The SAI mainly has the following clocks: bus clock control and configure registers and to generate synchronous interrupts and DMA requests. mclk1, mclk2, mclk3 to generate the bit clock when the receiver or transmitter is configured for an internally generated bit clock. So this patch adds these clocks and their clock controls to the driver. [ To concern the old DTB cases, I've added a bit of extra code to make the driver compatible with them. And by marking clock NULL if failed to get, the clk_prepare() or clk_get_rate() would easily return 0 so no further path should be broken. -- by Nicolin ] Signed-off-by: Nicolin Chen Acked-by: Xiubo Li Signed-off-by: Mark Brown --- .../devicetree/bindings/sound/fsl-sai.txt | 9 +++-- sound/soc/fsl/fsl_sai.c | 38 ++++++++++++++++++++-- sound/soc/fsl/fsl_sai.h | 4 +++ 3 files changed, 46 insertions(+), 5 deletions(-) diff --git a/Documentation/devicetree/bindings/sound/fsl-sai.txt b/Documentation/devicetree/bindings/sound/fsl-sai.txt index 35c09fe5847a..0f4e23828190 100644 --- a/Documentation/devicetree/bindings/sound/fsl-sai.txt +++ b/Documentation/devicetree/bindings/sound/fsl-sai.txt @@ -10,7 +10,8 @@ Required properties: - compatible: Compatible list, contains "fsl,vf610-sai" or "fsl,imx6sx-sai". - reg: Offset and length of the register set for the device. - clocks: Must contain an entry for each entry in clock-names. -- clock-names : Must include the "sai" entry. +- clock-names : Must include the "bus" for register access and "mclk1" "mclk2" + "mclk3" for bit clock and frame clock providing. - dmas : Generic dma devicetree binding as described in Documentation/devicetree/bindings/dma/dma.txt. - dma-names : Two dmas have to be defined, "tx" and "rx". @@ -30,8 +31,10 @@ sai2: sai@40031000 { reg = <0x40031000 0x1000>; pinctrl-names = "default"; pinctrl-0 = <&pinctrl_sai2_1>; - clocks = <&clks VF610_CLK_SAI2>; - clock-names = "sai"; + clocks = <&clks VF610_CLK_PLATFORM_BUS>, + <&clks VF610_CLK_SAI2>, + <&clks 0>, <&clks 0>; + clock-names = "bus", "mclk1", "mclk2", "mclk3"; dma-names = "tx", "rx"; dmas = <&edma0 0 VF610_EDMA_MUXID0_SAI2_TX>, <&edma0 0 VF610_EDMA_MUXID0_SAI2_RX>; diff --git a/sound/soc/fsl/fsl_sai.c b/sound/soc/fsl/fsl_sai.c index dde084273c64..1c93282fbd26 100644 --- a/sound/soc/fsl/fsl_sai.c +++ b/sound/soc/fsl/fsl_sai.c @@ -427,7 +427,15 @@ static int fsl_sai_startup(struct snd_pcm_substream *substream, struct snd_soc_dai *cpu_dai) { struct fsl_sai *sai = snd_soc_dai_get_drvdata(cpu_dai); + struct device *dev = &sai->pdev->dev; u32 reg; + int ret; + + ret = clk_prepare_enable(sai->bus_clk); + if (ret) { + dev_err(dev, "failed to enable bus clock: %d\n", ret); + return ret; + } if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) reg = FSL_SAI_TCR3; @@ -453,6 +461,8 @@ static void fsl_sai_shutdown(struct snd_pcm_substream *substream, regmap_update_bits(sai->regmap, reg, FSL_SAI_CR3_TRCE, ~FSL_SAI_CR3_TRCE); + + clk_disable_unprepare(sai->bus_clk); } static const struct snd_soc_dai_ops fsl_sai_pcm_dai_ops = { @@ -585,7 +595,8 @@ static int fsl_sai_probe(struct platform_device *pdev) struct fsl_sai *sai; struct resource *res; void __iomem *base; - int irq, ret; + char tmp[8]; + int irq, ret, i; sai = devm_kzalloc(&pdev->dev, sizeof(*sai), GFP_KERNEL); if (!sai) @@ -608,12 +619,35 @@ static int fsl_sai_probe(struct platform_device *pdev) return PTR_ERR(base); sai->regmap = devm_regmap_init_mmio_clk(&pdev->dev, - "sai", base, &fsl_sai_regmap_config); + "bus", base, &fsl_sai_regmap_config); + + /* Compatible with old DTB cases */ + if (IS_ERR(sai->regmap)) + sai->regmap = devm_regmap_init_mmio_clk(&pdev->dev, + "sai", base, &fsl_sai_regmap_config); if (IS_ERR(sai->regmap)) { dev_err(&pdev->dev, "regmap init failed\n"); return PTR_ERR(sai->regmap); } + /* No error out for old DTB cases but only mark the clock NULL */ + sai->bus_clk = devm_clk_get(&pdev->dev, "bus"); + if (IS_ERR(sai->bus_clk)) { + dev_err(&pdev->dev, "failed to get bus clock: %ld\n", + PTR_ERR(sai->bus_clk)); + sai->bus_clk = NULL; + } + + for (i = 0; i < FSL_SAI_MCLK_MAX; i++) { + sprintf(tmp, "mclk%d", i + 1); + sai->mclk_clk[i] = devm_clk_get(&pdev->dev, tmp); + if (IS_ERR(sai->mclk_clk[i])) { + dev_err(&pdev->dev, "failed to get mclk%d clock: %ld\n", + i + 1, PTR_ERR(sai->mclk_clk[i])); + sai->mclk_clk[i] = NULL; + } + } + irq = platform_get_irq(pdev, 0); if (irq < 0) { dev_err(&pdev->dev, "no irq for node %s\n", np->full_name); diff --git a/sound/soc/fsl/fsl_sai.h b/sound/soc/fsl/fsl_sai.h index 677670d62fcd..0e6c9f595d75 100644 --- a/sound/soc/fsl/fsl_sai.h +++ b/sound/soc/fsl/fsl_sai.h @@ -119,6 +119,8 @@ #define FSL_SAI_CLK_MAST2 2 #define FSL_SAI_CLK_MAST3 3 +#define FSL_SAI_MCLK_MAX 3 + /* SAI data transfer numbers per DMA request */ #define FSL_SAI_MAXBURST_TX 6 #define FSL_SAI_MAXBURST_RX 6 @@ -126,6 +128,8 @@ struct fsl_sai { struct platform_device *pdev; struct regmap *regmap; + struct clk *bus_clk; + struct clk *mclk_clk[FSL_SAI_MCLK_MAX]; bool big_endian_regs; bool big_endian_data; -- cgit v1.2.3 From 2b0db996ba2d9b833c2bd2d73cbf301abe11c60e Mon Sep 17 00:00:00 2001 From: Markus Pargmann Date: Sat, 15 Mar 2014 13:44:09 +0100 Subject: ASoC: fsl-ssi: Remove fsl_ssi_setup fsl_ssi_set_dai_fmt() manages most of the register setup routines now. fsl_ssi_setup() makes the same as fsl_ssi_set_dai_fmt() but it relies on DT properties. In most cases the settings of fsl_ssi_setup() are already overwritten by fsl_ssi_set_dai_fmt() when it is called by the soc-core when a sound card is added. As these settings depend on the combination of codec and cpu DAI, this should really be done by sound cards. This patch removes fsl_ssi_setup() and adds the missing register setups to fsl_ssi_set_dai_fmt(). It also removes all calls to fsl_ssi_setup(). Signed-off-by: Markus Pargmann Signed-off-by: Mark Brown --- sound/soc/fsl/fsl_ssi.c | 143 +++++++++++++----------------------------------- 1 file changed, 39 insertions(+), 104 deletions(-) diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c index 5428a1fda260..144934eb9463 100644 --- a/sound/soc/fsl/fsl_ssi.c +++ b/sound/soc/fsl/fsl_ssi.c @@ -642,96 +642,6 @@ static void fsl_ssi_setup_ac97(struct fsl_ssi_private *ssi_private) write_ssi(CCSR_SSI_SOR_WAIT(3), &ssi->sor); } -static int fsl_ssi_setup(struct fsl_ssi_private *ssi_private) -{ - struct ccsr_ssi __iomem *ssi = ssi_private->ssi; - u8 wm; - int synchronous = ssi_private->cpu_dai_drv.symmetric_rates; - - fsl_ssi_setup_reg_vals(ssi_private); - - if (ssi_private->imx_ac97) - ssi_private->i2s_mode = CCSR_SSI_SCR_I2S_MODE_NORMAL | CCSR_SSI_SCR_NET; - else - ssi_private->i2s_mode = CCSR_SSI_SCR_I2S_MODE_SLAVE; - - /* - * Section 16.5 of the MPC8610 reference manual says that the SSI needs - * to be disabled before updating the registers we set here. - */ - write_ssi_mask(&ssi->scr, CCSR_SSI_SCR_SSIEN, 0); - - /* - * Program the SSI into I2S Slave Non-Network Synchronous mode. Also - * enable the transmit and receive FIFO. - * - * FIXME: Little-endian samples require a different shift dir - */ - write_ssi_mask(&ssi->scr, - CCSR_SSI_SCR_I2S_MODE_MASK | CCSR_SSI_SCR_SYN, - CCSR_SSI_SCR_TFR_CLK_DIS | - ssi_private->i2s_mode | - (synchronous ? CCSR_SSI_SCR_SYN : 0)); - - write_ssi(CCSR_SSI_STCR_TXBIT0 | CCSR_SSI_STCR_TFSI | - CCSR_SSI_STCR_TEFS | CCSR_SSI_STCR_TSCKP, &ssi->stcr); - - write_ssi(CCSR_SSI_SRCR_RXBIT0 | CCSR_SSI_SRCR_RFSI | - CCSR_SSI_SRCR_REFS | CCSR_SSI_SRCR_RSCKP, &ssi->srcr); - - /* - * The DC and PM bits are only used if the SSI is the clock master. - */ - - /* - * Set the watermark for transmit FIFI 0 and receive FIFO 0. We don't - * use FIFO 1. We program the transmit water to signal a DMA transfer - * if there are only two (or fewer) elements left in the FIFO. Two - * elements equals one frame (left channel, right channel). This value, - * however, depends on the depth of the transmit buffer. - * - * We set the watermark on the same level as the DMA burstsize. For - * fiq it is probably better to use the biggest possible watermark - * size. - */ - if (ssi_private->use_dma) - wm = ssi_private->fifo_depth - 2; - else - wm = ssi_private->fifo_depth; - - write_ssi(CCSR_SSI_SFCSR_TFWM0(wm) | CCSR_SSI_SFCSR_RFWM0(wm) | - CCSR_SSI_SFCSR_TFWM1(wm) | CCSR_SSI_SFCSR_RFWM1(wm), - &ssi->sfcsr); - - /* - * For ac97 interrupts are enabled with the startup of the substream - * because it is also running without an active substream. Normally SSI - * is only enabled when there is a substream. - */ - if (ssi_private->imx_ac97) - fsl_ssi_setup_ac97(ssi_private); - - /* - * Set a default slot number so that there is no need for those common - * cases like I2S mode to call the extra set_tdm_slot() any more. - */ - if (!ssi_private->imx_ac97) { - write_ssi_mask(&ssi->stccr, CCSR_SSI_SxCCR_DC_MASK, - CCSR_SSI_SxCCR_DC(2)); - write_ssi_mask(&ssi->srccr, CCSR_SSI_SxCCR_DC_MASK, - CCSR_SSI_SxCCR_DC(2)); - } - - if (ssi_private->use_dual_fifo) { - write_ssi_mask(&ssi->srcr, 0, CCSR_SSI_SRCR_RFEN1); - write_ssi_mask(&ssi->stcr, 0, CCSR_SSI_STCR_TFEN1); - write_ssi_mask(&ssi->scr, 0, CCSR_SSI_SCR_TCH_EN); - } - - return 0; -} - - /** * fsl_ssi_startup: create a new substream * @@ -748,12 +658,7 @@ static int fsl_ssi_startup(struct snd_pcm_substream *substream, snd_soc_dai_get_drvdata(rtd->cpu_dai); unsigned long flags; - /* First, we only do fsl_ssi_setup() when SSI is going to be active. - * Second, fsl_ssi_setup was already called by ac97_init earlier if - * the driver is in ac97 mode. - */ if (!dai->active && !ssi_private->imx_ac97) { - fsl_ssi_setup(ssi_private); spin_lock_irqsave(&ssi_private->baudclk_lock, flags); ssi_private->baudclk_locked = false; spin_unlock_irqrestore(&ssi_private->baudclk_lock, flags); @@ -835,6 +740,9 @@ static int fsl_ssi_set_dai_fmt(struct snd_soc_dai *cpu_dai, unsigned int fmt) struct fsl_ssi_private *ssi_private = snd_soc_dai_get_drvdata(cpu_dai); struct ccsr_ssi __iomem *ssi = ssi_private->ssi; u32 strcr = 0, stcr, srcr, scr, mask; + u8 wm; + + fsl_ssi_setup_reg_vals(ssi_private); scr = read_ssi(&ssi->scr) & ~(CCSR_SSI_SCR_SYN | CCSR_SSI_SCR_I2S_MODE_MASK); scr |= CCSR_SSI_SCR_NET; @@ -857,7 +765,6 @@ static int fsl_ssi_set_dai_fmt(struct snd_soc_dai *cpu_dai, unsigned int fmt) default: return -EINVAL; } - scr |= ssi_private->i2s_mode; /* Data on rising edge of bclk, frame low, 1clk before data */ strcr |= CCSR_SSI_STCR_TFSI | CCSR_SSI_STCR_TSCKP | @@ -877,9 +784,13 @@ static int fsl_ssi_set_dai_fmt(struct snd_soc_dai *cpu_dai, unsigned int fmt) strcr |= CCSR_SSI_STCR_TFSL | CCSR_SSI_STCR_TSCKP | CCSR_SSI_STCR_TXBIT0; break; + case SND_SOC_DAIFMT_AC97: + ssi_private->i2s_mode = CCSR_SSI_SCR_I2S_MODE_NORMAL; + break; default: return -EINVAL; } + scr |= ssi_private->i2s_mode; /* DAI clock inversion */ switch (fmt & SND_SOC_DAIFMT_INV_MASK) { @@ -929,6 +840,38 @@ static int fsl_ssi_set_dai_fmt(struct snd_soc_dai *cpu_dai, unsigned int fmt) write_ssi(srcr, &ssi->srcr); write_ssi(scr, &ssi->scr); + /* + * Set the watermark for transmit FIFI 0 and receive FIFO 0. We don't + * use FIFO 1. We program the transmit water to signal a DMA transfer + * if there are only two (or fewer) elements left in the FIFO. Two + * elements equals one frame (left channel, right channel). This value, + * however, depends on the depth of the transmit buffer. + * + * We set the watermark on the same level as the DMA burstsize. For + * fiq it is probably better to use the biggest possible watermark + * size. + */ + if (ssi_private->use_dma) + wm = ssi_private->fifo_depth - 2; + else + wm = ssi_private->fifo_depth; + + write_ssi(CCSR_SSI_SFCSR_TFWM0(wm) | CCSR_SSI_SFCSR_RFWM0(wm) | + CCSR_SSI_SFCSR_TFWM1(wm) | CCSR_SSI_SFCSR_RFWM1(wm), + &ssi->sfcsr); + + if (ssi_private->use_dual_fifo) { + write_ssi_mask(&ssi->srcr, CCSR_SSI_SRCR_RFEN1, + CCSR_SSI_SRCR_RFEN1); + write_ssi_mask(&ssi->stcr, CCSR_SSI_STCR_TFEN1, + CCSR_SSI_STCR_TFEN1); + write_ssi_mask(&ssi->scr, CCSR_SSI_SCR_TCH_EN, + CCSR_SSI_SCR_TCH_EN); + } + + if (fmt & SND_SOC_DAIFMT_AC97) + fsl_ssi_setup_ac97(ssi_private); + return 0; } @@ -1184,11 +1127,6 @@ static struct snd_soc_dai_driver fsl_ssi_ac97_dai = { static struct fsl_ssi_private *fsl_ac97_data; -static void fsl_ssi_ac97_init(void) -{ - fsl_ssi_setup(fsl_ac97_data); -} - static void fsl_ssi_ac97_write(struct snd_ac97 *ac97, unsigned short reg, unsigned short val) { @@ -1547,9 +1485,6 @@ static int fsl_ssi_probe(struct platform_device *pdev) } done: - if (ssi_private->imx_ac97) - fsl_ssi_ac97_init(); - return 0; error_dai: -- cgit v1.2.3 From 07a28dbe7ad8e72868239450ff796c90e621d46f Mon Sep 17 00:00:00 2001 From: Markus Pargmann Date: Sat, 15 Mar 2014 13:44:10 +0100 Subject: ASoC: fsl-ssi: Fix i2s_mode variable setup In fsl_ssi_hw_params() we update the I2S and NET bits using the i2s_mode variable. The fsl_ssi_set_dai_fmt() function only writes the i2s-mode to the i2s_mode variable and not the NET bit. This fixes it by adding that bit to i2s_mode. Signed-off-by: Markus Pargmann Signed-off-by: Mark Brown --- sound/soc/fsl/fsl_ssi.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c index 144934eb9463..fdb123d6817c 100644 --- a/sound/soc/fsl/fsl_ssi.c +++ b/sound/soc/fsl/fsl_ssi.c @@ -745,7 +745,6 @@ static int fsl_ssi_set_dai_fmt(struct snd_soc_dai *cpu_dai, unsigned int fmt) fsl_ssi_setup_reg_vals(ssi_private); scr = read_ssi(&ssi->scr) & ~(CCSR_SSI_SCR_SYN | CCSR_SSI_SCR_I2S_MODE_MASK); - scr |= CCSR_SSI_SCR_NET; mask = CCSR_SSI_STCR_TXBIT0 | CCSR_SSI_STCR_TFDIR | CCSR_SSI_STCR_TXDIR | CCSR_SSI_STCR_TSCKP | CCSR_SSI_STCR_TFSI | CCSR_SSI_STCR_TFSL | @@ -753,14 +752,15 @@ static int fsl_ssi_set_dai_fmt(struct snd_soc_dai *cpu_dai, unsigned int fmt) stcr = read_ssi(&ssi->stcr) & ~mask; srcr = read_ssi(&ssi->srcr) & ~mask; + ssi_private->i2s_mode = CCSR_SSI_SCR_NET; switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { case SND_SOC_DAIFMT_I2S: switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { case SND_SOC_DAIFMT_CBS_CFS: - ssi_private->i2s_mode = CCSR_SSI_SCR_I2S_MODE_MASTER; + ssi_private->i2s_mode |= CCSR_SSI_SCR_I2S_MODE_MASTER; break; case SND_SOC_DAIFMT_CBM_CFM: - ssi_private->i2s_mode = CCSR_SSI_SCR_I2S_MODE_SLAVE; + ssi_private->i2s_mode |= CCSR_SSI_SCR_I2S_MODE_SLAVE; break; default: return -EINVAL; @@ -785,7 +785,7 @@ static int fsl_ssi_set_dai_fmt(struct snd_soc_dai *cpu_dai, unsigned int fmt) CCSR_SSI_STCR_TXBIT0; break; case SND_SOC_DAIFMT_AC97: - ssi_private->i2s_mode = CCSR_SSI_SCR_I2S_MODE_NORMAL; + ssi_private->i2s_mode |= CCSR_SSI_SCR_I2S_MODE_NORMAL; break; default: return -EINVAL; -- cgit v1.2.3 From 74a1672068c7f52f1525a5fca17cdc1ed6961239 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Wed, 12 Mar 2014 15:27:30 +0100 Subject: ASoC: ams-delta: Convert to table based DAPM and control setup Use table based setup to register the controls and DAPM widgets and routes. This on one hand makes the code a bit shorter and cleaner and on the other hand the board level DAPM elements get registered in the card's DAPM context rather than in the CODEC's DAPM context. Signed-off-by: Lars-Peter Clausen Signed-off-by: Mark Brown --- sound/soc/omap/ams-delta.c | 64 +++++++++++++++------------------------------- 1 file changed, 21 insertions(+), 43 deletions(-) diff --git a/sound/soc/omap/ams-delta.c b/sound/soc/omap/ams-delta.c index 56a5219c0a00..2ac0a0c3b570 100644 --- a/sound/soc/omap/ams-delta.c +++ b/sound/soc/omap/ams-delta.c @@ -38,7 +38,6 @@ #include "omap-mcbsp.h" #include "../codecs/cx20442.h" - /* Board specific DAPM widgets */ static const struct snd_soc_dapm_widget ams_delta_dapm_widgets[] = { /* Handset */ @@ -90,17 +89,23 @@ static const unsigned short ams_delta_audio_mode_pins[] = { static unsigned short ams_delta_audio_agc; +/* + * Used for passing a codec structure pointer + * from the board initialization code to the tty line discipline. + */ +static struct snd_soc_codec *cx20442_codec; + static int ams_delta_set_audio_mode(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); - struct snd_soc_dapm_context *dapm = &codec->dapm; + struct snd_soc_card *card = snd_kcontrol_chip(kcontrol); + struct snd_soc_dapm_context *dapm = &card->dapm; struct soc_enum *control = (struct soc_enum *)kcontrol->private_value; unsigned short pins; int pin, changed = 0; /* Refuse any mode changes if we are not able to control the codec. */ - if (!codec->hw_write) + if (!cx20442_codec->hw_write) return -EUNATCH; if (ucontrol->value.enumerated.item[0] >= control->items) @@ -166,8 +171,8 @@ static int ams_delta_set_audio_mode(struct snd_kcontrol *kcontrol, static int ams_delta_get_audio_mode(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); - struct snd_soc_dapm_context *dapm = &codec->dapm; + struct snd_soc_card *card = snd_kcontrol_chip(kcontrol); + struct snd_soc_dapm_context *dapm = &card->dapm; unsigned short pins, mode; pins = ((snd_soc_dapm_get_pin_status(dapm, "Mouthpiece") << @@ -270,12 +275,6 @@ static void cx81801_timeout(unsigned long data) ams_delta_latch2_write(AMS_DELTA_LATCH2_MODEM_CODEC, 0); } -/* - * Used for passing a codec structure pointer - * from the board initialization code to the tty line discipline. - */ -static struct snd_soc_codec *cx20442_codec; - /* Line discipline .open() */ static int cx81801_open(struct tty_struct *tty) { @@ -302,7 +301,7 @@ static int cx81801_open(struct tty_struct *tty) static void cx81801_close(struct tty_struct *tty) { struct snd_soc_codec *codec = tty->disc_data; - struct snd_soc_dapm_context *dapm = &codec->dapm; + struct snd_soc_dapm_context *dapm = &codec->card->dapm; del_timer_sync(&cx81801_timer); @@ -475,15 +474,14 @@ static void ams_delta_shutdown(struct snd_pcm_substream *substream) static int ams_delta_cx20442_init(struct snd_soc_pcm_runtime *rtd) { - struct snd_soc_codec *codec = rtd->codec; - struct snd_soc_dapm_context *dapm = &codec->dapm; struct snd_soc_dai *codec_dai = rtd->codec_dai; struct snd_soc_card *card = rtd->card; + struct snd_soc_dapm_context *dapm = &card->dapm; int ret; /* Codec is ready, now add/activate board specific controls */ /* Store a pointer to the codec structure for tty ldisc use */ - cx20442_codec = codec; + cx20442_codec = rtd->codec; /* Set up digital mute if not provided by the codec */ if (!codec_dai->driver->ops) { @@ -520,25 +518,6 @@ static int ams_delta_cx20442_init(struct snd_soc_pcm_runtime *rtd) return 0; } - /* Add board specific DAPM widgets and routes */ - ret = snd_soc_dapm_new_controls(dapm, ams_delta_dapm_widgets, - ARRAY_SIZE(ams_delta_dapm_widgets)); - if (ret) { - dev_warn(card->dev, - "Failed to register DAPM controls, " - "will continue without any.\n"); - return 0; - } - - ret = snd_soc_dapm_add_routes(dapm, ams_delta_audio_map, - ARRAY_SIZE(ams_delta_audio_map)); - if (ret) { - dev_warn(card->dev, - "Failed to set up DAPM routes, " - "will continue with codec default map.\n"); - return 0; - } - /* Set up initial pin constellation */ snd_soc_dapm_disable_pin(dapm, "Mouthpiece"); snd_soc_dapm_enable_pin(dapm, "Earpiece"); @@ -547,14 +526,6 @@ static int ams_delta_cx20442_init(struct snd_soc_pcm_runtime *rtd) snd_soc_dapm_disable_pin(dapm, "AGCIN"); snd_soc_dapm_disable_pin(dapm, "AGCOUT"); - /* Add virtual switch */ - ret = snd_soc_add_codec_controls(codec, ams_delta_audio_controls, - ARRAY_SIZE(ams_delta_audio_controls)); - if (ret) - dev_warn(card->dev, - "Failed to register audio mode control, " - "will continue without it.\n"); - return 0; } @@ -576,6 +547,13 @@ static struct snd_soc_card ams_delta_audio_card = { .owner = THIS_MODULE, .dai_link = &ams_delta_dai_link, .num_links = 1, + + .controls = ams_delta_audio_controls, + .num_controls = ARRAY_SIZE(ams_delta_audio_controls), + .dapm_widgets = ams_delta_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(ams_delta_dapm_widgets), + .dapm_routes = ams_delta_audio_map, + .num_dapm_routes = ARRAY_SIZE(ams_delta_audio_map), }; /* Module init/exit */ -- cgit v1.2.3 From 81fc5dd4d19faa3dda886910cb8fdad639fa828b Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Wed, 12 Mar 2014 15:27:33 +0100 Subject: ASoC: omap: rx51: Convert to table based control and DAPM setup Use table based setup to register the controls and DAPM widgets and routes. This on one hand makes the code a bit shorter and cleaner and on the other hand the board level DAPM elements get registered in the card's DAPM context rather than in the CODEC's DAPM context. Signed-off-by: Lars-Peter Clausen Signed-off-by: Mark Brown --- sound/soc/omap/rx51.c | 47 +++++++---------------------------------------- 1 file changed, 7 insertions(+), 40 deletions(-) diff --git a/sound/soc/omap/rx51.c b/sound/soc/omap/rx51.c index 7fb3d4b10370..2b4641123142 100644 --- a/sound/soc/omap/rx51.c +++ b/sound/soc/omap/rx51.c @@ -237,9 +237,6 @@ static const struct snd_soc_dapm_widget aic34_dapm_widgets[] = { SND_SOC_DAPM_HP("Headphone Jack", rx51_hp_event), SND_SOC_DAPM_MIC("HS Mic", NULL), SND_SOC_DAPM_LINE("FM Transmitter", NULL), -}; - -static const struct snd_soc_dapm_widget aic34_dapm_widgetsb[] = { SND_SOC_DAPM_SPK("Earphone", NULL), }; @@ -253,9 +250,7 @@ static const struct snd_soc_dapm_route audio_map[] = { {"DMic Rate 64", NULL, "Mic Bias"}, {"Mic Bias", NULL, "DMic"}, -}; -static const struct snd_soc_dapm_route audio_mapb[] = { {"b LINE2R", NULL, "MONO_LOUT"}, {"Earphone", NULL, "b HPLOUT"}, @@ -281,9 +276,6 @@ static const struct snd_kcontrol_new aic34_rx51_controls[] = { SOC_ENUM_EXT("Jack Function", rx51_enum[2], rx51_get_jack, rx51_set_jack), SOC_DAPM_PIN_SWITCH("FM Transmitter"), -}; - -static const struct snd_kcontrol_new aic34_rx51_controlsb[] = { SOC_DAPM_PIN_SWITCH("Earphone"), }; @@ -298,19 +290,6 @@ static int rx51_aic34_init(struct snd_soc_pcm_runtime *rtd) snd_soc_dapm_nc_pin(dapm, "MIC3R"); snd_soc_dapm_nc_pin(dapm, "LINE1R"); - /* Add RX-51 specific controls */ - err = snd_soc_add_card_controls(rtd->card, aic34_rx51_controls, - ARRAY_SIZE(aic34_rx51_controls)); - if (err < 0) - return err; - - /* Add RX-51 specific widgets */ - snd_soc_dapm_new_controls(dapm, aic34_dapm_widgets, - ARRAY_SIZE(aic34_dapm_widgets)); - - /* Set up RX-51 specific audio path audio_map */ - snd_soc_dapm_add_routes(dapm, audio_map, ARRAY_SIZE(audio_map)); - err = tpa6130a2_add_controls(codec); if (err < 0) return err; @@ -333,24 +312,6 @@ static int rx51_aic34_init(struct snd_soc_pcm_runtime *rtd) return err; } -static int rx51_aic34b_init(struct snd_soc_dapm_context *dapm) -{ - int err; - - err = snd_soc_add_card_controls(dapm->card, aic34_rx51_controlsb, - ARRAY_SIZE(aic34_rx51_controlsb)); - if (err < 0) - return err; - - err = snd_soc_dapm_new_controls(dapm, aic34_dapm_widgetsb, - ARRAY_SIZE(aic34_dapm_widgetsb)); - if (err < 0) - return 0; - - return snd_soc_dapm_add_routes(dapm, audio_mapb, - ARRAY_SIZE(audio_mapb)); -} - /* Digital audio interface glue - connects codec <--> CPU */ static struct snd_soc_dai_link rx51_dai[] = { { @@ -371,7 +332,6 @@ static struct snd_soc_aux_dev rx51_aux_dev[] = { { .name = "TLV320AIC34b", .codec_name = "tlv320aic3x-codec.2-0019", - .init = rx51_aic34b_init, }, }; @@ -392,6 +352,13 @@ static struct snd_soc_card rx51_sound_card = { .num_aux_devs = ARRAY_SIZE(rx51_aux_dev), .codec_conf = rx51_codec_conf, .num_configs = ARRAY_SIZE(rx51_codec_conf), + + .controls = aic34_rx51_controls, + .num_controls = ARRAY_SIZE(aic34_rx51_controls), + .dapm_widgets = aic34_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(aic34_dapm_widgets), + .dapm_routes = audio_map, + .num_dapm_routes = ARRAY_SIZE(audio_map), }; static struct platform_device *rx51_snd_device; -- cgit v1.2.3 From b2e69054ea1a36f2c1ace15a55240937aa091cba Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Wed, 12 Mar 2014 15:27:34 +0100 Subject: ASoC: omap3pandora: Convert to table based DAPM setup Use table based setup to register the controls and DAPM widgets and routes. This on one hand makes the code a bit shorter and cleaner and on the other hand the board level DAPM elements get registered in the card's DAPM context rather than in the CODEC's DAPM context. Signed-off-by: Lars-Peter Clausen Signed-off-by: Mark Brown --- sound/soc/omap/omap3pandora.c | 31 +++++++++---------------------- 1 file changed, 9 insertions(+), 22 deletions(-) diff --git a/sound/soc/omap/omap3pandora.c b/sound/soc/omap/omap3pandora.c index cf604a2faa18..02181bb70400 100644 --- a/sound/soc/omap/omap3pandora.c +++ b/sound/soc/omap/omap3pandora.c @@ -121,7 +121,7 @@ static int omap3pandora_hp_event(struct snd_soc_dapm_widget *w, * |A| <~~clk~~+ * |P| <--- TWL4030 <--------- Line In and MICs */ -static const struct snd_soc_dapm_widget omap3pandora_out_dapm_widgets[] = { +static const struct snd_soc_dapm_widget omap3pandora_dapm_widgets[] = { SND_SOC_DAPM_DAC_E("PCM DAC", "HiFi Playback", SND_SOC_NOPM, 0, 0, omap3pandora_dac_event, SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD), @@ -130,22 +130,18 @@ static const struct snd_soc_dapm_widget omap3pandora_out_dapm_widgets[] = { SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD), SND_SOC_DAPM_HP("Headphone Jack", NULL), SND_SOC_DAPM_LINE("Line Out", NULL), -}; -static const struct snd_soc_dapm_widget omap3pandora_in_dapm_widgets[] = { SND_SOC_DAPM_MIC("Mic (internal)", NULL), SND_SOC_DAPM_MIC("Mic (external)", NULL), SND_SOC_DAPM_LINE("Line In", NULL), }; -static const struct snd_soc_dapm_route omap3pandora_out_map[] = { +static const struct snd_soc_dapm_route omap3pandora_map[] = { {"PCM DAC", NULL, "APLL Enable"}, {"Headphone Amplifier", NULL, "PCM DAC"}, {"Line Out", NULL, "PCM DAC"}, {"Headphone Jack", NULL, "Headphone Amplifier"}, -}; -static const struct snd_soc_dapm_route omap3pandora_in_map[] = { {"AUXL", NULL, "Line In"}, {"AUXR", NULL, "Line In"}, @@ -160,7 +156,6 @@ static int omap3pandora_out_init(struct snd_soc_pcm_runtime *rtd) { struct snd_soc_codec *codec = rtd->codec; struct snd_soc_dapm_context *dapm = &codec->dapm; - int ret; /* All TWL4030 output pins are floating */ snd_soc_dapm_nc_pin(dapm, "EARPIECE"); @@ -174,20 +169,13 @@ static int omap3pandora_out_init(struct snd_soc_pcm_runtime *rtd) snd_soc_dapm_nc_pin(dapm, "HFR"); snd_soc_dapm_nc_pin(dapm, "VIBRA"); - ret = snd_soc_dapm_new_controls(dapm, omap3pandora_out_dapm_widgets, - ARRAY_SIZE(omap3pandora_out_dapm_widgets)); - if (ret < 0) - return ret; - - return snd_soc_dapm_add_routes(dapm, omap3pandora_out_map, - ARRAY_SIZE(omap3pandora_out_map)); + return 0; } static int omap3pandora_in_init(struct snd_soc_pcm_runtime *rtd) { struct snd_soc_codec *codec = rtd->codec; struct snd_soc_dapm_context *dapm = &codec->dapm; - int ret; /* Not comnnected */ snd_soc_dapm_nc_pin(dapm, "HSMIC"); @@ -195,13 +183,7 @@ static int omap3pandora_in_init(struct snd_soc_pcm_runtime *rtd) snd_soc_dapm_nc_pin(dapm, "DIGIMIC0"); snd_soc_dapm_nc_pin(dapm, "DIGIMIC1"); - ret = snd_soc_dapm_new_controls(dapm, omap3pandora_in_dapm_widgets, - ARRAY_SIZE(omap3pandora_in_dapm_widgets)); - if (ret < 0) - return ret; - - return snd_soc_dapm_add_routes(dapm, omap3pandora_in_map, - ARRAY_SIZE(omap3pandora_in_map)); + return 0; } static struct snd_soc_ops omap3pandora_ops = { @@ -241,6 +223,11 @@ static struct snd_soc_card snd_soc_card_omap3pandora = { .owner = THIS_MODULE, .dai_link = omap3pandora_dai, .num_links = ARRAY_SIZE(omap3pandora_dai), + + .dapm_widgets = omap3pandora_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(omap3pandora_dapm_widgets), + .dapm_routes = omap3pandora_map, + .num_dapm_routes = ARRAY_SIZE(omap3pandora_map), }; static struct platform_device *omap3pandora_snd_device; -- cgit v1.2.3 From 4c9185be5e8eefd10b0f172e794b108697d86985 Mon Sep 17 00:00:00 2001 From: Oder Chiou Date: Thu, 27 Mar 2014 15:55:47 +0800 Subject: ASoC: rt5640: Move cache sync() to resume() The patch fixes the defect in case of resume which doesn't sync the cache. Signed-off-by: Oder Chiou Signed-off-by: Mark Brown --- sound/soc/codecs/rt5640.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sound/soc/codecs/rt5640.c b/sound/soc/codecs/rt5640.c index 68b4dd622b87..4a7bd0a16912 100644 --- a/sound/soc/codecs/rt5640.c +++ b/sound/soc/codecs/rt5640.c @@ -1890,11 +1890,9 @@ static int rt5640_set_dai_pll(struct snd_soc_dai *dai, int pll_id, int source, static int rt5640_set_bias_level(struct snd_soc_codec *codec, enum snd_soc_bias_level level) { - struct rt5640_priv *rt5640 = snd_soc_codec_get_drvdata(codec); switch (level) { case SND_SOC_BIAS_STANDBY: if (SND_SOC_BIAS_OFF == codec->dapm.bias_level) { - regcache_cache_only(rt5640->regmap, false); snd_soc_update_bits(codec, RT5640_PWR_ANLG1, RT5640_PWR_VREF1 | RT5640_PWR_MB | RT5640_PWR_BG | RT5640_PWR_VREF2, @@ -1904,7 +1902,6 @@ static int rt5640_set_bias_level(struct snd_soc_codec *codec, snd_soc_update_bits(codec, RT5640_PWR_ANLG1, RT5640_PWR_FV1 | RT5640_PWR_FV2, RT5640_PWR_FV1 | RT5640_PWR_FV2); - regcache_sync(rt5640->regmap); snd_soc_update_bits(codec, RT5640_DUMMY1, 0x0301, 0x0301); snd_soc_update_bits(codec, RT5640_MICBIAS, @@ -1979,6 +1976,9 @@ static int rt5640_resume(struct snd_soc_codec *codec) msleep(400); } + regcache_cache_only(rt5640->regmap, false); + regcache_sync(rt5640->regmap); + return 0; } #else -- cgit v1.2.3 From 9bccae733b8d0e281729464267191103c09b3d13 Mon Sep 17 00:00:00 2001 From: Oder Chiou Date: Thu, 27 Mar 2014 19:34:51 +0800 Subject: ASoC: rt5640: Correct the judgement of data length The patch corrects the judgement of data length. Signed-off-by: Oder Chiou Signed-off-by: Mark Brown --- sound/soc/codecs/rt5640.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/sound/soc/codecs/rt5640.c b/sound/soc/codecs/rt5640.c index 4a7bd0a16912..f0717db3e935 100644 --- a/sound/soc/codecs/rt5640.c +++ b/sound/soc/codecs/rt5640.c @@ -1622,16 +1622,16 @@ static int rt5640_hw_params(struct snd_pcm_substream *substream, dev_dbg(dai->dev, "bclk_ms is %d and pre_div is %d for iis %d\n", bclk_ms, pre_div, dai->id); - switch (params_format(params)) { - case SNDRV_PCM_FORMAT_S16_LE: + switch (params_width(params)) { + case 16: break; - case SNDRV_PCM_FORMAT_S20_3LE: + case 20: val_len |= RT5640_I2S_DL_20; break; - case SNDRV_PCM_FORMAT_S24_LE: + case 24: val_len |= RT5640_I2S_DL_24; break; - case SNDRV_PCM_FORMAT_S8: + case 8: val_len |= RT5640_I2S_DL_8; break; default: -- cgit v1.2.3 From 71d97a7943017faf03707836d00a260a108f4c89 Mon Sep 17 00:00:00 2001 From: Oder Chiou Date: Fri, 28 Mar 2014 10:46:18 +0800 Subject: ASoC: rt5640: Use the platform data for DMIC settings The patch uses the platform data for DMIC settings. Signed-off-by: Oder Chiou Signed-off-by: Mark Brown --- include/sound/rt5640.h | 4 +++ sound/soc/codecs/rt5640.c | 77 ++++++++++++++--------------------------------- 2 files changed, 27 insertions(+), 54 deletions(-) diff --git a/include/sound/rt5640.h b/include/sound/rt5640.h index 27cc75ed67f8..59d26dd81e45 100644 --- a/include/sound/rt5640.h +++ b/include/sound/rt5640.h @@ -16,6 +16,10 @@ struct rt5640_platform_data { bool in1_diff; bool in2_diff; + bool dmic_en; + bool dmic1_data_pin; /* 0 = IN1P; 1 = GPIO3 */ + bool dmic2_data_pin; /* 0 = IN1N; 1 = GPIO4 */ + int ldo1_en; /* GPIO for LDO1_EN */ }; diff --git a/sound/soc/codecs/rt5640.c b/sound/soc/codecs/rt5640.c index f0717db3e935..6ede622ad44f 100644 --- a/sound/soc/codecs/rt5640.c +++ b/sound/soc/codecs/rt5640.c @@ -872,54 +872,6 @@ static SOC_ENUM_SINGLE_DECL(rt5640_sdi_sel_enum, RT5640_I2S2_SDP, static const struct snd_kcontrol_new rt5640_sdi_mux = SOC_DAPM_ENUM("SDI select", rt5640_sdi_sel_enum); -static int rt5640_set_dmic1_event(struct snd_soc_dapm_widget *w, - struct snd_kcontrol *kcontrol, int event) -{ - struct snd_soc_codec *codec = w->codec; - - switch (event) { - case SND_SOC_DAPM_PRE_PMU: - snd_soc_update_bits(codec, RT5640_GPIO_CTRL1, - RT5640_GP2_PIN_MASK | RT5640_GP3_PIN_MASK, - RT5640_GP2_PIN_DMIC1_SCL | RT5640_GP3_PIN_DMIC1_SDA); - snd_soc_update_bits(codec, RT5640_DMIC, - RT5640_DMIC_1L_LH_MASK | RT5640_DMIC_1R_LH_MASK | - RT5640_DMIC_1_DP_MASK, - RT5640_DMIC_1L_LH_FALLING | RT5640_DMIC_1R_LH_RISING | - RT5640_DMIC_1_DP_IN1P); - break; - - default: - return 0; - } - - return 0; -} - -static int rt5640_set_dmic2_event(struct snd_soc_dapm_widget *w, - struct snd_kcontrol *kcontrol, int event) -{ - struct snd_soc_codec *codec = w->codec; - - switch (event) { - case SND_SOC_DAPM_PRE_PMU: - snd_soc_update_bits(codec, RT5640_GPIO_CTRL1, - RT5640_GP2_PIN_MASK | RT5640_GP4_PIN_MASK, - RT5640_GP2_PIN_DMIC1_SCL | RT5640_GP4_PIN_DMIC2_SDA); - snd_soc_update_bits(codec, RT5640_DMIC, - RT5640_DMIC_2L_LH_MASK | RT5640_DMIC_2R_LH_MASK | - RT5640_DMIC_2_DP_MASK, - RT5640_DMIC_2L_LH_FALLING | RT5640_DMIC_2R_LH_RISING | - RT5640_DMIC_2_DP_IN1N); - break; - - default: - return 0; - } - - return 0; -} - static void hp_amp_power_on(struct snd_soc_codec *codec) { struct rt5640_priv *rt5640 = snd_soc_codec_get_drvdata(codec); @@ -1054,12 +1006,10 @@ static const struct snd_soc_dapm_widget rt5640_dapm_widgets[] = { SND_SOC_DAPM_SUPPLY("DMIC CLK", SND_SOC_NOPM, 0, 0, set_dmic_clk, SND_SOC_DAPM_PRE_PMU), - SND_SOC_DAPM_SUPPLY("DMIC1 Power", RT5640_DMIC, - RT5640_DMIC_1_EN_SFT, 0, rt5640_set_dmic1_event, - SND_SOC_DAPM_PRE_PMU), - SND_SOC_DAPM_SUPPLY("DMIC2 Power", RT5640_DMIC, - RT5640_DMIC_2_EN_SFT, 0, rt5640_set_dmic2_event, - SND_SOC_DAPM_PRE_PMU), + SND_SOC_DAPM_SUPPLY("DMIC1 Power", RT5640_DMIC, RT5640_DMIC_1_EN_SFT, 0, + NULL, 0), + SND_SOC_DAPM_SUPPLY("DMIC2 Power", RT5640_DMIC, RT5640_DMIC_2_EN_SFT, 0, + NULL, 0), /* Boost */ SND_SOC_DAPM_PGA("BST1", RT5640_PWR_ANLG2, RT5640_PWR_BST1_BIT, 0, NULL, 0), @@ -2187,6 +2137,25 @@ static int rt5640_i2c_probe(struct i2c_client *i2c, regmap_update_bits(rt5640->regmap, RT5640_IN3_IN4, RT5640_IN_DF2, RT5640_IN_DF2); + if (rt5640->pdata.dmic_en) { + regmap_update_bits(rt5640->regmap, RT5640_GPIO_CTRL1, + RT5640_GP2_PIN_MASK, RT5640_GP2_PIN_DMIC1_SCL); + + if (rt5640->pdata.dmic1_data_pin) { + regmap_update_bits(rt5640->regmap, RT5640_DMIC, + RT5640_DMIC_1_DP_MASK, RT5640_DMIC_1_DP_GPIO3); + regmap_update_bits(rt5640->regmap, RT5640_GPIO_CTRL1, + RT5640_GP3_PIN_MASK, RT5640_GP3_PIN_DMIC1_SDA); + } + + if (rt5640->pdata.dmic2_data_pin) { + regmap_update_bits(rt5640->regmap, RT5640_DMIC, + RT5640_DMIC_2_DP_MASK, RT5640_DMIC_2_DP_GPIO4); + regmap_update_bits(rt5640->regmap, RT5640_GPIO_CTRL1, + RT5640_GP4_PIN_MASK, RT5640_GP4_PIN_DMIC2_SDA); + } + } + rt5640->hp_mute = 1; ret = snd_soc_register_codec(&i2c->dev, &soc_codec_dev_rt5640, -- cgit v1.2.3 From 2f2a714c1bed2702e5abf55381c03ccdf7b0fd06 Mon Sep 17 00:00:00 2001 From: Oder Chiou Date: Fri, 28 Mar 2014 20:28:25 +0800 Subject: ASoC: rt5640: Remove the pre-allocated size of reg_default In order to prevent the redundant memory usage, the pre-allocated size of reg_default should be remove. Signed-off-by: Oder Chiou Signed-off-by: Mark Brown --- sound/soc/codecs/rt5640.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/soc/codecs/rt5640.c b/sound/soc/codecs/rt5640.c index 6ede622ad44f..84ee7ef8eb17 100644 --- a/sound/soc/codecs/rt5640.c +++ b/sound/soc/codecs/rt5640.c @@ -59,7 +59,7 @@ static struct reg_default init_list[] = { }; #define RT5640_INIT_REG_LEN ARRAY_SIZE(init_list) -static const struct reg_default rt5640_reg[RT5640_VENDOR_ID2 + 1] = { +static const struct reg_default rt5640_reg[] = { { 0x00, 0x000e }, { 0x01, 0xc8c8 }, { 0x02, 0xc8c8 }, -- cgit v1.2.3 From 218a3f963822aca1d38b0175b6454fe53d15c2dd Mon Sep 17 00:00:00 2001 From: Oder Chiou Date: Fri, 28 Mar 2014 20:28:26 +0800 Subject: ASoC: rt5640: Rename the function of clock checking In order to identify clearly, the patch renames the function "check_sysclk1_source" to "is_sys_clk_from_pll". Signed-off-by: Oder Chiou Signed-off-by: Mark Brown --- sound/soc/codecs/rt5640.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/sound/soc/codecs/rt5640.c b/sound/soc/codecs/rt5640.c index 84ee7ef8eb17..19634d0992bc 100644 --- a/sound/soc/codecs/rt5640.c +++ b/sound/soc/codecs/rt5640.c @@ -480,7 +480,7 @@ static int set_dmic_clk(struct snd_soc_dapm_widget *w, return idx; } -static int check_sysclk1_source(struct snd_soc_dapm_widget *source, +static int is_sys_clk_from_pll(struct snd_soc_dapm_widget *source, struct snd_soc_dapm_widget *sink) { unsigned int val; @@ -1273,22 +1273,22 @@ static const struct snd_soc_dapm_route rt5640_dapm_routes[] = { {"Stereo ADC MIXL", "ADC1 Switch", "Stereo ADC L1 Mux"}, {"Stereo ADC MIXL", "ADC2 Switch", "Stereo ADC L2 Mux"}, {"Stereo ADC MIXL", NULL, "Stereo Filter"}, - {"Stereo Filter", NULL, "PLL1", check_sysclk1_source}, + {"Stereo Filter", NULL, "PLL1", is_sys_clk_from_pll}, {"Stereo ADC MIXR", "ADC1 Switch", "Stereo ADC R1 Mux"}, {"Stereo ADC MIXR", "ADC2 Switch", "Stereo ADC R2 Mux"}, {"Stereo ADC MIXR", NULL, "Stereo Filter"}, - {"Stereo Filter", NULL, "PLL1", check_sysclk1_source}, + {"Stereo Filter", NULL, "PLL1", is_sys_clk_from_pll}, {"Mono ADC MIXL", "ADC1 Switch", "Mono ADC L1 Mux"}, {"Mono ADC MIXL", "ADC2 Switch", "Mono ADC L2 Mux"}, {"Mono ADC MIXL", NULL, "Mono Left Filter"}, - {"Mono Left Filter", NULL, "PLL1", check_sysclk1_source}, + {"Mono Left Filter", NULL, "PLL1", is_sys_clk_from_pll}, {"Mono ADC MIXR", "ADC1 Switch", "Mono ADC R1 Mux"}, {"Mono ADC MIXR", "ADC2 Switch", "Mono ADC R2 Mux"}, {"Mono ADC MIXR", NULL, "Mono Right Filter"}, - {"Mono Right Filter", NULL, "PLL1", check_sysclk1_source}, + {"Mono Right Filter", NULL, "PLL1", is_sys_clk_from_pll}, {"IF2 ADC L", NULL, "Mono ADC MIXL"}, {"IF2 ADC R", NULL, "Mono ADC MIXR"}, @@ -1377,13 +1377,13 @@ static const struct snd_soc_dapm_route rt5640_dapm_routes[] = { {"DIG MIXR", "DAC R2 Switch", "DAC R2 Mux"}, {"DAC L1", NULL, "Stereo DAC MIXL"}, - {"DAC L1", NULL, "PLL1", check_sysclk1_source}, + {"DAC L1", NULL, "PLL1", is_sys_clk_from_pll}, {"DAC R1", NULL, "Stereo DAC MIXR"}, - {"DAC R1", NULL, "PLL1", check_sysclk1_source}, + {"DAC R1", NULL, "PLL1", is_sys_clk_from_pll}, {"DAC L2", NULL, "Mono DAC MIXL"}, - {"DAC L2", NULL, "PLL1", check_sysclk1_source}, + {"DAC L2", NULL, "PLL1", is_sys_clk_from_pll}, {"DAC R2", NULL, "Mono DAC MIXR"}, - {"DAC R2", NULL, "PLL1", check_sysclk1_source}, + {"DAC R2", NULL, "PLL1", is_sys_clk_from_pll}, {"SPK MIXL", "REC MIXL Switch", "RECMIXL"}, {"SPK MIXL", "INL Switch", "INL VOL"}, -- cgit v1.2.3 From acf04e639bba2270fd07e161fa984234591ef43b Mon Sep 17 00:00:00 2001 From: Oder Chiou Date: Fri, 28 Mar 2014 20:28:27 +0800 Subject: ASoC: rt5640: Remove the unused or incorrect setting of clock source The patch removes the unused or incorrect setting of clock source. Signed-off-by: Oder Chiou Signed-off-by: Mark Brown --- sound/soc/codecs/rt5640.c | 8 +------- sound/soc/codecs/rt5640.h | 2 -- 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/sound/soc/codecs/rt5640.c b/sound/soc/codecs/rt5640.c index 19634d0992bc..4c866135e40f 100644 --- a/sound/soc/codecs/rt5640.c +++ b/sound/soc/codecs/rt5640.c @@ -487,7 +487,7 @@ static int is_sys_clk_from_pll(struct snd_soc_dapm_widget *source, val = snd_soc_read(source->codec, RT5640_GLB_CLK); val &= RT5640_SCLK_SRC_MASK; - if (val == RT5640_SCLK_SRC_PLL1 || val == RT5640_SCLK_SRC_PLL1T) + if (val == RT5640_SCLK_SRC_PLL1) return 1; else return 0; @@ -1694,12 +1694,6 @@ static int rt5640_set_dai_sysclk(struct snd_soc_dai *dai, case RT5640_SCLK_S_PLL1: reg_val |= RT5640_SCLK_SRC_PLL1; break; - case RT5640_SCLK_S_PLL1_TK: - reg_val |= RT5640_SCLK_SRC_PLL1T; - break; - case RT5640_SCLK_S_RCCLK: - reg_val |= RT5640_SCLK_SRC_RCCLK; - break; default: dev_err(codec->dev, "Invalid clock id (%d)\n", clk_id); return -EINVAL; diff --git a/sound/soc/codecs/rt5640.h b/sound/soc/codecs/rt5640.h index 5e8df25a13f3..cbd07b5f8060 100644 --- a/sound/soc/codecs/rt5640.h +++ b/sound/soc/codecs/rt5640.h @@ -976,8 +976,6 @@ #define RT5640_SCLK_SRC_SFT 14 #define RT5640_SCLK_SRC_MCLK (0x0 << 14) #define RT5640_SCLK_SRC_PLL1 (0x1 << 14) -#define RT5640_SCLK_SRC_PLL1T (0x2 << 14) -#define RT5640_SCLK_SRC_RCCLK (0x3 << 14) /* 15MHz */ #define RT5640_PLL1_SRC_MASK (0x3 << 12) #define RT5640_PLL1_SRC_SFT 12 #define RT5640_PLL1_SRC_MCLK (0x0 << 12) -- cgit v1.2.3 From bc49e462cd6ded128cc6dbb6775de4a4c3d6bbc8 Mon Sep 17 00:00:00 2001 From: Oder Chiou Date: Fri, 28 Mar 2014 20:28:28 +0800 Subject: ASoC: rt5640: Remove the unused field in private data The patch removes the unused field in private data. Signed-off-by: Oder Chiou Signed-off-by: Mark Brown --- sound/soc/codecs/rt5640.h | 1 - 1 file changed, 1 deletion(-) diff --git a/sound/soc/codecs/rt5640.h b/sound/soc/codecs/rt5640.h index cbd07b5f8060..d7bd525caf85 100644 --- a/sound/soc/codecs/rt5640.h +++ b/sound/soc/codecs/rt5640.h @@ -2095,7 +2095,6 @@ struct rt5640_priv { int pll_in; int pll_out; - int dmic_en; bool hp_mute; }; -- cgit v1.2.3 From 3441e524293c5e8d640488e343f2eb2bcc944108 Mon Sep 17 00:00:00 2001 From: Oder Chiou Date: Fri, 28 Mar 2014 20:28:29 +0800 Subject: ASoC: rt5640: Remove the unnecessary parentheses The patch removes the unnecessary parentheses. Signed-off-by: Oder Chiou Signed-off-by: Mark Brown --- sound/soc/codecs/rt5640.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/soc/codecs/rt5640.c b/sound/soc/codecs/rt5640.c index 4c866135e40f..b6a02c16f100 100644 --- a/sound/soc/codecs/rt5640.c +++ b/sound/soc/codecs/rt5640.c @@ -2110,7 +2110,7 @@ static int rt5640_i2c_probe(struct i2c_client *i2c, } regmap_read(rt5640->regmap, RT5640_VENDOR_ID2, &val); - if ((val != RT5640_DEVICE_ID)) { + if (val != RT5640_DEVICE_ID) { dev_err(&i2c->dev, "Device with ID register %x is not rt5640/39\n", val); return -ENODEV; -- cgit v1.2.3 From 09caf300540c4a610dbe6e46afdab18f365be7e7 Mon Sep 17 00:00:00 2001 From: Oder Chiou Date: Mon, 31 Mar 2014 10:21:10 +0800 Subject: ASoC: rt5640: Change the setting method of idle_bias_off The patch moves the idle_bias_off setting to struct "soc_codec_dev_rt5640". Signed-off-by: Oder Chiou Signed-off-by: Mark Brown --- sound/soc/codecs/rt5640.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/soc/codecs/rt5640.c b/sound/soc/codecs/rt5640.c index b6a02c16f100..a7db7ef38cfc 100644 --- a/sound/soc/codecs/rt5640.c +++ b/sound/soc/codecs/rt5640.c @@ -1879,7 +1879,6 @@ static int rt5640_probe(struct snd_soc_codec *codec) rt5640->codec = codec; - codec->dapm.idle_bias_off = 1; rt5640_set_bias_level(codec, SND_SOC_BIAS_OFF); snd_soc_update_bits(codec, RT5640_DUMMY1, 0x0301, 0x0301); @@ -1988,6 +1987,7 @@ static struct snd_soc_codec_driver soc_codec_dev_rt5640 = { .suspend = rt5640_suspend, .resume = rt5640_resume, .set_bias_level = rt5640_set_bias_level, + .idle_bias_off = true, .controls = rt5640_snd_controls, .num_controls = ARRAY_SIZE(rt5640_snd_controls), .dapm_widgets = rt5640_dapm_widgets, -- cgit v1.2.3 From 022d21f004c14db2151d08143a544b292324d099 Mon Sep 17 00:00:00 2001 From: Oder Chiou Date: Tue, 8 Apr 2014 19:40:00 +0800 Subject: ASoC: rt5640: add rt5639 support This patch adds the rt5639 support Signed-off-by: Oder Chiou Signed-off-by: Mark Brown --- sound/soc/codecs/rt5640.c | 286 ++++++++++++++++++++++++++++++++++------------ sound/soc/codecs/rt5640.h | 3 + 2 files changed, 213 insertions(+), 76 deletions(-) diff --git a/sound/soc/codecs/rt5640.c b/sound/soc/codecs/rt5640.c index a7db7ef38cfc..a20781eda719 100644 --- a/sound/soc/codecs/rt5640.c +++ b/sound/soc/codecs/rt5640.c @@ -398,18 +398,13 @@ static const struct snd_kcontrol_new rt5640_snd_controls[] = { RT5640_VOL_L_SFT, RT5640_VOL_R_SFT, 1, 1), SOC_DOUBLE_TLV("OUT Playback Volume", RT5640_OUTPUT, RT5640_L_VOL_SFT, RT5640_R_VOL_SFT, 39, 1, out_vol_tlv), - /* MONO Output Control */ - SOC_SINGLE("Mono Playback Switch", RT5640_MONO_OUT, - RT5640_L_MUTE_SFT, 1, 1), + /* DAC Digital Volume */ SOC_DOUBLE("DAC2 Playback Switch", RT5640_DAC2_CTRL, RT5640_M_DAC_L2_VOL_SFT, RT5640_M_DAC_R2_VOL_SFT, 1, 1), SOC_DOUBLE_TLV("DAC1 Playback Volume", RT5640_DAC1_DIG_VOL, RT5640_L_VOL_SFT, RT5640_R_VOL_SFT, 175, 0, dac_vol_tlv), - SOC_DOUBLE_TLV("Mono DAC Playback Volume", RT5640_DAC2_DIG_VOL, - RT5640_L_VOL_SFT, RT5640_R_VOL_SFT, - 175, 0, dac_vol_tlv), /* IN1/IN2 Control */ SOC_SINGLE_TLV("IN1 Boost", RT5640_IN1_IN2, RT5640_BST_SFT1, 8, 0, bst_tlv), @@ -441,6 +436,15 @@ static const struct snd_kcontrol_new rt5640_snd_controls[] = { SOC_ENUM("DAC IF2 Data Switch", rt5640_if2_dac_enum), }; +static const struct snd_kcontrol_new rt5640_specific_snd_controls[] = { + /* MONO Output Control */ + SOC_SINGLE("Mono Playback Switch", RT5640_MONO_OUT, RT5640_L_MUTE_SFT, + 1, 1), + + SOC_DOUBLE_TLV("Mono DAC Playback Volume", RT5640_DAC2_DIG_VOL, + RT5640_L_VOL_SFT, RT5640_R_VOL_SFT, 175, 0, dac_vol_tlv), +}; + /** * set_dmic_clk - Set parameter of dmic. * @@ -554,6 +558,20 @@ static const struct snd_kcontrol_new rt5640_sto_dac_r_mix[] = { RT5640_M_ANC_DAC_R_SFT, 1, 1), }; +static const struct snd_kcontrol_new rt5639_sto_dac_l_mix[] = { + SOC_DAPM_SINGLE("DAC L1 Switch", RT5640_STO_DAC_MIXER, + RT5640_M_DAC_L1_SFT, 1, 1), + SOC_DAPM_SINGLE("DAC L2 Switch", RT5640_STO_DAC_MIXER, + RT5640_M_DAC_L2_SFT, 1, 1), +}; + +static const struct snd_kcontrol_new rt5639_sto_dac_r_mix[] = { + SOC_DAPM_SINGLE("DAC R1 Switch", RT5640_STO_DAC_MIXER, + RT5640_M_DAC_R1_SFT, 1, 1), + SOC_DAPM_SINGLE("DAC R2 Switch", RT5640_STO_DAC_MIXER, + RT5640_M_DAC_R2_SFT, 1, 1), +}; + static const struct snd_kcontrol_new rt5640_mono_dac_l_mix[] = { SOC_DAPM_SINGLE("DAC L1 Switch", RT5640_MONO_DAC_MIXER, RT5640_M_DAC_L1_MONO_L_SFT, 1, 1), @@ -676,6 +694,30 @@ static const struct snd_kcontrol_new rt5640_out_r_mix[] = { RT5640_M_DAC_R1_OM_R_SFT, 1, 1), }; +static const struct snd_kcontrol_new rt5639_out_l_mix[] = { + SOC_DAPM_SINGLE("BST1 Switch", RT5640_OUT_L3_MIXER, + RT5640_M_BST1_OM_L_SFT, 1, 1), + SOC_DAPM_SINGLE("INL Switch", RT5640_OUT_L3_MIXER, + RT5640_M_IN_L_OM_L_SFT, 1, 1), + SOC_DAPM_SINGLE("REC MIXL Switch", RT5640_OUT_L3_MIXER, + RT5640_M_RM_L_OM_L_SFT, 1, 1), + SOC_DAPM_SINGLE("DAC L1 Switch", RT5640_OUT_L3_MIXER, + RT5640_M_DAC_L1_OM_L_SFT, 1, 1), +}; + +static const struct snd_kcontrol_new rt5639_out_r_mix[] = { + SOC_DAPM_SINGLE("BST2 Switch", RT5640_OUT_R3_MIXER, + RT5640_M_BST4_OM_R_SFT, 1, 1), + SOC_DAPM_SINGLE("BST1 Switch", RT5640_OUT_R3_MIXER, + RT5640_M_BST1_OM_R_SFT, 1, 1), + SOC_DAPM_SINGLE("INR Switch", RT5640_OUT_R3_MIXER, + RT5640_M_IN_R_OM_R_SFT, 1, 1), + SOC_DAPM_SINGLE("REC MIXR Switch", RT5640_OUT_R3_MIXER, + RT5640_M_RM_R_OM_R_SFT, 1, 1), + SOC_DAPM_SINGLE("DAC R1 Switch", RT5640_OUT_R3_MIXER, + RT5640_M_DAC_R1_OM_R_SFT, 1, 1), +}; + static const struct snd_kcontrol_new rt5640_spo_l_mix[] = { SOC_DAPM_SINGLE("DAC R1 Switch", RT5640_SPO_L_MIXER, RT5640_M_DAC_R1_SPM_L_SFT, 1, 1), @@ -707,6 +749,13 @@ static const struct snd_kcontrol_new rt5640_hpo_mix[] = { RT5640_M_HPVOL_HM_SFT, 1, 1), }; +static const struct snd_kcontrol_new rt5639_hpo_mix[] = { + SOC_DAPM_SINGLE("HPO MIX DAC1 Switch", RT5640_HPO_MIXER, + RT5640_M_DAC1_HM_SFT, 1, 1), + SOC_DAPM_SINGLE("HPO MIX HPVOL Switch", RT5640_HPO_MIXER, + RT5640_M_HPVOL_HM_SFT, 1, 1), +}; + static const struct snd_kcontrol_new rt5640_lout_mix[] = { SOC_DAPM_SINGLE("DAC L1 Switch", RT5640_LOUT_MIXER, RT5640_M_DAC_L1_LM_SFT, 1, 1), @@ -1096,26 +1145,15 @@ static const struct snd_soc_dapm_widget rt5640_dapm_widgets[] = { SND_SOC_DAPM_AIF_OUT("AIF1TX", "AIF1 Capture", 0, SND_SOC_NOPM, 0, 0), SND_SOC_DAPM_AIF_IN("AIF2RX", "AIF2 Playback", 0, SND_SOC_NOPM, 0, 0), SND_SOC_DAPM_AIF_OUT("AIF2TX", "AIF2 Capture", 0, SND_SOC_NOPM, 0, 0), - /* Audio DSP */ - SND_SOC_DAPM_PGA("Audio DSP", SND_SOC_NOPM, 0, 0, NULL, 0), - /* ANC */ - SND_SOC_DAPM_PGA("ANC", SND_SOC_NOPM, 0, 0, NULL, 0), + /* Output Side */ /* DAC mixer before sound effect */ SND_SOC_DAPM_MIXER("DAC MIXL", SND_SOC_NOPM, 0, 0, rt5640_dac_l_mix, ARRAY_SIZE(rt5640_dac_l_mix)), SND_SOC_DAPM_MIXER("DAC MIXR", SND_SOC_NOPM, 0, 0, rt5640_dac_r_mix, ARRAY_SIZE(rt5640_dac_r_mix)), - /* DAC2 channel Mux */ - SND_SOC_DAPM_MUX("DAC L2 Mux", SND_SOC_NOPM, 0, 0, - &rt5640_dac_l2_mux), - SND_SOC_DAPM_MUX("DAC R2 Mux", SND_SOC_NOPM, 0, 0, - &rt5640_dac_r2_mux), + /* DAC Mixer */ - SND_SOC_DAPM_MIXER("Stereo DAC MIXL", SND_SOC_NOPM, 0, 0, - rt5640_sto_dac_l_mix, ARRAY_SIZE(rt5640_sto_dac_l_mix)), - SND_SOC_DAPM_MIXER("Stereo DAC MIXR", SND_SOC_NOPM, 0, 0, - rt5640_sto_dac_r_mix, ARRAY_SIZE(rt5640_sto_dac_r_mix)), SND_SOC_DAPM_MIXER("Mono DAC MIXL", SND_SOC_NOPM, 0, 0, rt5640_mono_dac_l_mix, ARRAY_SIZE(rt5640_mono_dac_l_mix)), SND_SOC_DAPM_MIXER("Mono DAC MIXR", SND_SOC_NOPM, 0, 0, @@ -1127,21 +1165,14 @@ static const struct snd_soc_dapm_widget rt5640_dapm_widgets[] = { /* DACs */ SND_SOC_DAPM_DAC("DAC L1", NULL, RT5640_PWR_DIG1, RT5640_PWR_DAC_L1_BIT, 0), - SND_SOC_DAPM_DAC("DAC L2", NULL, RT5640_PWR_DIG1, - RT5640_PWR_DAC_L2_BIT, 0), SND_SOC_DAPM_DAC("DAC R1", NULL, RT5640_PWR_DIG1, RT5640_PWR_DAC_R1_BIT, 0), - SND_SOC_DAPM_DAC("DAC R2", NULL, RT5640_PWR_DIG1, - RT5640_PWR_DAC_R2_BIT, 0), + /* SPK/OUT Mixer */ SND_SOC_DAPM_MIXER("SPK MIXL", RT5640_PWR_MIXER, RT5640_PWR_SM_L_BIT, 0, rt5640_spk_l_mix, ARRAY_SIZE(rt5640_spk_l_mix)), SND_SOC_DAPM_MIXER("SPK MIXR", RT5640_PWR_MIXER, RT5640_PWR_SM_R_BIT, 0, rt5640_spk_r_mix, ARRAY_SIZE(rt5640_spk_r_mix)), - SND_SOC_DAPM_MIXER("OUT MIXL", RT5640_PWR_MIXER, RT5640_PWR_OM_L_BIT, - 0, rt5640_out_l_mix, ARRAY_SIZE(rt5640_out_l_mix)), - SND_SOC_DAPM_MIXER("OUT MIXR", RT5640_PWR_MIXER, RT5640_PWR_OM_R_BIT, - 0, rt5640_out_r_mix, ARRAY_SIZE(rt5640_out_r_mix)), /* Ouput Volume */ SND_SOC_DAPM_PGA("SPKVOL L", RT5640_PWR_VOL, RT5640_PWR_SV_L_BIT, 0, NULL, 0), @@ -1160,16 +1191,8 @@ static const struct snd_soc_dapm_widget rt5640_dapm_widgets[] = { 0, rt5640_spo_l_mix, ARRAY_SIZE(rt5640_spo_l_mix)), SND_SOC_DAPM_MIXER("SPOR MIX", SND_SOC_NOPM, 0, 0, rt5640_spo_r_mix, ARRAY_SIZE(rt5640_spo_r_mix)), - SND_SOC_DAPM_MIXER("HPO MIX L", SND_SOC_NOPM, 0, 0, - rt5640_hpo_mix, ARRAY_SIZE(rt5640_hpo_mix)), - SND_SOC_DAPM_MIXER("HPO MIX R", SND_SOC_NOPM, 0, 0, - rt5640_hpo_mix, ARRAY_SIZE(rt5640_hpo_mix)), SND_SOC_DAPM_MIXER("LOUT MIX", RT5640_PWR_ANLG1, RT5640_PWR_LM_BIT, 0, rt5640_lout_mix, ARRAY_SIZE(rt5640_lout_mix)), - SND_SOC_DAPM_MIXER("Mono MIX", RT5640_PWR_ANLG1, RT5640_PWR_MM_BIT, 0, - rt5640_mono_mix, ARRAY_SIZE(rt5640_mono_mix)), - SND_SOC_DAPM_SUPPLY("Improve MONO Amp Drv", RT5640_PWR_ANLG1, - RT5640_PWR_MA_BIT, 0, NULL, 0), SND_SOC_DAPM_SUPPLY_S("Improve HP Amp Drv", 1, SND_SOC_NOPM, 0, 0, rt5640_hp_power_event, SND_SOC_DAPM_POST_PMU), SND_SOC_DAPM_PGA_S("HP Amp", 1, SND_SOC_NOPM, 0, 0, @@ -1201,10 +1224,69 @@ static const struct snd_soc_dapm_widget rt5640_dapm_widgets[] = { SND_SOC_DAPM_OUTPUT("HPOR"), SND_SOC_DAPM_OUTPUT("LOUTL"), SND_SOC_DAPM_OUTPUT("LOUTR"), +}; + +static const struct snd_soc_dapm_widget rt5640_specific_dapm_widgets[] = { + /* Audio DSP */ + SND_SOC_DAPM_PGA("Audio DSP", SND_SOC_NOPM, 0, 0, NULL, 0), + /* ANC */ + SND_SOC_DAPM_PGA("ANC", SND_SOC_NOPM, 0, 0, NULL, 0), + + /* DAC2 channel Mux */ + SND_SOC_DAPM_MUX("DAC L2 Mux", SND_SOC_NOPM, 0, 0, &rt5640_dac_l2_mux), + SND_SOC_DAPM_MUX("DAC R2 Mux", SND_SOC_NOPM, 0, 0, &rt5640_dac_r2_mux), + + SND_SOC_DAPM_MIXER("Stereo DAC MIXL", SND_SOC_NOPM, 0, 0, + rt5640_sto_dac_l_mix, ARRAY_SIZE(rt5640_sto_dac_l_mix)), + SND_SOC_DAPM_MIXER("Stereo DAC MIXR", SND_SOC_NOPM, 0, 0, + rt5640_sto_dac_r_mix, ARRAY_SIZE(rt5640_sto_dac_r_mix)), + + SND_SOC_DAPM_DAC("DAC R2", NULL, RT5640_PWR_DIG1, RT5640_PWR_DAC_R2_BIT, + 0), + SND_SOC_DAPM_DAC("DAC L2", NULL, RT5640_PWR_DIG1, RT5640_PWR_DAC_L2_BIT, + 0), + + SND_SOC_DAPM_MIXER("OUT MIXL", RT5640_PWR_MIXER, RT5640_PWR_OM_L_BIT, + 0, rt5640_out_l_mix, ARRAY_SIZE(rt5640_out_l_mix)), + SND_SOC_DAPM_MIXER("OUT MIXR", RT5640_PWR_MIXER, RT5640_PWR_OM_R_BIT, + 0, rt5640_out_r_mix, ARRAY_SIZE(rt5640_out_r_mix)), + + SND_SOC_DAPM_MIXER("HPO MIX L", SND_SOC_NOPM, 0, 0, + rt5640_hpo_mix, ARRAY_SIZE(rt5640_hpo_mix)), + SND_SOC_DAPM_MIXER("HPO MIX R", SND_SOC_NOPM, 0, 0, + rt5640_hpo_mix, ARRAY_SIZE(rt5640_hpo_mix)), + + SND_SOC_DAPM_MIXER("Mono MIX", RT5640_PWR_ANLG1, RT5640_PWR_MM_BIT, 0, + rt5640_mono_mix, ARRAY_SIZE(rt5640_mono_mix)), + SND_SOC_DAPM_SUPPLY("Improve MONO Amp Drv", RT5640_PWR_ANLG1, + RT5640_PWR_MA_BIT, 0, NULL, 0), + SND_SOC_DAPM_OUTPUT("MONOP"), SND_SOC_DAPM_OUTPUT("MONON"), }; +static const struct snd_soc_dapm_widget rt5639_specific_dapm_widgets[] = { + SND_SOC_DAPM_MIXER("Stereo DAC MIXL", SND_SOC_NOPM, 0, 0, + rt5639_sto_dac_l_mix, ARRAY_SIZE(rt5639_sto_dac_l_mix)), + SND_SOC_DAPM_MIXER("Stereo DAC MIXR", SND_SOC_NOPM, 0, 0, + rt5639_sto_dac_r_mix, ARRAY_SIZE(rt5639_sto_dac_r_mix)), + + SND_SOC_DAPM_SUPPLY("DAC L2 Filter", RT5640_PWR_DIG1, + RT5640_PWR_DAC_L2_BIT, 0, NULL, 0), + SND_SOC_DAPM_SUPPLY("DAC R2 Filter", RT5640_PWR_DIG1, + RT5640_PWR_DAC_R2_BIT, 0, NULL, 0), + + SND_SOC_DAPM_MIXER("OUT MIXL", RT5640_PWR_MIXER, RT5640_PWR_OM_L_BIT, + 0, rt5639_out_l_mix, ARRAY_SIZE(rt5639_out_l_mix)), + SND_SOC_DAPM_MIXER("OUT MIXR", RT5640_PWR_MIXER, RT5640_PWR_OM_R_BIT, + 0, rt5639_out_r_mix, ARRAY_SIZE(rt5639_out_r_mix)), + + SND_SOC_DAPM_MIXER("HPO MIX L", SND_SOC_NOPM, 0, 0, + rt5639_hpo_mix, ARRAY_SIZE(rt5639_hpo_mix)), + SND_SOC_DAPM_MIXER("HPO MIX R", SND_SOC_NOPM, 0, 0, + rt5639_hpo_mix, ARRAY_SIZE(rt5639_hpo_mix)), +}; + static const struct snd_soc_dapm_route rt5640_dapm_routes[] = { {"IN1P", NULL, "LDO2"}, {"IN2P", NULL, "LDO2"}, @@ -1346,71 +1428,38 @@ static const struct snd_soc_dapm_route rt5640_dapm_routes[] = { {"DAC MIXR", "Stereo ADC Switch", "Stereo ADC MIXR"}, {"DAC MIXR", "INF1 Switch", "IF1 DAC R"}, - {"ANC", NULL, "Stereo ADC MIXL"}, - {"ANC", NULL, "Stereo ADC MIXR"}, - - {"Audio DSP", NULL, "DAC MIXL"}, - {"Audio DSP", NULL, "DAC MIXR"}, - - {"DAC L2 Mux", "IF2", "IF2 DAC L"}, - {"DAC L2 Mux", "Base L/R", "Audio DSP"}, - - {"DAC R2 Mux", "IF2", "IF2 DAC R"}, - {"Stereo DAC MIXL", "DAC L1 Switch", "DAC MIXL"}, - {"Stereo DAC MIXL", "DAC L2 Switch", "DAC L2 Mux"}, - {"Stereo DAC MIXL", "ANC Switch", "ANC"}, {"Stereo DAC MIXR", "DAC R1 Switch", "DAC MIXR"}, - {"Stereo DAC MIXR", "DAC R2 Switch", "DAC R2 Mux"}, - {"Stereo DAC MIXR", "ANC Switch", "ANC"}, {"Mono DAC MIXL", "DAC L1 Switch", "DAC MIXL"}, - {"Mono DAC MIXL", "DAC L2 Switch", "DAC L2 Mux"}, - {"Mono DAC MIXL", "DAC R2 Switch", "DAC R2 Mux"}, {"Mono DAC MIXR", "DAC R1 Switch", "DAC MIXR"}, - {"Mono DAC MIXR", "DAC R2 Switch", "DAC R2 Mux"}, - {"Mono DAC MIXR", "DAC L2 Switch", "DAC L2 Mux"}, {"DIG MIXL", "DAC L1 Switch", "DAC MIXL"}, - {"DIG MIXL", "DAC L2 Switch", "DAC L2 Mux"}, {"DIG MIXR", "DAC R1 Switch", "DAC MIXR"}, - {"DIG MIXR", "DAC R2 Switch", "DAC R2 Mux"}, {"DAC L1", NULL, "Stereo DAC MIXL"}, {"DAC L1", NULL, "PLL1", is_sys_clk_from_pll}, {"DAC R1", NULL, "Stereo DAC MIXR"}, {"DAC R1", NULL, "PLL1", is_sys_clk_from_pll}, - {"DAC L2", NULL, "Mono DAC MIXL"}, - {"DAC L2", NULL, "PLL1", is_sys_clk_from_pll}, - {"DAC R2", NULL, "Mono DAC MIXR"}, - {"DAC R2", NULL, "PLL1", is_sys_clk_from_pll}, {"SPK MIXL", "REC MIXL Switch", "RECMIXL"}, {"SPK MIXL", "INL Switch", "INL VOL"}, {"SPK MIXL", "DAC L1 Switch", "DAC L1"}, - {"SPK MIXL", "DAC L2 Switch", "DAC L2"}, {"SPK MIXL", "OUT MIXL Switch", "OUT MIXL"}, {"SPK MIXR", "REC MIXR Switch", "RECMIXR"}, {"SPK MIXR", "INR Switch", "INR VOL"}, {"SPK MIXR", "DAC R1 Switch", "DAC R1"}, - {"SPK MIXR", "DAC R2 Switch", "DAC R2"}, {"SPK MIXR", "OUT MIXR Switch", "OUT MIXR"}, - {"OUT MIXL", "SPK MIXL Switch", "SPK MIXL"}, {"OUT MIXL", "BST1 Switch", "BST1"}, {"OUT MIXL", "INL Switch", "INL VOL"}, {"OUT MIXL", "REC MIXL Switch", "RECMIXL"}, - {"OUT MIXL", "DAC R2 Switch", "DAC R2"}, - {"OUT MIXL", "DAC L2 Switch", "DAC L2"}, {"OUT MIXL", "DAC L1 Switch", "DAC L1"}, - {"OUT MIXR", "SPK MIXR Switch", "SPK MIXR"}, {"OUT MIXR", "BST2 Switch", "BST2"}, {"OUT MIXR", "BST1 Switch", "BST1"}, {"OUT MIXR", "INR Switch", "INR VOL"}, {"OUT MIXR", "REC MIXR Switch", "RECMIXR"}, - {"OUT MIXR", "DAC L2 Switch", "DAC L2"}, - {"OUT MIXR", "DAC R2 Switch", "DAC R2"}, {"OUT MIXR", "DAC R1 Switch", "DAC R1"}, {"SPKVOL L", NULL, "SPK MIXL"}, @@ -1429,11 +1478,9 @@ static const struct snd_soc_dapm_route rt5640_dapm_routes[] = { {"SPOR MIX", "SPKVOL R Switch", "SPKVOL R"}, {"SPOR MIX", "BST1 Switch", "BST1"}, - {"HPO MIX L", "HPO MIX DAC2 Switch", "DAC L2"}, {"HPO MIX L", "HPO MIX DAC1 Switch", "DAC L1"}, {"HPO MIX L", "HPO MIX HPVOL Switch", "HPOVOL L"}, {"HPO MIX L", NULL, "HP L Amp"}, - {"HPO MIX R", "HPO MIX DAC2 Switch", "DAC R2"}, {"HPO MIX R", "HPO MIX DAC1 Switch", "DAC R1"}, {"HPO MIX R", "HPO MIX HPVOL Switch", "HPOVOL R"}, {"HPO MIX R", NULL, "HP R Amp"}, @@ -1443,12 +1490,6 @@ static const struct snd_soc_dapm_route rt5640_dapm_routes[] = { {"LOUT MIX", "OUTVOL L Switch", "OUTVOL L"}, {"LOUT MIX", "OUTVOL R Switch", "OUTVOL R"}, - {"Mono MIX", "DAC R2 Switch", "DAC R2"}, - {"Mono MIX", "DAC L2 Switch", "DAC L2"}, - {"Mono MIX", "OUTVOL R Switch", "OUTVOL R"}, - {"Mono MIX", "OUTVOL L Switch", "OUTVOL L"}, - {"Mono MIX", "BST1 Switch", "BST1"}, - {"HP Amp", NULL, "HPO MIX L"}, {"HP Amp", NULL, "HPO MIX R"}, @@ -1473,11 +1514,82 @@ static const struct snd_soc_dapm_route rt5640_dapm_routes[] = { {"HPOR", NULL, "HP R Playback"}, {"LOUTL", NULL, "LOUT MIX"}, {"LOUTR", NULL, "LOUT MIX"}, +}; + +static const struct snd_soc_dapm_route rt5640_specific_dapm_routes[] = { + {"ANC", NULL, "Stereo ADC MIXL"}, + {"ANC", NULL, "Stereo ADC MIXR"}, + + {"Audio DSP", NULL, "DAC MIXL"}, + {"Audio DSP", NULL, "DAC MIXR"}, + + {"DAC L2 Mux", "IF2", "IF2 DAC L"}, + {"DAC L2 Mux", "Base L/R", "Audio DSP"}, + + {"DAC R2 Mux", "IF2", "IF2 DAC R"}, + + {"Stereo DAC MIXL", "DAC L2 Switch", "DAC L2 Mux"}, + {"Stereo DAC MIXL", "ANC Switch", "ANC"}, + {"Stereo DAC MIXR", "DAC R2 Switch", "DAC R2 Mux"}, + {"Stereo DAC MIXR", "ANC Switch", "ANC"}, + + {"Mono DAC MIXL", "DAC L2 Switch", "DAC L2 Mux"}, + {"Mono DAC MIXL", "DAC R2 Switch", "DAC R2 Mux"}, + + {"Mono DAC MIXR", "DAC R2 Switch", "DAC R2 Mux"}, + {"Mono DAC MIXR", "DAC L2 Switch", "DAC L2 Mux"}, + + {"DIG MIXR", "DAC R2 Switch", "DAC R2 Mux"}, + {"DIG MIXL", "DAC L2 Switch", "DAC L2 Mux"}, + + {"DAC L2", NULL, "Mono DAC MIXL"}, + {"DAC L2", NULL, "PLL1", is_sys_clk_from_pll}, + {"DAC R2", NULL, "Mono DAC MIXR"}, + {"DAC R2", NULL, "PLL1", is_sys_clk_from_pll}, + + {"SPK MIXL", "DAC L2 Switch", "DAC L2"}, + {"SPK MIXR", "DAC R2 Switch", "DAC R2"}, + + {"OUT MIXL", "SPK MIXL Switch", "SPK MIXL"}, + {"OUT MIXR", "SPK MIXR Switch", "SPK MIXR"}, + + {"OUT MIXL", "DAC R2 Switch", "DAC R2"}, + {"OUT MIXL", "DAC L2 Switch", "DAC L2"}, + + {"OUT MIXR", "DAC L2 Switch", "DAC L2"}, + {"OUT MIXR", "DAC R2 Switch", "DAC R2"}, + + {"HPO MIX L", "HPO MIX DAC2 Switch", "DAC L2"}, + {"HPO MIX R", "HPO MIX DAC2 Switch", "DAC R2"}, + + {"Mono MIX", "DAC R2 Switch", "DAC R2"}, + {"Mono MIX", "DAC L2 Switch", "DAC L2"}, + {"Mono MIX", "OUTVOL R Switch", "OUTVOL R"}, + {"Mono MIX", "OUTVOL L Switch", "OUTVOL L"}, + {"Mono MIX", "BST1 Switch", "BST1"}, + {"MONOP", NULL, "Mono MIX"}, {"MONON", NULL, "Mono MIX"}, {"MONOP", NULL, "Improve MONO Amp Drv"}, }; +static const struct snd_soc_dapm_route rt5639_specific_dapm_routes[] = { + {"Stereo DAC MIXL", "DAC L2 Switch", "IF2 DAC L"}, + {"Stereo DAC MIXR", "DAC R2 Switch", "IF2 DAC R"}, + + {"Mono DAC MIXL", "DAC L2 Switch", "IF2 DAC L"}, + {"Mono DAC MIXL", "DAC R2 Switch", "IF2 DAC R"}, + + {"Mono DAC MIXR", "DAC R2 Switch", "IF2 DAC R"}, + {"Mono DAC MIXR", "DAC L2 Switch", "IF2 DAC L"}, + + {"DIG MIXL", "DAC L2 Switch", "IF2 DAC L"}, + {"DIG MIXR", "DAC R2 Switch", "IF2 DAC R"}, + + {"IF2 DAC L", NULL, "DAC L2 Filter"}, + {"IF2 DAC R", NULL, "DAC R2 Filter"}, +}; + static int get_sdp_info(struct snd_soc_codec *codec, int dai_id) { int ret = 0, val; @@ -1885,6 +1997,28 @@ static int rt5640_probe(struct snd_soc_codec *codec) snd_soc_update_bits(codec, RT5640_MICBIAS, 0x0030, 0x0030); snd_soc_update_bits(codec, RT5640_DSP_PATH2, 0xfc00, 0x0c00); + switch (snd_soc_read(codec, RT5640_RESET)) { + case RT5640_RESET_ID: + snd_soc_add_codec_controls(codec, + rt5640_specific_snd_controls, + ARRAY_SIZE(rt5640_specific_snd_controls)); + snd_soc_dapm_new_controls(&codec->dapm, + rt5640_specific_dapm_widgets, + ARRAY_SIZE(rt5640_specific_dapm_widgets)); + snd_soc_dapm_add_routes(&codec->dapm, + rt5640_specific_dapm_routes, + ARRAY_SIZE(rt5640_specific_dapm_routes)); + break; + case RT5639_RESET_ID: + snd_soc_dapm_new_controls(&codec->dapm, + rt5639_specific_dapm_widgets, + ARRAY_SIZE(rt5639_specific_dapm_widgets)); + snd_soc_dapm_add_routes(&codec->dapm, + rt5639_specific_dapm_routes, + ARRAY_SIZE(rt5639_specific_dapm_routes)); + break; + } + return 0; } diff --git a/sound/soc/codecs/rt5640.h b/sound/soc/codecs/rt5640.h index d7bd525caf85..3b50459a83b4 100644 --- a/sound/soc/codecs/rt5640.h +++ b/sound/soc/codecs/rt5640.h @@ -14,6 +14,9 @@ #include +#define RT5639_RESET_ID 0x0008 +#define RT5640_RESET_ID 0x000c + /* Info */ #define RT5640_RESET 0x00 #define RT5640_VENDOR_ID 0xfd -- cgit v1.2.3 From b0c278469777b75d0af3b5718369084acb71c344 Mon Sep 17 00:00:00 2001 From: Oder Chiou Date: Thu, 10 Apr 2014 10:57:34 +0800 Subject: ASoC: rt5640: Add the string "rt5639" to the list of I2C device IDs The patch adds the string "rt5639" to the list of I2C device IDs. Signed-off-by: Oder Chiou Signed-off-by: Mark Brown --- sound/soc/codecs/rt5640.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sound/soc/codecs/rt5640.c b/sound/soc/codecs/rt5640.c index a20781eda719..6674372be12c 100644 --- a/sound/soc/codecs/rt5640.c +++ b/sound/soc/codecs/rt5640.c @@ -1,5 +1,5 @@ /* - * rt5640.c -- RT5640 ALSA SoC audio codec driver + * rt5640.c -- RT5640/RT5639 ALSA SoC audio codec driver * * Copyright 2011 Realtek Semiconductor Corp. * Author: Johnny Hsu @@ -2148,6 +2148,7 @@ static const struct regmap_config rt5640_regmap = { static const struct i2c_device_id rt5640_i2c_id[] = { { "rt5640", 0 }, + { "rt5639", 0 }, { } }; MODULE_DEVICE_TABLE(i2c, rt5640_i2c_id); @@ -2316,6 +2317,6 @@ static struct i2c_driver rt5640_i2c_driver = { }; module_i2c_driver(rt5640_i2c_driver); -MODULE_DESCRIPTION("ASoC RT5640 driver"); +MODULE_DESCRIPTION("ASoC RT5640/RT5639 driver"); MODULE_AUTHOR("Johnny Hsu "); MODULE_LICENSE("GPL v2"); -- cgit v1.2.3 From 908b7032a8b5cb7110beac213f7d3058097fa5aa Mon Sep 17 00:00:00 2001 From: Oder Chiou Date: Thu, 10 Apr 2014 10:57:35 +0800 Subject: ASoC: rt5640: Add the info of rt5639 to the binding document The patch adds the info of rt5639 to the binding document. Signed-off-by: Oder Chiou Signed-off-by: Mark Brown --- Documentation/devicetree/bindings/sound/rt5640.txt | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/Documentation/devicetree/bindings/sound/rt5640.txt b/Documentation/devicetree/bindings/sound/rt5640.txt index 068a1141b06f..bac4d9ac1edc 100644 --- a/Documentation/devicetree/bindings/sound/rt5640.txt +++ b/Documentation/devicetree/bindings/sound/rt5640.txt @@ -1,10 +1,10 @@ -RT5640 audio CODEC +RT5640/RT5639 audio CODEC This device supports I2C only. Required properties: -- compatible : "realtek,rt5640". +- compatible : One of "realtek,rt5640" or "realtek,rt5639". - reg : The I2C address of the device. @@ -18,7 +18,7 @@ Optional properties: - realtek,ldo1-en-gpios : The GPIO that controls the CODEC's LDO1_EN pin. -Pins on the device (for linking into audio routes): +Pins on the device (for linking into audio routes) for RT5639/RT5640: * DMIC1 * DMIC2 @@ -31,13 +31,16 @@ Pins on the device (for linking into audio routes): * HPOR * LOUTL * LOUTR - * MONOP - * MONON * SPOLP * SPOLN * SPORP * SPORN +Additional pins on the device for RT5640: + + * MONOP + * MONON + Example: rt5640 { -- cgit v1.2.3 From b87704cef258a4f44ab1386a70b7628ec3cefd36 Mon Sep 17 00:00:00 2001 From: Rongjun Ying Date: Thu, 20 Mar 2014 15:46:19 +0800 Subject: ASoC: sirf: Move the tx rx enable from port to codec, that will not need register sharing The port driver only used to register component and dmaengine pcm. Signed-off-by: Rongjun Ying Signed-off-by: Mark Brown --- sound/soc/codecs/sirf-audio-codec.c | 74 ++++++++++++++++++++++--- sound/soc/codecs/sirf-audio-codec.h | 50 +++++++++++++++++ sound/soc/sirf/sirf-audio-port.c | 107 ------------------------------------ sound/soc/sirf/sirf-audio-port.h | 62 --------------------- 4 files changed, 116 insertions(+), 177 deletions(-) delete mode 100644 sound/soc/sirf/sirf-audio-port.h diff --git a/sound/soc/codecs/sirf-audio-codec.c b/sound/soc/codecs/sirf-audio-codec.c index 58e7c1f23771..c5177bc5df82 100644 --- a/sound/soc/codecs/sirf-audio-codec.c +++ b/sound/soc/codecs/sirf-audio-codec.c @@ -279,13 +279,63 @@ static const struct snd_soc_dapm_route sirf_audio_codec_map[] = { {"Mic input mode mux", "Differential", "MICIN1"}, }; +static void sirf_audio_codec_tx_enable(struct sirf_audio_codec *sirf_audio_codec) +{ + regmap_update_bits(sirf_audio_codec->regmap, AUDIO_PORT_IC_TXFIFO_OP, + AUDIO_FIFO_RESET, AUDIO_FIFO_RESET); + regmap_update_bits(sirf_audio_codec->regmap, AUDIO_PORT_IC_TXFIFO_OP, + AUDIO_FIFO_RESET, ~AUDIO_FIFO_RESET); + regmap_write(sirf_audio_codec->regmap, AUDIO_PORT_IC_TXFIFO_INT_MSK, 0); + regmap_write(sirf_audio_codec->regmap, AUDIO_PORT_IC_TXFIFO_OP, 0); + regmap_update_bits(sirf_audio_codec->regmap, AUDIO_PORT_IC_TXFIFO_OP, + AUDIO_FIFO_START, AUDIO_FIFO_START); + regmap_update_bits(sirf_audio_codec->regmap, + AUDIO_PORT_IC_CODEC_TX_CTRL, IC_TX_ENABLE, IC_TX_ENABLE); +} + +static void sirf_audio_codec_tx_disable(struct sirf_audio_codec *sirf_audio_codec) +{ + regmap_write(sirf_audio_codec->regmap, AUDIO_PORT_IC_TXFIFO_OP, 0); + regmap_update_bits(sirf_audio_codec->regmap, + AUDIO_PORT_IC_CODEC_TX_CTRL, IC_TX_ENABLE, ~IC_TX_ENABLE); +} + +static void sirf_audio_codec_rx_enable(struct sirf_audio_codec *sirf_audio_codec, + int channels) +{ + regmap_update_bits(sirf_audio_codec->regmap, AUDIO_PORT_IC_RXFIFO_OP, + AUDIO_FIFO_RESET, AUDIO_FIFO_RESET); + regmap_update_bits(sirf_audio_codec->regmap, AUDIO_PORT_IC_RXFIFO_OP, + AUDIO_FIFO_RESET, ~AUDIO_FIFO_RESET); + regmap_write(sirf_audio_codec->regmap, + AUDIO_PORT_IC_RXFIFO_INT_MSK, 0); + regmap_write(sirf_audio_codec->regmap, AUDIO_PORT_IC_RXFIFO_OP, 0); + regmap_update_bits(sirf_audio_codec->regmap, AUDIO_PORT_IC_RXFIFO_OP, + AUDIO_FIFO_START, AUDIO_FIFO_START); + if (channels == 1) + regmap_update_bits(sirf_audio_codec->regmap, + AUDIO_PORT_IC_CODEC_RX_CTRL, + IC_RX_ENABLE_MONO, IC_RX_ENABLE_MONO); + else + regmap_update_bits(sirf_audio_codec->regmap, + AUDIO_PORT_IC_CODEC_RX_CTRL, + IC_RX_ENABLE_STEREO, IC_RX_ENABLE_STEREO); +} + +static void sirf_audio_codec_rx_disable(struct sirf_audio_codec *sirf_audio_codec) +{ + regmap_update_bits(sirf_audio_codec->regmap, + AUDIO_PORT_IC_CODEC_RX_CTRL, + IC_RX_ENABLE_STEREO, ~IC_RX_ENABLE_STEREO); +} + static int sirf_audio_codec_trigger(struct snd_pcm_substream *substream, int cmd, struct snd_soc_dai *dai) { - int playback = substream->stream == SNDRV_PCM_STREAM_PLAYBACK; struct snd_soc_codec *codec = dai->codec; - u32 val = 0; + struct sirf_audio_codec *sirf_audio_codec = snd_soc_codec_get_drvdata(codec); + int playback = substream->stream == SNDRV_PCM_STREAM_PLAYBACK; /* * This is a workaround, When stop playback, @@ -295,20 +345,28 @@ static int sirf_audio_codec_trigger(struct snd_pcm_substream *substream, case SNDRV_PCM_TRIGGER_STOP: case SNDRV_PCM_TRIGGER_SUSPEND: case SNDRV_PCM_TRIGGER_PAUSE_PUSH: + if (playback) { + snd_soc_update_bits(codec, AUDIO_IC_CODEC_CTRL0, + IC_HSLEN | IC_HSREN, 0); + sirf_audio_codec_tx_disable(sirf_audio_codec); + } else + sirf_audio_codec_rx_disable(sirf_audio_codec); break; case SNDRV_PCM_TRIGGER_START: case SNDRV_PCM_TRIGGER_RESUME: case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: - if (playback) - val = IC_HSLEN | IC_HSREN; + if (playback) { + sirf_audio_codec_tx_enable(sirf_audio_codec); + snd_soc_update_bits(codec, AUDIO_IC_CODEC_CTRL0, + IC_HSLEN | IC_HSREN, IC_HSLEN | IC_HSREN); + } else + sirf_audio_codec_rx_enable(sirf_audio_codec, + substream->runtime->channels); break; default: return -EINVAL; } - if (playback) - snd_soc_update_bits(codec, AUDIO_IC_CODEC_CTRL0, - IC_HSLEN | IC_HSREN, val); return 0; } @@ -392,7 +450,7 @@ static const struct regmap_config sirf_audio_codec_regmap_config = { .reg_bits = 32, .reg_stride = 4, .val_bits = 32, - .max_register = AUDIO_IC_CODEC_CTRL3, + .max_register = AUDIO_PORT_IC_RXFIFO_INT_MSK, .cache_type = REGCACHE_NONE, }; diff --git a/sound/soc/codecs/sirf-audio-codec.h b/sound/soc/codecs/sirf-audio-codec.h index d4c187b8e54a..ba1adc03839f 100644 --- a/sound/soc/codecs/sirf-audio-codec.h +++ b/sound/soc/codecs/sirf-audio-codec.h @@ -72,4 +72,54 @@ #define IC_RXPGAR 0x7B #define IC_RXPGAL 0x7B +#define AUDIO_PORT_TX_FIFO_LEVEL_CHECK_MASK 0x3F +#define AUDIO_PORT_TX_FIFO_SC_OFFSET 0 +#define AUDIO_PORT_TX_FIFO_LC_OFFSET 10 +#define AUDIO_PORT_TX_FIFO_HC_OFFSET 20 + +#define TX_FIFO_SC(x) (((x) & AUDIO_PORT_TX_FIFO_LEVEL_CHECK_MASK) \ + << AUDIO_PORT_TX_FIFO_SC_OFFSET) +#define TX_FIFO_LC(x) (((x) & AUDIO_PORT_TX_FIFO_LEVEL_CHECK_MASK) \ + << AUDIO_PORT_TX_FIFO_LC_OFFSET) +#define TX_FIFO_HC(x) (((x) & AUDIO_PORT_TX_FIFO_LEVEL_CHECK_MASK) \ + << AUDIO_PORT_TX_FIFO_HC_OFFSET) + +#define AUDIO_PORT_RX_FIFO_LEVEL_CHECK_MASK 0x0F +#define AUDIO_PORT_RX_FIFO_SC_OFFSET 0 +#define AUDIO_PORT_RX_FIFO_LC_OFFSET 10 +#define AUDIO_PORT_RX_FIFO_HC_OFFSET 20 + +#define RX_FIFO_SC(x) (((x) & AUDIO_PORT_RX_FIFO_LEVEL_CHECK_MASK) \ + << AUDIO_PORT_RX_FIFO_SC_OFFSET) +#define RX_FIFO_LC(x) (((x) & AUDIO_PORT_RX_FIFO_LEVEL_CHECK_MASK) \ + << AUDIO_PORT_RX_FIFO_LC_OFFSET) +#define RX_FIFO_HC(x) (((x) & AUDIO_PORT_RX_FIFO_LEVEL_CHECK_MASK) \ + << AUDIO_PORT_RX_FIFO_HC_OFFSET) +#define AUDIO_PORT_IC_CODEC_TX_CTRL (0x00F4) +#define AUDIO_PORT_IC_CODEC_RX_CTRL (0x00F8) + +#define AUDIO_PORT_IC_TXFIFO_OP (0x00FC) +#define AUDIO_PORT_IC_TXFIFO_LEV_CHK (0x0100) +#define AUDIO_PORT_IC_TXFIFO_STS (0x0104) +#define AUDIO_PORT_IC_TXFIFO_INT (0x0108) +#define AUDIO_PORT_IC_TXFIFO_INT_MSK (0x010C) + +#define AUDIO_PORT_IC_RXFIFO_OP (0x0110) +#define AUDIO_PORT_IC_RXFIFO_LEV_CHK (0x0114) +#define AUDIO_PORT_IC_RXFIFO_STS (0x0118) +#define AUDIO_PORT_IC_RXFIFO_INT (0x011C) +#define AUDIO_PORT_IC_RXFIFO_INT_MSK (0x0120) + +#define AUDIO_FIFO_START (1 << 0) +#define AUDIO_FIFO_RESET (1 << 1) + +#define AUDIO_FIFO_FULL (1 << 0) +#define AUDIO_FIFO_EMPTY (1 << 1) +#define AUDIO_FIFO_OFLOW (1 << 2) +#define AUDIO_FIFO_UFLOW (1 << 3) + +#define IC_TX_ENABLE (0x03) +#define IC_RX_ENABLE_MONO (0x01) +#define IC_RX_ENABLE_STEREO (0x03) + #endif /*__SIRF_AUDIO_CODEC_H*/ diff --git a/sound/soc/sirf/sirf-audio-port.c b/sound/soc/sirf/sirf-audio-port.c index b04a53f2b4f6..b4afa31b2bc1 100644 --- a/sound/soc/sirf/sirf-audio-port.c +++ b/sound/soc/sirf/sirf-audio-port.c @@ -6,60 +6,15 @@ * Licensed under GPLv2 or later. */ #include -#include -#include #include #include -#include "sirf-audio-port.h" - struct sirf_audio_port { struct regmap *regmap; struct snd_dmaengine_dai_dma_data playback_dma_data; struct snd_dmaengine_dai_dma_data capture_dma_data; }; -static void sirf_audio_port_tx_enable(struct sirf_audio_port *port) -{ - regmap_update_bits(port->regmap, AUDIO_PORT_IC_TXFIFO_OP, - AUDIO_FIFO_RESET, AUDIO_FIFO_RESET); - regmap_write(port->regmap, AUDIO_PORT_IC_TXFIFO_INT_MSK, 0); - regmap_write(port->regmap, AUDIO_PORT_IC_TXFIFO_OP, 0); - regmap_update_bits(port->regmap, AUDIO_PORT_IC_TXFIFO_OP, - AUDIO_FIFO_START, AUDIO_FIFO_START); - regmap_update_bits(port->regmap, AUDIO_PORT_IC_CODEC_TX_CTRL, - IC_TX_ENABLE, IC_TX_ENABLE); -} - -static void sirf_audio_port_tx_disable(struct sirf_audio_port *port) -{ - regmap_write(port->regmap, AUDIO_PORT_IC_TXFIFO_OP, 0); - regmap_update_bits(port->regmap, AUDIO_PORT_IC_CODEC_TX_CTRL, - IC_TX_ENABLE, ~IC_TX_ENABLE); -} - -static void sirf_audio_port_rx_enable(struct sirf_audio_port *port, - int channels) -{ - regmap_update_bits(port->regmap, AUDIO_PORT_IC_RXFIFO_OP, - AUDIO_FIFO_RESET, AUDIO_FIFO_RESET); - regmap_write(port->regmap, AUDIO_PORT_IC_RXFIFO_INT_MSK, 0); - regmap_write(port->regmap, AUDIO_PORT_IC_RXFIFO_OP, 0); - regmap_update_bits(port->regmap, AUDIO_PORT_IC_RXFIFO_OP, - AUDIO_FIFO_START, AUDIO_FIFO_START); - if (channels == 1) - regmap_update_bits(port->regmap, AUDIO_PORT_IC_CODEC_RX_CTRL, - IC_RX_ENABLE_MONO, IC_RX_ENABLE_MONO); - else - regmap_update_bits(port->regmap, AUDIO_PORT_IC_CODEC_RX_CTRL, - IC_RX_ENABLE_STEREO, IC_RX_ENABLE_STEREO); -} - -static void sirf_audio_port_rx_disable(struct sirf_audio_port *port) -{ - regmap_update_bits(port->regmap, AUDIO_PORT_IC_CODEC_RX_CTRL, - IC_RX_ENABLE_STEREO, ~IC_RX_ENABLE_STEREO); -} static int sirf_audio_port_dai_probe(struct snd_soc_dai *dai) { @@ -69,41 +24,6 @@ static int sirf_audio_port_dai_probe(struct snd_soc_dai *dai) return 0; } -static int sirf_audio_port_trigger(struct snd_pcm_substream *substream, int cmd, - struct snd_soc_dai *dai) -{ - struct sirf_audio_port *port = snd_soc_dai_get_drvdata(dai); - int playback = substream->stream == SNDRV_PCM_STREAM_PLAYBACK; - - switch (cmd) { - case SNDRV_PCM_TRIGGER_STOP: - case SNDRV_PCM_TRIGGER_SUSPEND: - case SNDRV_PCM_TRIGGER_PAUSE_PUSH: - if (playback) - sirf_audio_port_tx_disable(port); - else - sirf_audio_port_rx_disable(port); - break; - case SNDRV_PCM_TRIGGER_START: - case SNDRV_PCM_TRIGGER_RESUME: - case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: - if (playback) - sirf_audio_port_tx_enable(port); - else - sirf_audio_port_rx_enable(port, - substream->runtime->channels); - break; - default: - return -EINVAL; - } - - return 0; -} - -static const struct snd_soc_dai_ops sirf_audio_port_dai_ops = { - .trigger = sirf_audio_port_trigger, -}; - static struct snd_soc_dai_driver sirf_audio_port_dai = { .probe = sirf_audio_port_dai_probe, .name = "sirf-audio-port", @@ -120,49 +40,22 @@ static struct snd_soc_dai_driver sirf_audio_port_dai = { .rates = SNDRV_PCM_RATE_48000, .formats = SNDRV_PCM_FMTBIT_S16_LE, }, - .ops = &sirf_audio_port_dai_ops, }; static const struct snd_soc_component_driver sirf_audio_port_component = { .name = "sirf-audio-port", }; -static const struct regmap_config sirf_audio_port_regmap_config = { - .reg_bits = 32, - .reg_stride = 4, - .val_bits = 32, - .max_register = AUDIO_PORT_IC_RXFIFO_INT_MSK, - .cache_type = REGCACHE_NONE, -}; - static int sirf_audio_port_probe(struct platform_device *pdev) { int ret; struct sirf_audio_port *port; - void __iomem *base; - struct resource *mem_res; port = devm_kzalloc(&pdev->dev, sizeof(struct sirf_audio_port), GFP_KERNEL); if (!port) return -ENOMEM; - mem_res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - if (!mem_res) { - dev_err(&pdev->dev, "no mem resource?\n"); - return -ENODEV; - } - - base = devm_ioremap(&pdev->dev, mem_res->start, - resource_size(mem_res)); - if (base == NULL) - return -ENOMEM; - - port->regmap = devm_regmap_init_mmio(&pdev->dev, base, - &sirf_audio_port_regmap_config); - if (IS_ERR(port->regmap)) - return PTR_ERR(port->regmap); - ret = devm_snd_soc_register_component(&pdev->dev, &sirf_audio_port_component, &sirf_audio_port_dai, 1); if (ret) diff --git a/sound/soc/sirf/sirf-audio-port.h b/sound/soc/sirf/sirf-audio-port.h deleted file mode 100644 index f32dc54f4499..000000000000 --- a/sound/soc/sirf/sirf-audio-port.h +++ /dev/null @@ -1,62 +0,0 @@ -/* - * SiRF Audio port controllers define - * - * Copyright (c) 2011 Cambridge Silicon Radio Limited, a CSR plc group company. - * - * Licensed under GPLv2 or later. - */ - -#ifndef _SIRF_AUDIO_PORT_H -#define _SIRF_AUDIO_PORT_H - -#define AUDIO_PORT_TX_FIFO_LEVEL_CHECK_MASK 0x3F -#define AUDIO_PORT_TX_FIFO_SC_OFFSET 0 -#define AUDIO_PORT_TX_FIFO_LC_OFFSET 10 -#define AUDIO_PORT_TX_FIFO_HC_OFFSET 20 - -#define TX_FIFO_SC(x) (((x) & AUDIO_PORT_TX_FIFO_LEVEL_CHECK_MASK) \ - << AUDIO_PORT_TX_FIFO_SC_OFFSET) -#define TX_FIFO_LC(x) (((x) & AUDIO_PORT_TX_FIFO_LEVEL_CHECK_MASK) \ - << AUDIO_PORT_TX_FIFO_LC_OFFSET) -#define TX_FIFO_HC(x) (((x) & AUDIO_PORT_TX_FIFO_LEVEL_CHECK_MASK) \ - << AUDIO_PORT_TX_FIFO_HC_OFFSET) - -#define AUDIO_PORT_RX_FIFO_LEVEL_CHECK_MASK 0x0F -#define AUDIO_PORT_RX_FIFO_SC_OFFSET 0 -#define AUDIO_PORT_RX_FIFO_LC_OFFSET 10 -#define AUDIO_PORT_RX_FIFO_HC_OFFSET 20 - -#define RX_FIFO_SC(x) (((x) & AUDIO_PORT_RX_FIFO_LEVEL_CHECK_MASK) \ - << AUDIO_PORT_RX_FIFO_SC_OFFSET) -#define RX_FIFO_LC(x) (((x) & AUDIO_PORT_RX_FIFO_LEVEL_CHECK_MASK) \ - << AUDIO_PORT_RX_FIFO_LC_OFFSET) -#define RX_FIFO_HC(x) (((x) & AUDIO_PORT_RX_FIFO_LEVEL_CHECK_MASK) \ - << AUDIO_PORT_RX_FIFO_HC_OFFSET) -#define AUDIO_PORT_IC_CODEC_TX_CTRL (0x00F4) -#define AUDIO_PORT_IC_CODEC_RX_CTRL (0x00F8) - -#define AUDIO_PORT_IC_TXFIFO_OP (0x00FC) -#define AUDIO_PORT_IC_TXFIFO_LEV_CHK (0x0100) -#define AUDIO_PORT_IC_TXFIFO_STS (0x0104) -#define AUDIO_PORT_IC_TXFIFO_INT (0x0108) -#define AUDIO_PORT_IC_TXFIFO_INT_MSK (0x010C) - -#define AUDIO_PORT_IC_RXFIFO_OP (0x0110) -#define AUDIO_PORT_IC_RXFIFO_LEV_CHK (0x0114) -#define AUDIO_PORT_IC_RXFIFO_STS (0x0118) -#define AUDIO_PORT_IC_RXFIFO_INT (0x011C) -#define AUDIO_PORT_IC_RXFIFO_INT_MSK (0x0120) - -#define AUDIO_FIFO_START (1 << 0) -#define AUDIO_FIFO_RESET (1 << 1) - -#define AUDIO_FIFO_FULL (1 << 0) -#define AUDIO_FIFO_EMPTY (1 << 1) -#define AUDIO_FIFO_OFLOW (1 << 2) -#define AUDIO_FIFO_UFLOW (1 << 3) - -#define IC_TX_ENABLE (0x03) -#define IC_RX_ENABLE_MONO (0x01) -#define IC_RX_ENABLE_STEREO (0x03) - -#endif /*__SIRF_AUDIO_PORT_H*/ -- cgit v1.2.3 From 2439ea1f0f8f4cc98dfae0d1cd5ba88f6c3ee9ad Mon Sep 17 00:00:00 2001 From: Sven Brandau Date: Wed, 2 Apr 2014 10:25:05 +0200 Subject: ASoC: sta350: Add codec driver The TI STA350 is an integrated 2.1-channel power amplifier that is controllable over I2C. This patch adds an ASoC driver for it. At a glance, this chip is very similar to the STA320 for which a driver already exists. In details, however, the register maps contain subtle differences which made a whole new driver easier to write and maintain. [daniel@zonque.org: cleanups, DT property rework, rebased on asoc-next] Signed-off-by: Sven Brandau Signed-off-by: Daniel Mack Signed-off-by: Mark Brown --- .../devicetree/bindings/sound/st,sta350.txt | 107 ++ include/sound/sta350.h | 52 + sound/soc/codecs/Kconfig | 5 + sound/soc/codecs/Makefile | 2 + sound/soc/codecs/sta350.c | 1266 ++++++++++++++++++++ sound/soc/codecs/sta350.h | 228 ++++ 6 files changed, 1660 insertions(+) create mode 100644 Documentation/devicetree/bindings/sound/st,sta350.txt create mode 100644 include/sound/sta350.h create mode 100644 sound/soc/codecs/sta350.c create mode 100644 sound/soc/codecs/sta350.h diff --git a/Documentation/devicetree/bindings/sound/st,sta350.txt b/Documentation/devicetree/bindings/sound/st,sta350.txt new file mode 100644 index 000000000000..950188891abd --- /dev/null +++ b/Documentation/devicetree/bindings/sound/st,sta350.txt @@ -0,0 +1,107 @@ +STA350 audio CODEC + +The driver for this device only supports I2C. + +Required properties: + + - compatible: "st,sta350" + - reg: the I2C address of the device for I2C + - reset-gpios: a GPIO spec for the reset pin. If specified, it will be + deasserted before communication to the codec starts. + + - power-down-gpios: a GPIO spec for the power down pin. If specified, + it will be deasserted before communication to the codec + starts. + + - vdd-dig-supply: regulator spec, providing 3.3V + - vdd-pll-supply: regulator spec, providing 3.3V + - vcc-supply: regulator spec, providing 5V - 26V + +Optional properties: + + - st,output-conf: number, Selects the output configuration: + 0: 2-channel (full-bridge) power, 2-channel data-out + 1: 2 (half-bridge). 1 (full-bridge) on-board power + 2: 2 Channel (Full-Bridge) Power, 1 Channel FFX + 3: 1 Channel Mono-Parallel + If parameter is missing, mode 0 will be enabled. + + - st,ch1-output-mapping: Channel 1 output mapping + - st,ch2-output-mapping: Channel 2 output mapping + - st,ch3-output-mapping: Channel 3 output mapping + 0: Channel 1 + 1: Channel 2 + 2: Channel 3 + If parameter is missing, channel 1 is choosen. + + - st,thermal-warning-recover: + If present, thermal warning recovery is enabled. + + - st,thermal-warning-adjustment: + If present, thermal warning adjustment is enabled. + + - st,fault-detect-recovery: + If present, then fault recovery will be enabled. + + - st,ffx-power-output-mode: string + The FFX power output mode selects how the FFX output timing is + configured. Must be one of these values: + - "drop-compensation" + - "tapered-compensation" + - "full-power-mode" + - "variable-drop-compensation" (default) + + - st,drop-compensation-ns: number + Only required for "st,ffx-power-output-mode" == + "variable-drop-compensation". + Specifies the drop compensation in nanoseconds. + The value must be in the range of 0..300, and only + multiples of 20 are allowed. Default is 140ns. + + - st,overcurrent-warning-adjustment: + If present, overcurrent warning adjustment is enabled. + + - st,max-power-use-mpcc: + If present, then MPCC bits are used for MPC coefficients, + otherwise standard MPC coefficients are used. + + - st,max-power-corr: + If present, power bridge correction for THD reduction near maximum + power output is enabled. + + - st,am-reduction-mode: + If present, FFX mode runs in AM reduction mode, otherwise normal + FFX mode is used. + + - st,odd-pwm-speed-mode: + If present, PWM speed mode run on odd speed mode (341.3 kHz) on all + channels. If not present, normal PWM spped mode (384 kHz) will be used. + + - st,distortion-compensation: + If present, distortion compensation variable uses DCC coefficient. + If not present, preset DC coefficient is used. + + - st,invalid-input-detect-mute: + If not present, automatic invalid input detect mute is enabled. + + + +Example: + +codec: sta350@38 { + compatible = "st,sta350"; + reg = <0x1c>; + reset-gpios = <&gpio1 19 0>; + power-down-gpios = <&gpio1 16 0>; + st,output-conf = <0x3>; // set output to 2-channel + // (full-bridge) power, + // 2-channel data-out + st,ch1-output-mapping = <0>; // set channel 1 output ch 1 + st,ch2-output-mapping = <0>; // set channel 2 output ch 1 + st,ch3-output-mapping = <0>; // set channel 3 output ch 1 + st,max-power-correction; // enables power bridge + // correction for THD reduction + // near maximum power output + st,invalid-input-detect-mute; // mute if no valid digital + // audio signal is provided. +}; diff --git a/include/sound/sta350.h b/include/sound/sta350.h new file mode 100644 index 000000000000..3a3298106b22 --- /dev/null +++ b/include/sound/sta350.h @@ -0,0 +1,52 @@ +/* + * Platform data for ST STA350 ASoC codec driver. + * + * Copyright: 2014 Raumfeld GmbH + * Author: Sven Brandau + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + */ +#ifndef __LINUX_SND__STA350_H +#define __LINUX_SND__STA350_H + +#define STA350_OCFG_2CH 0 +#define STA350_OCFG_2_1CH 1 +#define STA350_OCFG_1CH 3 + +#define STA350_OM_CH1 0 +#define STA350_OM_CH2 1 +#define STA350_OM_CH3 2 + +#define STA350_THERMAL_ADJUSTMENT_ENABLE 1 +#define STA350_THERMAL_RECOVERY_ENABLE 2 +#define STA350_FAULT_DETECT_RECOVERY_BYPASS 1 + +#define STA350_FFX_PM_DROP_COMP 0 +#define STA350_FFX_PM_TAPERED_COMP 1 +#define STA350_FFX_PM_FULL_POWER 2 +#define STA350_FFX_PM_VARIABLE_DROP_COMP 3 + + +struct sta350_platform_data { + u8 output_conf; + u8 ch1_output_mapping; + u8 ch2_output_mapping; + u8 ch3_output_mapping; + u8 ffx_power_output_mode; + u8 drop_compensation_ns; + unsigned int thermal_warning_recovery:1; + unsigned int thermal_warning_adjustment:1; + unsigned int fault_detect_recovery:1; + unsigned int oc_warning_adjustment:1; + unsigned int max_power_use_mpcc:1; + unsigned int max_power_correction:1; + unsigned int am_reduction_mode:1; + unsigned int odd_pwm_speed_mode:1; + unsigned int distortion_compensation:1; + unsigned int invalid_input_detect_mute:1; +}; + +#endif /* __LINUX_SND__STA350_H */ diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig index f0e840137887..c7b853f520cf 100644 --- a/sound/soc/codecs/Kconfig +++ b/sound/soc/codecs/Kconfig @@ -80,6 +80,7 @@ config SND_SOC_ALL_CODECS select SND_SOC_SSM2602_SPI if SPI_MASTER select SND_SOC_SSM2602_I2C if I2C select SND_SOC_STA32X if I2C + select SND_SOC_STA350 if I2C select SND_SOC_STA529 if I2C select SND_SOC_STAC9766 if SND_SOC_AC97_BUS select SND_SOC_TAS5086 if I2C @@ -435,6 +436,10 @@ config SND_SOC_SSM2602_I2C config SND_SOC_STA32X tristate +config SND_SOC_STA350 + tristate "STA350 speaker amplifier" + depends on I2C + config SND_SOC_STA529 tristate diff --git a/sound/soc/codecs/Makefile b/sound/soc/codecs/Makefile index 3c4d275d064b..efdb4d060201 100644 --- a/sound/soc/codecs/Makefile +++ b/sound/soc/codecs/Makefile @@ -74,6 +74,7 @@ snd-soc-ssm2602-objs := ssm2602.o snd-soc-ssm2602-spi-objs := ssm2602-spi.o snd-soc-ssm2602-i2c-objs := ssm2602-i2c.o snd-soc-sta32x-objs := sta32x.o +snd-soc-sta350-objs := sta350.o snd-soc-sta529-objs := sta529.o snd-soc-stac9766-objs := stac9766.o snd-soc-tas5086-objs := tas5086.o @@ -221,6 +222,7 @@ obj-$(CONFIG_SND_SOC_SSM2602) += snd-soc-ssm2602.o obj-$(CONFIG_SND_SOC_SSM2602_SPI) += snd-soc-ssm2602-spi.o obj-$(CONFIG_SND_SOC_SSM2602_I2C) += snd-soc-ssm2602-i2c.o obj-$(CONFIG_SND_SOC_STA32X) += snd-soc-sta32x.o +obj-$(CONFIG_SND_SOC_STA350) += snd-soc-sta350.o obj-$(CONFIG_SND_SOC_STA529) += snd-soc-sta529.o obj-$(CONFIG_SND_SOC_STAC9766) += snd-soc-stac9766.o obj-$(CONFIG_SND_SOC_TAS5086) += snd-soc-tas5086.o diff --git a/sound/soc/codecs/sta350.c b/sound/soc/codecs/sta350.c new file mode 100644 index 000000000000..552e92a6b770 --- /dev/null +++ b/sound/soc/codecs/sta350.c @@ -0,0 +1,1266 @@ +/* + * Codec driver for ST STA350 2.1-channel high-efficiency digital audio system + * + * Copyright: 2014 Raumfeld GmbH + * Author: Sven Brandau + * + * based on code from: + * Raumfeld GmbH + * Johannes Stezenbach + * Wolfson Microelectronics PLC. + * Mark Brown + * Freescale Semiconductor, Inc. + * Timur Tabi + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + */ + +#define pr_fmt(fmt) KBUILD_MODNAME ":%s:%d: " fmt, __func__, __LINE__ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include "sta350.h" + +#define STA350_RATES (SNDRV_PCM_RATE_32000 | \ + SNDRV_PCM_RATE_44100 | \ + SNDRV_PCM_RATE_48000 | \ + SNDRV_PCM_RATE_88200 | \ + SNDRV_PCM_RATE_96000 | \ + SNDRV_PCM_RATE_176400 | \ + SNDRV_PCM_RATE_192000) + +#define STA350_FORMATS \ + (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S16_BE | \ + SNDRV_PCM_FMTBIT_S18_3LE | SNDRV_PCM_FMTBIT_S18_3BE | \ + SNDRV_PCM_FMTBIT_S20_3LE | SNDRV_PCM_FMTBIT_S20_3BE | \ + SNDRV_PCM_FMTBIT_S24_3LE | SNDRV_PCM_FMTBIT_S24_3BE | \ + SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S24_BE | \ + SNDRV_PCM_FMTBIT_S32_LE | SNDRV_PCM_FMTBIT_S32_BE) + +/* Power-up register defaults */ +static const struct reg_default sta350_regs[] = { + { 0x0, 0x63 }, + { 0x1, 0x80 }, + { 0x2, 0xdf }, + { 0x3, 0x40 }, + { 0x4, 0xc2 }, + { 0x5, 0x5c }, + { 0x6, 0x00 }, + { 0x7, 0xff }, + { 0x8, 0x60 }, + { 0x9, 0x60 }, + { 0xa, 0x60 }, + { 0xb, 0x00 }, + { 0xc, 0x00 }, + { 0xd, 0x00 }, + { 0xe, 0x00 }, + { 0xf, 0x40 }, + { 0x10, 0x80 }, + { 0x11, 0x77 }, + { 0x12, 0x6a }, + { 0x13, 0x69 }, + { 0x14, 0x6a }, + { 0x15, 0x69 }, + { 0x16, 0x00 }, + { 0x17, 0x00 }, + { 0x18, 0x00 }, + { 0x19, 0x00 }, + { 0x1a, 0x00 }, + { 0x1b, 0x00 }, + { 0x1c, 0x00 }, + { 0x1d, 0x00 }, + { 0x1e, 0x00 }, + { 0x1f, 0x00 }, + { 0x20, 0x00 }, + { 0x21, 0x00 }, + { 0x22, 0x00 }, + { 0x23, 0x00 }, + { 0x24, 0x00 }, + { 0x25, 0x00 }, + { 0x26, 0x00 }, + { 0x27, 0x2a }, + { 0x28, 0xc0 }, + { 0x29, 0xf3 }, + { 0x2a, 0x33 }, + { 0x2b, 0x00 }, + { 0x2c, 0x0c }, + { 0x31, 0x00 }, + { 0x36, 0x00 }, + { 0x37, 0x00 }, + { 0x38, 0x00 }, + { 0x39, 0x01 }, + { 0x3a, 0xee }, + { 0x3b, 0xff }, + { 0x3c, 0x7e }, + { 0x3d, 0xc0 }, + { 0x3e, 0x26 }, + { 0x3f, 0x00 }, + { 0x48, 0x00 }, + { 0x49, 0x00 }, + { 0x4a, 0x00 }, + { 0x4b, 0x04 }, + { 0x4c, 0x00 }, +}; + +static const struct regmap_range sta350_write_regs_range[] = { + regmap_reg_range(STA350_CONFA, STA350_AUTO2), + regmap_reg_range(STA350_C1CFG, STA350_FDRC2), + regmap_reg_range(STA350_EQCFG, STA350_EVOLRES), + regmap_reg_range(STA350_NSHAPE, STA350_MISC2), +}; + +static const struct regmap_range sta350_read_regs_range[] = { + regmap_reg_range(STA350_CONFA, STA350_AUTO2), + regmap_reg_range(STA350_C1CFG, STA350_STATUS), + regmap_reg_range(STA350_EQCFG, STA350_EVOLRES), + regmap_reg_range(STA350_NSHAPE, STA350_MISC2), +}; + +static const struct regmap_range sta350_volatile_regs_range[] = { + regmap_reg_range(STA350_CFADDR2, STA350_CFUD), + regmap_reg_range(STA350_STATUS, STA350_STATUS), +}; + +static const struct regmap_access_table sta350_write_regs = { + .yes_ranges = sta350_write_regs_range, + .n_yes_ranges = ARRAY_SIZE(sta350_write_regs_range), +}; + +static const struct regmap_access_table sta350_read_regs = { + .yes_ranges = sta350_read_regs_range, + .n_yes_ranges = ARRAY_SIZE(sta350_read_regs_range), +}; + +static const struct regmap_access_table sta350_volatile_regs = { + .yes_ranges = sta350_volatile_regs_range, + .n_yes_ranges = ARRAY_SIZE(sta350_volatile_regs_range), +}; + +/* regulator power supply names */ +static const char * const sta350_supply_names[] = { + "vdd-dig", /* digital supply, 3.3V */ + "vdd-pll", /* pll supply, 3.3V */ + "vcc" /* power amp supply, 5V - 26V */ +}; + +/* codec private data */ +struct sta350_priv { + struct regmap *regmap; + struct regulator_bulk_data supplies[ARRAY_SIZE(sta350_supply_names)]; + struct sta350_platform_data *pdata; + + unsigned int mclk; + unsigned int format; + + u32 coef_shadow[STA350_COEF_COUNT]; + int shutdown; + + struct gpio_desc *gpiod_nreset; + struct gpio_desc *gpiod_power_down; + + struct mutex coeff_lock; +}; + +static const DECLARE_TLV_DB_SCALE(mvol_tlv, -12750, 50, 1); +static const DECLARE_TLV_DB_SCALE(chvol_tlv, -7950, 50, 1); +static const DECLARE_TLV_DB_SCALE(tone_tlv, -1200, 200, 0); + +static const char * const sta350_drc_ac[] = { + "Anti-Clipping", "Dynamic Range Compression" +}; +static const char * const sta350_auto_gc_mode[] = { + "User", "AC no clipping", "AC limited clipping (10%)", + "DRC nighttime listening mode" +}; +static const char * const sta350_auto_xo_mode[] = { + "User", "80Hz", "100Hz", "120Hz", "140Hz", "160Hz", "180Hz", + "200Hz", "220Hz", "240Hz", "260Hz", "280Hz", "300Hz", "320Hz", + "340Hz", "360Hz" +}; +static const char * const sta350_binary_output[] = { + "FFX 3-state output - normal operation", "Binary output" +}; +static const char * const sta350_limiter_select[] = { + "Limiter Disabled", "Limiter #1", "Limiter #2" +}; +static const char * const sta350_limiter_attack_rate[] = { + "3.1584", "2.7072", "2.2560", "1.8048", "1.3536", "0.9024", + "0.4512", "0.2256", "0.1504", "0.1123", "0.0902", "0.0752", + "0.0645", "0.0564", "0.0501", "0.0451" +}; +static const char * const sta350_limiter_release_rate[] = { + "0.5116", "0.1370", "0.0744", "0.0499", "0.0360", "0.0299", + "0.0264", "0.0208", "0.0198", "0.0172", "0.0147", "0.0137", + "0.0134", "0.0117", "0.0110", "0.0104" +}; +static const char * const sta350_noise_shaper_type[] = { + "Third order", "Fourth order" +}; + +static DECLARE_TLV_DB_RANGE(sta350_limiter_ac_attack_tlv, + 0, 7, TLV_DB_SCALE_ITEM(-1200, 200, 0), + 8, 16, TLV_DB_SCALE_ITEM(300, 100, 0), +); + +static DECLARE_TLV_DB_RANGE(sta350_limiter_ac_release_tlv, + 0, 0, TLV_DB_SCALE_ITEM(TLV_DB_GAIN_MUTE, 0, 0), + 1, 1, TLV_DB_SCALE_ITEM(-2900, 0, 0), + 2, 2, TLV_DB_SCALE_ITEM(-2000, 0, 0), + 3, 8, TLV_DB_SCALE_ITEM(-1400, 200, 0), + 8, 16, TLV_DB_SCALE_ITEM(-700, 100, 0), +); + +static DECLARE_TLV_DB_RANGE(sta350_limiter_drc_attack_tlv, + 0, 7, TLV_DB_SCALE_ITEM(-3100, 200, 0), + 8, 13, TLV_DB_SCALE_ITEM(-1600, 100, 0), + 14, 16, TLV_DB_SCALE_ITEM(-1000, 300, 0), +); + +static DECLARE_TLV_DB_RANGE(sta350_limiter_drc_release_tlv, + 0, 0, TLV_DB_SCALE_ITEM(TLV_DB_GAIN_MUTE, 0, 0), + 1, 2, TLV_DB_SCALE_ITEM(-3800, 200, 0), + 3, 4, TLV_DB_SCALE_ITEM(-3300, 200, 0), + 5, 12, TLV_DB_SCALE_ITEM(-3000, 200, 0), + 13, 16, TLV_DB_SCALE_ITEM(-1500, 300, 0), +); + +static SOC_ENUM_SINGLE_DECL(sta350_drc_ac_enum, + STA350_CONFD, STA350_CONFD_DRC_SHIFT, + sta350_drc_ac); +static SOC_ENUM_SINGLE_DECL(sta350_noise_shaper_enum, + STA350_CONFE, STA350_CONFE_NSBW_SHIFT, + sta350_noise_shaper_type); +static SOC_ENUM_SINGLE_DECL(sta350_auto_gc_enum, + STA350_AUTO1, STA350_AUTO1_AMGC_SHIFT, + sta350_auto_gc_mode); +static SOC_ENUM_SINGLE_DECL(sta350_auto_xo_enum, + STA350_AUTO2, STA350_AUTO2_XO_SHIFT, + sta350_auto_xo_mode); +static SOC_ENUM_SINGLE_DECL(sta350_binary_output_ch1_enum, + STA350_C1CFG, STA350_CxCFG_BO_SHIFT, + sta350_binary_output); +static SOC_ENUM_SINGLE_DECL(sta350_binary_output_ch2_enum, + STA350_C2CFG, STA350_CxCFG_BO_SHIFT, + sta350_binary_output); +static SOC_ENUM_SINGLE_DECL(sta350_binary_output_ch3_enum, + STA350_C3CFG, STA350_CxCFG_BO_SHIFT, + sta350_binary_output); +static SOC_ENUM_SINGLE_DECL(sta350_limiter_ch1_enum, + STA350_C1CFG, STA350_CxCFG_LS_SHIFT, + sta350_limiter_select); +static SOC_ENUM_SINGLE_DECL(sta350_limiter_ch2_enum, + STA350_C2CFG, STA350_CxCFG_LS_SHIFT, + sta350_limiter_select); +static SOC_ENUM_SINGLE_DECL(sta350_limiter_ch3_enum, + STA350_C3CFG, STA350_CxCFG_LS_SHIFT, + sta350_limiter_select); +static SOC_ENUM_SINGLE_DECL(sta350_limiter1_attack_rate_enum, + STA350_L1AR, STA350_LxA_SHIFT, + sta350_limiter_attack_rate); +static SOC_ENUM_SINGLE_DECL(sta350_limiter2_attack_rate_enum, + STA350_L2AR, STA350_LxA_SHIFT, + sta350_limiter_attack_rate); +static SOC_ENUM_SINGLE_DECL(sta350_limiter1_release_rate_enum, + STA350_L1AR, STA350_LxR_SHIFT, + sta350_limiter_release_rate); +static SOC_ENUM_SINGLE_DECL(sta350_limiter2_release_rate_enum, + STA350_L2AR, STA350_LxR_SHIFT, + sta350_limiter_release_rate); + +/* + * byte array controls for setting biquad, mixer, scaling coefficients; + * for biquads all five coefficients need to be set in one go, + * mixer and pre/postscale coefs can be set individually; + * each coef is 24bit, the bytes are ordered in the same way + * as given in the STA350 data sheet (big endian; b1, b2, a1, a2, b0) + */ + +static int sta350_coefficient_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) +{ + int numcoef = kcontrol->private_value >> 16; + uinfo->type = SNDRV_CTL_ELEM_TYPE_BYTES; + uinfo->count = 3 * numcoef; + return 0; +} + +static int sta350_coefficient_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct sta350_priv *sta350 = snd_soc_codec_get_drvdata(codec); + int numcoef = kcontrol->private_value >> 16; + int index = kcontrol->private_value & 0xffff; + unsigned int cfud, val; + int i, ret = 0; + + mutex_lock(&sta350->coeff_lock); + + /* preserve reserved bits in STA350_CFUD */ + regmap_read(sta350->regmap, STA350_CFUD, &cfud); + cfud &= 0xf0; + /* + * chip documentation does not say if the bits are self clearing, + * so do it explicitly + */ + regmap_write(sta350->regmap, STA350_CFUD, cfud); + + regmap_write(sta350->regmap, STA350_CFADDR2, index); + if (numcoef == 1) { + regmap_write(sta350->regmap, STA350_CFUD, cfud | 0x04); + } else if (numcoef == 5) { + regmap_write(sta350->regmap, STA350_CFUD, cfud | 0x08); + } else { + ret = -EINVAL; + goto exit_unlock; + } + + for (i = 0; i < 3 * numcoef; i++) { + regmap_read(sta350->regmap, STA350_B1CF1 + i, &val); + ucontrol->value.bytes.data[i] = val; + } + +exit_unlock: + mutex_unlock(&sta350->coeff_lock); + + return ret; +} + +static int sta350_coefficient_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct sta350_priv *sta350 = snd_soc_codec_get_drvdata(codec); + int numcoef = kcontrol->private_value >> 16; + int index = kcontrol->private_value & 0xffff; + unsigned int cfud; + int i; + + /* preserve reserved bits in STA350_CFUD */ + regmap_read(sta350->regmap, STA350_CFUD, &cfud); + cfud &= 0xf0; + /* + * chip documentation does not say if the bits are self clearing, + * so do it explicitly + */ + regmap_write(sta350->regmap, STA350_CFUD, cfud); + + regmap_write(sta350->regmap, STA350_CFADDR2, index); + for (i = 0; i < numcoef && (index + i < STA350_COEF_COUNT); i++) + sta350->coef_shadow[index + i] = + (ucontrol->value.bytes.data[3 * i] << 16) + | (ucontrol->value.bytes.data[3 * i + 1] << 8) + | (ucontrol->value.bytes.data[3 * i + 2]); + for (i = 0; i < 3 * numcoef; i++) + regmap_write(sta350->regmap, STA350_B1CF1 + i, + ucontrol->value.bytes.data[i]); + if (numcoef == 1) + regmap_write(sta350->regmap, STA350_CFUD, cfud | 0x01); + else if (numcoef == 5) + regmap_write(sta350->regmap, STA350_CFUD, cfud | 0x02); + else + return -EINVAL; + + return 0; +} + +static int sta350_sync_coef_shadow(struct snd_soc_codec *codec) +{ + struct sta350_priv *sta350 = snd_soc_codec_get_drvdata(codec); + unsigned int cfud; + int i; + + /* preserve reserved bits in STA350_CFUD */ + regmap_read(sta350->regmap, STA350_CFUD, &cfud); + cfud &= 0xf0; + + for (i = 0; i < STA350_COEF_COUNT; i++) { + regmap_write(sta350->regmap, STA350_CFADDR2, i); + regmap_write(sta350->regmap, STA350_B1CF1, + (sta350->coef_shadow[i] >> 16) & 0xff); + regmap_write(sta350->regmap, STA350_B1CF2, + (sta350->coef_shadow[i] >> 8) & 0xff); + regmap_write(sta350->regmap, STA350_B1CF3, + (sta350->coef_shadow[i]) & 0xff); + /* + * chip documentation does not say if the bits are + * self-clearing, so do it explicitly + */ + regmap_write(sta350->regmap, STA350_CFUD, cfud); + regmap_write(sta350->regmap, STA350_CFUD, cfud | 0x01); + } + return 0; +} + +static int sta350_cache_sync(struct snd_soc_codec *codec) +{ + struct sta350_priv *sta350 = snd_soc_codec_get_drvdata(codec); + unsigned int mute; + int rc; + + /* mute during register sync */ + regmap_read(sta350->regmap, STA350_CFUD, &mute); + regmap_write(sta350->regmap, STA350_MMUTE, mute | STA350_MMUTE_MMUTE); + sta350_sync_coef_shadow(codec); + rc = regcache_sync(sta350->regmap); + regmap_write(sta350->regmap, STA350_MMUTE, mute); + return rc; +} + +#define SINGLE_COEF(xname, index) \ +{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \ + .info = sta350_coefficient_info, \ + .get = sta350_coefficient_get,\ + .put = sta350_coefficient_put, \ + .private_value = index | (1 << 16) } + +#define BIQUAD_COEFS(xname, index) \ +{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \ + .info = sta350_coefficient_info, \ + .get = sta350_coefficient_get,\ + .put = sta350_coefficient_put, \ + .private_value = index | (5 << 16) } + +static const struct snd_kcontrol_new sta350_snd_controls[] = { +SOC_SINGLE_TLV("Master Volume", STA350_MVOL, 0, 0xff, 1, mvol_tlv), +/* VOL */ +SOC_SINGLE_TLV("Ch1 Volume", STA350_C1VOL, 0, 0xff, 1, chvol_tlv), +SOC_SINGLE_TLV("Ch2 Volume", STA350_C2VOL, 0, 0xff, 1, chvol_tlv), +SOC_SINGLE_TLV("Ch3 Volume", STA350_C3VOL, 0, 0xff, 1, chvol_tlv), +/* CONFD */ +SOC_SINGLE("High Pass Filter Bypass Switch", + STA350_CONFD, STA350_CONFD_HPB_SHIFT, 1, 1), +SOC_SINGLE("De-emphasis Filter Switch", + STA350_CONFD, STA350_CONFD_DEMP_SHIFT, 1, 0), +SOC_SINGLE("DSP Bypass Switch", + STA350_CONFD, STA350_CONFD_DSPB_SHIFT, 1, 0), +SOC_SINGLE("Post-scale Link Switch", + STA350_CONFD, STA350_CONFD_PSL_SHIFT, 1, 0), +SOC_SINGLE("Biquad Coefficient Link Switch", + STA350_CONFD, STA350_CONFD_BQL_SHIFT, 1, 0), +SOC_ENUM("Compressor/Limiter Switch", sta350_drc_ac_enum), +SOC_ENUM("Noise Shaper Bandwidth", sta350_noise_shaper_enum), +SOC_SINGLE("Zero-detect Mute Enable Switch", + STA350_CONFD, STA350_CONFD_ZDE_SHIFT, 1, 0), +SOC_SINGLE("Submix Mode Switch", + STA350_CONFD, STA350_CONFD_SME_SHIFT, 1, 0), +/* CONFE */ +SOC_SINGLE("Zero Cross Switch", STA350_CONFE, STA350_CONFE_ZCE_SHIFT, 1, 0), +SOC_SINGLE("Soft Ramp Switch", STA350_CONFE, STA350_CONFE_SVE_SHIFT, 1, 0), +/* MUTE */ +SOC_SINGLE("Master Switch", STA350_MMUTE, STA350_MMUTE_MMUTE_SHIFT, 1, 1), +SOC_SINGLE("Ch1 Switch", STA350_MMUTE, STA350_MMUTE_C1M_SHIFT, 1, 1), +SOC_SINGLE("Ch2 Switch", STA350_MMUTE, STA350_MMUTE_C2M_SHIFT, 1, 1), +SOC_SINGLE("Ch3 Switch", STA350_MMUTE, STA350_MMUTE_C3M_SHIFT, 1, 1), +/* AUTOx */ +SOC_ENUM("Automode GC", sta350_auto_gc_enum), +SOC_ENUM("Automode XO", sta350_auto_xo_enum), +/* CxCFG */ +SOC_SINGLE("Ch1 Tone Control Bypass Switch", + STA350_C1CFG, STA350_CxCFG_TCB_SHIFT, 1, 0), +SOC_SINGLE("Ch2 Tone Control Bypass Switch", + STA350_C2CFG, STA350_CxCFG_TCB_SHIFT, 1, 0), +SOC_SINGLE("Ch1 EQ Bypass Switch", + STA350_C1CFG, STA350_CxCFG_EQBP_SHIFT, 1, 0), +SOC_SINGLE("Ch2 EQ Bypass Switch", + STA350_C2CFG, STA350_CxCFG_EQBP_SHIFT, 1, 0), +SOC_SINGLE("Ch1 Master Volume Bypass Switch", + STA350_C1CFG, STA350_CxCFG_VBP_SHIFT, 1, 0), +SOC_SINGLE("Ch2 Master Volume Bypass Switch", + STA350_C1CFG, STA350_CxCFG_VBP_SHIFT, 1, 0), +SOC_SINGLE("Ch3 Master Volume Bypass Switch", + STA350_C1CFG, STA350_CxCFG_VBP_SHIFT, 1, 0), +SOC_ENUM("Ch1 Binary Output Select", sta350_binary_output_ch1_enum), +SOC_ENUM("Ch2 Binary Output Select", sta350_binary_output_ch2_enum), +SOC_ENUM("Ch3 Binary Output Select", sta350_binary_output_ch3_enum), +SOC_ENUM("Ch1 Limiter Select", sta350_limiter_ch1_enum), +SOC_ENUM("Ch2 Limiter Select", sta350_limiter_ch2_enum), +SOC_ENUM("Ch3 Limiter Select", sta350_limiter_ch3_enum), +/* TONE */ +SOC_SINGLE_RANGE_TLV("Bass Tone Control Volume", + STA350_TONE, STA350_TONE_BTC_SHIFT, 1, 13, 0, tone_tlv), +SOC_SINGLE_RANGE_TLV("Treble Tone Control Volume", + STA350_TONE, STA350_TONE_TTC_SHIFT, 1, 13, 0, tone_tlv), +SOC_ENUM("Limiter1 Attack Rate (dB/ms)", sta350_limiter1_attack_rate_enum), +SOC_ENUM("Limiter2 Attack Rate (dB/ms)", sta350_limiter2_attack_rate_enum), +SOC_ENUM("Limiter1 Release Rate (dB/ms)", sta350_limiter1_release_rate_enum), +SOC_ENUM("Limiter2 Release Rate (dB/ms)", sta350_limiter2_release_rate_enum), + +/* + * depending on mode, the attack/release thresholds have + * two different enum definitions; provide both + */ +SOC_SINGLE_TLV("Limiter1 Attack Threshold (AC Mode)", + STA350_L1ATRT, STA350_LxA_SHIFT, + 16, 0, sta350_limiter_ac_attack_tlv), +SOC_SINGLE_TLV("Limiter2 Attack Threshold (AC Mode)", + STA350_L2ATRT, STA350_LxA_SHIFT, + 16, 0, sta350_limiter_ac_attack_tlv), +SOC_SINGLE_TLV("Limiter1 Release Threshold (AC Mode)", + STA350_L1ATRT, STA350_LxR_SHIFT, + 16, 0, sta350_limiter_ac_release_tlv), +SOC_SINGLE_TLV("Limiter2 Release Threshold (AC Mode)", + STA350_L2ATRT, STA350_LxR_SHIFT, + 16, 0, sta350_limiter_ac_release_tlv), +SOC_SINGLE_TLV("Limiter1 Attack Threshold (DRC Mode)", + STA350_L1ATRT, STA350_LxA_SHIFT, + 16, 0, sta350_limiter_drc_attack_tlv), +SOC_SINGLE_TLV("Limiter2 Attack Threshold (DRC Mode)", + STA350_L2ATRT, STA350_LxA_SHIFT, + 16, 0, sta350_limiter_drc_attack_tlv), +SOC_SINGLE_TLV("Limiter1 Release Threshold (DRC Mode)", + STA350_L1ATRT, STA350_LxR_SHIFT, + 16, 0, sta350_limiter_drc_release_tlv), +SOC_SINGLE_TLV("Limiter2 Release Threshold (DRC Mode)", + STA350_L2ATRT, STA350_LxR_SHIFT, + 16, 0, sta350_limiter_drc_release_tlv), + +BIQUAD_COEFS("Ch1 - Biquad 1", 0), +BIQUAD_COEFS("Ch1 - Biquad 2", 5), +BIQUAD_COEFS("Ch1 - Biquad 3", 10), +BIQUAD_COEFS("Ch1 - Biquad 4", 15), +BIQUAD_COEFS("Ch2 - Biquad 1", 20), +BIQUAD_COEFS("Ch2 - Biquad 2", 25), +BIQUAD_COEFS("Ch2 - Biquad 3", 30), +BIQUAD_COEFS("Ch2 - Biquad 4", 35), +BIQUAD_COEFS("High-pass", 40), +BIQUAD_COEFS("Low-pass", 45), +SINGLE_COEF("Ch1 - Prescale", 50), +SINGLE_COEF("Ch2 - Prescale", 51), +SINGLE_COEF("Ch1 - Postscale", 52), +SINGLE_COEF("Ch2 - Postscale", 53), +SINGLE_COEF("Ch3 - Postscale", 54), +SINGLE_COEF("Thermal warning - Postscale", 55), +SINGLE_COEF("Ch1 - Mix 1", 56), +SINGLE_COEF("Ch1 - Mix 2", 57), +SINGLE_COEF("Ch2 - Mix 1", 58), +SINGLE_COEF("Ch2 - Mix 2", 59), +SINGLE_COEF("Ch3 - Mix 1", 60), +SINGLE_COEF("Ch3 - Mix 2", 61), +}; + +static const struct snd_soc_dapm_widget sta350_dapm_widgets[] = { +SND_SOC_DAPM_DAC("DAC", NULL, SND_SOC_NOPM, 0, 0), +SND_SOC_DAPM_OUTPUT("LEFT"), +SND_SOC_DAPM_OUTPUT("RIGHT"), +SND_SOC_DAPM_OUTPUT("SUB"), +}; + +static const struct snd_soc_dapm_route sta350_dapm_routes[] = { + { "LEFT", NULL, "DAC" }, + { "RIGHT", NULL, "DAC" }, + { "SUB", NULL, "DAC" }, + { "DAC", NULL, "Playback" }, +}; + +/* MCLK interpolation ratio per fs */ +static struct { + int fs; + int ir; +} interpolation_ratios[] = { + { 32000, 0 }, + { 44100, 0 }, + { 48000, 0 }, + { 88200, 1 }, + { 96000, 1 }, + { 176400, 2 }, + { 192000, 2 }, +}; + +/* MCLK to fs clock ratios */ +static int mcs_ratio_table[3][6] = { + { 768, 512, 384, 256, 128, 576 }, + { 384, 256, 192, 128, 64, 0 }, + { 192, 128, 96, 64, 32, 0 }, +}; + +/** + * sta350_set_dai_sysclk - configure MCLK + * @codec_dai: the codec DAI + * @clk_id: the clock ID (ignored) + * @freq: the MCLK input frequency + * @dir: the clock direction (ignored) + * + * The value of MCLK is used to determine which sample rates are supported + * by the STA350, based on the mcs_ratio_table. + * + * This function must be called by the machine driver's 'startup' function, + * otherwise the list of supported sample rates will not be available in + * time for ALSA. + */ +static int sta350_set_dai_sysclk(struct snd_soc_dai *codec_dai, + int clk_id, unsigned int freq, int dir) +{ + struct snd_soc_codec *codec = codec_dai->codec; + struct sta350_priv *sta350 = snd_soc_codec_get_drvdata(codec); + + dev_dbg(codec->dev, "mclk=%u\n", freq); + sta350->mclk = freq; + + return 0; +} + +/** + * sta350_set_dai_fmt - configure the codec for the selected audio format + * @codec_dai: the codec DAI + * @fmt: a SND_SOC_DAIFMT_x value indicating the data format + * + * This function takes a bitmask of SND_SOC_DAIFMT_x bits and programs the + * codec accordingly. + */ +static int sta350_set_dai_fmt(struct snd_soc_dai *codec_dai, + unsigned int fmt) +{ + struct snd_soc_codec *codec = codec_dai->codec; + struct sta350_priv *sta350 = snd_soc_codec_get_drvdata(codec); + unsigned int confb = 0; + + switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { + case SND_SOC_DAIFMT_CBS_CFS: + break; + default: + return -EINVAL; + } + + switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { + case SND_SOC_DAIFMT_I2S: + case SND_SOC_DAIFMT_RIGHT_J: + case SND_SOC_DAIFMT_LEFT_J: + sta350->format = fmt & SND_SOC_DAIFMT_FORMAT_MASK; + break; + default: + return -EINVAL; + } + + switch (fmt & SND_SOC_DAIFMT_INV_MASK) { + case SND_SOC_DAIFMT_NB_NF: + confb |= STA350_CONFB_C2IM; + break; + case SND_SOC_DAIFMT_NB_IF: + confb |= STA350_CONFB_C1IM; + break; + default: + return -EINVAL; + } + + return regmap_update_bits(sta350->regmap, STA350_CONFB, + STA350_CONFB_C1IM | STA350_CONFB_C2IM, confb); +} + +/** + * sta350_hw_params - program the STA350 with the given hardware parameters. + * @substream: the audio stream + * @params: the hardware parameters to set + * @dai: the SOC DAI (ignored) + * + * This function programs the hardware with the values provided. + * Specifically, the sample rate and the data format. + */ +static int sta350_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *params, + struct snd_soc_dai *dai) +{ + struct snd_soc_codec *codec = dai->codec; + struct sta350_priv *sta350 = snd_soc_codec_get_drvdata(codec); + int i, mcs = -EINVAL, ir = -EINVAL; + unsigned int confa, confb; + unsigned int rate, ratio; + int ret; + + if (!sta350->mclk) { + dev_err(codec->dev, + "sta350->mclk is unset. Unable to determine ratio\n"); + return -EIO; + } + + rate = params_rate(params); + ratio = sta350->mclk / rate; + dev_dbg(codec->dev, "rate: %u, ratio: %u\n", rate, ratio); + + for (i = 0; i < ARRAY_SIZE(interpolation_ratios); i++) { + if (interpolation_ratios[i].fs == rate) { + ir = interpolation_ratios[i].ir; + break; + } + } + + if (ir < 0) { + dev_err(codec->dev, "Unsupported samplerate: %u\n", rate); + return -EINVAL; + } + + for (i = 0; i < 6; i++) { + if (mcs_ratio_table[ir][i] == ratio) { + mcs = i; + break; + } + } + + if (mcs < 0) { + dev_err(codec->dev, "Unresolvable ratio: %u\n", ratio); + return -EINVAL; + } + + confa = (ir << STA350_CONFA_IR_SHIFT) | + (mcs << STA350_CONFA_MCS_SHIFT); + confb = 0; + + switch (params_width(params)) { + case 24: + dev_dbg(codec->dev, "24bit\n"); + /* fall through */ + case 32: + dev_dbg(codec->dev, "24bit or 32bit\n"); + switch (sta350->format) { + case SND_SOC_DAIFMT_I2S: + confb |= 0x0; + break; + case SND_SOC_DAIFMT_LEFT_J: + confb |= 0x1; + break; + case SND_SOC_DAIFMT_RIGHT_J: + confb |= 0x2; + break; + } + + break; + case 20: + dev_dbg(codec->dev, "20bit\n"); + switch (sta350->format) { + case SND_SOC_DAIFMT_I2S: + confb |= 0x4; + break; + case SND_SOC_DAIFMT_LEFT_J: + confb |= 0x5; + break; + case SND_SOC_DAIFMT_RIGHT_J: + confb |= 0x6; + break; + } + + break; + case 18: + dev_dbg(codec->dev, "18bit\n"); + switch (sta350->format) { + case SND_SOC_DAIFMT_I2S: + confb |= 0x8; + break; + case SND_SOC_DAIFMT_LEFT_J: + confb |= 0x9; + break; + case SND_SOC_DAIFMT_RIGHT_J: + confb |= 0xa; + break; + } + + break; + case 16: + dev_dbg(codec->dev, "16bit\n"); + switch (sta350->format) { + case SND_SOC_DAIFMT_I2S: + confb |= 0x0; + break; + case SND_SOC_DAIFMT_LEFT_J: + confb |= 0xd; + break; + case SND_SOC_DAIFMT_RIGHT_J: + confb |= 0xe; + break; + } + + break; + default: + return -EINVAL; + } + + ret = regmap_update_bits(sta350->regmap, STA350_CONFA, + STA350_CONFA_MCS_MASK | STA350_CONFA_IR_MASK, + confa); + if (ret < 0) + return ret; + + ret = regmap_update_bits(sta350->regmap, STA350_CONFB, + STA350_CONFB_SAI_MASK | STA350_CONFB_SAIFB, + confb); + if (ret < 0) + return ret; + + return 0; +} + +static int sta350_startup_sequence(struct sta350_priv *sta350) +{ + if (sta350->gpiod_power_down) + gpiod_set_value(sta350->gpiod_power_down, 1); + + if (sta350->gpiod_nreset) { + gpiod_set_value(sta350->gpiod_nreset, 0); + mdelay(1); + gpiod_set_value(sta350->gpiod_nreset, 1); + mdelay(1); + } + + return 0; +} + +/** + * sta350_set_bias_level - DAPM callback + * @codec: the codec device + * @level: DAPM power level + * + * This is called by ALSA to put the codec into low power mode + * or to wake it up. If the codec is powered off completely + * all registers must be restored after power on. + */ +static int sta350_set_bias_level(struct snd_soc_codec *codec, + enum snd_soc_bias_level level) +{ + struct sta350_priv *sta350 = snd_soc_codec_get_drvdata(codec); + int ret; + + dev_dbg(codec->dev, "level = %d\n", level); + switch (level) { + case SND_SOC_BIAS_ON: + break; + + case SND_SOC_BIAS_PREPARE: + /* Full power on */ + regmap_update_bits(sta350->regmap, STA350_CONFF, + STA350_CONFF_PWDN | STA350_CONFF_EAPD, + STA350_CONFF_PWDN | STA350_CONFF_EAPD); + break; + + case SND_SOC_BIAS_STANDBY: + if (codec->dapm.bias_level == SND_SOC_BIAS_OFF) { + ret = regulator_bulk_enable( + ARRAY_SIZE(sta350->supplies), + sta350->supplies); + if (ret < 0) { + dev_err(codec->dev, + "Failed to enable supplies: %d\n", + ret); + return ret; + } + sta350_startup_sequence(sta350); + sta350_cache_sync(codec); + } + + /* Power down */ + regmap_update_bits(sta350->regmap, STA350_CONFF, + STA350_CONFF_PWDN | STA350_CONFF_EAPD, + 0); + + break; + + case SND_SOC_BIAS_OFF: + /* The chip runs through the power down sequence for us */ + regmap_update_bits(sta350->regmap, STA350_CONFF, + STA350_CONFF_PWDN | STA350_CONFF_EAPD, 0); + + /* power down: low */ + if (sta350->gpiod_power_down) + gpiod_set_value(sta350->gpiod_power_down, 0); + + if (sta350->gpiod_nreset) + gpiod_set_value(sta350->gpiod_nreset, 0); + + regulator_bulk_disable(ARRAY_SIZE(sta350->supplies), + sta350->supplies); + break; + } + codec->dapm.bias_level = level; + return 0; +} + +static const struct snd_soc_dai_ops sta350_dai_ops = { + .hw_params = sta350_hw_params, + .set_sysclk = sta350_set_dai_sysclk, + .set_fmt = sta350_set_dai_fmt, +}; + +static struct snd_soc_dai_driver sta350_dai = { + .name = "sta350-hifi", + .playback = { + .stream_name = "Playback", + .channels_min = 2, + .channels_max = 2, + .rates = STA350_RATES, + .formats = STA350_FORMATS, + }, + .ops = &sta350_dai_ops, +}; + +#ifdef CONFIG_PM +static int sta350_suspend(struct snd_soc_codec *codec) +{ + sta350_set_bias_level(codec, SND_SOC_BIAS_OFF); + return 0; +} + +static int sta350_resume(struct snd_soc_codec *codec) +{ + sta350_set_bias_level(codec, SND_SOC_BIAS_STANDBY); + return 0; +} +#else +#define sta350_suspend NULL +#define sta350_resume NULL +#endif + +static int sta350_probe(struct snd_soc_codec *codec) +{ + struct sta350_priv *sta350 = snd_soc_codec_get_drvdata(codec); + struct sta350_platform_data *pdata = sta350->pdata; + int i, ret = 0, thermal = 0; + + ret = regulator_bulk_enable(ARRAY_SIZE(sta350->supplies), + sta350->supplies); + if (ret < 0) { + dev_err(codec->dev, "Failed to enable supplies: %d\n", ret); + return ret; + } + + ret = sta350_startup_sequence(sta350); + if (ret < 0) { + dev_err(codec->dev, "Failed to startup device\n"); + return ret; + } + + /* CONFA */ + if (!pdata->thermal_warning_recovery) + thermal |= STA350_CONFA_TWAB; + if (!pdata->thermal_warning_adjustment) + thermal |= STA350_CONFA_TWRB; + if (!pdata->fault_detect_recovery) + thermal |= STA350_CONFA_FDRB; + regmap_update_bits(sta350->regmap, STA350_CONFA, + STA350_CONFA_TWAB | STA350_CONFA_TWRB | + STA350_CONFA_FDRB, + thermal); + + /* CONFC */ + regmap_update_bits(sta350->regmap, STA350_CONFC, + STA350_CONFC_OM_MASK, + pdata->ffx_power_output_mode + << STA350_CONFC_OM_SHIFT); + regmap_update_bits(sta350->regmap, STA350_CONFC, + STA350_CONFC_CSZ_MASK, + pdata->drop_compensation_ns + << STA350_CONFC_CSZ_SHIFT); + regmap_update_bits(sta350->regmap, + STA350_CONFC, + STA350_CONFC_OCRB, + pdata->oc_warning_adjustment ? + STA350_CONFC_OCRB : 0); + + /* CONFE */ + regmap_update_bits(sta350->regmap, STA350_CONFE, + STA350_CONFE_MPCV, + pdata->max_power_use_mpcc ? + STA350_CONFE_MPCV : 0); + regmap_update_bits(sta350->regmap, STA350_CONFE, + STA350_CONFE_MPC, + pdata->max_power_correction ? + STA350_CONFE_MPC : 0); + regmap_update_bits(sta350->regmap, STA350_CONFE, + STA350_CONFE_AME, + pdata->am_reduction_mode ? + STA350_CONFE_AME : 0); + regmap_update_bits(sta350->regmap, STA350_CONFE, + STA350_CONFE_PWMS, + pdata->odd_pwm_speed_mode ? + STA350_CONFE_PWMS : 0); + regmap_update_bits(sta350->regmap, STA350_CONFE, + STA350_CONFE_DCCV, + pdata->distortion_compensation ? + STA350_CONFE_DCCV : 0); + /* CONFF */ + regmap_update_bits(sta350->regmap, STA350_CONFF, + STA350_CONFF_IDE, + pdata->invalid_input_detect_mute ? + STA350_CONFF_IDE : 0); + regmap_update_bits(sta350->regmap, STA350_CONFF, + STA350_CONFF_OCFG_MASK, + pdata->output_conf + << STA350_CONFF_OCFG_SHIFT); + + /* channel to output mapping */ + regmap_update_bits(sta350->regmap, STA350_C1CFG, + STA350_CxCFG_OM_MASK, + pdata->ch1_output_mapping + << STA350_CxCFG_OM_SHIFT); + regmap_update_bits(sta350->regmap, STA350_C2CFG, + STA350_CxCFG_OM_MASK, + pdata->ch2_output_mapping + << STA350_CxCFG_OM_SHIFT); + regmap_update_bits(sta350->regmap, STA350_C3CFG, + STA350_CxCFG_OM_MASK, + pdata->ch3_output_mapping + << STA350_CxCFG_OM_SHIFT); + + /* initialize coefficient shadow RAM with reset values */ + for (i = 4; i <= 49; i += 5) + sta350->coef_shadow[i] = 0x400000; + for (i = 50; i <= 54; i++) + sta350->coef_shadow[i] = 0x7fffff; + sta350->coef_shadow[55] = 0x5a9df7; + sta350->coef_shadow[56] = 0x7fffff; + sta350->coef_shadow[59] = 0x7fffff; + sta350->coef_shadow[60] = 0x400000; + sta350->coef_shadow[61] = 0x400000; + + sta350_set_bias_level(codec, SND_SOC_BIAS_STANDBY); + /* Bias level configuration will have done an extra enable */ + regulator_bulk_disable(ARRAY_SIZE(sta350->supplies), sta350->supplies); + + return 0; +} + +static int sta350_remove(struct snd_soc_codec *codec) +{ + struct sta350_priv *sta350 = snd_soc_codec_get_drvdata(codec); + + sta350_set_bias_level(codec, SND_SOC_BIAS_OFF); + regulator_bulk_disable(ARRAY_SIZE(sta350->supplies), sta350->supplies); + + return 0; +} + +static const struct snd_soc_codec_driver sta350_codec = { + .probe = sta350_probe, + .remove = sta350_remove, + .suspend = sta350_suspend, + .resume = sta350_resume, + .set_bias_level = sta350_set_bias_level, + .controls = sta350_snd_controls, + .num_controls = ARRAY_SIZE(sta350_snd_controls), + .dapm_widgets = sta350_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(sta350_dapm_widgets), + .dapm_routes = sta350_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(sta350_dapm_routes), +}; + +static const struct regmap_config sta350_regmap = { + .reg_bits = 8, + .val_bits = 8, + .max_register = STA350_MISC2, + .reg_defaults = sta350_regs, + .num_reg_defaults = ARRAY_SIZE(sta350_regs), + .cache_type = REGCACHE_RBTREE, + .wr_table = &sta350_write_regs, + .rd_table = &sta350_read_regs, + .volatile_table = &sta350_volatile_regs, +}; + +#ifdef CONFIG_OF +static const struct of_device_id st350_dt_ids[] = { + { .compatible = "st,sta350", }, + { } +}; +MODULE_DEVICE_TABLE(of, st350_dt_ids); + +static const char * const sta350_ffx_modes[] = { + [STA350_FFX_PM_DROP_COMP] = "drop-compensation", + [STA350_FFX_PM_TAPERED_COMP] = "tapered-compensation", + [STA350_FFX_PM_FULL_POWER] = "full-power-mode", + [STA350_FFX_PM_VARIABLE_DROP_COMP] = "variable-drop-compensation", +}; + +static int sta350_probe_dt(struct device *dev, struct sta350_priv *sta350) +{ + struct device_node *np = dev->of_node; + struct sta350_platform_data *pdata; + const char *ffx_power_mode; + u16 tmp; + + pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL); + if (!pdata) + return -ENOMEM; + + of_property_read_u8(np, "st,output-conf", + &pdata->output_conf); + of_property_read_u8(np, "st,ch1-output-mapping", + &pdata->ch1_output_mapping); + of_property_read_u8(np, "st,ch2-output-mapping", + &pdata->ch2_output_mapping); + of_property_read_u8(np, "st,ch3-output-mapping", + &pdata->ch3_output_mapping); + + if (of_get_property(np, "st,thermal-warning-recovery", NULL)) + pdata->thermal_warning_recovery = 1; + if (of_get_property(np, "st,thermal-warning-adjustment", NULL)) + pdata->thermal_warning_adjustment = 1; + if (of_get_property(np, "st,fault-detect-recovery", NULL)) + pdata->fault_detect_recovery = 1; + + pdata->ffx_power_output_mode = STA350_FFX_PM_VARIABLE_DROP_COMP; + if (!of_property_read_string(np, "st,ffx-power-output-mode", + &ffx_power_mode)) { + int i, mode = -EINVAL; + + for (i = 0; i < ARRAY_SIZE(sta350_ffx_modes); i++) + if (!strcasecmp(ffx_power_mode, sta350_ffx_modes[i])) + mode = i; + + if (mode < 0) + dev_warn(dev, "Unsupported ffx output mode: %s\n", + ffx_power_mode); + else + pdata->ffx_power_output_mode = mode; + } + + tmp = 140; + of_property_read_u16(np, "st,drop-compensation-ns", &tmp); + pdata->drop_compensation_ns = clamp_t(u16, tmp, 0, 300) / 20; + + if (of_get_property(np, "st,overcurrent-warning-adjustment", NULL)) + pdata->oc_warning_adjustment = 1; + + /* CONFE */ + if (of_get_property(np, "st,max-power-use-mpcc", NULL)) + pdata->max_power_use_mpcc = 1; + + if (of_get_property(np, "st,max-power-correction", NULL)) + pdata->max_power_correction = 1; + + if (of_get_property(np, "st,am-reduction-mode", NULL)) + pdata->am_reduction_mode = 1; + + if (of_get_property(np, "st,odd-pwm-speed-mode", NULL)) + pdata->odd_pwm_speed_mode = 1; + + if (of_get_property(np, "st,distortion-compensation", NULL)) + pdata->distortion_compensation = 1; + + /* CONFF */ + if (of_get_property(np, "st,invalid-input-detect-mute", NULL)) + pdata->invalid_input_detect_mute = 1; + + sta350->pdata = pdata; + + return 0; +} +#endif + +static int sta350_i2c_probe(struct i2c_client *i2c, + const struct i2c_device_id *id) +{ + struct device *dev = &i2c->dev; + struct sta350_priv *sta350; + int ret, i; + + sta350 = devm_kzalloc(dev, sizeof(struct sta350_priv), GFP_KERNEL); + if (!sta350) + return -ENOMEM; + + mutex_init(&sta350->coeff_lock); + sta350->pdata = dev_get_platdata(dev); + +#ifdef CONFIG_OF + if (dev->of_node) { + ret = sta350_probe_dt(dev, sta350); + if (ret < 0) + return ret; + } +#endif + + /* GPIOs */ + sta350->gpiod_nreset = devm_gpiod_get(dev, "reset"); + if (IS_ERR(sta350->gpiod_nreset)) { + ret = PTR_ERR(sta350->gpiod_nreset); + if (ret != -ENOENT && ret != -ENOSYS) + return ret; + + sta350->gpiod_nreset = NULL; + } else { + gpiod_direction_output(sta350->gpiod_nreset, 0); + } + + sta350->gpiod_power_down = devm_gpiod_get(dev, "power-down"); + if (IS_ERR(sta350->gpiod_power_down)) { + ret = PTR_ERR(sta350->gpiod_power_down); + if (ret != -ENOENT && ret != -ENOSYS) + return ret; + + sta350->gpiod_power_down = NULL; + } else { + gpiod_direction_output(sta350->gpiod_power_down, 0); + } + + /* regulators */ + for (i = 0; i < ARRAY_SIZE(sta350->supplies); i++) + sta350->supplies[i].supply = sta350_supply_names[i]; + + ret = devm_regulator_bulk_get(dev, ARRAY_SIZE(sta350->supplies), + sta350->supplies); + if (ret < 0) { + dev_err(dev, "Failed to request supplies: %d\n", ret); + return ret; + } + + sta350->regmap = devm_regmap_init_i2c(i2c, &sta350_regmap); + if (IS_ERR(sta350->regmap)) { + ret = PTR_ERR(sta350->regmap); + dev_err(dev, "Failed to init regmap: %d\n", ret); + return ret; + } + + i2c_set_clientdata(i2c, sta350); + + ret = snd_soc_register_codec(dev, &sta350_codec, &sta350_dai, 1); + if (ret < 0) + dev_err(dev, "Failed to register codec (%d)\n", ret); + + return ret; +} + +static int sta350_i2c_remove(struct i2c_client *client) +{ + snd_soc_unregister_codec(&client->dev); + return 0; +} + +static const struct i2c_device_id sta350_i2c_id[] = { + { "sta350", 0 }, + { } +}; +MODULE_DEVICE_TABLE(i2c, sta350_i2c_id); + +static struct i2c_driver sta350_i2c_driver = { + .driver = { + .name = "sta350", + .owner = THIS_MODULE, + .of_match_table = of_match_ptr(st350_dt_ids), + }, + .probe = sta350_i2c_probe, + .remove = sta350_i2c_remove, + .id_table = sta350_i2c_id, +}; + +module_i2c_driver(sta350_i2c_driver); + +MODULE_DESCRIPTION("ASoC STA350 driver"); +MODULE_AUTHOR("Sven Brandau "); +MODULE_LICENSE("GPL"); diff --git a/sound/soc/codecs/sta350.h b/sound/soc/codecs/sta350.h new file mode 100644 index 000000000000..c3248f0fad2c --- /dev/null +++ b/sound/soc/codecs/sta350.h @@ -0,0 +1,228 @@ +/* + * Codec driver for ST STA350 2.1-channel high-efficiency digital audio system + * + * Copyright: 2011 Raumfeld GmbH + * Author: Sven Brandau + * + * based on code from: + * Raumfeld GmbH + * Johannes Stezenbach + * Wolfson Microelectronics PLC. + * Mark Brown + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + */ +#ifndef _ASOC_STA_350_H +#define _ASOC_STA_350_H + +/* STA50 register addresses */ + +#define STA350_REGISTER_COUNT 0x4D +#define STA350_COEF_COUNT 62 + +#define STA350_CONFA 0x00 +#define STA350_CONFB 0x01 +#define STA350_CONFC 0x02 +#define STA350_CONFD 0x03 +#define STA350_CONFE 0x04 +#define STA350_CONFF 0x05 +#define STA350_MMUTE 0x06 +#define STA350_MVOL 0x07 +#define STA350_C1VOL 0x08 +#define STA350_C2VOL 0x09 +#define STA350_C3VOL 0x0a +#define STA350_AUTO1 0x0b +#define STA350_AUTO2 0x0c +#define STA350_AUTO3 0x0d +#define STA350_C1CFG 0x0e +#define STA350_C2CFG 0x0f +#define STA350_C3CFG 0x10 +#define STA350_TONE 0x11 +#define STA350_L1AR 0x12 +#define STA350_L1ATRT 0x13 +#define STA350_L2AR 0x14 +#define STA350_L2ATRT 0x15 +#define STA350_CFADDR2 0x16 +#define STA350_B1CF1 0x17 +#define STA350_B1CF2 0x18 +#define STA350_B1CF3 0x19 +#define STA350_B2CF1 0x1a +#define STA350_B2CF2 0x1b +#define STA350_B2CF3 0x1c +#define STA350_A1CF1 0x1d +#define STA350_A1CF2 0x1e +#define STA350_A1CF3 0x1f +#define STA350_A2CF1 0x20 +#define STA350_A2CF2 0x21 +#define STA350_A2CF3 0x22 +#define STA350_B0CF1 0x23 +#define STA350_B0CF2 0x24 +#define STA350_B0CF3 0x25 +#define STA350_CFUD 0x26 +#define STA350_MPCC1 0x27 +#define STA350_MPCC2 0x28 +#define STA350_DCC1 0x29 +#define STA350_DCC2 0x2a +#define STA350_FDRC1 0x2b +#define STA350_FDRC2 0x2c +#define STA350_STATUS 0x2d +/* reserved: 0x2d - 0x30 */ +#define STA350_EQCFG 0x31 +#define STA350_EATH1 0x32 +#define STA350_ERTH1 0x33 +#define STA350_EATH2 0x34 +#define STA350_ERTH2 0x35 +#define STA350_CONFX 0x36 +#define STA350_SVCA 0x37 +#define STA350_SVCB 0x38 +#define STA350_RMS0A 0x39 +#define STA350_RMS0B 0x3a +#define STA350_RMS0C 0x3b +#define STA350_RMS1A 0x3c +#define STA350_RMS1B 0x3d +#define STA350_RMS1C 0x3e +#define STA350_EVOLRES 0x3f +/* reserved: 0x40 - 0x47 */ +#define STA350_NSHAPE 0x48 +#define STA350_CTXB4B1 0x49 +#define STA350_CTXB7B5 0x4a +#define STA350_MISC1 0x4b +#define STA350_MISC2 0x4c + +/* 0x00 CONFA */ +#define STA350_CONFA_MCS_MASK 0x03 +#define STA350_CONFA_MCS_SHIFT 0 +#define STA350_CONFA_IR_MASK 0x18 +#define STA350_CONFA_IR_SHIFT 3 +#define STA350_CONFA_TWRB BIT(5) +#define STA350_CONFA_TWAB BIT(6) +#define STA350_CONFA_FDRB BIT(7) + +/* 0x01 CONFB */ +#define STA350_CONFB_SAI_MASK 0x0f +#define STA350_CONFB_SAI_SHIFT 0 +#define STA350_CONFB_SAIFB BIT(4) +#define STA350_CONFB_DSCKE BIT(5) +#define STA350_CONFB_C1IM BIT(6) +#define STA350_CONFB_C2IM BIT(7) + +/* 0x02 CONFC */ +#define STA350_CONFC_OM_MASK 0x03 +#define STA350_CONFC_OM_SHIFT 0 +#define STA350_CONFC_CSZ_MASK 0x3c +#define STA350_CONFC_CSZ_SHIFT 2 +#define STA350_CONFC_OCRB BIT(7) + +/* 0x03 CONFD */ +#define STA350_CONFD_HPB_SHIFT 0 +#define STA350_CONFD_DEMP_SHIFT 1 +#define STA350_CONFD_DSPB_SHIFT 2 +#define STA350_CONFD_PSL_SHIFT 3 +#define STA350_CONFD_BQL_SHIFT 4 +#define STA350_CONFD_DRC_SHIFT 5 +#define STA350_CONFD_ZDE_SHIFT 6 +#define STA350_CONFD_SME_SHIFT 7 + +/* 0x04 CONFE */ +#define STA350_CONFE_MPCV BIT(0) +#define STA350_CONFE_MPCV_SHIFT 0 +#define STA350_CONFE_MPC BIT(1) +#define STA350_CONFE_MPC_SHIFT 1 +#define STA350_CONFE_NSBW BIT(2) +#define STA350_CONFE_NSBW_SHIFT 2 +#define STA350_CONFE_AME BIT(3) +#define STA350_CONFE_AME_SHIFT 3 +#define STA350_CONFE_PWMS BIT(4) +#define STA350_CONFE_PWMS_SHIFT 4 +#define STA350_CONFE_DCCV BIT(5) +#define STA350_CONFE_DCCV_SHIFT 5 +#define STA350_CONFE_ZCE BIT(6) +#define STA350_CONFE_ZCE_SHIFT 6 +#define STA350_CONFE_SVE BIT(7) +#define STA350_CONFE_SVE_SHIFT 7 + +/* 0x05 CONFF */ +#define STA350_CONFF_OCFG_MASK 0x03 +#define STA350_CONFF_OCFG_SHIFT 0 +#define STA350_CONFF_IDE BIT(2) +#define STA350_CONFF_BCLE BIT(3) +#define STA350_CONFF_LDTE BIT(4) +#define STA350_CONFF_ECLE BIT(5) +#define STA350_CONFF_PWDN BIT(6) +#define STA350_CONFF_EAPD BIT(7) + +/* 0x06 MMUTE */ +#define STA350_MMUTE_MMUTE 0x01 +#define STA350_MMUTE_MMUTE_SHIFT 0 +#define STA350_MMUTE_C1M 0x02 +#define STA350_MMUTE_C1M_SHIFT 1 +#define STA350_MMUTE_C2M 0x04 +#define STA350_MMUTE_C2M_SHIFT 2 +#define STA350_MMUTE_C3M 0x08 +#define STA350_MMUTE_C3M_SHIFT 3 +#define STA350_MMUTE_LOC_MASK 0xC0 +#define STA350_MMUTE_LOC_SHIFT 6 + +/* 0x0b AUTO1 */ +#define STA350_AUTO1_AMGC_MASK 0x30 +#define STA350_AUTO1_AMGC_SHIFT 4 + +/* 0x0c AUTO2 */ +#define STA350_AUTO2_AMAME 0x01 +#define STA350_AUTO2_AMAM_MASK 0x0e +#define STA350_AUTO2_AMAM_SHIFT 1 +#define STA350_AUTO2_XO_MASK 0xf0 +#define STA350_AUTO2_XO_SHIFT 4 + +/* 0x0d AUTO3 */ +#define STA350_AUTO3_PEQ_MASK 0x1f +#define STA350_AUTO3_PEQ_SHIFT 0 + +/* 0x0e 0x0f 0x10 CxCFG */ +#define STA350_CxCFG_TCB_SHIFT 0 +#define STA350_CxCFG_EQBP_SHIFT 1 +#define STA350_CxCFG_VBP_SHIFT 2 +#define STA350_CxCFG_BO_SHIFT 3 +#define STA350_CxCFG_LS_SHIFT 4 +#define STA350_CxCFG_OM_MASK 0xc0 +#define STA350_CxCFG_OM_SHIFT 6 + +/* 0x11 TONE */ +#define STA350_TONE_BTC_SHIFT 0 +#define STA350_TONE_TTC_SHIFT 4 + +/* 0x12 0x13 0x14 0x15 limiter attack/release */ +#define STA350_LxA_SHIFT 0 +#define STA350_LxR_SHIFT 4 + +/* 0x26 CFUD */ +#define STA350_CFUD_W1 0x01 +#define STA350_CFUD_WA 0x02 +#define STA350_CFUD_R1 0x04 +#define STA350_CFUD_RA 0x08 + + +/* biquad filter coefficient table offsets */ +#define STA350_C1_BQ_BASE 0 +#define STA350_C2_BQ_BASE 20 +#define STA350_CH_BQ_NUM 4 +#define STA350_BQ_NUM_COEF 5 +#define STA350_XO_HP_BQ_BASE 40 +#define STA350_XO_LP_BQ_BASE 45 +#define STA350_C1_PRESCALE 50 +#define STA350_C2_PRESCALE 51 +#define STA350_C1_POSTSCALE 52 +#define STA350_C2_POSTSCALE 53 +#define STA350_C3_POSTSCALE 54 +#define STA350_TW_POSTSCALE 55 +#define STA350_C1_MIX1 56 +#define STA350_C1_MIX2 57 +#define STA350_C2_MIX1 58 +#define STA350_C2_MIX2 59 +#define STA350_C3_MIX1 60 +#define STA350_C3_MIX2 61 + +#endif /* _ASOC_STA_350_H */ -- cgit v1.2.3 From 766e3721990d2c78e0d614b57753f105adbaa8c5 Mon Sep 17 00:00:00 2001 From: Scott Jiang Date: Fri, 4 Apr 2014 16:27:17 +0800 Subject: spi: convert spi-bfin-v3.c to a multiplatform driver Spi v3 controller is not only used on Blackfin. So rename it and use ioread/iowrite api to make it work on other platform. Signed-off-by: Scott Jiang Signed-off-by: Mark Brown --- arch/blackfin/include/asm/bfin_spi3.h | 258 --------- arch/blackfin/mach-bf609/boards/ezkit.c | 22 +- drivers/spi/Kconfig | 4 +- drivers/spi/Makefile | 2 +- drivers/spi/spi-adi-v3.c | 985 ++++++++++++++++++++++++++++++++ drivers/spi/spi-bfin-v3.c | 965 ------------------------------- include/linux/spi/adi_spi3.h | 254 ++++++++ 7 files changed, 1253 insertions(+), 1237 deletions(-) delete mode 100644 arch/blackfin/include/asm/bfin_spi3.h create mode 100644 drivers/spi/spi-adi-v3.c delete mode 100644 drivers/spi/spi-bfin-v3.c create mode 100644 include/linux/spi/adi_spi3.h diff --git a/arch/blackfin/include/asm/bfin_spi3.h b/arch/blackfin/include/asm/bfin_spi3.h deleted file mode 100644 index 0957e65a54be..000000000000 --- a/arch/blackfin/include/asm/bfin_spi3.h +++ /dev/null @@ -1,258 +0,0 @@ -/* - * Analog Devices SPI3 controller driver - * - * Copyright (c) 2011 Analog Devices Inc. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#ifndef _SPI_CHANNEL_H_ -#define _SPI_CHANNEL_H_ - -#include - -/* SPI_CONTROL */ -#define SPI_CTL_EN 0x00000001 /* Enable */ -#define SPI_CTL_MSTR 0x00000002 /* Master/Slave */ -#define SPI_CTL_PSSE 0x00000004 /* controls modf error in master mode */ -#define SPI_CTL_ODM 0x00000008 /* Open Drain Mode */ -#define SPI_CTL_CPHA 0x00000010 /* Clock Phase */ -#define SPI_CTL_CPOL 0x00000020 /* Clock Polarity */ -#define SPI_CTL_ASSEL 0x00000040 /* Slave Select Pin Control */ -#define SPI_CTL_SELST 0x00000080 /* Slave Select Polarity in-between transfers */ -#define SPI_CTL_EMISO 0x00000100 /* Enable MISO */ -#define SPI_CTL_SIZE 0x00000600 /* Word Transfer Size */ -#define SPI_CTL_SIZE08 0x00000000 /* SIZE: 8 bits */ -#define SPI_CTL_SIZE16 0x00000200 /* SIZE: 16 bits */ -#define SPI_CTL_SIZE32 0x00000400 /* SIZE: 32 bits */ -#define SPI_CTL_LSBF 0x00001000 /* LSB First */ -#define SPI_CTL_FCEN 0x00002000 /* Flow-Control Enable */ -#define SPI_CTL_FCCH 0x00004000 /* Flow-Control Channel Selection */ -#define SPI_CTL_FCPL 0x00008000 /* Flow-Control Polarity */ -#define SPI_CTL_FCWM 0x00030000 /* Flow-Control Water-Mark */ -#define SPI_CTL_FIFO0 0x00000000 /* FCWM: TFIFO empty or RFIFO Full */ -#define SPI_CTL_FIFO1 0x00010000 /* FCWM: TFIFO 75% or more empty or RFIFO 75% or more full */ -#define SPI_CTL_FIFO2 0x00020000 /* FCWM: TFIFO 50% or more empty or RFIFO 50% or more full */ -#define SPI_CTL_FMODE 0x00040000 /* Fast-mode Enable */ -#define SPI_CTL_MIOM 0x00300000 /* Multiple I/O Mode */ -#define SPI_CTL_MIO_DIS 0x00000000 /* MIOM: Disable */ -#define SPI_CTL_MIO_DUAL 0x00100000 /* MIOM: Enable DIOM (Dual I/O Mode) */ -#define SPI_CTL_MIO_QUAD 0x00200000 /* MIOM: Enable QUAD (Quad SPI Mode) */ -#define SPI_CTL_SOSI 0x00400000 /* Start on MOSI */ -/* SPI_RX_CONTROL */ -#define SPI_RXCTL_REN 0x00000001 /* Receive Channel Enable */ -#define SPI_RXCTL_RTI 0x00000004 /* Receive Transfer Initiate */ -#define SPI_RXCTL_RWCEN 0x00000008 /* Receive Word Counter Enable */ -#define SPI_RXCTL_RDR 0x00000070 /* Receive Data Request */ -#define SPI_RXCTL_RDR_DIS 0x00000000 /* RDR: Disabled */ -#define SPI_RXCTL_RDR_NE 0x00000010 /* RDR: RFIFO not empty */ -#define SPI_RXCTL_RDR_25 0x00000020 /* RDR: RFIFO 25% full */ -#define SPI_RXCTL_RDR_50 0x00000030 /* RDR: RFIFO 50% full */ -#define SPI_RXCTL_RDR_75 0x00000040 /* RDR: RFIFO 75% full */ -#define SPI_RXCTL_RDR_FULL 0x00000050 /* RDR: RFIFO full */ -#define SPI_RXCTL_RDO 0x00000100 /* Receive Data Over-Run */ -#define SPI_RXCTL_RRWM 0x00003000 /* FIFO Regular Water-Mark */ -#define SPI_RXCTL_RWM_0 0x00000000 /* RRWM: RFIFO Empty */ -#define SPI_RXCTL_RWM_25 0x00001000 /* RRWM: RFIFO 25% full */ -#define SPI_RXCTL_RWM_50 0x00002000 /* RRWM: RFIFO 50% full */ -#define SPI_RXCTL_RWM_75 0x00003000 /* RRWM: RFIFO 75% full */ -#define SPI_RXCTL_RUWM 0x00070000 /* FIFO Urgent Water-Mark */ -#define SPI_RXCTL_UWM_DIS 0x00000000 /* RUWM: Disabled */ -#define SPI_RXCTL_UWM_25 0x00010000 /* RUWM: RFIFO 25% full */ -#define SPI_RXCTL_UWM_50 0x00020000 /* RUWM: RFIFO 50% full */ -#define SPI_RXCTL_UWM_75 0x00030000 /* RUWM: RFIFO 75% full */ -#define SPI_RXCTL_UWM_FULL 0x00040000 /* RUWM: RFIFO full */ -/* SPI_TX_CONTROL */ -#define SPI_TXCTL_TEN 0x00000001 /* Transmit Channel Enable */ -#define SPI_TXCTL_TTI 0x00000004 /* Transmit Transfer Initiate */ -#define SPI_TXCTL_TWCEN 0x00000008 /* Transmit Word Counter Enable */ -#define SPI_TXCTL_TDR 0x00000070 /* Transmit Data Request */ -#define SPI_TXCTL_TDR_DIS 0x00000000 /* TDR: Disabled */ -#define SPI_TXCTL_TDR_NF 0x00000010 /* TDR: TFIFO not full */ -#define SPI_TXCTL_TDR_25 0x00000020 /* TDR: TFIFO 25% empty */ -#define SPI_TXCTL_TDR_50 0x00000030 /* TDR: TFIFO 50% empty */ -#define SPI_TXCTL_TDR_75 0x00000040 /* TDR: TFIFO 75% empty */ -#define SPI_TXCTL_TDR_EMPTY 0x00000050 /* TDR: TFIFO empty */ -#define SPI_TXCTL_TDU 0x00000100 /* Transmit Data Under-Run */ -#define SPI_TXCTL_TRWM 0x00003000 /* FIFO Regular Water-Mark */ -#define SPI_TXCTL_RWM_FULL 0x00000000 /* TRWM: TFIFO full */ -#define SPI_TXCTL_RWM_25 0x00001000 /* TRWM: TFIFO 25% empty */ -#define SPI_TXCTL_RWM_50 0x00002000 /* TRWM: TFIFO 50% empty */ -#define SPI_TXCTL_RWM_75 0x00003000 /* TRWM: TFIFO 75% empty */ -#define SPI_TXCTL_TUWM 0x00070000 /* FIFO Urgent Water-Mark */ -#define SPI_TXCTL_UWM_DIS 0x00000000 /* TUWM: Disabled */ -#define SPI_TXCTL_UWM_25 0x00010000 /* TUWM: TFIFO 25% empty */ -#define SPI_TXCTL_UWM_50 0x00020000 /* TUWM: TFIFO 50% empty */ -#define SPI_TXCTL_UWM_75 0x00030000 /* TUWM: TFIFO 75% empty */ -#define SPI_TXCTL_UWM_EMPTY 0x00040000 /* TUWM: TFIFO empty */ -/* SPI_CLOCK */ -#define SPI_CLK_BAUD 0x0000FFFF /* Baud Rate */ -/* SPI_DELAY */ -#define SPI_DLY_STOP 0x000000FF /* Transfer delay time in multiples of SCK period */ -#define SPI_DLY_LEADX 0x00000100 /* Extended (1 SCK) LEAD Control */ -#define SPI_DLY_LAGX 0x00000200 /* Extended (1 SCK) LAG control */ -/* SPI_SSEL */ -#define SPI_SLVSEL_SSE1 0x00000002 /* SPISSEL1 Enable */ -#define SPI_SLVSEL_SSE2 0x00000004 /* SPISSEL2 Enable */ -#define SPI_SLVSEL_SSE3 0x00000008 /* SPISSEL3 Enable */ -#define SPI_SLVSEL_SSE4 0x00000010 /* SPISSEL4 Enable */ -#define SPI_SLVSEL_SSE5 0x00000020 /* SPISSEL5 Enable */ -#define SPI_SLVSEL_SSE6 0x00000040 /* SPISSEL6 Enable */ -#define SPI_SLVSEL_SSE7 0x00000080 /* SPISSEL7 Enable */ -#define SPI_SLVSEL_SSEL1 0x00000200 /* SPISSEL1 Value */ -#define SPI_SLVSEL_SSEL2 0x00000400 /* SPISSEL2 Value */ -#define SPI_SLVSEL_SSEL3 0x00000800 /* SPISSEL3 Value */ -#define SPI_SLVSEL_SSEL4 0x00001000 /* SPISSEL4 Value */ -#define SPI_SLVSEL_SSEL5 0x00002000 /* SPISSEL5 Value */ -#define SPI_SLVSEL_SSEL6 0x00004000 /* SPISSEL6 Value */ -#define SPI_SLVSEL_SSEL7 0x00008000 /* SPISSEL7 Value */ -/* SPI_RWC */ -#define SPI_RWC_VALUE 0x0000FFFF /* Received Word-Count */ -/* SPI_RWCR */ -#define SPI_RWCR_VALUE 0x0000FFFF /* Received Word-Count Reload */ -/* SPI_TWC */ -#define SPI_TWC_VALUE 0x0000FFFF /* Transmitted Word-Count */ -/* SPI_TWCR */ -#define SPI_TWCR_VALUE 0x0000FFFF /* Transmitted Word-Count Reload */ -/* SPI_IMASK */ -#define SPI_IMSK_RUWM 0x00000002 /* Receive Urgent Water-Mark Interrupt Mask */ -#define SPI_IMSK_TUWM 0x00000004 /* Transmit Urgent Water-Mark Interrupt Mask */ -#define SPI_IMSK_ROM 0x00000010 /* Receive Over-Run Error Interrupt Mask */ -#define SPI_IMSK_TUM 0x00000020 /* Transmit Under-Run Error Interrupt Mask */ -#define SPI_IMSK_TCM 0x00000040 /* Transmit Collision Error Interrupt Mask */ -#define SPI_IMSK_MFM 0x00000080 /* Mode Fault Error Interrupt Mask */ -#define SPI_IMSK_RSM 0x00000100 /* Receive Start Interrupt Mask */ -#define SPI_IMSK_TSM 0x00000200 /* Transmit Start Interrupt Mask */ -#define SPI_IMSK_RFM 0x00000400 /* Receive Finish Interrupt Mask */ -#define SPI_IMSK_TFM 0x00000800 /* Transmit Finish Interrupt Mask */ -/* SPI_IMASKCL */ -#define SPI_IMSK_CLR_RUW 0x00000002 /* Receive Urgent Water-Mark Interrupt Mask */ -#define SPI_IMSK_CLR_TUWM 0x00000004 /* Transmit Urgent Water-Mark Interrupt Mask */ -#define SPI_IMSK_CLR_ROM 0x00000010 /* Receive Over-Run Error Interrupt Mask */ -#define SPI_IMSK_CLR_TUM 0x00000020 /* Transmit Under-Run Error Interrupt Mask */ -#define SPI_IMSK_CLR_TCM 0x00000040 /* Transmit Collision Error Interrupt Mask */ -#define SPI_IMSK_CLR_MFM 0x00000080 /* Mode Fault Error Interrupt Mask */ -#define SPI_IMSK_CLR_RSM 0x00000100 /* Receive Start Interrupt Mask */ -#define SPI_IMSK_CLR_TSM 0x00000200 /* Transmit Start Interrupt Mask */ -#define SPI_IMSK_CLR_RFM 0x00000400 /* Receive Finish Interrupt Mask */ -#define SPI_IMSK_CLR_TFM 0x00000800 /* Transmit Finish Interrupt Mask */ -/* SPI_IMASKST */ -#define SPI_IMSK_SET_RUWM 0x00000002 /* Receive Urgent Water-Mark Interrupt Mask */ -#define SPI_IMSK_SET_TUWM 0x00000004 /* Transmit Urgent Water-Mark Interrupt Mask */ -#define SPI_IMSK_SET_ROM 0x00000010 /* Receive Over-Run Error Interrupt Mask */ -#define SPI_IMSK_SET_TUM 0x00000020 /* Transmit Under-Run Error Interrupt Mask */ -#define SPI_IMSK_SET_TCM 0x00000040 /* Transmit Collision Error Interrupt Mask */ -#define SPI_IMSK_SET_MFM 0x00000080 /* Mode Fault Error Interrupt Mask */ -#define SPI_IMSK_SET_RSM 0x00000100 /* Receive Start Interrupt Mask */ -#define SPI_IMSK_SET_TSM 0x00000200 /* Transmit Start Interrupt Mask */ -#define SPI_IMSK_SET_RFM 0x00000400 /* Receive Finish Interrupt Mask */ -#define SPI_IMSK_SET_TFM 0x00000800 /* Transmit Finish Interrupt Mask */ -/* SPI_STATUS */ -#define SPI_STAT_SPIF 0x00000001 /* SPI Finished */ -#define SPI_STAT_RUWM 0x00000002 /* Receive Urgent Water-Mark Breached */ -#define SPI_STAT_TUWM 0x00000004 /* Transmit Urgent Water-Mark Breached */ -#define SPI_STAT_ROE 0x00000010 /* Receive Over-Run Error Indication */ -#define SPI_STAT_TUE 0x00000020 /* Transmit Under-Run Error Indication */ -#define SPI_STAT_TCE 0x00000040 /* Transmit Collision Error Indication */ -#define SPI_STAT_MODF 0x00000080 /* Mode Fault Error Indication */ -#define SPI_STAT_RS 0x00000100 /* Receive Start Indication */ -#define SPI_STAT_TS 0x00000200 /* Transmit Start Indication */ -#define SPI_STAT_RF 0x00000400 /* Receive Finish Indication */ -#define SPI_STAT_TF 0x00000800 /* Transmit Finish Indication */ -#define SPI_STAT_RFS 0x00007000 /* SPI_RFIFO status */ -#define SPI_STAT_RFIFO_EMPTY 0x00000000 /* RFS: RFIFO Empty */ -#define SPI_STAT_RFIFO_25 0x00001000 /* RFS: RFIFO 25% Full */ -#define SPI_STAT_RFIFO_50 0x00002000 /* RFS: RFIFO 50% Full */ -#define SPI_STAT_RFIFO_75 0x00003000 /* RFS: RFIFO 75% Full */ -#define SPI_STAT_RFIFO_FULL 0x00004000 /* RFS: RFIFO Full */ -#define SPI_STAT_TFS 0x00070000 /* SPI_TFIFO status */ -#define SPI_STAT_TFIFO_FULL 0x00000000 /* TFS: TFIFO full */ -#define SPI_STAT_TFIFO_25 0x00010000 /* TFS: TFIFO 25% empty */ -#define SPI_STAT_TFIFO_50 0x00020000 /* TFS: TFIFO 50% empty */ -#define SPI_STAT_TFIFO_75 0x00030000 /* TFS: TFIFO 75% empty */ -#define SPI_STAT_TFIFO_EMPTY 0x00040000 /* TFS: TFIFO empty */ -#define SPI_STAT_FCS 0x00100000 /* Flow-Control Stall Indication */ -#define SPI_STAT_RFE 0x00400000 /* SPI_RFIFO Empty */ -#define SPI_STAT_TFF 0x00800000 /* SPI_TFIFO Full */ -/* SPI_ILAT */ -#define SPI_ILAT_RUWMI 0x00000002 /* Receive Urgent Water Mark Interrupt */ -#define SPI_ILAT_TUWMI 0x00000004 /* Transmit Urgent Water Mark Interrupt */ -#define SPI_ILAT_ROI 0x00000010 /* Receive Over-Run Error Indication */ -#define SPI_ILAT_TUI 0x00000020 /* Transmit Under-Run Error Indication */ -#define SPI_ILAT_TCI 0x00000040 /* Transmit Collision Error Indication */ -#define SPI_ILAT_MFI 0x00000080 /* Mode Fault Error Indication */ -#define SPI_ILAT_RSI 0x00000100 /* Receive Start Indication */ -#define SPI_ILAT_TSI 0x00000200 /* Transmit Start Indication */ -#define SPI_ILAT_RFI 0x00000400 /* Receive Finish Indication */ -#define SPI_ILAT_TFI 0x00000800 /* Transmit Finish Indication */ -/* SPI_ILATCL */ -#define SPI_ILAT_CLR_RUWMI 0x00000002 /* Receive Urgent Water Mark Interrupt */ -#define SPI_ILAT_CLR_TUWMI 0x00000004 /* Transmit Urgent Water Mark Interrupt */ -#define SPI_ILAT_CLR_ROI 0x00000010 /* Receive Over-Run Error Indication */ -#define SPI_ILAT_CLR_TUI 0x00000020 /* Transmit Under-Run Error Indication */ -#define SPI_ILAT_CLR_TCI 0x00000040 /* Transmit Collision Error Indication */ -#define SPI_ILAT_CLR_MFI 0x00000080 /* Mode Fault Error Indication */ -#define SPI_ILAT_CLR_RSI 0x00000100 /* Receive Start Indication */ -#define SPI_ILAT_CLR_TSI 0x00000200 /* Transmit Start Indication */ -#define SPI_ILAT_CLR_RFI 0x00000400 /* Receive Finish Indication */ -#define SPI_ILAT_CLR_TFI 0x00000800 /* Transmit Finish Indication */ - -/* - * bfin spi3 registers layout - */ -struct bfin_spi_regs { - u32 revid; - u32 control; - u32 rx_control; - u32 tx_control; - u32 clock; - u32 delay; - u32 ssel; - u32 rwc; - u32 rwcr; - u32 twc; - u32 twcr; - u32 reserved0; - u32 emask; - u32 emaskcl; - u32 emaskst; - u32 reserved1; - u32 status; - u32 elat; - u32 elatcl; - u32 reserved2; - u32 rfifo; - u32 reserved3; - u32 tfifo; -}; - -#define MAX_CTRL_CS 8 /* cs in spi controller */ - -/* device.platform_data for SSP controller devices */ -struct bfin_spi3_master { - u16 num_chipselect; - u16 pin_req[7]; -}; - -/* spi_board_info.controller_data for SPI slave devices, - * copied to spi_device.platform_data ... mostly for dma tuning - */ -struct bfin_spi3_chip { - u32 control; - u16 cs_chg_udelay; /* Some devices require 16-bit delays */ - u32 tx_dummy_val; /* tx value for rx only transfer */ - bool enable_dma; -}; - -#endif /* _SPI_CHANNEL_H_ */ diff --git a/arch/blackfin/mach-bf609/boards/ezkit.c b/arch/blackfin/mach-bf609/boards/ezkit.c index 943f7e95ec15..1ba4600de69f 100644 --- a/arch/blackfin/mach-bf609/boards/ezkit.c +++ b/arch/blackfin/mach-bf609/boards/ezkit.c @@ -20,7 +20,7 @@ #include #include #include -#include +#include #include #include #include @@ -767,13 +767,13 @@ static struct flash_platform_data bfin_spi_flash_data = { .type = "w25q32", }; -static struct bfin_spi3_chip spi_flash_chip_info = { +static struct adi_spi3_chip spi_flash_chip_info = { .enable_dma = true, /* use dma transfer with this chip*/ }; #endif #if IS_ENABLED(CONFIG_SPI_SPIDEV) -static struct bfin_spi3_chip spidev_chip_info = { +static struct adi_spi3_chip spidev_chip_info = { .enable_dma = true, }; #endif @@ -1736,7 +1736,7 @@ static struct spi_board_info bfin_spi_board_info[] __initdata = { }, #endif }; -#if IS_ENABLED(CONFIG_SPI_BFIN_V3) +#if IS_ENABLED(CONFIG_SPI_ADI_V3) /* SPI (0) */ static struct resource bfin_spi0_resource[] = { { @@ -1777,13 +1777,13 @@ static struct resource bfin_spi1_resource[] = { }; /* SPI controller data */ -static struct bfin_spi3_master bf60x_spi_master_info0 = { +static struct adi_spi3_master bf60x_spi_master_info0 = { .num_chipselect = MAX_CTRL_CS + MAX_BLACKFIN_GPIOS, .pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0}, }; static struct platform_device bf60x_spi_master0 = { - .name = "bfin-spi3", + .name = "adi-spi3", .id = 0, /* Bus number */ .num_resources = ARRAY_SIZE(bfin_spi0_resource), .resource = bfin_spi0_resource, @@ -1792,13 +1792,13 @@ static struct platform_device bf60x_spi_master0 = { }, }; -static struct bfin_spi3_master bf60x_spi_master_info1 = { +static struct adi_spi3_master bf60x_spi_master_info1 = { .num_chipselect = MAX_CTRL_CS + MAX_BLACKFIN_GPIOS, .pin_req = {P_SPI1_SCK, P_SPI1_MISO, P_SPI1_MOSI, 0}, }; static struct platform_device bf60x_spi_master1 = { - .name = "bfin-spi3", + .name = "adi-spi3", .id = 1, /* Bus number */ .num_resources = ARRAY_SIZE(bfin_spi1_resource), .resource = bfin_spi1_resource, @@ -1990,7 +1990,7 @@ static struct platform_device *ezkit_devices[] __initdata = { &bfin_sdh_device, #endif -#if IS_ENABLED(CONFIG_SPI_BFIN_V3) +#if IS_ENABLED(CONFIG_SPI_ADI_V3) &bf60x_spi_master0, &bf60x_spi_master1, #endif @@ -2051,8 +2051,8 @@ static struct pinctrl_map __initdata bfin_pinmux_map[] = { PIN_MAP_MUX_GROUP_DEFAULT("bfin_sir.1", "pinctrl-adi2.0", NULL, "uart1"), PIN_MAP_MUX_GROUP_DEFAULT("bfin-sdh.0", "pinctrl-adi2.0", NULL, "rsi0"), PIN_MAP_MUX_GROUP_DEFAULT("stmmaceth.0", "pinctrl-adi2.0", NULL, "eth0"), - PIN_MAP_MUX_GROUP_DEFAULT("bfin-spi3.0", "pinctrl-adi2.0", NULL, "spi0"), - PIN_MAP_MUX_GROUP_DEFAULT("bfin-spi3.1", "pinctrl-adi2.0", NULL, "spi1"), + PIN_MAP_MUX_GROUP_DEFAULT("adi-spi3.0", "pinctrl-adi2.0", NULL, "spi0"), + PIN_MAP_MUX_GROUP_DEFAULT("adi-spi3.1", "pinctrl-adi2.0", NULL, "spi1"), PIN_MAP_MUX_GROUP_DEFAULT("i2c-bfin-twi.0", "pinctrl-adi2.0", NULL, "twi0"), PIN_MAP_MUX_GROUP_DEFAULT("i2c-bfin-twi.1", "pinctrl-adi2.0", NULL, "twi1"), PIN_MAP_MUX_GROUP_DEFAULT("bfin-rotary", "pinctrl-adi2.0", NULL, "rotary"), diff --git a/drivers/spi/Kconfig b/drivers/spi/Kconfig index 60f2b41c7310..a52e0edb7146 100644 --- a/drivers/spi/Kconfig +++ b/drivers/spi/Kconfig @@ -91,8 +91,8 @@ config SPI_BFIN5XX help This is the SPI controller master driver for Blackfin 5xx processor. -config SPI_BFIN_V3 - tristate "SPI controller v3 for Blackfin" +config SPI_ADI_V3 + tristate "SPI controller v3 for ADI" depends on BF60x help This is the SPI controller v3 master driver diff --git a/drivers/spi/Makefile b/drivers/spi/Makefile index bd792669e563..71e65dfc0ea3 100644 --- a/drivers/spi/Makefile +++ b/drivers/spi/Makefile @@ -18,7 +18,7 @@ obj-$(CONFIG_SPI_BCM2835) += spi-bcm2835.o obj-$(CONFIG_SPI_BCM63XX) += spi-bcm63xx.o obj-$(CONFIG_SPI_BCM63XX_HSSPI) += spi-bcm63xx-hsspi.o obj-$(CONFIG_SPI_BFIN5XX) += spi-bfin5xx.o -obj-$(CONFIG_SPI_BFIN_V3) += spi-bfin-v3.o +obj-$(CONFIG_SPI_ADI_V3) += spi-adi-v3.o obj-$(CONFIG_SPI_BFIN_SPORT) += spi-bfin-sport.o obj-$(CONFIG_SPI_BITBANG) += spi-bitbang.o obj-$(CONFIG_SPI_BUTTERFLY) += spi-butterfly.o diff --git a/drivers/spi/spi-adi-v3.c b/drivers/spi/spi-adi-v3.c new file mode 100644 index 000000000000..0c2914cfcdb5 --- /dev/null +++ b/drivers/spi/spi-adi-v3.c @@ -0,0 +1,985 @@ +/* + * Analog Devices SPI3 controller driver + * + * Copyright (c) 2014 Analog Devices Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +enum adi_spi_state { + START_STATE, + RUNNING_STATE, + DONE_STATE, + ERROR_STATE +}; + +struct adi_spi_master; + +struct adi_spi_transfer_ops { + void (*write) (struct adi_spi_master *); + void (*read) (struct adi_spi_master *); + void (*duplex) (struct adi_spi_master *); +}; + +/* runtime info for spi master */ +struct adi_spi_master { + /* SPI framework hookup */ + struct spi_master *master; + + /* Regs base of SPI controller */ + struct adi_spi_regs __iomem *regs; + + /* Pin request list */ + u16 *pin_req; + + /* Message Transfer pump */ + struct tasklet_struct pump_transfers; + + /* Current message transfer state info */ + struct spi_message *cur_msg; + struct spi_transfer *cur_transfer; + struct adi_spi_device *cur_chip; + unsigned transfer_len; + + /* transfer buffer */ + void *tx; + void *tx_end; + void *rx; + void *rx_end; + + /* dma info */ + unsigned int tx_dma; + unsigned int rx_dma; + dma_addr_t tx_dma_addr; + dma_addr_t rx_dma_addr; + unsigned long dummy_buffer; /* used in unidirectional transfer */ + unsigned long tx_dma_size; + unsigned long rx_dma_size; + int tx_num; + int rx_num; + + /* store register value for suspend/resume */ + u32 control; + u32 ssel; + + unsigned long sclk; + enum adi_spi_state state; + + const struct adi_spi_transfer_ops *ops; +}; + +struct adi_spi_device { + u32 control; + u32 clock; + u32 ssel; + + u8 cs; + u16 cs_chg_udelay; /* Some devices require > 255usec delay */ + u32 cs_gpio; + u32 tx_dummy_val; /* tx value for rx only transfer */ + bool enable_dma; + const struct adi_spi_transfer_ops *ops; +}; + +static void adi_spi_enable(struct adi_spi_master *drv_data) +{ + u32 ctl; + + ctl = ioread32(&drv_data->regs->control); + ctl |= SPI_CTL_EN; + iowrite32(ctl, &drv_data->regs->control); +} + +static void adi_spi_disable(struct adi_spi_master *drv_data) +{ + u32 ctl; + + ctl = ioread32(&drv_data->regs->control); + ctl &= ~SPI_CTL_EN; + iowrite32(ctl, &drv_data->regs->control); +} + +/* Caculate the SPI_CLOCK register value based on input HZ */ +static u32 hz_to_spi_clock(u32 sclk, u32 speed_hz) +{ + u32 spi_clock = sclk / speed_hz; + + if (spi_clock) + spi_clock--; + return spi_clock; +} + +static int adi_spi_flush(struct adi_spi_master *drv_data) +{ + unsigned long limit = loops_per_jiffy << 1; + + /* wait for stop and clear stat */ + while (!(ioread32(&drv_data->regs->status) & SPI_STAT_SPIF) && --limit) + cpu_relax(); + + iowrite32(0xFFFFFFFF, &drv_data->regs->status); + + return limit; +} + +/* Chip select operation functions for cs_change flag */ +static void adi_spi_cs_active(struct adi_spi_master *drv_data, struct adi_spi_device *chip) +{ + if (likely(chip->cs < MAX_CTRL_CS)) { + u32 reg; + reg = ioread32(&drv_data->regs->ssel); + reg &= ~chip->ssel; + iowrite32(reg, &drv_data->regs->ssel); + } else { + gpio_set_value(chip->cs_gpio, 0); + } +} + +static void adi_spi_cs_deactive(struct adi_spi_master *drv_data, + struct adi_spi_device *chip) +{ + if (likely(chip->cs < MAX_CTRL_CS)) { + u32 reg; + reg = ioread32(&drv_data->regs->ssel); + reg |= chip->ssel; + iowrite32(reg, &drv_data->regs->ssel); + } else { + gpio_set_value(chip->cs_gpio, 1); + } + + /* Move delay here for consistency */ + if (chip->cs_chg_udelay) + udelay(chip->cs_chg_udelay); +} + +/* enable or disable the pin muxed by GPIO and SPI CS to work as SPI CS */ +static inline void adi_spi_cs_enable(struct adi_spi_master *drv_data, + struct adi_spi_device *chip) +{ + if (chip->cs < MAX_CTRL_CS) { + u32 reg; + reg = ioread32(&drv_data->regs->ssel); + reg |= chip->ssel >> 8; + iowrite32(reg, &drv_data->regs->ssel); + } +} + +static inline void adi_spi_cs_disable(struct adi_spi_master *drv_data, + struct adi_spi_device *chip) +{ + if (chip->cs < MAX_CTRL_CS) { + u32 reg; + reg = ioread32(&drv_data->regs->ssel); + reg &= ~(chip->ssel >> 8); + iowrite32(reg, &drv_data->regs->ssel); + } +} + +/* stop controller and re-config current chip*/ +static void adi_spi_restore_state(struct adi_spi_master *drv_data) +{ + struct adi_spi_device *chip = drv_data->cur_chip; + + /* Clear status and disable clock */ + iowrite32(0xFFFFFFFF, &drv_data->regs->status); + iowrite32(0x0, &drv_data->regs->rx_control); + iowrite32(0x0, &drv_data->regs->tx_control); + adi_spi_disable(drv_data); + + /* Load the registers */ + iowrite32(chip->control, &drv_data->regs->control); + iowrite32(chip->clock, &drv_data->regs->clock); + + adi_spi_enable(drv_data); + drv_data->tx_num = drv_data->rx_num = 0; + /* we always choose tx transfer initiate */ + iowrite32(SPI_RXCTL_REN, &drv_data->regs->rx_control); + iowrite32(SPI_TXCTL_TEN | SPI_TXCTL_TTI, &drv_data->regs->tx_control); + adi_spi_cs_active(drv_data, chip); +} + +/* discard invalid rx data and empty rfifo */ +static inline void dummy_read(struct adi_spi_master *drv_data) +{ + while (!(ioread32(&drv_data->regs->status) & SPI_STAT_RFE)) + ioread32(&drv_data->regs->rfifo); +} + +static void adi_spi_u8_write(struct adi_spi_master *drv_data) +{ + dummy_read(drv_data); + while (drv_data->tx < drv_data->tx_end) { + iowrite32(*(u8 *)(drv_data->tx++), &drv_data->regs->tfifo); + while (ioread32(&drv_data->regs->status) & SPI_STAT_RFE) + cpu_relax(); + ioread32(&drv_data->regs->rfifo); + } +} + +static void adi_spi_u8_read(struct adi_spi_master *drv_data) +{ + u32 tx_val = drv_data->cur_chip->tx_dummy_val; + + dummy_read(drv_data); + while (drv_data->rx < drv_data->rx_end) { + iowrite32(tx_val, &drv_data->regs->tfifo); + while (ioread32(&drv_data->regs->status) & SPI_STAT_RFE) + cpu_relax(); + *(u8 *)(drv_data->rx++) = ioread32(&drv_data->regs->rfifo); + } +} + +static void adi_spi_u8_duplex(struct adi_spi_master *drv_data) +{ + dummy_read(drv_data); + while (drv_data->rx < drv_data->rx_end) { + iowrite32(*(u8 *)(drv_data->tx++), &drv_data->regs->tfifo); + while (ioread32(&drv_data->regs->status) & SPI_STAT_RFE) + cpu_relax(); + *(u8 *)(drv_data->rx++) = ioread32(&drv_data->regs->rfifo); + } +} + +static const struct adi_spi_transfer_ops adi_spi_transfer_ops_u8 = { + .write = adi_spi_u8_write, + .read = adi_spi_u8_read, + .duplex = adi_spi_u8_duplex, +}; + +static void adi_spi_u16_write(struct adi_spi_master *drv_data) +{ + dummy_read(drv_data); + while (drv_data->tx < drv_data->tx_end) { + iowrite32(*(u16 *)drv_data->tx, &drv_data->regs->tfifo); + drv_data->tx += 2; + while (ioread32(&drv_data->regs->status) & SPI_STAT_RFE) + cpu_relax(); + ioread32(&drv_data->regs->rfifo); + } +} + +static void adi_spi_u16_read(struct adi_spi_master *drv_data) +{ + u32 tx_val = drv_data->cur_chip->tx_dummy_val; + + dummy_read(drv_data); + while (drv_data->rx < drv_data->rx_end) { + iowrite32(tx_val, &drv_data->regs->tfifo); + while (ioread32(&drv_data->regs->status) & SPI_STAT_RFE) + cpu_relax(); + *(u16 *)drv_data->rx = ioread32(&drv_data->regs->rfifo); + drv_data->rx += 2; + } +} + +static void adi_spi_u16_duplex(struct adi_spi_master *drv_data) +{ + dummy_read(drv_data); + while (drv_data->rx < drv_data->rx_end) { + iowrite32(*(u16 *)drv_data->tx, &drv_data->regs->tfifo); + drv_data->tx += 2; + while (ioread32(&drv_data->regs->status) & SPI_STAT_RFE) + cpu_relax(); + *(u16 *)drv_data->rx = ioread32(&drv_data->regs->rfifo); + drv_data->rx += 2; + } +} + +static const struct adi_spi_transfer_ops adi_spi_transfer_ops_u16 = { + .write = adi_spi_u16_write, + .read = adi_spi_u16_read, + .duplex = adi_spi_u16_duplex, +}; + +static void adi_spi_u32_write(struct adi_spi_master *drv_data) +{ + dummy_read(drv_data); + while (drv_data->tx < drv_data->tx_end) { + iowrite32(*(u32 *)drv_data->tx, &drv_data->regs->tfifo); + drv_data->tx += 4; + while (ioread32(&drv_data->regs->status) & SPI_STAT_RFE) + cpu_relax(); + ioread32(&drv_data->regs->rfifo); + } +} + +static void adi_spi_u32_read(struct adi_spi_master *drv_data) +{ + u32 tx_val = drv_data->cur_chip->tx_dummy_val; + + dummy_read(drv_data); + while (drv_data->rx < drv_data->rx_end) { + iowrite32(tx_val, &drv_data->regs->tfifo); + while (ioread32(&drv_data->regs->status) & SPI_STAT_RFE) + cpu_relax(); + *(u32 *)drv_data->rx = ioread32(&drv_data->regs->rfifo); + drv_data->rx += 4; + } +} + +static void adi_spi_u32_duplex(struct adi_spi_master *drv_data) +{ + dummy_read(drv_data); + while (drv_data->rx < drv_data->rx_end) { + iowrite32(*(u32 *)drv_data->tx, &drv_data->regs->tfifo); + drv_data->tx += 4; + while (ioread32(&drv_data->regs->status) & SPI_STAT_RFE) + cpu_relax(); + *(u32 *)drv_data->rx = ioread32(&drv_data->regs->rfifo); + drv_data->rx += 4; + } +} + +static const struct adi_spi_transfer_ops adi_spi_transfer_ops_u32 = { + .write = adi_spi_u32_write, + .read = adi_spi_u32_read, + .duplex = adi_spi_u32_duplex, +}; + + +/* test if there is more transfer to be done */ +static void adi_spi_next_transfer(struct adi_spi_master *drv) +{ + struct spi_message *msg = drv->cur_msg; + struct spi_transfer *t = drv->cur_transfer; + + /* Move to next transfer */ + if (t->transfer_list.next != &msg->transfers) { + drv->cur_transfer = list_entry(t->transfer_list.next, + struct spi_transfer, transfer_list); + drv->state = RUNNING_STATE; + } else { + drv->state = DONE_STATE; + drv->cur_transfer = NULL; + } +} + +static void adi_spi_giveback(struct adi_spi_master *drv_data) +{ + struct adi_spi_device *chip = drv_data->cur_chip; + + adi_spi_cs_deactive(drv_data, chip); + spi_finalize_current_message(drv_data->master); +} + +static int adi_spi_setup_transfer(struct adi_spi_master *drv) +{ + struct spi_transfer *t = drv->cur_transfer; + u32 cr, cr_width; + + if (t->tx_buf) { + drv->tx = (void *)t->tx_buf; + drv->tx_end = drv->tx + t->len; + } else { + drv->tx = NULL; + } + + if (t->rx_buf) { + drv->rx = t->rx_buf; + drv->rx_end = drv->rx + t->len; + } else { + drv->rx = NULL; + } + + drv->transfer_len = t->len; + + /* bits per word setup */ + switch (t->bits_per_word) { + case 8: + cr_width = SPI_CTL_SIZE08; + drv->ops = &adi_spi_transfer_ops_u8; + break; + case 16: + cr_width = SPI_CTL_SIZE16; + drv->ops = &adi_spi_transfer_ops_u16; + break; + case 32: + cr_width = SPI_CTL_SIZE32; + drv->ops = &adi_spi_transfer_ops_u32; + break; + default: + return -EINVAL; + } + cr = ioread32(&drv->regs->control) & ~SPI_CTL_SIZE; + cr |= cr_width; + iowrite32(cr, &drv->regs->control); + + /* speed setup */ + iowrite32(hz_to_spi_clock(drv->sclk, t->speed_hz), &drv->regs->clock); + return 0; +} + +static int adi_spi_dma_xfer(struct adi_spi_master *drv_data) +{ + struct spi_transfer *t = drv_data->cur_transfer; + struct spi_message *msg = drv_data->cur_msg; + struct adi_spi_device *chip = drv_data->cur_chip; + u32 dma_config; + unsigned long word_count, word_size; + void *tx_buf, *rx_buf; + + switch (t->bits_per_word) { + case 8: + dma_config = WDSIZE_8 | PSIZE_8; + word_count = drv_data->transfer_len; + word_size = 1; + break; + case 16: + dma_config = WDSIZE_16 | PSIZE_16; + word_count = drv_data->transfer_len / 2; + word_size = 2; + break; + default: + dma_config = WDSIZE_32 | PSIZE_32; + word_count = drv_data->transfer_len / 4; + word_size = 4; + break; + } + + if (!drv_data->rx) { + tx_buf = drv_data->tx; + rx_buf = &drv_data->dummy_buffer; + drv_data->tx_dma_size = drv_data->transfer_len; + drv_data->rx_dma_size = sizeof(drv_data->dummy_buffer); + set_dma_x_modify(drv_data->tx_dma, word_size); + set_dma_x_modify(drv_data->rx_dma, 0); + } else if (!drv_data->tx) { + drv_data->dummy_buffer = chip->tx_dummy_val; + tx_buf = &drv_data->dummy_buffer; + rx_buf = drv_data->rx; + drv_data->tx_dma_size = sizeof(drv_data->dummy_buffer); + drv_data->rx_dma_size = drv_data->transfer_len; + set_dma_x_modify(drv_data->tx_dma, 0); + set_dma_x_modify(drv_data->rx_dma, word_size); + } else { + tx_buf = drv_data->tx; + rx_buf = drv_data->rx; + drv_data->tx_dma_size = drv_data->rx_dma_size + = drv_data->transfer_len; + set_dma_x_modify(drv_data->tx_dma, word_size); + set_dma_x_modify(drv_data->rx_dma, word_size); + } + + drv_data->tx_dma_addr = dma_map_single(&msg->spi->dev, + (void *)tx_buf, + drv_data->tx_dma_size, + DMA_TO_DEVICE); + if (dma_mapping_error(&msg->spi->dev, + drv_data->tx_dma_addr)) + return -ENOMEM; + + drv_data->rx_dma_addr = dma_map_single(&msg->spi->dev, + (void *)rx_buf, + drv_data->rx_dma_size, + DMA_FROM_DEVICE); + if (dma_mapping_error(&msg->spi->dev, + drv_data->rx_dma_addr)) { + dma_unmap_single(&msg->spi->dev, + drv_data->tx_dma_addr, + drv_data->tx_dma_size, + DMA_TO_DEVICE); + return -ENOMEM; + } + + dummy_read(drv_data); + set_dma_x_count(drv_data->tx_dma, word_count); + set_dma_x_count(drv_data->rx_dma, word_count); + set_dma_start_addr(drv_data->tx_dma, drv_data->tx_dma_addr); + set_dma_start_addr(drv_data->rx_dma, drv_data->rx_dma_addr); + dma_config |= DMAFLOW_STOP | RESTART | DI_EN; + set_dma_config(drv_data->tx_dma, dma_config); + set_dma_config(drv_data->rx_dma, dma_config | WNR); + enable_dma(drv_data->tx_dma); + enable_dma(drv_data->rx_dma); + + iowrite32(SPI_RXCTL_REN | SPI_RXCTL_RDR_NE, + &drv_data->regs->rx_control); + iowrite32(SPI_TXCTL_TEN | SPI_TXCTL_TTI | SPI_TXCTL_TDR_NF, + &drv_data->regs->tx_control); + + return 0; +} + +static int adi_spi_pio_xfer(struct adi_spi_master *drv_data) +{ + struct spi_message *msg = drv_data->cur_msg; + + if (!drv_data->rx) { + /* write only half duplex */ + drv_data->ops->write(drv_data); + if (drv_data->tx != drv_data->tx_end) + return -EIO; + } else if (!drv_data->tx) { + /* read only half duplex */ + drv_data->ops->read(drv_data); + if (drv_data->rx != drv_data->rx_end) + return -EIO; + } else { + /* full duplex mode */ + drv_data->ops->duplex(drv_data); + if (drv_data->tx != drv_data->tx_end) + return -EIO; + } + + if (!adi_spi_flush(drv_data)) + return -EIO; + msg->actual_length += drv_data->transfer_len; + tasklet_schedule(&drv_data->pump_transfers); + return 0; +} + +static void adi_spi_pump_transfers(unsigned long data) +{ + struct adi_spi_master *drv_data = (struct adi_spi_master *)data; + struct spi_message *msg = NULL; + struct spi_transfer *t = NULL; + struct adi_spi_device *chip = NULL; + int ret; + + /* Get current state information */ + msg = drv_data->cur_msg; + t = drv_data->cur_transfer; + chip = drv_data->cur_chip; + + /* Handle for abort */ + if (drv_data->state == ERROR_STATE) { + msg->status = -EIO; + adi_spi_giveback(drv_data); + return; + } + + if (drv_data->state == RUNNING_STATE) { + if (t->delay_usecs) + udelay(t->delay_usecs); + if (t->cs_change) + adi_spi_cs_deactive(drv_data, chip); + adi_spi_next_transfer(drv_data); + t = drv_data->cur_transfer; + } + /* Handle end of message */ + if (drv_data->state == DONE_STATE) { + msg->status = 0; + adi_spi_giveback(drv_data); + return; + } + + if ((t->len == 0) || (t->tx_buf == NULL && t->rx_buf == NULL)) { + /* Schedule next transfer tasklet */ + tasklet_schedule(&drv_data->pump_transfers); + return; + } + + ret = adi_spi_setup_transfer(drv_data); + if (ret) { + msg->status = ret; + adi_spi_giveback(drv_data); + } + + iowrite32(0xFFFFFFFF, &drv_data->regs->status); + adi_spi_cs_active(drv_data, chip); + drv_data->state = RUNNING_STATE; + + if (chip->enable_dma) + ret = adi_spi_dma_xfer(drv_data); + else + ret = adi_spi_pio_xfer(drv_data); + if (ret) { + msg->status = ret; + adi_spi_giveback(drv_data); + } +} + +static int adi_spi_transfer_one_message(struct spi_master *master, + struct spi_message *m) +{ + struct adi_spi_master *drv_data = spi_master_get_devdata(master); + + drv_data->cur_msg = m; + drv_data->cur_chip = spi_get_ctldata(drv_data->cur_msg->spi); + adi_spi_restore_state(drv_data); + + drv_data->state = START_STATE; + drv_data->cur_transfer = list_entry(drv_data->cur_msg->transfers.next, + struct spi_transfer, transfer_list); + + tasklet_schedule(&drv_data->pump_transfers); + return 0; +} + +#define MAX_SPI_SSEL 7 + +static const u16 ssel[][MAX_SPI_SSEL] = { + {P_SPI0_SSEL1, P_SPI0_SSEL2, P_SPI0_SSEL3, + P_SPI0_SSEL4, P_SPI0_SSEL5, + P_SPI0_SSEL6, P_SPI0_SSEL7}, + + {P_SPI1_SSEL1, P_SPI1_SSEL2, P_SPI1_SSEL3, + P_SPI1_SSEL4, P_SPI1_SSEL5, + P_SPI1_SSEL6, P_SPI1_SSEL7}, + + {P_SPI2_SSEL1, P_SPI2_SSEL2, P_SPI2_SSEL3, + P_SPI2_SSEL4, P_SPI2_SSEL5, + P_SPI2_SSEL6, P_SPI2_SSEL7}, +}; + +static int adi_spi_setup(struct spi_device *spi) +{ + struct adi_spi_master *drv_data = spi_master_get_devdata(spi->master); + struct adi_spi_device *chip = spi_get_ctldata(spi); + u32 ctl_reg = SPI_CTL_ODM | SPI_CTL_PSSE; + int ret = -EINVAL; + + if (!chip) { + struct adi_spi3_chip *chip_info = spi->controller_data; + + chip = kzalloc(sizeof(*chip), GFP_KERNEL); + if (!chip) { + dev_err(&spi->dev, "can not allocate chip data\n"); + return -ENOMEM; + } + if (chip_info) { + if (chip_info->control & ~ctl_reg) { + dev_err(&spi->dev, + "do not set bits that the SPI framework manages\n"); + goto error; + } + chip->control = chip_info->control; + chip->cs_chg_udelay = chip_info->cs_chg_udelay; + chip->tx_dummy_val = chip_info->tx_dummy_val; + chip->enable_dma = chip_info->enable_dma; + } + chip->cs = spi->chip_select; + + if (chip->cs < MAX_CTRL_CS) { + chip->ssel = (1 << chip->cs) << 8; + ret = peripheral_request(ssel[spi->master->bus_num] + [chip->cs-1], dev_name(&spi->dev)); + if (ret) { + dev_err(&spi->dev, "peripheral_request() error\n"); + goto error; + } + } else { + chip->cs_gpio = chip->cs - MAX_CTRL_CS; + ret = gpio_request_one(chip->cs_gpio, GPIOF_OUT_INIT_HIGH, + dev_name(&spi->dev)); + if (ret) { + dev_err(&spi->dev, "gpio_request_one() error\n"); + goto error; + } + } + spi_set_ctldata(spi, chip); + } + + /* force a default base state */ + chip->control &= ctl_reg; + + if (spi->mode & SPI_CPOL) + chip->control |= SPI_CTL_CPOL; + if (spi->mode & SPI_CPHA) + chip->control |= SPI_CTL_CPHA; + if (spi->mode & SPI_LSB_FIRST) + chip->control |= SPI_CTL_LSBF; + chip->control |= SPI_CTL_MSTR; + /* we choose software to controll cs */ + chip->control &= ~SPI_CTL_ASSEL; + + chip->clock = hz_to_spi_clock(drv_data->sclk, spi->max_speed_hz); + + adi_spi_cs_enable(drv_data, chip); + adi_spi_cs_deactive(drv_data, chip); + + return 0; +error: + if (chip) { + kfree(chip); + spi_set_ctldata(spi, NULL); + } + + return ret; +} + +static void adi_spi_cleanup(struct spi_device *spi) +{ + struct adi_spi_device *chip = spi_get_ctldata(spi); + struct adi_spi_master *drv_data = spi_master_get_devdata(spi->master); + + if (!chip) + return; + + if (chip->cs < MAX_CTRL_CS) { + peripheral_free(ssel[spi->master->bus_num] + [chip->cs-1]); + adi_spi_cs_disable(drv_data, chip); + } else { + gpio_free(chip->cs_gpio); + } + + kfree(chip); + spi_set_ctldata(spi, NULL); +} + +static irqreturn_t adi_spi_tx_dma_isr(int irq, void *dev_id) +{ + struct adi_spi_master *drv_data = dev_id; + u32 dma_stat = get_dma_curr_irqstat(drv_data->tx_dma); + u32 tx_ctl; + + clear_dma_irqstat(drv_data->tx_dma); + if (dma_stat & DMA_DONE) { + drv_data->tx_num++; + } else { + dev_err(&drv_data->master->dev, + "spi tx dma error: %d\n", dma_stat); + if (drv_data->tx) + drv_data->state = ERROR_STATE; + } + tx_ctl = ioread32(&drv_data->regs->tx_control); + tx_ctl &= ~SPI_TXCTL_TDR_NF; + iowrite32(tx_ctl, &drv_data->regs->tx_control); + return IRQ_HANDLED; +} + +static irqreturn_t adi_spi_rx_dma_isr(int irq, void *dev_id) +{ + struct adi_spi_master *drv_data = dev_id; + struct spi_message *msg = drv_data->cur_msg; + u32 dma_stat = get_dma_curr_irqstat(drv_data->rx_dma); + + clear_dma_irqstat(drv_data->rx_dma); + if (dma_stat & DMA_DONE) { + drv_data->rx_num++; + /* we may fail on tx dma */ + if (drv_data->state != ERROR_STATE) + msg->actual_length += drv_data->transfer_len; + } else { + drv_data->state = ERROR_STATE; + dev_err(&drv_data->master->dev, + "spi rx dma error: %d\n", dma_stat); + } + iowrite32(0, &drv_data->regs->tx_control); + iowrite32(0, &drv_data->regs->rx_control); + if (drv_data->rx_num != drv_data->tx_num) + dev_dbg(&drv_data->master->dev, + "dma interrupt missing: tx=%d,rx=%d\n", + drv_data->tx_num, drv_data->rx_num); + tasklet_schedule(&drv_data->pump_transfers); + return IRQ_HANDLED; +} + +static int adi_spi_probe(struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + struct adi_spi3_master *info = dev_get_platdata(dev); + struct spi_master *master; + struct adi_spi_master *drv_data; + struct resource *mem, *res; + unsigned int tx_dma, rx_dma; + unsigned long sclk; + int ret; + + if (!info) { + dev_err(dev, "platform data missing!\n"); + return -ENODEV; + } + + sclk = get_sclk1(); + if (!sclk) { + dev_err(dev, "can not get sclk1\n"); + return -ENXIO; + } + + res = platform_get_resource(pdev, IORESOURCE_DMA, 0); + if (!res) { + dev_err(dev, "can not get tx dma resource\n"); + return -ENXIO; + } + tx_dma = res->start; + + res = platform_get_resource(pdev, IORESOURCE_DMA, 1); + if (!res) { + dev_err(dev, "can not get rx dma resource\n"); + return -ENXIO; + } + rx_dma = res->start; + + /* allocate master with space for drv_data */ + master = spi_alloc_master(dev, sizeof(*drv_data)); + if (!master) { + dev_err(dev, "can not alloc spi_master\n"); + return -ENOMEM; + } + platform_set_drvdata(pdev, master); + + /* the mode bits supported by this driver */ + master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_LSB_FIRST; + + master->bus_num = pdev->id; + master->num_chipselect = info->num_chipselect; + master->cleanup = adi_spi_cleanup; + master->setup = adi_spi_setup; + master->transfer_one_message = adi_spi_transfer_one_message; + master->bits_per_word_mask = SPI_BPW_MASK(32) | SPI_BPW_MASK(16) | + SPI_BPW_MASK(8); + + drv_data = spi_master_get_devdata(master); + drv_data->master = master; + drv_data->tx_dma = tx_dma; + drv_data->rx_dma = rx_dma; + drv_data->pin_req = info->pin_req; + drv_data->sclk = sclk; + + mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); + drv_data->regs = devm_ioremap_resource(dev, mem); + if (IS_ERR(drv_data->regs)) { + ret = PTR_ERR(drv_data->regs); + goto err_put_master; + } + + /* request tx and rx dma */ + ret = request_dma(tx_dma, "SPI_TX_DMA"); + if (ret) { + dev_err(dev, "can not request SPI TX DMA channel\n"); + goto err_put_master; + } + set_dma_callback(tx_dma, adi_spi_tx_dma_isr, drv_data); + + ret = request_dma(rx_dma, "SPI_RX_DMA"); + if (ret) { + dev_err(dev, "can not request SPI RX DMA channel\n"); + goto err_free_tx_dma; + } + set_dma_callback(drv_data->rx_dma, adi_spi_rx_dma_isr, drv_data); + + /* request CLK, MOSI and MISO */ + ret = peripheral_request_list(drv_data->pin_req, "adi-spi3"); + if (ret < 0) { + dev_err(dev, "can not request spi pins\n"); + goto err_free_rx_dma; + } + + iowrite32(SPI_CTL_MSTR | SPI_CTL_CPHA, &drv_data->regs->control); + iowrite32(0x0000FE00, &drv_data->regs->ssel); + iowrite32(0x0, &drv_data->regs->delay); + + tasklet_init(&drv_data->pump_transfers, + adi_spi_pump_transfers, (unsigned long)drv_data); + /* register with the SPI framework */ + ret = devm_spi_register_master(dev, master); + if (ret) { + dev_err(dev, "can not register spi master\n"); + goto err_free_peripheral; + } + + return ret; + +err_free_peripheral: + peripheral_free_list(drv_data->pin_req); +err_free_rx_dma: + free_dma(rx_dma); +err_free_tx_dma: + free_dma(tx_dma); +err_put_master: + spi_master_put(master); + + return ret; +} + +static int adi_spi_remove(struct platform_device *pdev) +{ + struct spi_master *master = platform_get_drvdata(pdev); + struct adi_spi_master *drv_data = spi_master_get_devdata(master); + + adi_spi_disable(drv_data); + peripheral_free_list(drv_data->pin_req); + free_dma(drv_data->rx_dma); + free_dma(drv_data->tx_dma); + return 0; +} + +#ifdef CONFIG_PM +static int adi_spi_suspend(struct device *dev) +{ + struct spi_master *master = dev_get_drvdata(dev); + struct adi_spi_master *drv_data = spi_master_get_devdata(master); + + spi_master_suspend(master); + + drv_data->control = ioread32(&drv_data->regs->control); + drv_data->ssel = ioread32(&drv_data->regs->ssel); + + iowrite32(SPI_CTL_MSTR | SPI_CTL_CPHA, &drv_data->regs->control); + iowrite32(0x0000FE00, &drv_data->regs->ssel); + dma_disable_irq(drv_data->rx_dma); + dma_disable_irq(drv_data->tx_dma); + + return 0; +} + +static int adi_spi_resume(struct device *dev) +{ + struct spi_master *master = dev_get_drvdata(dev); + struct adi_spi_master *drv_data = spi_master_get_devdata(master); + int ret = 0; + + /* bootrom may modify spi and dma status when resume in spi boot mode */ + disable_dma(drv_data->rx_dma); + + dma_enable_irq(drv_data->rx_dma); + dma_enable_irq(drv_data->tx_dma); + iowrite32(drv_data->control, &drv_data->regs->control); + iowrite32(drv_data->ssel, &drv_data->regs->ssel); + + ret = spi_master_resume(master); + if (ret) { + free_dma(drv_data->rx_dma); + free_dma(drv_data->tx_dma); + } + + return ret; +} +#endif +static const struct dev_pm_ops adi_spi_pm_ops = { + SET_SYSTEM_SLEEP_PM_OPS(adi_spi_suspend, adi_spi_resume) +}; + +MODULE_ALIAS("platform:adi-spi3"); +static struct platform_driver adi_spi_driver = { + .driver = { + .name = "adi-spi3", + .owner = THIS_MODULE, + .pm = &adi_spi_pm_ops, + }, + .remove = adi_spi_remove, +}; + +module_platform_driver_probe(adi_spi_driver, adi_spi_probe); + +MODULE_DESCRIPTION("Analog Devices SPI3 controller driver"); +MODULE_AUTHOR("Scott Jiang "); +MODULE_LICENSE("GPL v2"); diff --git a/drivers/spi/spi-bfin-v3.c b/drivers/spi/spi-bfin-v3.c deleted file mode 100644 index 4089d0e0d84e..000000000000 --- a/drivers/spi/spi-bfin-v3.c +++ /dev/null @@ -1,965 +0,0 @@ -/* - * Analog Devices SPI3 controller driver - * - * Copyright (c) 2013 Analog Devices Inc. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -enum bfin_spi_state { - START_STATE, - RUNNING_STATE, - DONE_STATE, - ERROR_STATE -}; - -struct bfin_spi_master; - -struct bfin_spi_transfer_ops { - void (*write) (struct bfin_spi_master *); - void (*read) (struct bfin_spi_master *); - void (*duplex) (struct bfin_spi_master *); -}; - -/* runtime info for spi master */ -struct bfin_spi_master { - /* SPI framework hookup */ - struct spi_master *master; - - /* Regs base of SPI controller */ - struct bfin_spi_regs __iomem *regs; - - /* Pin request list */ - u16 *pin_req; - - /* Message Transfer pump */ - struct tasklet_struct pump_transfers; - - /* Current message transfer state info */ - struct spi_message *cur_msg; - struct spi_transfer *cur_transfer; - struct bfin_spi_device *cur_chip; - unsigned transfer_len; - - /* transfer buffer */ - void *tx; - void *tx_end; - void *rx; - void *rx_end; - - /* dma info */ - unsigned int tx_dma; - unsigned int rx_dma; - dma_addr_t tx_dma_addr; - dma_addr_t rx_dma_addr; - unsigned long dummy_buffer; /* used in unidirectional transfer */ - unsigned long tx_dma_size; - unsigned long rx_dma_size; - int tx_num; - int rx_num; - - /* store register value for suspend/resume */ - u32 control; - u32 ssel; - - unsigned long sclk; - enum bfin_spi_state state; - - const struct bfin_spi_transfer_ops *ops; -}; - -struct bfin_spi_device { - u32 control; - u32 clock; - u32 ssel; - - u8 cs; - u16 cs_chg_udelay; /* Some devices require > 255usec delay */ - u32 cs_gpio; - u32 tx_dummy_val; /* tx value for rx only transfer */ - bool enable_dma; - const struct bfin_spi_transfer_ops *ops; -}; - -static void bfin_spi_enable(struct bfin_spi_master *drv_data) -{ - bfin_write_or(&drv_data->regs->control, SPI_CTL_EN); -} - -static void bfin_spi_disable(struct bfin_spi_master *drv_data) -{ - bfin_write_and(&drv_data->regs->control, ~SPI_CTL_EN); -} - -/* Caculate the SPI_CLOCK register value based on input HZ */ -static u32 hz_to_spi_clock(u32 sclk, u32 speed_hz) -{ - u32 spi_clock = sclk / speed_hz; - - if (spi_clock) - spi_clock--; - return spi_clock; -} - -static int bfin_spi_flush(struct bfin_spi_master *drv_data) -{ - unsigned long limit = loops_per_jiffy << 1; - - /* wait for stop and clear stat */ - while (!(bfin_read(&drv_data->regs->status) & SPI_STAT_SPIF) && --limit) - cpu_relax(); - - bfin_write(&drv_data->regs->status, 0xFFFFFFFF); - - return limit; -} - -/* Chip select operation functions for cs_change flag */ -static void bfin_spi_cs_active(struct bfin_spi_master *drv_data, struct bfin_spi_device *chip) -{ - if (likely(chip->cs < MAX_CTRL_CS)) - bfin_write_and(&drv_data->regs->ssel, ~chip->ssel); - else - gpio_set_value(chip->cs_gpio, 0); -} - -static void bfin_spi_cs_deactive(struct bfin_spi_master *drv_data, - struct bfin_spi_device *chip) -{ - if (likely(chip->cs < MAX_CTRL_CS)) - bfin_write_or(&drv_data->regs->ssel, chip->ssel); - else - gpio_set_value(chip->cs_gpio, 1); - - /* Move delay here for consistency */ - if (chip->cs_chg_udelay) - udelay(chip->cs_chg_udelay); -} - -/* enable or disable the pin muxed by GPIO and SPI CS to work as SPI CS */ -static inline void bfin_spi_cs_enable(struct bfin_spi_master *drv_data, - struct bfin_spi_device *chip) -{ - if (chip->cs < MAX_CTRL_CS) - bfin_write_or(&drv_data->regs->ssel, chip->ssel >> 8); -} - -static inline void bfin_spi_cs_disable(struct bfin_spi_master *drv_data, - struct bfin_spi_device *chip) -{ - if (chip->cs < MAX_CTRL_CS) - bfin_write_and(&drv_data->regs->ssel, ~(chip->ssel >> 8)); -} - -/* stop controller and re-config current chip*/ -static void bfin_spi_restore_state(struct bfin_spi_master *drv_data) -{ - struct bfin_spi_device *chip = drv_data->cur_chip; - - /* Clear status and disable clock */ - bfin_write(&drv_data->regs->status, 0xFFFFFFFF); - bfin_write(&drv_data->regs->rx_control, 0x0); - bfin_write(&drv_data->regs->tx_control, 0x0); - bfin_spi_disable(drv_data); - - SSYNC(); - - /* Load the registers */ - bfin_write(&drv_data->regs->control, chip->control); - bfin_write(&drv_data->regs->clock, chip->clock); - - bfin_spi_enable(drv_data); - drv_data->tx_num = drv_data->rx_num = 0; - /* we always choose tx transfer initiate */ - bfin_write(&drv_data->regs->rx_control, SPI_RXCTL_REN); - bfin_write(&drv_data->regs->tx_control, - SPI_TXCTL_TEN | SPI_TXCTL_TTI); - bfin_spi_cs_active(drv_data, chip); -} - -/* discard invalid rx data and empty rfifo */ -static inline void dummy_read(struct bfin_spi_master *drv_data) -{ - while (!(bfin_read(&drv_data->regs->status) & SPI_STAT_RFE)) - bfin_read(&drv_data->regs->rfifo); -} - -static void bfin_spi_u8_write(struct bfin_spi_master *drv_data) -{ - dummy_read(drv_data); - while (drv_data->tx < drv_data->tx_end) { - bfin_write(&drv_data->regs->tfifo, (*(u8 *)(drv_data->tx++))); - while (bfin_read(&drv_data->regs->status) & SPI_STAT_RFE) - cpu_relax(); - bfin_read(&drv_data->regs->rfifo); - } -} - -static void bfin_spi_u8_read(struct bfin_spi_master *drv_data) -{ - u32 tx_val = drv_data->cur_chip->tx_dummy_val; - - dummy_read(drv_data); - while (drv_data->rx < drv_data->rx_end) { - bfin_write(&drv_data->regs->tfifo, tx_val); - while (bfin_read(&drv_data->regs->status) & SPI_STAT_RFE) - cpu_relax(); - *(u8 *)(drv_data->rx++) = bfin_read(&drv_data->regs->rfifo); - } -} - -static void bfin_spi_u8_duplex(struct bfin_spi_master *drv_data) -{ - dummy_read(drv_data); - while (drv_data->rx < drv_data->rx_end) { - bfin_write(&drv_data->regs->tfifo, (*(u8 *)(drv_data->tx++))); - while (bfin_read(&drv_data->regs->status) & SPI_STAT_RFE) - cpu_relax(); - *(u8 *)(drv_data->rx++) = bfin_read(&drv_data->regs->rfifo); - } -} - -static const struct bfin_spi_transfer_ops bfin_bfin_spi_transfer_ops_u8 = { - .write = bfin_spi_u8_write, - .read = bfin_spi_u8_read, - .duplex = bfin_spi_u8_duplex, -}; - -static void bfin_spi_u16_write(struct bfin_spi_master *drv_data) -{ - dummy_read(drv_data); - while (drv_data->tx < drv_data->tx_end) { - bfin_write(&drv_data->regs->tfifo, (*(u16 *)drv_data->tx)); - drv_data->tx += 2; - while (bfin_read(&drv_data->regs->status) & SPI_STAT_RFE) - cpu_relax(); - bfin_read(&drv_data->regs->rfifo); - } -} - -static void bfin_spi_u16_read(struct bfin_spi_master *drv_data) -{ - u32 tx_val = drv_data->cur_chip->tx_dummy_val; - - dummy_read(drv_data); - while (drv_data->rx < drv_data->rx_end) { - bfin_write(&drv_data->regs->tfifo, tx_val); - while (bfin_read(&drv_data->regs->status) & SPI_STAT_RFE) - cpu_relax(); - *(u16 *)drv_data->rx = bfin_read(&drv_data->regs->rfifo); - drv_data->rx += 2; - } -} - -static void bfin_spi_u16_duplex(struct bfin_spi_master *drv_data) -{ - dummy_read(drv_data); - while (drv_data->rx < drv_data->rx_end) { - bfin_write(&drv_data->regs->tfifo, (*(u16 *)drv_data->tx)); - drv_data->tx += 2; - while (bfin_read(&drv_data->regs->status) & SPI_STAT_RFE) - cpu_relax(); - *(u16 *)drv_data->rx = bfin_read(&drv_data->regs->rfifo); - drv_data->rx += 2; - } -} - -static const struct bfin_spi_transfer_ops bfin_bfin_spi_transfer_ops_u16 = { - .write = bfin_spi_u16_write, - .read = bfin_spi_u16_read, - .duplex = bfin_spi_u16_duplex, -}; - -static void bfin_spi_u32_write(struct bfin_spi_master *drv_data) -{ - dummy_read(drv_data); - while (drv_data->tx < drv_data->tx_end) { - bfin_write(&drv_data->regs->tfifo, (*(u32 *)drv_data->tx)); - drv_data->tx += 4; - while (bfin_read(&drv_data->regs->status) & SPI_STAT_RFE) - cpu_relax(); - bfin_read(&drv_data->regs->rfifo); - } -} - -static void bfin_spi_u32_read(struct bfin_spi_master *drv_data) -{ - u32 tx_val = drv_data->cur_chip->tx_dummy_val; - - dummy_read(drv_data); - while (drv_data->rx < drv_data->rx_end) { - bfin_write(&drv_data->regs->tfifo, tx_val); - while (bfin_read(&drv_data->regs->status) & SPI_STAT_RFE) - cpu_relax(); - *(u32 *)drv_data->rx = bfin_read(&drv_data->regs->rfifo); - drv_data->rx += 4; - } -} - -static void bfin_spi_u32_duplex(struct bfin_spi_master *drv_data) -{ - dummy_read(drv_data); - while (drv_data->rx < drv_data->rx_end) { - bfin_write(&drv_data->regs->tfifo, (*(u32 *)drv_data->tx)); - drv_data->tx += 4; - while (bfin_read(&drv_data->regs->status) & SPI_STAT_RFE) - cpu_relax(); - *(u32 *)drv_data->rx = bfin_read(&drv_data->regs->rfifo); - drv_data->rx += 4; - } -} - -static const struct bfin_spi_transfer_ops bfin_bfin_spi_transfer_ops_u32 = { - .write = bfin_spi_u32_write, - .read = bfin_spi_u32_read, - .duplex = bfin_spi_u32_duplex, -}; - - -/* test if there is more transfer to be done */ -static void bfin_spi_next_transfer(struct bfin_spi_master *drv) -{ - struct spi_message *msg = drv->cur_msg; - struct spi_transfer *t = drv->cur_transfer; - - /* Move to next transfer */ - if (t->transfer_list.next != &msg->transfers) { - drv->cur_transfer = list_entry(t->transfer_list.next, - struct spi_transfer, transfer_list); - drv->state = RUNNING_STATE; - } else { - drv->state = DONE_STATE; - drv->cur_transfer = NULL; - } -} - -static void bfin_spi_giveback(struct bfin_spi_master *drv_data) -{ - struct bfin_spi_device *chip = drv_data->cur_chip; - - bfin_spi_cs_deactive(drv_data, chip); - spi_finalize_current_message(drv_data->master); -} - -static int bfin_spi_setup_transfer(struct bfin_spi_master *drv) -{ - struct spi_transfer *t = drv->cur_transfer; - u32 cr, cr_width; - - if (t->tx_buf) { - drv->tx = (void *)t->tx_buf; - drv->tx_end = drv->tx + t->len; - } else { - drv->tx = NULL; - } - - if (t->rx_buf) { - drv->rx = t->rx_buf; - drv->rx_end = drv->rx + t->len; - } else { - drv->rx = NULL; - } - - drv->transfer_len = t->len; - - /* bits per word setup */ - switch (t->bits_per_word) { - case 8: - cr_width = SPI_CTL_SIZE08; - drv->ops = &bfin_bfin_spi_transfer_ops_u8; - break; - case 16: - cr_width = SPI_CTL_SIZE16; - drv->ops = &bfin_bfin_spi_transfer_ops_u16; - break; - case 32: - cr_width = SPI_CTL_SIZE32; - drv->ops = &bfin_bfin_spi_transfer_ops_u32; - break; - default: - return -EINVAL; - } - cr = bfin_read(&drv->regs->control) & ~SPI_CTL_SIZE; - cr |= cr_width; - bfin_write(&drv->regs->control, cr); - - /* speed setup */ - bfin_write(&drv->regs->clock, - hz_to_spi_clock(drv->sclk, t->speed_hz)); - return 0; -} - -static int bfin_spi_dma_xfer(struct bfin_spi_master *drv_data) -{ - struct spi_transfer *t = drv_data->cur_transfer; - struct spi_message *msg = drv_data->cur_msg; - struct bfin_spi_device *chip = drv_data->cur_chip; - u32 dma_config; - unsigned long word_count, word_size; - void *tx_buf, *rx_buf; - - switch (t->bits_per_word) { - case 8: - dma_config = WDSIZE_8 | PSIZE_8; - word_count = drv_data->transfer_len; - word_size = 1; - break; - case 16: - dma_config = WDSIZE_16 | PSIZE_16; - word_count = drv_data->transfer_len / 2; - word_size = 2; - break; - default: - dma_config = WDSIZE_32 | PSIZE_32; - word_count = drv_data->transfer_len / 4; - word_size = 4; - break; - } - - if (!drv_data->rx) { - tx_buf = drv_data->tx; - rx_buf = &drv_data->dummy_buffer; - drv_data->tx_dma_size = drv_data->transfer_len; - drv_data->rx_dma_size = sizeof(drv_data->dummy_buffer); - set_dma_x_modify(drv_data->tx_dma, word_size); - set_dma_x_modify(drv_data->rx_dma, 0); - } else if (!drv_data->tx) { - drv_data->dummy_buffer = chip->tx_dummy_val; - tx_buf = &drv_data->dummy_buffer; - rx_buf = drv_data->rx; - drv_data->tx_dma_size = sizeof(drv_data->dummy_buffer); - drv_data->rx_dma_size = drv_data->transfer_len; - set_dma_x_modify(drv_data->tx_dma, 0); - set_dma_x_modify(drv_data->rx_dma, word_size); - } else { - tx_buf = drv_data->tx; - rx_buf = drv_data->rx; - drv_data->tx_dma_size = drv_data->rx_dma_size - = drv_data->transfer_len; - set_dma_x_modify(drv_data->tx_dma, word_size); - set_dma_x_modify(drv_data->rx_dma, word_size); - } - - drv_data->tx_dma_addr = dma_map_single(&msg->spi->dev, - (void *)tx_buf, - drv_data->tx_dma_size, - DMA_TO_DEVICE); - if (dma_mapping_error(&msg->spi->dev, - drv_data->tx_dma_addr)) - return -ENOMEM; - - drv_data->rx_dma_addr = dma_map_single(&msg->spi->dev, - (void *)rx_buf, - drv_data->rx_dma_size, - DMA_FROM_DEVICE); - if (dma_mapping_error(&msg->spi->dev, - drv_data->rx_dma_addr)) { - dma_unmap_single(&msg->spi->dev, - drv_data->tx_dma_addr, - drv_data->tx_dma_size, - DMA_TO_DEVICE); - return -ENOMEM; - } - - dummy_read(drv_data); - set_dma_x_count(drv_data->tx_dma, word_count); - set_dma_x_count(drv_data->rx_dma, word_count); - set_dma_start_addr(drv_data->tx_dma, drv_data->tx_dma_addr); - set_dma_start_addr(drv_data->rx_dma, drv_data->rx_dma_addr); - dma_config |= DMAFLOW_STOP | RESTART | DI_EN; - set_dma_config(drv_data->tx_dma, dma_config); - set_dma_config(drv_data->rx_dma, dma_config | WNR); - enable_dma(drv_data->tx_dma); - enable_dma(drv_data->rx_dma); - SSYNC(); - - bfin_write(&drv_data->regs->rx_control, SPI_RXCTL_REN | SPI_RXCTL_RDR_NE); - SSYNC(); - bfin_write(&drv_data->regs->tx_control, - SPI_TXCTL_TEN | SPI_TXCTL_TTI | SPI_TXCTL_TDR_NF); - - return 0; -} - -static int bfin_spi_pio_xfer(struct bfin_spi_master *drv_data) -{ - struct spi_message *msg = drv_data->cur_msg; - - if (!drv_data->rx) { - /* write only half duplex */ - drv_data->ops->write(drv_data); - if (drv_data->tx != drv_data->tx_end) - return -EIO; - } else if (!drv_data->tx) { - /* read only half duplex */ - drv_data->ops->read(drv_data); - if (drv_data->rx != drv_data->rx_end) - return -EIO; - } else { - /* full duplex mode */ - drv_data->ops->duplex(drv_data); - if (drv_data->tx != drv_data->tx_end) - return -EIO; - } - - if (!bfin_spi_flush(drv_data)) - return -EIO; - msg->actual_length += drv_data->transfer_len; - tasklet_schedule(&drv_data->pump_transfers); - return 0; -} - -static void bfin_spi_pump_transfers(unsigned long data) -{ - struct bfin_spi_master *drv_data = (struct bfin_spi_master *)data; - struct spi_message *msg = NULL; - struct spi_transfer *t = NULL; - struct bfin_spi_device *chip = NULL; - int ret; - - /* Get current state information */ - msg = drv_data->cur_msg; - t = drv_data->cur_transfer; - chip = drv_data->cur_chip; - - /* Handle for abort */ - if (drv_data->state == ERROR_STATE) { - msg->status = -EIO; - bfin_spi_giveback(drv_data); - return; - } - - if (drv_data->state == RUNNING_STATE) { - if (t->delay_usecs) - udelay(t->delay_usecs); - if (t->cs_change) - bfin_spi_cs_deactive(drv_data, chip); - bfin_spi_next_transfer(drv_data); - t = drv_data->cur_transfer; - } - /* Handle end of message */ - if (drv_data->state == DONE_STATE) { - msg->status = 0; - bfin_spi_giveback(drv_data); - return; - } - - if ((t->len == 0) || (t->tx_buf == NULL && t->rx_buf == NULL)) { - /* Schedule next transfer tasklet */ - tasklet_schedule(&drv_data->pump_transfers); - return; - } - - ret = bfin_spi_setup_transfer(drv_data); - if (ret) { - msg->status = ret; - bfin_spi_giveback(drv_data); - } - - bfin_write(&drv_data->regs->status, 0xFFFFFFFF); - bfin_spi_cs_active(drv_data, chip); - drv_data->state = RUNNING_STATE; - - if (chip->enable_dma) - ret = bfin_spi_dma_xfer(drv_data); - else - ret = bfin_spi_pio_xfer(drv_data); - if (ret) { - msg->status = ret; - bfin_spi_giveback(drv_data); - } -} - -static int bfin_spi_transfer_one_message(struct spi_master *master, - struct spi_message *m) -{ - struct bfin_spi_master *drv_data = spi_master_get_devdata(master); - - drv_data->cur_msg = m; - drv_data->cur_chip = spi_get_ctldata(drv_data->cur_msg->spi); - bfin_spi_restore_state(drv_data); - - drv_data->state = START_STATE; - drv_data->cur_transfer = list_entry(drv_data->cur_msg->transfers.next, - struct spi_transfer, transfer_list); - - tasklet_schedule(&drv_data->pump_transfers); - return 0; -} - -#define MAX_SPI_SSEL 7 - -static const u16 ssel[][MAX_SPI_SSEL] = { - {P_SPI0_SSEL1, P_SPI0_SSEL2, P_SPI0_SSEL3, - P_SPI0_SSEL4, P_SPI0_SSEL5, - P_SPI0_SSEL6, P_SPI0_SSEL7}, - - {P_SPI1_SSEL1, P_SPI1_SSEL2, P_SPI1_SSEL3, - P_SPI1_SSEL4, P_SPI1_SSEL5, - P_SPI1_SSEL6, P_SPI1_SSEL7}, - - {P_SPI2_SSEL1, P_SPI2_SSEL2, P_SPI2_SSEL3, - P_SPI2_SSEL4, P_SPI2_SSEL5, - P_SPI2_SSEL6, P_SPI2_SSEL7}, -}; - -static int bfin_spi_setup(struct spi_device *spi) -{ - struct bfin_spi_master *drv_data = spi_master_get_devdata(spi->master); - struct bfin_spi_device *chip = spi_get_ctldata(spi); - u32 bfin_ctl_reg = SPI_CTL_ODM | SPI_CTL_PSSE; - int ret = -EINVAL; - - if (!chip) { - struct bfin_spi3_chip *chip_info = spi->controller_data; - - chip = kzalloc(sizeof(*chip), GFP_KERNEL); - if (!chip) { - dev_err(&spi->dev, "can not allocate chip data\n"); - return -ENOMEM; - } - if (chip_info) { - if (chip_info->control & ~bfin_ctl_reg) { - dev_err(&spi->dev, - "do not set bits that the SPI framework manages\n"); - goto error; - } - chip->control = chip_info->control; - chip->cs_chg_udelay = chip_info->cs_chg_udelay; - chip->tx_dummy_val = chip_info->tx_dummy_val; - chip->enable_dma = chip_info->enable_dma; - } - chip->cs = spi->chip_select; - if (chip->cs < MAX_CTRL_CS) { - chip->ssel = (1 << chip->cs) << 8; - ret = peripheral_request(ssel[spi->master->bus_num] - [chip->cs-1], dev_name(&spi->dev)); - if (ret) { - dev_err(&spi->dev, "peripheral_request() error\n"); - goto error; - } - } else { - chip->cs_gpio = chip->cs - MAX_CTRL_CS; - ret = gpio_request_one(chip->cs_gpio, GPIOF_OUT_INIT_HIGH, - dev_name(&spi->dev)); - if (ret) { - dev_err(&spi->dev, "gpio_request_one() error\n"); - goto error; - } - } - spi_set_ctldata(spi, chip); - } - - /* force a default base state */ - chip->control &= bfin_ctl_reg; - - if (spi->mode & SPI_CPOL) - chip->control |= SPI_CTL_CPOL; - if (spi->mode & SPI_CPHA) - chip->control |= SPI_CTL_CPHA; - if (spi->mode & SPI_LSB_FIRST) - chip->control |= SPI_CTL_LSBF; - chip->control |= SPI_CTL_MSTR; - /* we choose software to controll cs */ - chip->control &= ~SPI_CTL_ASSEL; - - chip->clock = hz_to_spi_clock(drv_data->sclk, spi->max_speed_hz); - - bfin_spi_cs_enable(drv_data, chip); - bfin_spi_cs_deactive(drv_data, chip); - - return 0; -error: - if (chip) { - kfree(chip); - spi_set_ctldata(spi, NULL); - } - - return ret; -} - -static void bfin_spi_cleanup(struct spi_device *spi) -{ - struct bfin_spi_device *chip = spi_get_ctldata(spi); - struct bfin_spi_master *drv_data = spi_master_get_devdata(spi->master); - - if (!chip) - return; - - if (chip->cs < MAX_CTRL_CS) { - peripheral_free(ssel[spi->master->bus_num] - [chip->cs-1]); - bfin_spi_cs_disable(drv_data, chip); - } else { - gpio_free(chip->cs_gpio); - } - - kfree(chip); - spi_set_ctldata(spi, NULL); -} - -static irqreturn_t bfin_spi_tx_dma_isr(int irq, void *dev_id) -{ - struct bfin_spi_master *drv_data = dev_id; - u32 dma_stat = get_dma_curr_irqstat(drv_data->tx_dma); - - clear_dma_irqstat(drv_data->tx_dma); - if (dma_stat & DMA_DONE) { - drv_data->tx_num++; - } else { - dev_err(&drv_data->master->dev, - "spi tx dma error: %d\n", dma_stat); - if (drv_data->tx) - drv_data->state = ERROR_STATE; - } - bfin_write_and(&drv_data->regs->tx_control, ~SPI_TXCTL_TDR_NF); - return IRQ_HANDLED; -} - -static irqreturn_t bfin_spi_rx_dma_isr(int irq, void *dev_id) -{ - struct bfin_spi_master *drv_data = dev_id; - struct spi_message *msg = drv_data->cur_msg; - u32 dma_stat = get_dma_curr_irqstat(drv_data->rx_dma); - - clear_dma_irqstat(drv_data->rx_dma); - if (dma_stat & DMA_DONE) { - drv_data->rx_num++; - /* we may fail on tx dma */ - if (drv_data->state != ERROR_STATE) - msg->actual_length += drv_data->transfer_len; - } else { - drv_data->state = ERROR_STATE; - dev_err(&drv_data->master->dev, - "spi rx dma error: %d\n", dma_stat); - } - bfin_write(&drv_data->regs->tx_control, 0); - bfin_write(&drv_data->regs->rx_control, 0); - if (drv_data->rx_num != drv_data->tx_num) - dev_dbg(&drv_data->master->dev, - "dma interrupt missing: tx=%d,rx=%d\n", - drv_data->tx_num, drv_data->rx_num); - tasklet_schedule(&drv_data->pump_transfers); - return IRQ_HANDLED; -} - -static int bfin_spi_probe(struct platform_device *pdev) -{ - struct device *dev = &pdev->dev; - struct bfin_spi3_master *info = dev_get_platdata(dev); - struct spi_master *master; - struct bfin_spi_master *drv_data; - struct resource *mem, *res; - unsigned int tx_dma, rx_dma; - unsigned long sclk; - int ret; - - if (!info) { - dev_err(dev, "platform data missing!\n"); - return -ENODEV; - } - - sclk = get_sclk1(); - if (!sclk) { - dev_err(dev, "can not get sclk1\n"); - return -ENXIO; - } - - res = platform_get_resource(pdev, IORESOURCE_DMA, 0); - if (!res) { - dev_err(dev, "can not get tx dma resource\n"); - return -ENXIO; - } - tx_dma = res->start; - - res = platform_get_resource(pdev, IORESOURCE_DMA, 1); - if (!res) { - dev_err(dev, "can not get rx dma resource\n"); - return -ENXIO; - } - rx_dma = res->start; - - /* allocate master with space for drv_data */ - master = spi_alloc_master(dev, sizeof(*drv_data)); - if (!master) { - dev_err(dev, "can not alloc spi_master\n"); - return -ENOMEM; - } - platform_set_drvdata(pdev, master); - - /* the mode bits supported by this driver */ - master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_LSB_FIRST; - - master->bus_num = pdev->id; - master->num_chipselect = info->num_chipselect; - master->cleanup = bfin_spi_cleanup; - master->setup = bfin_spi_setup; - master->transfer_one_message = bfin_spi_transfer_one_message; - master->bits_per_word_mask = SPI_BPW_MASK(32) | SPI_BPW_MASK(16) | - SPI_BPW_MASK(8); - - drv_data = spi_master_get_devdata(master); - drv_data->master = master; - drv_data->tx_dma = tx_dma; - drv_data->rx_dma = rx_dma; - drv_data->pin_req = info->pin_req; - drv_data->sclk = sclk; - - mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); - drv_data->regs = devm_ioremap_resource(dev, mem); - if (IS_ERR(drv_data->regs)) { - ret = PTR_ERR(drv_data->regs); - goto err_put_master; - } - - /* request tx and rx dma */ - ret = request_dma(tx_dma, "SPI_TX_DMA"); - if (ret) { - dev_err(dev, "can not request SPI TX DMA channel\n"); - goto err_put_master; - } - set_dma_callback(tx_dma, bfin_spi_tx_dma_isr, drv_data); - - ret = request_dma(rx_dma, "SPI_RX_DMA"); - if (ret) { - dev_err(dev, "can not request SPI RX DMA channel\n"); - goto err_free_tx_dma; - } - set_dma_callback(drv_data->rx_dma, bfin_spi_rx_dma_isr, drv_data); - - /* request CLK, MOSI and MISO */ - ret = peripheral_request_list(drv_data->pin_req, "bfin-spi3"); - if (ret < 0) { - dev_err(dev, "can not request spi pins\n"); - goto err_free_rx_dma; - } - - bfin_write(&drv_data->regs->control, SPI_CTL_MSTR | SPI_CTL_CPHA); - bfin_write(&drv_data->regs->ssel, 0x0000FE00); - bfin_write(&drv_data->regs->delay, 0x0); - - tasklet_init(&drv_data->pump_transfers, - bfin_spi_pump_transfers, (unsigned long)drv_data); - /* register with the SPI framework */ - ret = devm_spi_register_master(dev, master); - if (ret) { - dev_err(dev, "can not register spi master\n"); - goto err_free_peripheral; - } - - return ret; - -err_free_peripheral: - peripheral_free_list(drv_data->pin_req); -err_free_rx_dma: - free_dma(rx_dma); -err_free_tx_dma: - free_dma(tx_dma); -err_put_master: - spi_master_put(master); - - return ret; -} - -static int bfin_spi_remove(struct platform_device *pdev) -{ - struct spi_master *master = platform_get_drvdata(pdev); - struct bfin_spi_master *drv_data = spi_master_get_devdata(master); - - bfin_spi_disable(drv_data); - - peripheral_free_list(drv_data->pin_req); - free_dma(drv_data->rx_dma); - free_dma(drv_data->tx_dma); - - return 0; -} - -#ifdef CONFIG_PM -static int bfin_spi_suspend(struct device *dev) -{ - struct spi_master *master = dev_get_drvdata(dev); - struct bfin_spi_master *drv_data = spi_master_get_devdata(master); - - spi_master_suspend(master); - - drv_data->control = bfin_read(&drv_data->regs->control); - drv_data->ssel = bfin_read(&drv_data->regs->ssel); - - bfin_write(&drv_data->regs->control, SPI_CTL_MSTR | SPI_CTL_CPHA); - bfin_write(&drv_data->regs->ssel, 0x0000FE00); - dma_disable_irq(drv_data->rx_dma); - dma_disable_irq(drv_data->tx_dma); - - return 0; -} - -static int bfin_spi_resume(struct device *dev) -{ - struct spi_master *master = dev_get_drvdata(dev); - struct bfin_spi_master *drv_data = spi_master_get_devdata(master); - int ret = 0; - - /* bootrom may modify spi and dma status when resume in spi boot mode */ - disable_dma(drv_data->rx_dma); - - dma_enable_irq(drv_data->rx_dma); - dma_enable_irq(drv_data->tx_dma); - bfin_write(&drv_data->regs->control, drv_data->control); - bfin_write(&drv_data->regs->ssel, drv_data->ssel); - - ret = spi_master_resume(master); - if (ret) { - free_dma(drv_data->rx_dma); - free_dma(drv_data->tx_dma); - } - - return ret; -} -#endif -static const struct dev_pm_ops bfin_spi_pm_ops = { - SET_SYSTEM_SLEEP_PM_OPS(bfin_spi_suspend, bfin_spi_resume) -}; - -MODULE_ALIAS("platform:bfin-spi3"); -static struct platform_driver bfin_spi_driver = { - .driver = { - .name = "bfin-spi3", - .owner = THIS_MODULE, - .pm = &bfin_spi_pm_ops, - }, - .remove = bfin_spi_remove, -}; - -module_platform_driver_probe(bfin_spi_driver, bfin_spi_probe); - -MODULE_DESCRIPTION("Analog Devices SPI3 controller driver"); -MODULE_AUTHOR("Scott Jiang "); -MODULE_LICENSE("GPL v2"); diff --git a/include/linux/spi/adi_spi3.h b/include/linux/spi/adi_spi3.h new file mode 100644 index 000000000000..c84123aa1d06 --- /dev/null +++ b/include/linux/spi/adi_spi3.h @@ -0,0 +1,254 @@ +/* + * Analog Devices SPI3 controller driver + * + * Copyright (c) 2014 Analog Devices Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#ifndef _ADI_SPI3_H_ +#define _ADI_SPI3_H_ + +#include + +/* SPI_CONTROL */ +#define SPI_CTL_EN 0x00000001 /* Enable */ +#define SPI_CTL_MSTR 0x00000002 /* Master/Slave */ +#define SPI_CTL_PSSE 0x00000004 /* controls modf error in master mode */ +#define SPI_CTL_ODM 0x00000008 /* Open Drain Mode */ +#define SPI_CTL_CPHA 0x00000010 /* Clock Phase */ +#define SPI_CTL_CPOL 0x00000020 /* Clock Polarity */ +#define SPI_CTL_ASSEL 0x00000040 /* Slave Select Pin Control */ +#define SPI_CTL_SELST 0x00000080 /* Slave Select Polarity in-between transfers */ +#define SPI_CTL_EMISO 0x00000100 /* Enable MISO */ +#define SPI_CTL_SIZE 0x00000600 /* Word Transfer Size */ +#define SPI_CTL_SIZE08 0x00000000 /* SIZE: 8 bits */ +#define SPI_CTL_SIZE16 0x00000200 /* SIZE: 16 bits */ +#define SPI_CTL_SIZE32 0x00000400 /* SIZE: 32 bits */ +#define SPI_CTL_LSBF 0x00001000 /* LSB First */ +#define SPI_CTL_FCEN 0x00002000 /* Flow-Control Enable */ +#define SPI_CTL_FCCH 0x00004000 /* Flow-Control Channel Selection */ +#define SPI_CTL_FCPL 0x00008000 /* Flow-Control Polarity */ +#define SPI_CTL_FCWM 0x00030000 /* Flow-Control Water-Mark */ +#define SPI_CTL_FIFO0 0x00000000 /* FCWM: TFIFO empty or RFIFO Full */ +#define SPI_CTL_FIFO1 0x00010000 /* FCWM: TFIFO 75% or more empty or RFIFO 75% or more full */ +#define SPI_CTL_FIFO2 0x00020000 /* FCWM: TFIFO 50% or more empty or RFIFO 50% or more full */ +#define SPI_CTL_FMODE 0x00040000 /* Fast-mode Enable */ +#define SPI_CTL_MIOM 0x00300000 /* Multiple I/O Mode */ +#define SPI_CTL_MIO_DIS 0x00000000 /* MIOM: Disable */ +#define SPI_CTL_MIO_DUAL 0x00100000 /* MIOM: Enable DIOM (Dual I/O Mode) */ +#define SPI_CTL_MIO_QUAD 0x00200000 /* MIOM: Enable QUAD (Quad SPI Mode) */ +#define SPI_CTL_SOSI 0x00400000 /* Start on MOSI */ +/* SPI_RX_CONTROL */ +#define SPI_RXCTL_REN 0x00000001 /* Receive Channel Enable */ +#define SPI_RXCTL_RTI 0x00000004 /* Receive Transfer Initiate */ +#define SPI_RXCTL_RWCEN 0x00000008 /* Receive Word Counter Enable */ +#define SPI_RXCTL_RDR 0x00000070 /* Receive Data Request */ +#define SPI_RXCTL_RDR_DIS 0x00000000 /* RDR: Disabled */ +#define SPI_RXCTL_RDR_NE 0x00000010 /* RDR: RFIFO not empty */ +#define SPI_RXCTL_RDR_25 0x00000020 /* RDR: RFIFO 25% full */ +#define SPI_RXCTL_RDR_50 0x00000030 /* RDR: RFIFO 50% full */ +#define SPI_RXCTL_RDR_75 0x00000040 /* RDR: RFIFO 75% full */ +#define SPI_RXCTL_RDR_FULL 0x00000050 /* RDR: RFIFO full */ +#define SPI_RXCTL_RDO 0x00000100 /* Receive Data Over-Run */ +#define SPI_RXCTL_RRWM 0x00003000 /* FIFO Regular Water-Mark */ +#define SPI_RXCTL_RWM_0 0x00000000 /* RRWM: RFIFO Empty */ +#define SPI_RXCTL_RWM_25 0x00001000 /* RRWM: RFIFO 25% full */ +#define SPI_RXCTL_RWM_50 0x00002000 /* RRWM: RFIFO 50% full */ +#define SPI_RXCTL_RWM_75 0x00003000 /* RRWM: RFIFO 75% full */ +#define SPI_RXCTL_RUWM 0x00070000 /* FIFO Urgent Water-Mark */ +#define SPI_RXCTL_UWM_DIS 0x00000000 /* RUWM: Disabled */ +#define SPI_RXCTL_UWM_25 0x00010000 /* RUWM: RFIFO 25% full */ +#define SPI_RXCTL_UWM_50 0x00020000 /* RUWM: RFIFO 50% full */ +#define SPI_RXCTL_UWM_75 0x00030000 /* RUWM: RFIFO 75% full */ +#define SPI_RXCTL_UWM_FULL 0x00040000 /* RUWM: RFIFO full */ +/* SPI_TX_CONTROL */ +#define SPI_TXCTL_TEN 0x00000001 /* Transmit Channel Enable */ +#define SPI_TXCTL_TTI 0x00000004 /* Transmit Transfer Initiate */ +#define SPI_TXCTL_TWCEN 0x00000008 /* Transmit Word Counter Enable */ +#define SPI_TXCTL_TDR 0x00000070 /* Transmit Data Request */ +#define SPI_TXCTL_TDR_DIS 0x00000000 /* TDR: Disabled */ +#define SPI_TXCTL_TDR_NF 0x00000010 /* TDR: TFIFO not full */ +#define SPI_TXCTL_TDR_25 0x00000020 /* TDR: TFIFO 25% empty */ +#define SPI_TXCTL_TDR_50 0x00000030 /* TDR: TFIFO 50% empty */ +#define SPI_TXCTL_TDR_75 0x00000040 /* TDR: TFIFO 75% empty */ +#define SPI_TXCTL_TDR_EMPTY 0x00000050 /* TDR: TFIFO empty */ +#define SPI_TXCTL_TDU 0x00000100 /* Transmit Data Under-Run */ +#define SPI_TXCTL_TRWM 0x00003000 /* FIFO Regular Water-Mark */ +#define SPI_TXCTL_RWM_FULL 0x00000000 /* TRWM: TFIFO full */ +#define SPI_TXCTL_RWM_25 0x00001000 /* TRWM: TFIFO 25% empty */ +#define SPI_TXCTL_RWM_50 0x00002000 /* TRWM: TFIFO 50% empty */ +#define SPI_TXCTL_RWM_75 0x00003000 /* TRWM: TFIFO 75% empty */ +#define SPI_TXCTL_TUWM 0x00070000 /* FIFO Urgent Water-Mark */ +#define SPI_TXCTL_UWM_DIS 0x00000000 /* TUWM: Disabled */ +#define SPI_TXCTL_UWM_25 0x00010000 /* TUWM: TFIFO 25% empty */ +#define SPI_TXCTL_UWM_50 0x00020000 /* TUWM: TFIFO 50% empty */ +#define SPI_TXCTL_UWM_75 0x00030000 /* TUWM: TFIFO 75% empty */ +#define SPI_TXCTL_UWM_EMPTY 0x00040000 /* TUWM: TFIFO empty */ +/* SPI_CLOCK */ +#define SPI_CLK_BAUD 0x0000FFFF /* Baud Rate */ +/* SPI_DELAY */ +#define SPI_DLY_STOP 0x000000FF /* Transfer delay time in multiples of SCK period */ +#define SPI_DLY_LEADX 0x00000100 /* Extended (1 SCK) LEAD Control */ +#define SPI_DLY_LAGX 0x00000200 /* Extended (1 SCK) LAG control */ +/* SPI_SSEL */ +#define SPI_SLVSEL_SSE1 0x00000002 /* SPISSEL1 Enable */ +#define SPI_SLVSEL_SSE2 0x00000004 /* SPISSEL2 Enable */ +#define SPI_SLVSEL_SSE3 0x00000008 /* SPISSEL3 Enable */ +#define SPI_SLVSEL_SSE4 0x00000010 /* SPISSEL4 Enable */ +#define SPI_SLVSEL_SSE5 0x00000020 /* SPISSEL5 Enable */ +#define SPI_SLVSEL_SSE6 0x00000040 /* SPISSEL6 Enable */ +#define SPI_SLVSEL_SSE7 0x00000080 /* SPISSEL7 Enable */ +#define SPI_SLVSEL_SSEL1 0x00000200 /* SPISSEL1 Value */ +#define SPI_SLVSEL_SSEL2 0x00000400 /* SPISSEL2 Value */ +#define SPI_SLVSEL_SSEL3 0x00000800 /* SPISSEL3 Value */ +#define SPI_SLVSEL_SSEL4 0x00001000 /* SPISSEL4 Value */ +#define SPI_SLVSEL_SSEL5 0x00002000 /* SPISSEL5 Value */ +#define SPI_SLVSEL_SSEL6 0x00004000 /* SPISSEL6 Value */ +#define SPI_SLVSEL_SSEL7 0x00008000 /* SPISSEL7 Value */ +/* SPI_RWC */ +#define SPI_RWC_VALUE 0x0000FFFF /* Received Word-Count */ +/* SPI_RWCR */ +#define SPI_RWCR_VALUE 0x0000FFFF /* Received Word-Count Reload */ +/* SPI_TWC */ +#define SPI_TWC_VALUE 0x0000FFFF /* Transmitted Word-Count */ +/* SPI_TWCR */ +#define SPI_TWCR_VALUE 0x0000FFFF /* Transmitted Word-Count Reload */ +/* SPI_IMASK */ +#define SPI_IMSK_RUWM 0x00000002 /* Receive Urgent Water-Mark Interrupt Mask */ +#define SPI_IMSK_TUWM 0x00000004 /* Transmit Urgent Water-Mark Interrupt Mask */ +#define SPI_IMSK_ROM 0x00000010 /* Receive Over-Run Error Interrupt Mask */ +#define SPI_IMSK_TUM 0x00000020 /* Transmit Under-Run Error Interrupt Mask */ +#define SPI_IMSK_TCM 0x00000040 /* Transmit Collision Error Interrupt Mask */ +#define SPI_IMSK_MFM 0x00000080 /* Mode Fault Error Interrupt Mask */ +#define SPI_IMSK_RSM 0x00000100 /* Receive Start Interrupt Mask */ +#define SPI_IMSK_TSM 0x00000200 /* Transmit Start Interrupt Mask */ +#define SPI_IMSK_RFM 0x00000400 /* Receive Finish Interrupt Mask */ +#define SPI_IMSK_TFM 0x00000800 /* Transmit Finish Interrupt Mask */ +/* SPI_IMASKCL */ +#define SPI_IMSK_CLR_RUW 0x00000002 /* Receive Urgent Water-Mark Interrupt Mask */ +#define SPI_IMSK_CLR_TUWM 0x00000004 /* Transmit Urgent Water-Mark Interrupt Mask */ +#define SPI_IMSK_CLR_ROM 0x00000010 /* Receive Over-Run Error Interrupt Mask */ +#define SPI_IMSK_CLR_TUM 0x00000020 /* Transmit Under-Run Error Interrupt Mask */ +#define SPI_IMSK_CLR_TCM 0x00000040 /* Transmit Collision Error Interrupt Mask */ +#define SPI_IMSK_CLR_MFM 0x00000080 /* Mode Fault Error Interrupt Mask */ +#define SPI_IMSK_CLR_RSM 0x00000100 /* Receive Start Interrupt Mask */ +#define SPI_IMSK_CLR_TSM 0x00000200 /* Transmit Start Interrupt Mask */ +#define SPI_IMSK_CLR_RFM 0x00000400 /* Receive Finish Interrupt Mask */ +#define SPI_IMSK_CLR_TFM 0x00000800 /* Transmit Finish Interrupt Mask */ +/* SPI_IMASKST */ +#define SPI_IMSK_SET_RUWM 0x00000002 /* Receive Urgent Water-Mark Interrupt Mask */ +#define SPI_IMSK_SET_TUWM 0x00000004 /* Transmit Urgent Water-Mark Interrupt Mask */ +#define SPI_IMSK_SET_ROM 0x00000010 /* Receive Over-Run Error Interrupt Mask */ +#define SPI_IMSK_SET_TUM 0x00000020 /* Transmit Under-Run Error Interrupt Mask */ +#define SPI_IMSK_SET_TCM 0x00000040 /* Transmit Collision Error Interrupt Mask */ +#define SPI_IMSK_SET_MFM 0x00000080 /* Mode Fault Error Interrupt Mask */ +#define SPI_IMSK_SET_RSM 0x00000100 /* Receive Start Interrupt Mask */ +#define SPI_IMSK_SET_TSM 0x00000200 /* Transmit Start Interrupt Mask */ +#define SPI_IMSK_SET_RFM 0x00000400 /* Receive Finish Interrupt Mask */ +#define SPI_IMSK_SET_TFM 0x00000800 /* Transmit Finish Interrupt Mask */ +/* SPI_STATUS */ +#define SPI_STAT_SPIF 0x00000001 /* SPI Finished */ +#define SPI_STAT_RUWM 0x00000002 /* Receive Urgent Water-Mark Breached */ +#define SPI_STAT_TUWM 0x00000004 /* Transmit Urgent Water-Mark Breached */ +#define SPI_STAT_ROE 0x00000010 /* Receive Over-Run Error Indication */ +#define SPI_STAT_TUE 0x00000020 /* Transmit Under-Run Error Indication */ +#define SPI_STAT_TCE 0x00000040 /* Transmit Collision Error Indication */ +#define SPI_STAT_MODF 0x00000080 /* Mode Fault Error Indication */ +#define SPI_STAT_RS 0x00000100 /* Receive Start Indication */ +#define SPI_STAT_TS 0x00000200 /* Transmit Start Indication */ +#define SPI_STAT_RF 0x00000400 /* Receive Finish Indication */ +#define SPI_STAT_TF 0x00000800 /* Transmit Finish Indication */ +#define SPI_STAT_RFS 0x00007000 /* SPI_RFIFO status */ +#define SPI_STAT_RFIFO_EMPTY 0x00000000 /* RFS: RFIFO Empty */ +#define SPI_STAT_RFIFO_25 0x00001000 /* RFS: RFIFO 25% Full */ +#define SPI_STAT_RFIFO_50 0x00002000 /* RFS: RFIFO 50% Full */ +#define SPI_STAT_RFIFO_75 0x00003000 /* RFS: RFIFO 75% Full */ +#define SPI_STAT_RFIFO_FULL 0x00004000 /* RFS: RFIFO Full */ +#define SPI_STAT_TFS 0x00070000 /* SPI_TFIFO status */ +#define SPI_STAT_TFIFO_FULL 0x00000000 /* TFS: TFIFO full */ +#define SPI_STAT_TFIFO_25 0x00010000 /* TFS: TFIFO 25% empty */ +#define SPI_STAT_TFIFO_50 0x00020000 /* TFS: TFIFO 50% empty */ +#define SPI_STAT_TFIFO_75 0x00030000 /* TFS: TFIFO 75% empty */ +#define SPI_STAT_TFIFO_EMPTY 0x00040000 /* TFS: TFIFO empty */ +#define SPI_STAT_FCS 0x00100000 /* Flow-Control Stall Indication */ +#define SPI_STAT_RFE 0x00400000 /* SPI_RFIFO Empty */ +#define SPI_STAT_TFF 0x00800000 /* SPI_TFIFO Full */ +/* SPI_ILAT */ +#define SPI_ILAT_RUWMI 0x00000002 /* Receive Urgent Water Mark Interrupt */ +#define SPI_ILAT_TUWMI 0x00000004 /* Transmit Urgent Water Mark Interrupt */ +#define SPI_ILAT_ROI 0x00000010 /* Receive Over-Run Error Indication */ +#define SPI_ILAT_TUI 0x00000020 /* Transmit Under-Run Error Indication */ +#define SPI_ILAT_TCI 0x00000040 /* Transmit Collision Error Indication */ +#define SPI_ILAT_MFI 0x00000080 /* Mode Fault Error Indication */ +#define SPI_ILAT_RSI 0x00000100 /* Receive Start Indication */ +#define SPI_ILAT_TSI 0x00000200 /* Transmit Start Indication */ +#define SPI_ILAT_RFI 0x00000400 /* Receive Finish Indication */ +#define SPI_ILAT_TFI 0x00000800 /* Transmit Finish Indication */ +/* SPI_ILATCL */ +#define SPI_ILAT_CLR_RUWMI 0x00000002 /* Receive Urgent Water Mark Interrupt */ +#define SPI_ILAT_CLR_TUWMI 0x00000004 /* Transmit Urgent Water Mark Interrupt */ +#define SPI_ILAT_CLR_ROI 0x00000010 /* Receive Over-Run Error Indication */ +#define SPI_ILAT_CLR_TUI 0x00000020 /* Transmit Under-Run Error Indication */ +#define SPI_ILAT_CLR_TCI 0x00000040 /* Transmit Collision Error Indication */ +#define SPI_ILAT_CLR_MFI 0x00000080 /* Mode Fault Error Indication */ +#define SPI_ILAT_CLR_RSI 0x00000100 /* Receive Start Indication */ +#define SPI_ILAT_CLR_TSI 0x00000200 /* Transmit Start Indication */ +#define SPI_ILAT_CLR_RFI 0x00000400 /* Receive Finish Indication */ +#define SPI_ILAT_CLR_TFI 0x00000800 /* Transmit Finish Indication */ + +/* + * adi spi3 registers layout + */ +struct adi_spi_regs { + u32 revid; + u32 control; + u32 rx_control; + u32 tx_control; + u32 clock; + u32 delay; + u32 ssel; + u32 rwc; + u32 rwcr; + u32 twc; + u32 twcr; + u32 reserved0; + u32 emask; + u32 emaskcl; + u32 emaskst; + u32 reserved1; + u32 status; + u32 elat; + u32 elatcl; + u32 reserved2; + u32 rfifo; + u32 reserved3; + u32 tfifo; +}; + +#define MAX_CTRL_CS 8 /* cs in spi controller */ + +/* device.platform_data for SSP controller devices */ +struct adi_spi3_master { + u16 num_chipselect; + u16 pin_req[7]; +}; + +/* spi_board_info.controller_data for SPI slave devices, + * copied to spi_device.platform_data ... mostly for dma tuning + */ +struct adi_spi3_chip { + u32 control; + u16 cs_chg_udelay; /* Some devices require 16-bit delays */ + u32 tx_dummy_val; /* tx value for rx only transfer */ + bool enable_dma; +}; + +#endif /* _ADI_SPI3_H_ */ -- cgit v1.2.3 From c34cc2487d5e6c225609696db3f49d40259787e2 Mon Sep 17 00:00:00 2001 From: Scott Jiang Date: Sat, 5 Apr 2014 11:29:09 +0800 Subject: spi: spi-adi-v3: convert to use common clk framework Use common clk api to get spi clock. Signed-off-by: Scott Jiang Signed-off-by: Mark Brown --- arch/blackfin/mach-bf609/clock.c | 7 +++++++ drivers/spi/spi-adi-v3.c | 13 +++++++------ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/arch/blackfin/mach-bf609/clock.c b/arch/blackfin/mach-bf609/clock.c index 56200f37cfc8..244fa4ab4c56 100644 --- a/arch/blackfin/mach-bf609/clock.c +++ b/arch/blackfin/mach-bf609/clock.c @@ -363,6 +363,12 @@ static struct clk ethclk = { .ops = &dummy_clk_ops, }; +static struct clk spiclk = { + .name = "spi", + .parent = &sclk1, + .ops = &dummy_clk_ops, +}; + static struct clk_lookup bf609_clks[] = { CLK(sys_clkin, NULL, "SYS_CLKIN"), CLK(pll_clk, NULL, "PLLCLK"), @@ -375,6 +381,7 @@ static struct clk_lookup bf609_clks[] = { CLK(dclk, NULL, "DCLK"), CLK(oclk, NULL, "OCLK"), CLK(ethclk, NULL, "stmmaceth"), + CLK(spiclk, NULL, "spi"), }; int __init clk_init(void) diff --git a/drivers/spi/spi-adi-v3.c b/drivers/spi/spi-adi-v3.c index 0c2914cfcdb5..dcb2287c7f8a 100644 --- a/drivers/spi/spi-adi-v3.c +++ b/drivers/spi/spi-adi-v3.c @@ -13,6 +13,7 @@ * GNU General Public License for more details. */ +#include #include #include #include @@ -800,7 +801,7 @@ static int adi_spi_probe(struct platform_device *pdev) struct adi_spi_master *drv_data; struct resource *mem, *res; unsigned int tx_dma, rx_dma; - unsigned long sclk; + struct clk *sclk; int ret; if (!info) { @@ -808,10 +809,10 @@ static int adi_spi_probe(struct platform_device *pdev) return -ENODEV; } - sclk = get_sclk1(); - if (!sclk) { - dev_err(dev, "can not get sclk1\n"); - return -ENXIO; + sclk = devm_clk_get(dev, "spi"); + if (IS_ERR(sclk)) { + dev_err(dev, "can not get spi clock\n"); + return PTR_ERR(sclk); } res = platform_get_resource(pdev, IORESOURCE_DMA, 0); @@ -852,7 +853,7 @@ static int adi_spi_probe(struct platform_device *pdev) drv_data->tx_dma = tx_dma; drv_data->rx_dma = rx_dma; drv_data->pin_req = info->pin_req; - drv_data->sclk = sclk; + drv_data->sclk = clk_get_rate(sclk); mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); drv_data->regs = devm_ioremap_resource(dev, mem); -- cgit v1.2.3 From 9403e462fb5ffa9eeaa9663cb23ded02b7e603a3 Mon Sep 17 00:00:00 2001 From: Leif Lindholm Date: Fri, 4 Apr 2014 13:25:46 +0100 Subject: efi: efi-stub-helper cleanup An #ifdef CONFIG_ARM clause in efi-stub-helper.c got included with some of the generic stub rework by Roy Franz. Drop it here to make subsequent patches less confusing. Also, In handle_cmdline_files(), fh is not initialized, and while the overall logic around this handling appears safe, gcc does not always pick this up. Initialize to NULL to remove the resulting warning. Signed-off-by: Leif Lindholm Signed-off-by: Matt Fleming --- drivers/firmware/efi/efi-stub-helper.c | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/drivers/firmware/efi/efi-stub-helper.c b/drivers/firmware/efi/efi-stub-helper.c index 2c41eaece2c1..47722003b8fc 100644 --- a/drivers/firmware/efi/efi-stub-helper.c +++ b/drivers/firmware/efi/efi-stub-helper.c @@ -267,7 +267,7 @@ static efi_status_t handle_cmdline_files(efi_system_table_t *sys_table_arg, struct file_info *files; unsigned long file_addr; u64 file_size_total; - efi_file_handle_t *fh; + efi_file_handle_t *fh = NULL; efi_status_t status; int nr_files; char *str; @@ -536,18 +536,8 @@ static char *efi_convert_cmdline_to_ascii(efi_system_table_t *sys_table_arg, } options_size++; /* NUL termination */ -#ifdef CONFIG_ARM - /* - * For ARM, allocate at a high address to avoid reserved - * regions at low addresses that we don't know the specfics of - * at the time we are processing the command line. - */ - status = efi_high_alloc(sys_table_arg, options_size, 0, - &cmdline_addr, 0xfffff000); -#else - status = efi_low_alloc(sys_table_arg, options_size, 0, - &cmdline_addr); -#endif + + status = efi_low_alloc(sys_table_arg, options_size, 0, &cmdline_addr); if (status != EFI_SUCCESS) return NULL; -- cgit v1.2.3 From e885cd805fc6e65ef5150a211c7bac02f925af04 Mon Sep 17 00:00:00 2001 From: Mark Salter Date: Fri, 10 Jan 2014 14:26:06 -0500 Subject: efi: create memory map iteration helper There are a lot of places in the kernel which iterate through an EFI memory map. Most of these places use essentially the same for-loop code. This patch adds a for_each_efi_memory_desc() helper to clean up all of the existing duplicate code and avoid more in the future. Signed-off-by: Mark Salter Signed-off-by: Leif Lindholm Signed-off-by: Matt Fleming --- include/linux/efi.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/include/linux/efi.h b/include/linux/efi.h index 6c100ff0cae4..82d0abb2b19f 100644 --- a/include/linux/efi.h +++ b/include/linux/efi.h @@ -863,6 +863,12 @@ extern int efi_set_rtc_mmss(const struct timespec *now); extern void efi_reserve_boot_services(void); extern struct efi_memory_map memmap; +/* Iterate through an efi_memory_map */ +#define for_each_efi_memory_desc(m, md) \ + for ((md) = (m)->map; \ + (md) <= (efi_memory_desc_t *)((m)->map_end - (m)->desc_size); \ + (md) = (void *)(md) + (m)->desc_size) + /** * efi_range_is_wc - check the WC bit on an address range * @start: starting kvirt address -- cgit v1.2.3 From f966ea021f947b20c22b31194d7e3042375c7f24 Mon Sep 17 00:00:00 2001 From: Roy Franz Date: Fri, 13 Dec 2013 11:04:49 -0800 Subject: efi: Add shared printk wrapper for consistent prefixing Add a wrapper for printk to standardize the prefix for informational and error messages from the EFI stub. Signed-off-by: Roy Franz Signed-off-by: Leif Lindholm Signed-off-by: Matt Fleming --- drivers/firmware/efi/efi-stub-helper.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/drivers/firmware/efi/efi-stub-helper.c b/drivers/firmware/efi/efi-stub-helper.c index 47722003b8fc..1bf439be9138 100644 --- a/drivers/firmware/efi/efi-stub-helper.c +++ b/drivers/firmware/efi/efi-stub-helper.c @@ -33,6 +33,9 @@ static void efi_printk(efi_system_table_t *sys_table_arg, char *str) } } +#define pr_efi(sys_table, msg) efi_printk(sys_table, "EFI stub: "msg) +#define pr_efi_err(sys_table, msg) efi_printk(sys_table, "EFI stub: ERROR: "msg) + static efi_status_t efi_get_memory_map(efi_system_table_t *sys_table_arg, efi_memory_desc_t **map, @@ -310,7 +313,7 @@ static efi_status_t handle_cmdline_files(efi_system_table_t *sys_table_arg, status = efi_call_early(allocate_pool, EFI_LOADER_DATA, nr_files * sizeof(*files), (void **)&files); if (status != EFI_SUCCESS) { - efi_printk(sys_table_arg, "Failed to alloc mem for file handle list\n"); + pr_efi_err(sys_table_arg, "Failed to alloc mem for file handle list\n"); goto fail; } @@ -374,13 +377,13 @@ static efi_status_t handle_cmdline_files(efi_system_table_t *sys_table_arg, status = efi_high_alloc(sys_table_arg, file_size_total, 0x1000, &file_addr, max_addr); if (status != EFI_SUCCESS) { - efi_printk(sys_table_arg, "Failed to alloc highmem for files\n"); + pr_efi_err(sys_table_arg, "Failed to alloc highmem for files\n"); goto close_handles; } /* We've run out of free low memory. */ if (file_addr > max_addr) { - efi_printk(sys_table_arg, "We've run out of free low memory\n"); + pr_efi_err(sys_table_arg, "We've run out of free low memory\n"); status = EFI_INVALID_PARAMETER; goto free_file_total; } @@ -401,7 +404,7 @@ static efi_status_t handle_cmdline_files(efi_system_table_t *sys_table_arg, &chunksize, (void *)addr); if (status != EFI_SUCCESS) { - efi_printk(sys_table_arg, "Failed to read file\n"); + pr_efi_err(sys_table_arg, "Failed to read file\n"); goto free_file_total; } addr += chunksize; @@ -486,7 +489,7 @@ static efi_status_t efi_relocate_kernel(efi_system_table_t *sys_table_arg, &new_addr); } if (status != EFI_SUCCESS) { - efi_printk(sys_table_arg, "ERROR: Failed to allocate usable memory for kernel.\n"); + pr_efi_err(sys_table_arg, "Failed to allocate usable memory for kernel.\n"); return status; } -- cgit v1.2.3 From 06654acb6698a92bb7e6deb6897006ed501cdc47 Mon Sep 17 00:00:00 2001 From: Heiko Stuebner Date: Wed, 19 Feb 2014 09:25:36 +0900 Subject: clk: samsung: add pll_6552 variant for s3c2416 According to the manual s3c2416 and s3c2450 use a pll 6552 and 6553 and while the pll_6553 matches exactly the one already implemented the pll_6552 differs to the one from the s3c64xx series. The change is solely in the bit locations of the mdiv and pdiv values. All calculations are the same for both implementatons and even the proposed divider-values for specific frequencies in the manuals are the same. Therefore implement a variant that simply uses the changed bit locations if necessary. Signed-off-by: Heiko Stuebner Acked-by: Tomasz Figa Acked-by: Mike Turquette Signed-off-by: Kukjin Kim --- drivers/clk/samsung/clk-pll.c | 12 ++++++++++-- drivers/clk/samsung/clk-pll.h | 1 + 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/drivers/clk/samsung/clk-pll.c b/drivers/clk/samsung/clk-pll.c index 81e6d2f49aa0..f9a35a612705 100644 --- a/drivers/clk/samsung/clk-pll.c +++ b/drivers/clk/samsung/clk-pll.c @@ -564,7 +564,9 @@ static const struct clk_ops samsung_pll46xx_clk_min_ops = { #define PLL6552_PDIV_MASK 0x3f #define PLL6552_SDIV_MASK 0x7 #define PLL6552_MDIV_SHIFT 16 +#define PLL6552_MDIV_SHIFT_2416 14 #define PLL6552_PDIV_SHIFT 8 +#define PLL6552_PDIV_SHIFT_2416 5 #define PLL6552_SDIV_SHIFT 0 static unsigned long samsung_pll6552_recalc_rate(struct clk_hw *hw, @@ -575,8 +577,13 @@ static unsigned long samsung_pll6552_recalc_rate(struct clk_hw *hw, u64 fvco = parent_rate; pll_con = __raw_readl(pll->con_reg); - mdiv = (pll_con >> PLL6552_MDIV_SHIFT) & PLL6552_MDIV_MASK; - pdiv = (pll_con >> PLL6552_PDIV_SHIFT) & PLL6552_PDIV_MASK; + if (pll->type == pll_6552_s3c2416) { + mdiv = (pll_con >> PLL6552_MDIV_SHIFT_2416) & PLL6552_MDIV_MASK; + pdiv = (pll_con >> PLL6552_PDIV_SHIFT_2416) & PLL6552_PDIV_MASK; + } else { + mdiv = (pll_con >> PLL6552_MDIV_SHIFT) & PLL6552_MDIV_MASK; + pdiv = (pll_con >> PLL6552_PDIV_SHIFT) & PLL6552_PDIV_MASK; + } sdiv = (pll_con >> PLL6552_SDIV_SHIFT) & PLL6552_SDIV_MASK; fvco *= mdiv; @@ -773,6 +780,7 @@ static void __init _samsung_clk_register_pll(struct samsung_pll_clock *pll_clk, init.ops = &samsung_pll36xx_clk_ops; break; case pll_6552: + case pll_6552_s3c2416: init.ops = &samsung_pll6552_clk_ops; break; case pll_6553: diff --git a/drivers/clk/samsung/clk-pll.h b/drivers/clk/samsung/clk-pll.h index 6c39030080fb..ddf9029c13c9 100644 --- a/drivers/clk/samsung/clk-pll.h +++ b/drivers/clk/samsung/clk-pll.h @@ -24,6 +24,7 @@ enum samsung_pll_type { pll_4650, pll_4650c, pll_6552, + pll_6552_s3c2416, pll_6553, }; -- cgit v1.2.3 From a951b1d91dcca8d373c92666c5e006de8234d34b Mon Sep 17 00:00:00 2001 From: Heiko Stuebner Date: Wed, 19 Feb 2014 09:25:41 +0900 Subject: clk: samsung: add plls used by the s3c2443 The s3c2443 uses different plls that are not present yet. Therefore add the two needed types. Signed-off-by: Heiko Stuebner Acked-by: Tomasz Figa Acked-by: Mike Turquette Signed-off-by: Kukjin Kim --- drivers/clk/samsung/clk-pll.c | 72 +++++++++++++++++++++++++++++++++++++++++++ drivers/clk/samsung/clk-pll.h | 2 ++ 2 files changed, 74 insertions(+) diff --git a/drivers/clk/samsung/clk-pll.c b/drivers/clk/samsung/clk-pll.c index f9a35a612705..8c9c015a4538 100644 --- a/drivers/clk/samsung/clk-pll.c +++ b/drivers/clk/samsung/clk-pll.c @@ -58,6 +58,72 @@ static long samsung_pll_round_rate(struct clk_hw *hw, return rate_table[i - 1].rate; } +/* + * PLL2126 Clock Type + */ + +#define PLL2126_MDIV_MASK (0xff) +#define PLL2126_PDIV_MASK (0x3f) +#define PLL2126_SDIV_MASK (0x3) +#define PLL2126_MDIV_SHIFT (16) +#define PLL2126_PDIV_SHIFT (8) +#define PLL2126_SDIV_SHIFT (0) + +static unsigned long samsung_pll2126_recalc_rate(struct clk_hw *hw, + unsigned long parent_rate) +{ + struct samsung_clk_pll *pll = to_clk_pll(hw); + u32 pll_con, mdiv, pdiv, sdiv; + u64 fvco = parent_rate; + + pll_con = __raw_readl(pll->con_reg); + mdiv = (pll_con >> PLL2126_MDIV_SHIFT) & PLL2126_MDIV_MASK; + pdiv = (pll_con >> PLL2126_PDIV_SHIFT) & PLL2126_PDIV_MASK; + sdiv = (pll_con >> PLL2126_SDIV_SHIFT) & PLL2126_SDIV_MASK; + + fvco *= (mdiv + 8); + do_div(fvco, (pdiv + 2) << sdiv); + + return (unsigned long)fvco; +} + +static const struct clk_ops samsung_pll2126_clk_ops = { + .recalc_rate = samsung_pll2126_recalc_rate, +}; + +/* + * PLL3000 Clock Type + */ + +#define PLL3000_MDIV_MASK (0xff) +#define PLL3000_PDIV_MASK (0x3) +#define PLL3000_SDIV_MASK (0x3) +#define PLL3000_MDIV_SHIFT (16) +#define PLL3000_PDIV_SHIFT (8) +#define PLL3000_SDIV_SHIFT (0) + +static unsigned long samsung_pll3000_recalc_rate(struct clk_hw *hw, + unsigned long parent_rate) +{ + struct samsung_clk_pll *pll = to_clk_pll(hw); + u32 pll_con, mdiv, pdiv, sdiv; + u64 fvco = parent_rate; + + pll_con = __raw_readl(pll->con_reg); + mdiv = (pll_con >> PLL3000_MDIV_SHIFT) & PLL3000_MDIV_MASK; + pdiv = (pll_con >> PLL3000_PDIV_SHIFT) & PLL3000_PDIV_MASK; + sdiv = (pll_con >> PLL3000_SDIV_SHIFT) & PLL3000_SDIV_MASK; + + fvco *= (2 * (mdiv + 8)); + do_div(fvco, pdiv << sdiv); + + return (unsigned long)fvco; +} + +static const struct clk_ops samsung_pll3000_clk_ops = { + .recalc_rate = samsung_pll3000_recalc_rate, +}; + /* * PLL35xx Clock Type */ @@ -753,6 +819,12 @@ static void __init _samsung_clk_register_pll(struct samsung_pll_clock *pll_clk, } switch (pll_clk->type) { + case pll_2126: + init.ops = &samsung_pll2126_clk_ops; + break; + case pll_3000: + init.ops = &samsung_pll3000_clk_ops; + break; /* clk_ops for 35xx and 2550 are similar */ case pll_35xx: case pll_2550: diff --git a/drivers/clk/samsung/clk-pll.h b/drivers/clk/samsung/clk-pll.h index ddf9029c13c9..5b64bdbb0906 100644 --- a/drivers/clk/samsung/clk-pll.h +++ b/drivers/clk/samsung/clk-pll.h @@ -13,6 +13,8 @@ #define __SAMSUNG_CLK_PLL_H enum samsung_pll_type { + pll_2126, + pll_3000, pll_35xx, pll_36xx, pll_2550, -- cgit v1.2.3 From 78435c812afa70b8ddee789c7f37fc88738079a0 Mon Sep 17 00:00:00 2001 From: Heiko Stuebner Date: Wed, 19 Feb 2014 09:25:45 +0900 Subject: dt-bindings: add binding for clock-controller of s3c2443 and following Starting with the s3c2443 the s3c24xx series got a new clock tree compared to the previous s3c24xx socs. This binding describes the clock controller found in the s3c2443, s3c2416 and s3c2450 socs. Signed-off-by: Heiko Stuebner Acked-by: Tomasz Figa Signed-off-by: Kukjin Kim --- .../bindings/clock/samsung,s3c2443-clock.txt | 56 ++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 Documentation/devicetree/bindings/clock/samsung,s3c2443-clock.txt diff --git a/Documentation/devicetree/bindings/clock/samsung,s3c2443-clock.txt b/Documentation/devicetree/bindings/clock/samsung,s3c2443-clock.txt new file mode 100644 index 000000000000..e67bb05478af --- /dev/null +++ b/Documentation/devicetree/bindings/clock/samsung,s3c2443-clock.txt @@ -0,0 +1,56 @@ +* Samsung S3C2443 Clock Controller + +The S3C2443 clock controller generates and supplies clock to various controllers +within the SoC. The clock binding described here is applicable to all SoCs in +the s3c24x family starting with the s3c2443. + +Required Properties: + +- compatible: should be one of the following. + - "samsung,s3c2416-clock" - controller compatible with S3C2416 SoC. + - "samsung,s3c2443-clock" - controller compatible with S3C2443 SoC. + - "samsung,s3c2450-clock" - controller compatible with S3C2450 SoC. +- reg: physical base address of the controller and length of memory mapped + region. +- #clock-cells: should be 1. + +Each clock is assigned an identifier and client nodes can use this identifier +to specify the clock which they consume. Some of the clocks are available only +on a particular SoC. + +All available clocks are defined as preprocessor macros in +dt-bindings/clock/s3c2443.h header and can be used in device +tree sources. + +External clocks: + +There are several clocks that are generated outside the SoC. It is expected +that they are defined using standard clock bindings with following +clock-output-names: + - "xti" - crystal input - required, + - "ext" - external clock source - optional, + - "ext_i2s" - external I2S clock - optional, + - "ext_uart" - external uart clock - optional, + +Example: Clock controller node: + + clocks: clock-controller@4c000000 { + compatible = "samsung,s3c2416-clock"; + reg = <0x4c000000 0x40>; + #clock-cells = <1>; + }; + +Example: UART controller node that consumes the clock generated by the clock + controller (refer to the standard clock bindings for information about + "clocks" and "clock-names" properties): + + serial@50004000 { + compatible = "samsung,s3c2440-uart"; + reg = <0x50004000 0x4000>; + interrupts = <1 23 3 4>, <1 23 4 4>; + clock-names = "uart", "clk_uart_baud2", + "clk_uart_baud3"; + clocks = <&clocks PCLK_UART0>, <&clocks PCLK_UART0>, + <&clocks SCLK_UART>; + status = "disabled"; + }; -- cgit v1.2.3 From 61fbb1d278cf09f29d67629b139b3ca08acbf177 Mon Sep 17 00:00:00 2001 From: Heiko Stuebner Date: Wed, 19 Feb 2014 09:25:49 +0900 Subject: clk: samsung: add clock-driver for s3c2416, s3c2443 and s3c2450 The three SoCs share a common clock tree which only differs in the existence of some special clocks. As with all parts common to these three SoCs the driver is named after the s3c2443, as it was the first SoC introducing this structure and there exists no other label to describe this s3c24xx epoch. The clock structure is built according to the manuals of the included SoCs and might include changes in comparison to the previous clock structure. As an example the sclk_uart gate was never handled previously and the div_uart was made to be the clock used by the serial driver. Signed-off-by: Heiko Stuebner Acked-by: Tomasz Figa Signed-off-by: Kukjin Kim --- arch/arm/mach-s3c24xx/Kconfig | 6 + drivers/clk/samsung/Makefile | 1 + drivers/clk/samsung/clk-s3c2443.c | 462 ++++++++++++++++++++++++++++++++++++ include/dt-bindings/clock/s3c2443.h | 92 +++++++ 4 files changed, 561 insertions(+) create mode 100644 drivers/clk/samsung/clk-s3c2443.c create mode 100644 include/dt-bindings/clock/s3c2443.h diff --git a/arch/arm/mach-s3c24xx/Kconfig b/arch/arm/mach-s3c24xx/Kconfig index 40cf50b9940c..abf9179c9d03 100644 --- a/arch/arm/mach-s3c24xx/Kconfig +++ b/arch/arm/mach-s3c24xx/Kconfig @@ -647,6 +647,12 @@ config S3C2443_COMMON Common code for the S3C2443 and similar processors, which includes the S3C2416 and S3C2450. +config S3C2443_COMMON_CLK + bool + help + Temporary symbol to build the clock driver based on the common clock + framework. + config S3C2443_DMA bool help diff --git a/drivers/clk/samsung/Makefile b/drivers/clk/samsung/Makefile index 8eb4799237f0..4c892c63a8dd 100644 --- a/drivers/clk/samsung/Makefile +++ b/drivers/clk/samsung/Makefile @@ -8,4 +8,5 @@ obj-$(CONFIG_SOC_EXYNOS5250) += clk-exynos5250.o obj-$(CONFIG_SOC_EXYNOS5420) += clk-exynos5420.o obj-$(CONFIG_SOC_EXYNOS5440) += clk-exynos5440.o obj-$(CONFIG_ARCH_EXYNOS) += clk-exynos-audss.o +obj-$(CONFIG_S3C2443_COMMON_CLK)+= clk-s3c2443.o obj-$(CONFIG_ARCH_S3C64XX) += clk-s3c64xx.o diff --git a/drivers/clk/samsung/clk-s3c2443.c b/drivers/clk/samsung/clk-s3c2443.c new file mode 100644 index 000000000000..8e4f4517e95c --- /dev/null +++ b/drivers/clk/samsung/clk-s3c2443.c @@ -0,0 +1,462 @@ +/* + * Copyright (c) 2013 Heiko Stuebner + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * Common Clock Framework support for S3C2443 and following SoCs. + */ + +#include +#include +#include +#include +#include +#include + +#include + +#include "clk.h" +#include "clk-pll.h" + +/* S3C2416 clock controller register offsets */ +#define LOCKCON0 0x00 +#define LOCKCON1 0x04 +#define MPLLCON 0x10 +#define EPLLCON 0x18 +#define EPLLCON_K 0x1C +#define CLKSRC 0x20 +#define CLKDIV0 0x24 +#define CLKDIV1 0x28 +#define CLKDIV2 0x2C +#define HCLKCON 0x30 +#define PCLKCON 0x34 +#define SCLKCON 0x38 + +/* the soc types */ +enum supported_socs { + S3C2416, + S3C2443, + S3C2450, +}; + +/* list of PLLs to be registered */ +enum s3c2443_plls { + mpll, epll, +}; + +static void __iomem *reg_base; + +#ifdef CONFIG_PM_SLEEP +static struct samsung_clk_reg_dump *s3c2443_save; + +/* + * list of controller registers to be saved and restored during a + * suspend/resume cycle. + */ +static unsigned long s3c2443_clk_regs[] __initdata = { + LOCKCON0, + LOCKCON1, + MPLLCON, + EPLLCON, + EPLLCON_K, + CLKSRC, + CLKDIV0, + CLKDIV1, + CLKDIV2, + PCLKCON, + HCLKCON, + SCLKCON, +}; + +static int s3c2443_clk_suspend(void) +{ + samsung_clk_save(reg_base, s3c2443_save, + ARRAY_SIZE(s3c2443_clk_regs)); + + return 0; +} + +static void s3c2443_clk_resume(void) +{ + samsung_clk_restore(reg_base, s3c2443_save, + ARRAY_SIZE(s3c2443_clk_regs)); +} + +static struct syscore_ops s3c2443_clk_syscore_ops = { + .suspend = s3c2443_clk_suspend, + .resume = s3c2443_clk_resume, +}; + +static void s3c2443_clk_sleep_init(void) +{ + s3c2443_save = samsung_clk_alloc_reg_dump(s3c2443_clk_regs, + ARRAY_SIZE(s3c2443_clk_regs)); + if (!s3c2443_save) { + pr_warn("%s: failed to allocate sleep save data, no sleep support!\n", + __func__); + return; + } + + register_syscore_ops(&s3c2443_clk_syscore_ops); + return; +} +#else +static void s3c2443_clk_sleep_init(void) {} +#endif + +PNAME(epllref_p) = { "mpllref", "mpllref", "xti", "ext" }; +PNAME(esysclk_p) = { "epllref", "epll" }; +PNAME(mpllref_p) = { "xti", "mdivclk" }; +PNAME(msysclk_p) = { "mpllref", "mpll" }; +PNAME(armclk_p) = { "armdiv" , "hclk" }; +PNAME(i2s0_p) = { "div_i2s0", "ext_i2s", "epllref", "epllref" }; + +struct samsung_mux_clock s3c2443_common_muxes[] __initdata = { + MUX(0, "epllref", epllref_p, CLKSRC, 7, 2), + MUX(ESYSCLK, "esysclk", esysclk_p, CLKSRC, 6, 1), + MUX(0, "mpllref", mpllref_p, CLKSRC, 3, 1), + MUX_A(MSYSCLK, "msysclk", msysclk_p, CLKSRC, 4, 1, "msysclk"), + MUX_A(ARMCLK, "armclk", armclk_p, CLKDIV0, 13, 1, "armclk"), + MUX(0, "mux_i2s0", i2s0_p, CLKSRC, 14, 2), +}; + +static struct clk_div_table hclk_d[] = { + { .val = 0, .div = 1 }, + { .val = 1, .div = 2 }, + { .val = 3, .div = 4 }, + { /* sentinel */ }, +}; + +static struct clk_div_table mdivclk_d[] = { + { .val = 0, .div = 1 }, + { .val = 1, .div = 3 }, + { .val = 2, .div = 5 }, + { .val = 3, .div = 7 }, + { .val = 4, .div = 9 }, + { .val = 5, .div = 11 }, + { .val = 6, .div = 13 }, + { .val = 7, .div = 15 }, + { /* sentinel */ }, +}; + +struct samsung_div_clock s3c2443_common_dividers[] __initdata = { + DIV_T(0, "mdivclk", "xti", CLKDIV0, 6, 3, mdivclk_d), + DIV(0, "prediv", "msysclk", CLKDIV0, 4, 2), + DIV_T(HCLK, "hclk", "prediv", CLKDIV0, 0, 2, hclk_d), + DIV(PCLK, "pclk", "hclk", CLKDIV0, 2, 1), + DIV(0, "div_hsspi0_epll", "esysclk", CLKDIV1, 24, 2), + DIV(0, "div_fimd", "esysclk", CLKDIV1, 16, 8), + DIV(0, "div_i2s0", "esysclk", CLKDIV1, 12, 4), + DIV(0, "div_uart", "esysclk", CLKDIV1, 8, 4), + DIV(0, "div_hsmmc1", "esysclk", CLKDIV1, 6, 2), + DIV(0, "div_usbhost", "esysclk", CLKDIV1, 4, 2), +}; + +struct samsung_gate_clock s3c2443_common_gates[] __initdata = { + GATE(SCLK_HSMMC_EXT, "sclk_hsmmcext", "ext", SCLKCON, 13, 0, 0), + GATE(SCLK_HSMMC1, "sclk_hsmmc1", "div_hsmmc1", SCLKCON, 12, 0, 0), + GATE(SCLK_FIMD, "sclk_fimd", "div_fimd", SCLKCON, 10, 0, 0), + GATE(SCLK_I2S0, "sclk_i2s0", "mux_i2s0", SCLKCON, 9, 0, 0), + GATE(SCLK_UART, "sclk_uart", "div_uart", SCLKCON, 8, 0, 0), + GATE(SCLK_USBH, "sclk_usbhost", "div_usbhost", SCLKCON, 1, 0, 0), + GATE(HCLK_DRAM, "dram", "hclk", HCLKCON, 19, CLK_IGNORE_UNUSED, 0), + GATE(HCLK_SSMC, "ssmc", "hclk", HCLKCON, 18, CLK_IGNORE_UNUSED, 0), + GATE(HCLK_HSMMC1, "hsmmc1", "hclk", HCLKCON, 16, 0, 0), + GATE(HCLK_USBD, "usb-device", "hclk", HCLKCON, 12, 0, 0), + GATE(HCLK_USBH, "usb-host", "hclk", HCLKCON, 11, 0, 0), + GATE(HCLK_LCD, "lcd", "hclk", HCLKCON, 9, 0, 0), + GATE(HCLK_DMA5, "dma5", "hclk", HCLKCON, 5, CLK_IGNORE_UNUSED, 0), + GATE(HCLK_DMA4, "dma4", "hclk", HCLKCON, 4, CLK_IGNORE_UNUSED, 0), + GATE(HCLK_DMA3, "dma3", "hclk", HCLKCON, 3, CLK_IGNORE_UNUSED, 0), + GATE(HCLK_DMA2, "dma2", "hclk", HCLKCON, 2, CLK_IGNORE_UNUSED, 0), + GATE(HCLK_DMA1, "dma1", "hclk", HCLKCON, 1, CLK_IGNORE_UNUSED, 0), + GATE(HCLK_DMA0, "dma0", "hclk", HCLKCON, 0, CLK_IGNORE_UNUSED, 0), + GATE(PCLK_GPIO, "gpio", "pclk", PCLKCON, 13, CLK_IGNORE_UNUSED, 0), + GATE(PCLK_RTC, "rtc", "pclk", PCLKCON, 12, 0, 0), + GATE(PCLK_WDT, "wdt", "pclk", PCLKCON, 11, 0, 0), + GATE(PCLK_PWM, "pwm", "pclk", PCLKCON, 10, 0, 0), + GATE(PCLK_I2S0, "i2s0", "pclk", PCLKCON, 9, 0, 0), + GATE(PCLK_AC97, "ac97", "pclk", PCLKCON, 8, 0, 0), + GATE(PCLK_ADC, "adc", "pclk", PCLKCON, 7, 0, 0), + GATE(PCLK_SPI0, "spi0", "pclk", PCLKCON, 6, 0, 0), + GATE(PCLK_I2C0, "i2c0", "pclk", PCLKCON, 4, 0, 0), + GATE(PCLK_UART3, "uart3", "pclk", PCLKCON, 3, 0, 0), + GATE(PCLK_UART2, "uart2", "pclk", PCLKCON, 2, 0, 0), + GATE(PCLK_UART1, "uart1", "pclk", PCLKCON, 1, 0, 0), + GATE(PCLK_UART0, "uart0", "pclk", PCLKCON, 0, 0, 0), +}; + +struct samsung_clock_alias s3c2443_common_aliases[] __initdata = { + ALIAS(HCLK, NULL, "hclk"), + ALIAS(HCLK_SSMC, NULL, "nand"), + ALIAS(PCLK_UART0, "s3c2440-uart.0", "uart"), + ALIAS(PCLK_UART1, "s3c2440-uart.1", "uart"), + ALIAS(PCLK_UART2, "s3c2440-uart.2", "uart"), + ALIAS(PCLK_UART3, "s3c2440-uart.3", "uart"), + ALIAS(PCLK_UART0, "s3c2440-uart.0", "clk_uart_baud2"), + ALIAS(PCLK_UART1, "s3c2440-uart.1", "clk_uart_baud2"), + ALIAS(PCLK_UART2, "s3c2440-uart.2", "clk_uart_baud2"), + ALIAS(PCLK_UART3, "s3c2440-uart.3", "clk_uart_baud2"), + ALIAS(SCLK_UART, NULL, "clk_uart_baud3"), + ALIAS(PCLK_PWM, NULL, "timers"), + ALIAS(PCLK_RTC, NULL, "rtc"), + ALIAS(PCLK_WDT, NULL, "watchdog"), + ALIAS(PCLK_ADC, NULL, "adc"), + ALIAS(PCLK_I2C0, "s3c2410-i2c.0", "i2c"), + ALIAS(HCLK_USBD, NULL, "usb-device"), + ALIAS(HCLK_USBH, NULL, "usb-host"), + ALIAS(SCLK_USBH, NULL, "usb-bus-host"), + ALIAS(PCLK_SPI0, "s3c2443-spi.0", "spi"), + ALIAS(PCLK_SPI0, "s3c2443-spi.0", "spi_busclk0"), + ALIAS(HCLK_HSMMC1, "s3c-sdhci.1", "hsmmc"), + ALIAS(HCLK_HSMMC1, "s3c-sdhci.1", "mmc_busclk.0"), + ALIAS(PCLK_I2S0, "samsung-i2s.0", "iis"), + ALIAS(SCLK_I2S0, NULL, "i2s-if"), + ALIAS(HCLK_LCD, NULL, "lcd"), + ALIAS(SCLK_FIMD, NULL, "sclk_fimd"), +}; + +/* S3C2416 specific clocks */ + +static struct samsung_pll_clock s3c2416_pll_clks[] __initdata = { + [mpll] = PLL(pll_6552_s3c2416, 0, "mpll", "mpllref", + LOCKCON0, MPLLCON, NULL), + [epll] = PLL(pll_6553, 0, "epll", "epllref", + LOCKCON1, EPLLCON, NULL), +}; + +PNAME(s3c2416_hsmmc0_p) = { "sclk_hsmmc0", "sclk_hsmmcext" }; +PNAME(s3c2416_hsmmc1_p) = { "sclk_hsmmc1", "sclk_hsmmcext" }; +PNAME(s3c2416_hsspi0_p) = { "hsspi0_epll", "hsspi0_mpll" }; + +static struct clk_div_table armdiv_s3c2416_d[] = { + { .val = 0, .div = 1 }, + { .val = 1, .div = 2 }, + { .val = 2, .div = 3 }, + { .val = 3, .div = 4 }, + { .val = 5, .div = 6 }, + { .val = 7, .div = 8 }, + { /* sentinel */ }, +}; + +struct samsung_div_clock s3c2416_dividers[] __initdata = { + DIV_T(ARMDIV, "armdiv", "msysclk", CLKDIV0, 9, 3, armdiv_s3c2416_d), + DIV(0, "div_hsspi0_mpll", "msysclk", CLKDIV2, 0, 4), + DIV(0, "div_hsmmc0", "esysclk", CLKDIV2, 6, 2), +}; + +struct samsung_mux_clock s3c2416_muxes[] __initdata = { + MUX(MUX_HSMMC0, "mux_hsmmc0", s3c2416_hsmmc0_p, CLKSRC, 16, 1), + MUX(MUX_HSMMC1, "mux_hsmmc1", s3c2416_hsmmc1_p, CLKSRC, 17, 1), + MUX(MUX_HSSPI0, "mux_hsspi0", s3c2416_hsspi0_p, CLKSRC, 18, 1), +}; + +struct samsung_gate_clock s3c2416_gates[] __initdata = { + GATE(0, "hsspi0_mpll", "div_hsspi0_mpll", SCLKCON, 19, 0, 0), + GATE(0, "hsspi0_epll", "div_hsspi0_epll", SCLKCON, 14, 0, 0), + GATE(0, "sclk_hsmmc0", "div_hsmmc0", SCLKCON, 6, 0, 0), + GATE(HCLK_2D, "2d", "hclk", HCLKCON, 20, 0, 0), + GATE(HCLK_HSMMC0, "hsmmc0", "hclk", HCLKCON, 15, 0, 0), + GATE(HCLK_IROM, "irom", "hclk", HCLKCON, 13, CLK_IGNORE_UNUSED, 0), + GATE(PCLK_PCM, "pcm", "pclk", PCLKCON, 19, 0, 0), +}; + +struct samsung_clock_alias s3c2416_aliases[] __initdata = { + ALIAS(HCLK_HSMMC0, "s3c-sdhci.0", "hsmmc"), + ALIAS(HCLK_HSMMC0, "s3c-sdhci.0", "mmc_busclk.0"), + ALIAS(MUX_HSMMC0, "s3c-sdhci.0", "mmc_busclk.2"), + ALIAS(MUX_HSMMC1, "s3c-sdhci.1", "mmc_busclk.2"), + ALIAS(MUX_HSSPI0, "s3c2443-spi.0", "spi_busclk2"), + ALIAS(ARMDIV, NULL, "armdiv"), +}; + +/* S3C2443 specific clocks */ + +static struct samsung_pll_clock s3c2443_pll_clks[] __initdata = { + [mpll] = PLL(pll_3000, 0, "mpll", "mpllref", + LOCKCON0, MPLLCON, NULL), + [epll] = PLL(pll_2126, 0, "epll", "epllref", + LOCKCON1, EPLLCON, NULL), +}; + +static struct clk_div_table armdiv_s3c2443_d[] = { + { .val = 0, .div = 1 }, + { .val = 8, .div = 2 }, + { .val = 2, .div = 3 }, + { .val = 9, .div = 4 }, + { .val = 10, .div = 6 }, + { .val = 11, .div = 8 }, + { .val = 13, .div = 12 }, + { .val = 15, .div = 16 }, + { /* sentinel */ }, +}; + +struct samsung_div_clock s3c2443_dividers[] __initdata = { + DIV_T(ARMDIV, "armdiv", "msysclk", CLKDIV0, 9, 4, armdiv_s3c2443_d), + DIV(0, "div_cam", "esysclk", CLKDIV1, 26, 4), +}; + +struct samsung_gate_clock s3c2443_gates[] __initdata = { + GATE(SCLK_HSSPI0, "sclk_hsspi0", "div_hsspi0_epll", SCLKCON, 14, 0, 0), + GATE(SCLK_CAM, "sclk_cam", "div_cam", SCLKCON, 11, 0, 0), + GATE(HCLK_CFC, "cfc", "hclk", HCLKCON, 17, CLK_IGNORE_UNUSED, 0), + GATE(HCLK_CAM, "cam", "hclk", HCLKCON, 8, 0, 0), + GATE(PCLK_SPI1, "spi1", "pclk", PCLKCON, 15, 0, 0), + GATE(PCLK_SDI, "sdi", "pclk", PCLKCON, 5, 0, 0), +}; + +struct samsung_clock_alias s3c2443_aliases[] __initdata = { + ALIAS(SCLK_HSSPI0, "s3c2443-spi.0", "spi_busclk2"), + ALIAS(SCLK_HSMMC1, "s3c-sdhci.1", "mmc_busclk.2"), + ALIAS(SCLK_CAM, NULL, "camif-upll"), + ALIAS(PCLK_SPI1, "s3c2410-spi.0", "spi"), + ALIAS(PCLK_SDI, NULL, "sdi"), + ALIAS(HCLK_CFC, NULL, "cfc"), + ALIAS(ARMDIV, NULL, "armdiv"), +}; + +/* S3C2450 specific clocks */ + +PNAME(s3c2450_cam_p) = { "div_cam", "hclk" }; +PNAME(s3c2450_hsspi1_p) = { "hsspi1_epll", "hsspi1_mpll" }; +PNAME(i2s1_p) = { "div_i2s1", "ext_i2s", "epllref", "epllref" }; + +struct samsung_div_clock s3c2450_dividers[] __initdata = { + DIV(0, "div_cam", "esysclk", CLKDIV1, 26, 4), + DIV(0, "div_hsspi1_epll", "esysclk", CLKDIV2, 24, 2), + DIV(0, "div_hsspi1_mpll", "msysclk", CLKDIV2, 16, 4), + DIV(0, "div_i2s1", "esysclk", CLKDIV2, 12, 4), +}; + +struct samsung_mux_clock s3c2450_muxes[] __initdata = { + MUX(0, "mux_cam", s3c2450_cam_p, CLKSRC, 20, 1), + MUX(MUX_HSSPI1, "mux_hsspi1", s3c2450_hsspi1_p, CLKSRC, 19, 1), + MUX(0, "mux_i2s1", i2s1_p, CLKSRC, 12, 2), +}; + +struct samsung_gate_clock s3c2450_gates[] __initdata = { + GATE(SCLK_I2S1, "sclk_i2s1", "div_i2s1", SCLKCON, 5, 0, 0), + GATE(HCLK_CFC, "cfc", "hclk", HCLKCON, 17, 0, 0), + GATE(HCLK_CAM, "cam", "hclk", HCLKCON, 8, 0, 0), + GATE(HCLK_DMA7, "dma7", "hclk", HCLKCON, 7, CLK_IGNORE_UNUSED, 0), + GATE(HCLK_DMA6, "dma6", "hclk", HCLKCON, 6, CLK_IGNORE_UNUSED, 0), + GATE(PCLK_I2S1, "i2s1", "pclk", PCLKCON, 17, 0, 0), + GATE(PCLK_I2C1, "i2c1", "pclk", PCLKCON, 16, 0, 0), + GATE(PCLK_SPI1, "spi1", "pclk", PCLKCON, 14, 0, 0), +}; + +struct samsung_clock_alias s3c2450_aliases[] __initdata = { + ALIAS(PCLK_SPI1, "s3c2443-spi.1", "spi"), + ALIAS(PCLK_SPI1, "s3c2443-spi.1", "spi_busclk0"), + ALIAS(MUX_HSSPI1, "s3c2443-spi.1", "spi_busclk2"), + ALIAS(PCLK_I2C1, "s3c2410-i2c.1", "i2c"), +}; + +/* + * fixed rate clocks generated outside the soc + * Only necessary until the devicetree-move is complete + */ +struct samsung_fixed_rate_clock s3c2443_common_frate_clks[] __initdata = { + FRATE(0, "xti", NULL, CLK_IS_ROOT, 0), + FRATE(0, "ext", NULL, CLK_IS_ROOT, 0), + FRATE(0, "ext_i2s", NULL, CLK_IS_ROOT, 0), + FRATE(0, "ext_uart", NULL, CLK_IS_ROOT, 0), +}; + +static void __init s3c2443_common_clk_register_fixed_ext(unsigned long xti_f) +{ + s3c2443_common_frate_clks[0].fixed_rate = xti_f; + samsung_clk_register_fixed_rate(s3c2443_common_frate_clks, + ARRAY_SIZE(s3c2443_common_frate_clks)); +} + +void __init s3c2443_common_clk_init(struct device_node *np, unsigned long xti_f, + int current_soc, + void __iomem *base) +{ + reg_base = base; + + if (np) { + reg_base = of_iomap(np, 0); + if (!reg_base) + panic("%s: failed to map registers\n", __func__); + } + + samsung_clk_init(np, reg_base, NR_CLKS); + + /* Register external clocks only in non-dt cases */ + if (!np) + s3c2443_common_clk_register_fixed_ext(xti_f); + + /* Register PLLs. */ + if (current_soc == S3C2416 || current_soc == S3C2450) + samsung_clk_register_pll(s3c2416_pll_clks, + ARRAY_SIZE(s3c2416_pll_clks), reg_base); + else + samsung_clk_register_pll(s3c2443_pll_clks, + ARRAY_SIZE(s3c2443_pll_clks), reg_base); + + /* Register common internal clocks. */ + samsung_clk_register_mux(s3c2443_common_muxes, + ARRAY_SIZE(s3c2443_common_muxes)); + samsung_clk_register_div(s3c2443_common_dividers, + ARRAY_SIZE(s3c2443_common_dividers)); + samsung_clk_register_gate(s3c2443_common_gates, + ARRAY_SIZE(s3c2443_common_gates)); + samsung_clk_register_alias(s3c2443_common_aliases, + ARRAY_SIZE(s3c2443_common_aliases)); + + /* Register SoC-specific clocks. */ + switch (current_soc) { + case S3C2450: + samsung_clk_register_div(s3c2450_dividers, + ARRAY_SIZE(s3c2450_dividers)); + samsung_clk_register_mux(s3c2450_muxes, + ARRAY_SIZE(s3c2450_muxes)); + samsung_clk_register_gate(s3c2450_gates, + ARRAY_SIZE(s3c2450_gates)); + samsung_clk_register_alias(s3c2450_aliases, + ARRAY_SIZE(s3c2450_aliases)); + /* fall through, as s3c2450 extends the s3c2416 clocks */ + case S3C2416: + samsung_clk_register_div(s3c2416_dividers, + ARRAY_SIZE(s3c2416_dividers)); + samsung_clk_register_mux(s3c2416_muxes, + ARRAY_SIZE(s3c2416_muxes)); + samsung_clk_register_gate(s3c2416_gates, + ARRAY_SIZE(s3c2416_gates)); + samsung_clk_register_alias(s3c2416_aliases, + ARRAY_SIZE(s3c2416_aliases)); + break; + case S3C2443: + samsung_clk_register_div(s3c2443_dividers, + ARRAY_SIZE(s3c2443_dividers)); + samsung_clk_register_gate(s3c2443_gates, + ARRAY_SIZE(s3c2443_gates)); + samsung_clk_register_alias(s3c2443_aliases, + ARRAY_SIZE(s3c2443_aliases)); + break; + } + + s3c2443_clk_sleep_init(); +} + +static void __init s3c2416_clk_init(struct device_node *np) +{ + s3c2443_common_clk_init(np, 0, S3C2416, 0); +} +CLK_OF_DECLARE(s3c2416_clk, "samsung,s3c2416-clock", s3c2416_clk_init); + +static void __init s3c2443_clk_init(struct device_node *np) +{ + s3c2443_common_clk_init(np, 0, S3C2443, 0); +} +CLK_OF_DECLARE(s3c2443_clk, "samsung,s3c2443-clock", s3c2443_clk_init); + +static void __init s3c2450_clk_init(struct device_node *np) +{ + s3c2443_common_clk_init(np, 0, S3C2450, 0); +} +CLK_OF_DECLARE(s3c2450_clk, "samsung,s3c2450-clock", s3c2450_clk_init); diff --git a/include/dt-bindings/clock/s3c2443.h b/include/dt-bindings/clock/s3c2443.h new file mode 100644 index 000000000000..37e66b054d64 --- /dev/null +++ b/include/dt-bindings/clock/s3c2443.h @@ -0,0 +1,92 @@ +/* + * Copyright (c) 2013 Heiko Stuebner + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * Device Tree binding constants clock controllers of Samsung S3C2443 and later. + */ + +#ifndef _DT_BINDINGS_CLOCK_SAMSUNG_S3C2443_CLOCK_H +#define _DT_BINDINGS_CLOCK_SAMSUNG_S3C2443_CLOCK_H + +/* + * Let each exported clock get a unique index, which is used on DT-enabled + * platforms to lookup the clock from a clock specifier. These indices are + * therefore considered an ABI and so must not be changed. This implies + * that new clocks should be added either in free spaces between clock groups + * or at the end. + */ + +/* Core clocks. */ +#define MSYSCLK 1 +#define ESYSCLK 2 +#define ARMDIV 3 +#define ARMCLK 4 +#define HCLK 5 +#define PCLK 6 + +/* Special clocks */ +#define SCLK_HSSPI0 16 +#define SCLK_FIMD 17 +#define SCLK_I2S0 18 +#define SCLK_I2S1 19 +#define SCLK_HSMMC1 20 +#define SCLK_HSMMC_EXT 21 +#define SCLK_CAM 22 +#define SCLK_UART 23 +#define SCLK_USBH 24 + +/* Muxes */ +#define MUX_HSSPI0 32 +#define MUX_HSSPI1 33 +#define MUX_HSMMC0 34 +#define MUX_HSMMC1 35 + +/* hclk-gates */ +#define HCLK_DMA0 48 +#define HCLK_DMA1 49 +#define HCLK_DMA2 50 +#define HCLK_DMA3 51 +#define HCLK_DMA4 52 +#define HCLK_DMA5 53 +#define HCLK_DMA6 54 +#define HCLK_DMA7 55 +#define HCLK_CAM 56 +#define HCLK_LCD 57 +#define HCLK_USBH 58 +#define HCLK_USBD 59 +#define HCLK_IROM 60 +#define HCLK_HSMMC0 61 +#define HCLK_HSMMC1 62 +#define HCLK_CFC 63 +#define HCLK_SSMC 64 +#define HCLK_DRAM 65 +#define HCLK_2D 66 + +/* pclk-gates */ +#define PCLK_UART0 72 +#define PCLK_UART1 73 +#define PCLK_UART2 74 +#define PCLK_UART3 75 +#define PCLK_I2C0 76 +#define PCLK_SDI 77 +#define PCLK_SPI0 78 +#define PCLK_ADC 79 +#define PCLK_AC97 80 +#define PCLK_I2S0 81 +#define PCLK_PWM 82 +#define PCLK_WDT 83 +#define PCLK_RTC 84 +#define PCLK_GPIO 85 +#define PCLK_SPI1 86 +#define PCLK_CHIPID 87 +#define PCLK_I2C1 88 +#define PCLK_I2S1 89 +#define PCLK_PCM 90 + +/* Total number of clocks. */ +#define NR_CLKS (PCLK_PCM + 1) + +#endif /* _DT_BINDINGS_CLOCK_SAMSUNG_S3C2443_CLOCK_H */ -- cgit v1.2.3 From 5ab9a428cf1d118779554b6a20161d7b339310db Mon Sep 17 00:00:00 2001 From: Heiko Stuebner Date: Wed, 19 Feb 2014 09:25:54 +0900 Subject: ARM: S3C24XX: prevent conflicts between ccf and non-ccf s3c24xx-socs As the conversion to the common-clock-framework is done in multiple steps, it is necessary to prevent conflicts between the different struct clk implementations. For this include the s3c24xx_setup_clocks function only when SAMSUNG_CLOCK is selected and make the socs we don't convert this time explicitly depend on SAMSUNG_CLOCK, which gets only selected automatically if COMMON_CLK is not enabled. Signed-off-by: Heiko Stuebner Reviewed-by: Tomasz Figa Signed-off-by: Kukjin Kim --- arch/arm/mach-s3c24xx/Kconfig | 4 ++++ arch/arm/mach-s3c24xx/common.c | 2 ++ 2 files changed, 6 insertions(+) diff --git a/arch/arm/mach-s3c24xx/Kconfig b/arch/arm/mach-s3c24xx/Kconfig index abf9179c9d03..f10af7faec98 100644 --- a/arch/arm/mach-s3c24xx/Kconfig +++ b/arch/arm/mach-s3c24xx/Kconfig @@ -25,6 +25,7 @@ comment "S3C24XX SoCs" config CPU_S3C2410 bool "SAMSUNG S3C2410" default y + depends on SAMSUNG_CLOCK select CPU_ARM920T select CPU_LLSERIAL_S3C2410 select S3C2410_CLOCK @@ -38,6 +39,7 @@ config CPU_S3C2410 config CPU_S3C2412 bool "SAMSUNG S3C2412" + depends on SAMSUNG_CLOCK select CPU_ARM926T select CPU_LLSERIAL_S3C2440 select S3C2412_DMA if S3C24XX_DMA @@ -58,6 +60,7 @@ config CPU_S3C2416 config CPU_S3C2440 bool "SAMSUNG S3C2440" + depends on SAMSUNG_CLOCK select CPU_ARM920T select CPU_LLSERIAL_S3C2440 select S3C2410_CLOCK @@ -68,6 +71,7 @@ config CPU_S3C2440 config CPU_S3C2442 bool "SAMSUNG S3C2442" + depends on SAMSUNG_CLOCK select CPU_ARM920T select CPU_LLSERIAL_S3C2440 select S3C2410_CLOCK diff --git a/arch/arm/mach-s3c24xx/common.c b/arch/arm/mach-s3c24xx/common.c index 1bc8e73c94f9..0fc6641ac57d 100644 --- a/arch/arm/mach-s3c24xx/common.c +++ b/arch/arm/mach-s3c24xx/common.c @@ -318,6 +318,7 @@ struct s3c24xx_uart_resources s3c2410_uart_resources[] __initdata = { /* initialise all the clocks */ +#ifdef CONFIG_SAMSUNG_CLOCK void __init_or_cpufreq s3c24xx_setup_clocks(unsigned long fclk, unsigned long hclk, unsigned long pclk) @@ -330,6 +331,7 @@ void __init_or_cpufreq s3c24xx_setup_clocks(unsigned long fclk, clk_p.rate = pclk; clk_f.rate = fclk; } +#endif #if defined(CONFIG_CPU_S3C2410) || defined(CONFIG_CPU_S3C2412) || \ defined(CONFIG_CPU_S3C2440) || defined(CONFIG_CPU_S3C2442) -- cgit v1.2.3 From 8cb28748154db139180ea4e24252530aecc3745b Mon Sep 17 00:00:00 2001 From: Heiko Stuebner Date: Wed, 19 Feb 2014 09:26:17 +0900 Subject: ARM: dts: add clock data for s3c2416 This adds the clock controller itself, the xti clock on the smdk2416 as well as the clock references in the individual device nodes. Signed-off-by: Heiko Stuebner Reviewed-by: Tomasz Figa Signed-off-by: Kukjin Kim --- arch/arm/boot/dts/s3c2416-smdk2416.dts | 13 +++++++++++ arch/arm/boot/dts/s3c2416.dtsi | 42 ++++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+) diff --git a/arch/arm/boot/dts/s3c2416-smdk2416.dts b/arch/arm/boot/dts/s3c2416-smdk2416.dts index 59594cf15998..ea92fd69529a 100644 --- a/arch/arm/boot/dts/s3c2416-smdk2416.dts +++ b/arch/arm/boot/dts/s3c2416-smdk2416.dts @@ -19,6 +19,19 @@ reg = <0x30000000 0x4000000>; }; + clocks { + compatible = "simple-bus"; + #address-cells = <1>; + #size-cells = <1>; + + xti: xti { + compatible = "fixed-clock"; + clock-frequency = <12000000>; + clock-output-names = "xti"; + #clock-cells = <0>; + }; + }; + serial@50000000 { status = "okay"; pinctrl-names = "default"; diff --git a/arch/arm/boot/dts/s3c2416.dtsi b/arch/arm/boot/dts/s3c2416.dtsi index e6555bdd81b8..955e4a4f8c31 100644 --- a/arch/arm/boot/dts/s3c2416.dtsi +++ b/arch/arm/boot/dts/s3c2416.dtsi @@ -8,6 +8,7 @@ * published by the Free Software Foundation. */ +#include #include "s3c24xx.dtsi" #include "s3c2416-pinctrl.dtsi" @@ -28,26 +29,53 @@ compatible = "samsung,s3c2416-irq"; }; + clocks: clock-controller@0x4c000000 { + compatible = "samsung,s3c2416-clock"; + reg = <0x4c000000 0x40>; + #clock-cells = <1>; + }; + pinctrl@56000000 { compatible = "samsung,s3c2416-pinctrl"; }; + timer@51000000 { + clocks = <&clocks PCLK_PWM>; + clock-names = "timers"; + }; + serial@50000000 { compatible = "samsung,s3c2440-uart"; + clock-names = "uart", "clk_uart_baud2", + "clk_uart_baud3"; + clocks = <&clocks PCLK_UART0>, <&clocks PCLK_UART0>, + <&clocks SCLK_UART>; }; serial@50004000 { compatible = "samsung,s3c2440-uart"; + clock-names = "uart", "clk_uart_baud2", + "clk_uart_baud3"; + clocks = <&clocks PCLK_UART1>, <&clocks PCLK_UART1>, + <&clocks SCLK_UART>; }; serial@50008000 { compatible = "samsung,s3c2440-uart"; + clock-names = "uart", "clk_uart_baud2", + "clk_uart_baud3"; + clocks = <&clocks PCLK_UART2>, <&clocks PCLK_UART2>, + <&clocks SCLK_UART>; }; serial@5000C000 { compatible = "samsung,s3c2440-uart"; reg = <0x5000C000 0x4000>; interrupts = <1 18 24 4>, <1 18 25 4>; + clock-names = "uart", "clk_uart_baud2", + "clk_uart_baud3"; + clocks = <&clocks PCLK_UART3>, <&clocks PCLK_UART3>, + <&clocks SCLK_UART>; status = "disabled"; }; @@ -55,6 +83,10 @@ compatible = "samsung,s3c6410-sdhci"; reg = <0x4AC00000 0x100>; interrupts = <0 0 21 3>; + clock-names = "hsmmc", "mmc_busclk.0", + "mmc_busclk.2"; + clocks = <&clocks HCLK_HSMMC0>, <&clocks HCLK_HSMMC0>, + <&clocks MUX_HSMMC0>; status = "disabled"; }; @@ -62,18 +94,28 @@ compatible = "samsung,s3c6410-sdhci"; reg = <0x4A800000 0x100>; interrupts = <0 0 20 3>; + clock-names = "hsmmc", "mmc_busclk.0", + "mmc_busclk.2"; + clocks = <&clocks HCLK_HSMMC1>, <&clocks HCLK_HSMMC1>, + <&clocks MUX_HSMMC1>; status = "disabled"; }; watchdog@53000000 { interrupts = <1 9 27 3>; + clocks = <&clocks PCLK_WDT>; + clock-names = "watchdog"; }; rtc@57000000 { compatible = "samsung,s3c2416-rtc"; + clocks = <&clocks PCLK_RTC>; + clock-names = "rtc"; }; i2c@54000000 { compatible = "samsung,s3c2440-i2c"; + clocks = <&clocks PCLK_I2C0>; + clock-names = "i2c"; }; }; -- cgit v1.2.3 From dfc0f5099a83f8633fc4480e2f0e8e5f6ac1331d Mon Sep 17 00:00:00 2001 From: Heiko Stuebner Date: Wed, 19 Feb 2014 09:26:21 +0900 Subject: ARM: S3C24XX: Convert s3c2416 and s3c2443 to common clock framework This converts the mentioned platforms to use the newly introduced driver for the common clock framework for them. With this the whole legacy clock structure can go away too. Signed-off-by: Heiko Stuebner Reviewed-by: Tomasz Figa Signed-off-by: Kukjin Kim --- arch/arm/mach-s3c24xx/Kconfig | 14 +- arch/arm/mach-s3c24xx/Makefile | 5 +- arch/arm/mach-s3c24xx/clock-s3c2416.c | 171 -------- arch/arm/mach-s3c24xx/clock-s3c2443.c | 212 ---------- arch/arm/mach-s3c24xx/common-s3c2443.c | 675 -------------------------------- arch/arm/mach-s3c24xx/common.c | 16 +- arch/arm/mach-s3c24xx/common.h | 6 + arch/arm/mach-s3c24xx/mach-s3c2416-dt.c | 38 +- arch/arm/mach-s3c24xx/mach-smdk2416.c | 9 +- arch/arm/mach-s3c24xx/mach-smdk2443.c | 9 +- 10 files changed, 41 insertions(+), 1114 deletions(-) delete mode 100644 arch/arm/mach-s3c24xx/clock-s3c2416.c delete mode 100644 arch/arm/mach-s3c24xx/clock-s3c2443.c delete mode 100644 arch/arm/mach-s3c24xx/common-s3c2443.c diff --git a/arch/arm/mach-s3c24xx/Kconfig b/arch/arm/mach-s3c24xx/Kconfig index f10af7faec98..52f1c40ccf07 100644 --- a/arch/arm/mach-s3c24xx/Kconfig +++ b/arch/arm/mach-s3c24xx/Kconfig @@ -49,12 +49,12 @@ config CPU_S3C2412 config CPU_S3C2416 bool "SAMSUNG S3C2416/S3C2450" + select COMMON_CLK select CPU_ARM926T select CPU_LLSERIAL_S3C2440 select S3C2416_PM if PM - select S3C2443_COMMON + select S3C2443_COMMON_CLK select S3C2443_DMA if S3C24XX_DMA - select SAMSUNG_CLKSRC help Support for the S3C2416 SoC from the S3C24XX line @@ -87,11 +87,11 @@ config CPU_S3C244X config CPU_S3C2443 bool "SAMSUNG S3C2443" + select COMMON_CLK select CPU_ARM920T select CPU_LLSERIAL_S3C2440 - select S3C2443_COMMON + select S3C2443_COMMON_CLK select S3C2443_DMA if S3C24XX_DMA - select SAMSUNG_CLKSRC help Support for the S3C2443 SoC from the S3C24XX line @@ -645,12 +645,6 @@ endif # CPU_S3C2442 if CPU_S3C2443 || CPU_S3C2416 -config S3C2443_COMMON - bool - help - Common code for the S3C2443 and similar processors, which includes - the S3C2416 and S3C2450. - config S3C2443_COMMON_CLK bool help diff --git a/arch/arm/mach-s3c24xx/Makefile b/arch/arm/mach-s3c24xx/Makefile index 7f54e5b954ca..ba0e5475a807 100644 --- a/arch/arm/mach-s3c24xx/Makefile +++ b/arch/arm/mach-s3c24xx/Makefile @@ -26,7 +26,7 @@ obj-$(CONFIG_S3C2412_DMA) += dma-s3c2412.o obj-$(CONFIG_S3C2412_PM) += pm-s3c2412.o obj-$(CONFIG_S3C2412_PM_SLEEP) += sleep-s3c2412.o -obj-$(CONFIG_CPU_S3C2416) += s3c2416.o clock-s3c2416.o +obj-$(CONFIG_CPU_S3C2416) += s3c2416.o obj-$(CONFIG_S3C2416_PM) += pm-s3c2416.o obj-$(CONFIG_CPU_S3C2440) += s3c2440.o clock-s3c2440.o @@ -36,7 +36,7 @@ obj-$(CONFIG_S3C2440_DMA) += dma-s3c2440.o obj-$(CONFIG_S3C2440_PLL_12000000) += pll-s3c2440-12000000.o obj-$(CONFIG_S3C2440_PLL_16934400) += pll-s3c2440-16934400.o -obj-$(CONFIG_CPU_S3C2443) += s3c2443.o clock-s3c2443.o +obj-$(CONFIG_CPU_S3C2443) += s3c2443.o # PM @@ -53,7 +53,6 @@ obj-$(CONFIG_S3C2410_CPUFREQ_UTILS) += cpufreq-utils.o obj-$(CONFIG_S3C2410_IOTIMING) += iotiming-s3c2410.o obj-$(CONFIG_S3C2412_IOTIMING) += iotiming-s3c2412.o -obj-$(CONFIG_S3C2443_COMMON) += common-s3c2443.o obj-$(CONFIG_S3C2443_DMA) += dma-s3c2443.o # diff --git a/arch/arm/mach-s3c24xx/clock-s3c2416.c b/arch/arm/mach-s3c24xx/clock-s3c2416.c deleted file mode 100644 index d421a72920a5..000000000000 --- a/arch/arm/mach-s3c24xx/clock-s3c2416.c +++ /dev/null @@ -1,171 +0,0 @@ -/* linux/arch/arm/mach-s3c2416/clock.c - * - * Copyright (c) 2010 Simtec Electronics - * Copyright (c) 2010 Ben Dooks - * - * S3C2416 Clock control support - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - */ - -#include -#include - -#include -#include -#include - -#include -#include - -#include - -#include -#include - -/* armdiv - * - * this clock is sourced from msysclk and can have a number of - * divider values applied to it to then be fed into armclk. - * The real clock definition is done in s3c2443-clock.c, - * only the armdiv divisor table must be defined here. -*/ - -static unsigned int armdiv[8] = { - [0] = 1, - [1] = 2, - [2] = 3, - [3] = 4, - [5] = 6, - [7] = 8, -}; - -static struct clksrc_clk hsspi_eplldiv = { - .clk = { - .name = "hsspi-eplldiv", - .parent = &clk_esysclk.clk, - .ctrlbit = (1 << 14), - .enable = s3c2443_clkcon_enable_s, - }, - .reg_div = { .reg = S3C2443_CLKDIV1, .size = 2, .shift = 24 }, -}; - -static struct clk *hsspi_sources[] = { - [0] = &hsspi_eplldiv.clk, - [1] = NULL, /* to fix */ -}; - -static struct clksrc_clk hsspi_mux = { - .clk = { - .name = "hsspi-if", - }, - .sources = &(struct clksrc_sources) { - .sources = hsspi_sources, - .nr_sources = ARRAY_SIZE(hsspi_sources), - }, - .reg_src = { .reg = S3C2443_CLKSRC, .size = 1, .shift = 18 }, -}; - -static struct clksrc_clk hsmmc_div[] = { - [0] = { - .clk = { - .name = "hsmmc-div", - .devname = "s3c-sdhci.0", - .parent = &clk_esysclk.clk, - }, - .reg_div = { .reg = S3C2416_CLKDIV2, .size = 2, .shift = 6 }, - }, - [1] = { - .clk = { - .name = "hsmmc-div", - .devname = "s3c-sdhci.1", - .parent = &clk_esysclk.clk, - }, - .reg_div = { .reg = S3C2443_CLKDIV1, .size = 2, .shift = 6 }, - }, -}; - -static struct clksrc_clk hsmmc_mux0 = { - .clk = { - .name = "hsmmc-if", - .devname = "s3c-sdhci.0", - .ctrlbit = (1 << 6), - .enable = s3c2443_clkcon_enable_s, - }, - .sources = &(struct clksrc_sources) { - .nr_sources = 2, - .sources = (struct clk * []) { - [0] = &hsmmc_div[0].clk, - [1] = NULL, /* to fix */ - }, - }, - .reg_src = { .reg = S3C2443_CLKSRC, .size = 1, .shift = 16 }, -}; - -static struct clksrc_clk hsmmc_mux1 = { - .clk = { - .name = "hsmmc-if", - .devname = "s3c-sdhci.1", - .ctrlbit = (1 << 12), - .enable = s3c2443_clkcon_enable_s, - }, - .sources = &(struct clksrc_sources) { - .nr_sources = 2, - .sources = (struct clk * []) { - [0] = &hsmmc_div[1].clk, - [1] = NULL, /* to fix */ - }, - }, - .reg_src = { .reg = S3C2443_CLKSRC, .size = 1, .shift = 17 }, -}; - -static struct clk hsmmc0_clk = { - .name = "hsmmc", - .devname = "s3c-sdhci.0", - .parent = &clk_h, - .enable = s3c2443_clkcon_enable_h, - .ctrlbit = S3C2416_HCLKCON_HSMMC0, -}; - -static struct clksrc_clk *clksrcs[] __initdata = { - &hsspi_eplldiv, - &hsspi_mux, - &hsmmc_div[0], - &hsmmc_div[1], - &hsmmc_mux0, - &hsmmc_mux1, -}; - -static struct clk_lookup s3c2416_clk_lookup[] = { - CLKDEV_INIT("s3c-sdhci.0", "mmc_busclk.0", &hsmmc0_clk), - CLKDEV_INIT("s3c-sdhci.0", "mmc_busclk.2", &hsmmc_mux0.clk), - CLKDEV_INIT("s3c-sdhci.1", "mmc_busclk.2", &hsmmc_mux1.clk), - /* s3c2443-spi.0 is used on s3c2416 and s3c2450 as well */ - CLKDEV_INIT("s3c2443-spi.0", "spi_busclk2", &hsspi_mux.clk), -}; - -void __init s3c2416_init_clocks(int xtal) -{ - u32 epllcon = __raw_readl(S3C2443_EPLLCON); - u32 epllcon1 = __raw_readl(S3C2443_EPLLCON+4); - int ptr; - - /* s3c2416 EPLL compatible with s3c64xx */ - clk_epll.rate = s3c_get_pll6553x(xtal, epllcon, epllcon1); - - clk_epll.parent = &clk_epllref.clk; - - s3c2443_common_init_clocks(xtal, s3c2416_get_pll, - armdiv, ARRAY_SIZE(armdiv), - S3C2416_CLKDIV0_ARMDIV_MASK); - - for (ptr = 0; ptr < ARRAY_SIZE(clksrcs); ptr++) - s3c_register_clksrc(clksrcs[ptr], 1); - - s3c24xx_register_clock(&hsmmc0_clk); - clkdev_add_table(s3c2416_clk_lookup, ARRAY_SIZE(s3c2416_clk_lookup)); - -} diff --git a/arch/arm/mach-s3c24xx/clock-s3c2443.c b/arch/arm/mach-s3c24xx/clock-s3c2443.c deleted file mode 100644 index 76cd31f7804e..000000000000 --- a/arch/arm/mach-s3c24xx/clock-s3c2443.c +++ /dev/null @@ -1,212 +0,0 @@ -/* linux/arch/arm/mach-s3c2443/clock.c - * - * Copyright (c) 2007, 2010 Simtec Electronics - * Ben Dooks - * - * S3C2443 Clock control support - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include - -#include - -#include - -#include -#include -#include - -/* We currently have to assume that the system is running - * from the XTPll input, and that all ***REFCLKs are being - * fed from it, as we cannot read the state of OM[4] from - * software. - * - * It would be possible for each board initialisation to - * set the correct muxing at initialisation -*/ - -/* clock selections */ - -/* armdiv - * - * this clock is sourced from msysclk and can have a number of - * divider values applied to it to then be fed into armclk. - * The real clock definition is done in s3c2443-clock.c, - * only the armdiv divisor table must be defined here. -*/ - -static unsigned int armdiv[16] = { - [S3C2443_CLKDIV0_ARMDIV_1 >> S3C2443_CLKDIV0_ARMDIV_SHIFT] = 1, - [S3C2443_CLKDIV0_ARMDIV_2 >> S3C2443_CLKDIV0_ARMDIV_SHIFT] = 2, - [S3C2443_CLKDIV0_ARMDIV_3 >> S3C2443_CLKDIV0_ARMDIV_SHIFT] = 3, - [S3C2443_CLKDIV0_ARMDIV_4 >> S3C2443_CLKDIV0_ARMDIV_SHIFT] = 4, - [S3C2443_CLKDIV0_ARMDIV_6 >> S3C2443_CLKDIV0_ARMDIV_SHIFT] = 6, - [S3C2443_CLKDIV0_ARMDIV_8 >> S3C2443_CLKDIV0_ARMDIV_SHIFT] = 8, - [S3C2443_CLKDIV0_ARMDIV_12 >> S3C2443_CLKDIV0_ARMDIV_SHIFT] = 12, - [S3C2443_CLKDIV0_ARMDIV_16 >> S3C2443_CLKDIV0_ARMDIV_SHIFT] = 16, -}; - -/* hsspi - * - * high-speed spi clock, sourced from esysclk -*/ - -static struct clksrc_clk clk_hsspi = { - .clk = { - .name = "hsspi-if", - .parent = &clk_esysclk.clk, - .ctrlbit = S3C2443_SCLKCON_HSSPICLK, - .enable = s3c2443_clkcon_enable_s, - }, - .reg_div = { .reg = S3C2443_CLKDIV1, .size = 2, .shift = 4 }, -}; - - -/* clk_hsmcc_div - * - * this clock is sourced from epll, and is fed through a divider, - * to a mux controlled by sclkcon where either it or a extclk can - * be fed to the hsmmc block -*/ - -static struct clksrc_clk clk_hsmmc_div = { - .clk = { - .name = "hsmmc-div", - .devname = "s3c-sdhci.1", - .parent = &clk_esysclk.clk, - }, - .reg_div = { .reg = S3C2443_CLKDIV1, .size = 2, .shift = 6 }, -}; - -static int s3c2443_setparent_hsmmc(struct clk *clk, struct clk *parent) -{ - unsigned long clksrc = __raw_readl(S3C2443_SCLKCON); - - clksrc &= ~(S3C2443_SCLKCON_HSMMCCLK_EXT | - S3C2443_SCLKCON_HSMMCCLK_EPLL); - - if (parent == &clk_epll) - clksrc |= S3C2443_SCLKCON_HSMMCCLK_EPLL; - else if (parent == &clk_ext) - clksrc |= S3C2443_SCLKCON_HSMMCCLK_EXT; - else - return -EINVAL; - - if (clk->usage > 0) { - __raw_writel(clksrc, S3C2443_SCLKCON); - } - - clk->parent = parent; - return 0; -} - -static int s3c2443_enable_hsmmc(struct clk *clk, int enable) -{ - return s3c2443_setparent_hsmmc(clk, clk->parent); -} - -static struct clk clk_hsmmc = { - .name = "hsmmc-if", - .devname = "s3c-sdhci.1", - .parent = &clk_hsmmc_div.clk, - .enable = s3c2443_enable_hsmmc, - .ops = &(struct clk_ops) { - .set_parent = s3c2443_setparent_hsmmc, - }, -}; - -/* standard clock definitions */ - -static struct clk init_clocks_off[] = { - { - .name = "sdi", - .parent = &clk_p, - .enable = s3c2443_clkcon_enable_p, - .ctrlbit = S3C2443_PCLKCON_SDI, - }, { - .name = "spi", - .devname = "s3c2410-spi.0", - .parent = &clk_p, - .enable = s3c2443_clkcon_enable_p, - .ctrlbit = S3C2443_PCLKCON_SPI1, - } -}; - -/* clocks to add straight away */ - -static struct clksrc_clk *clksrcs[] __initdata = { - &clk_hsspi, - &clk_hsmmc_div, -}; - -static struct clk *clks[] __initdata = { - &clk_hsmmc, -}; - -static struct clk_lookup s3c2443_clk_lookup[] = { - CLKDEV_INIT("s3c-sdhci.1", "mmc_busclk.2", &clk_hsmmc), - CLKDEV_INIT("s3c2443-spi.0", "spi_busclk2", &clk_hsspi.clk), -}; - -void __init s3c2443_init_clocks(int xtal) -{ - unsigned long epllcon = __raw_readl(S3C2443_EPLLCON); - int ptr; - - clk_epll.rate = s3c2443_get_epll(epllcon, xtal); - clk_epll.parent = &clk_epllref.clk; - - s3c2443_common_init_clocks(xtal, s3c2443_get_mpll, - armdiv, ARRAY_SIZE(armdiv), - S3C2443_CLKDIV0_ARMDIV_MASK); - - s3c24xx_register_clocks(clks, ARRAY_SIZE(clks)); - - for (ptr = 0; ptr < ARRAY_SIZE(clksrcs); ptr++) - s3c_register_clksrc(clksrcs[ptr], 1); - - /* We must be careful disabling the clocks we are not intending to - * be using at boot time, as subsystems such as the LCD which do - * their own DMA requests to the bus can cause the system to lockup - * if they where in the middle of requesting bus access. - * - * Disabling the LCD clock if the LCD is active is very dangerous, - * and therefore the bootloader should be careful to not enable - * the LCD clock if it is not needed. - */ - - /* install (and disable) the clocks we do not need immediately */ - - s3c_register_clocks(init_clocks_off, ARRAY_SIZE(init_clocks_off)); - s3c_disable_clocks(init_clocks_off, ARRAY_SIZE(init_clocks_off)); - clkdev_add_table(s3c2443_clk_lookup, ARRAY_SIZE(s3c2443_clk_lookup)); -} diff --git a/arch/arm/mach-s3c24xx/common-s3c2443.c b/arch/arm/mach-s3c24xx/common-s3c2443.c deleted file mode 100644 index 65d3eef73090..000000000000 --- a/arch/arm/mach-s3c24xx/common-s3c2443.c +++ /dev/null @@ -1,675 +0,0 @@ -/* - * Common code for SoCs starting with the S3C2443 - * - * Copyright (c) 2007, 2010 Simtec Electronics - * Ben Dooks - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - -#include -#include -#include - -#include - -#include -#include -#include - -#include - - -static int s3c2443_gate(void __iomem *reg, struct clk *clk, int enable) -{ - u32 ctrlbit = clk->ctrlbit; - u32 con = __raw_readl(reg); - - if (enable) - con |= ctrlbit; - else - con &= ~ctrlbit; - - __raw_writel(con, reg); - return 0; -} - -int s3c2443_clkcon_enable_h(struct clk *clk, int enable) -{ - return s3c2443_gate(S3C2443_HCLKCON, clk, enable); -} - -int s3c2443_clkcon_enable_p(struct clk *clk, int enable) -{ - return s3c2443_gate(S3C2443_PCLKCON, clk, enable); -} - -int s3c2443_clkcon_enable_s(struct clk *clk, int enable) -{ - return s3c2443_gate(S3C2443_SCLKCON, clk, enable); -} - -/* mpllref is a direct descendant of clk_xtal by default, but it is not - * elided as the EPLL can be either sourced by the XTAL or EXTCLK and as - * such directly equating the two source clocks is impossible. - */ -static struct clk clk_mpllref = { - .name = "mpllref", - .parent = &clk_xtal, -}; - -static struct clk *clk_epllref_sources[] = { - [0] = &clk_mpllref, - [1] = &clk_mpllref, - [2] = &clk_xtal, - [3] = &clk_ext, -}; - -struct clksrc_clk clk_epllref = { - .clk = { - .name = "epllref", - }, - .sources = &(struct clksrc_sources) { - .sources = clk_epllref_sources, - .nr_sources = ARRAY_SIZE(clk_epllref_sources), - }, - .reg_src = { .reg = S3C2443_CLKSRC, .size = 2, .shift = 7 }, -}; - -/* esysclk - * - * this is sourced from either the EPLL or the EPLLref clock -*/ - -static struct clk *clk_sysclk_sources[] = { - [0] = &clk_epllref.clk, - [1] = &clk_epll, -}; - -struct clksrc_clk clk_esysclk = { - .clk = { - .name = "esysclk", - .parent = &clk_epll, - }, - .sources = &(struct clksrc_sources) { - .sources = clk_sysclk_sources, - .nr_sources = ARRAY_SIZE(clk_sysclk_sources), - }, - .reg_src = { .reg = S3C2443_CLKSRC, .size = 1, .shift = 6 }, -}; - -static unsigned long s3c2443_getrate_mdivclk(struct clk *clk) -{ - unsigned long parent_rate = clk_get_rate(clk->parent); - unsigned long div = __raw_readl(S3C2443_CLKDIV0); - - div &= S3C2443_CLKDIV0_EXTDIV_MASK; - div >>= (S3C2443_CLKDIV0_EXTDIV_SHIFT-1); /* x2 */ - - return parent_rate / (div + 1); -} - -static struct clk clk_mdivclk = { - .name = "mdivclk", - .parent = &clk_mpllref, - .ops = &(struct clk_ops) { - .get_rate = s3c2443_getrate_mdivclk, - }, -}; - -static struct clk *clk_msysclk_sources[] = { - [0] = &clk_mpllref, - [1] = &clk_mpll, - [2] = &clk_mdivclk, - [3] = &clk_mpllref, -}; - -static struct clksrc_clk clk_msysclk = { - .clk = { - .name = "msysclk", - .parent = &clk_xtal, - }, - .sources = &(struct clksrc_sources) { - .sources = clk_msysclk_sources, - .nr_sources = ARRAY_SIZE(clk_msysclk_sources), - }, - .reg_src = { .reg = S3C2443_CLKSRC, .size = 2, .shift = 3 }, -}; - -/* prediv - * - * this divides the msysclk down to pass to h/p/etc. - */ - -static unsigned long s3c2443_prediv_getrate(struct clk *clk) -{ - unsigned long rate = clk_get_rate(clk->parent); - unsigned long clkdiv0 = __raw_readl(S3C2443_CLKDIV0); - - clkdiv0 &= S3C2443_CLKDIV0_PREDIV_MASK; - clkdiv0 >>= S3C2443_CLKDIV0_PREDIV_SHIFT; - - return rate / (clkdiv0 + 1); -} - -static struct clk clk_prediv = { - .name = "prediv", - .parent = &clk_msysclk.clk, - .ops = &(struct clk_ops) { - .get_rate = s3c2443_prediv_getrate, - }, -}; - -/* hclk divider - * - * divides the prediv and provides the hclk. - */ - -static unsigned long s3c2443_hclkdiv_getrate(struct clk *clk) -{ - unsigned long rate = clk_get_rate(clk->parent); - unsigned long clkdiv0 = __raw_readl(S3C2443_CLKDIV0); - - clkdiv0 &= S3C2443_CLKDIV0_HCLKDIV_MASK; - - return rate / (clkdiv0 + 1); -} - -static struct clk_ops clk_h_ops = { - .get_rate = s3c2443_hclkdiv_getrate, -}; - -/* pclk divider - * - * divides the hclk and provides the pclk. - */ - -static unsigned long s3c2443_pclkdiv_getrate(struct clk *clk) -{ - unsigned long rate = clk_get_rate(clk->parent); - unsigned long clkdiv0 = __raw_readl(S3C2443_CLKDIV0); - - clkdiv0 = ((clkdiv0 & S3C2443_CLKDIV0_HALF_PCLK) ? 1 : 0); - - return rate / (clkdiv0 + 1); -} - -static struct clk_ops clk_p_ops = { - .get_rate = s3c2443_pclkdiv_getrate, -}; - -/* armdiv - * - * this clock is sourced from msysclk and can have a number of - * divider values applied to it to then be fed into armclk. -*/ - -static unsigned int *armdiv; -static int nr_armdiv; -static int armdivmask; - -static unsigned long s3c2443_armclk_roundrate(struct clk *clk, - unsigned long rate) -{ - unsigned long parent = clk_get_rate(clk->parent); - unsigned long calc; - unsigned best = 256; /* bigger than any value */ - unsigned div; - int ptr; - - if (!nr_armdiv) - return -EINVAL; - - for (ptr = 0; ptr < nr_armdiv; ptr++) { - div = armdiv[ptr]; - if (div) { - /* cpufreq provides 266mhz as 266666000 not 266666666 */ - calc = (parent / div / 1000) * 1000; - if (calc <= rate && div < best) - best = div; - } - } - - return parent / best; -} - -static unsigned long s3c2443_armclk_getrate(struct clk *clk) -{ - unsigned long rate = clk_get_rate(clk->parent); - unsigned long clkcon0; - int val; - - if (!nr_armdiv || !armdivmask) - return -EINVAL; - - clkcon0 = __raw_readl(S3C2443_CLKDIV0); - clkcon0 &= armdivmask; - val = clkcon0 >> S3C2443_CLKDIV0_ARMDIV_SHIFT; - - return rate / armdiv[val]; -} - -static int s3c2443_armclk_setrate(struct clk *clk, unsigned long rate) -{ - unsigned long parent = clk_get_rate(clk->parent); - unsigned long calc; - unsigned div; - unsigned best = 256; /* bigger than any value */ - int ptr; - int val = -1; - - if (!nr_armdiv || !armdivmask) - return -EINVAL; - - for (ptr = 0; ptr < nr_armdiv; ptr++) { - div = armdiv[ptr]; - if (div) { - /* cpufreq provides 266mhz as 266666000 not 266666666 */ - calc = (parent / div / 1000) * 1000; - if (calc <= rate && div < best) { - best = div; - val = ptr; - } - } - } - - if (val >= 0) { - unsigned long clkcon0; - - clkcon0 = __raw_readl(S3C2443_CLKDIV0); - clkcon0 &= ~armdivmask; - clkcon0 |= val << S3C2443_CLKDIV0_ARMDIV_SHIFT; - __raw_writel(clkcon0, S3C2443_CLKDIV0); - } - - return (val == -1) ? -EINVAL : 0; -} - -static struct clk clk_armdiv = { - .name = "armdiv", - .parent = &clk_msysclk.clk, - .ops = &(struct clk_ops) { - .round_rate = s3c2443_armclk_roundrate, - .get_rate = s3c2443_armclk_getrate, - .set_rate = s3c2443_armclk_setrate, - }, -}; - -/* armclk - * - * this is the clock fed into the ARM core itself, from armdiv or from hclk. - */ - -static struct clk *clk_arm_sources[] = { - [0] = &clk_armdiv, - [1] = &clk_h, -}; - -static struct clksrc_clk clk_arm = { - .clk = { - .name = "armclk", - }, - .sources = &(struct clksrc_sources) { - .sources = clk_arm_sources, - .nr_sources = ARRAY_SIZE(clk_arm_sources), - }, - .reg_src = { .reg = S3C2443_CLKDIV0, .size = 1, .shift = 13 }, -}; - -/* usbhost - * - * usb host bus-clock, usually 48MHz to provide USB bus clock timing -*/ - -static struct clksrc_clk clk_usb_bus_host = { - .clk = { - .name = "usb-bus-host-parent", - .parent = &clk_esysclk.clk, - .ctrlbit = S3C2443_SCLKCON_USBHOST, - .enable = s3c2443_clkcon_enable_s, - }, - .reg_div = { .reg = S3C2443_CLKDIV1, .size = 2, .shift = 4 }, -}; - -/* common clksrc clocks */ - -static struct clksrc_clk clksrc_clks[] = { - { - /* camera interface bus-clock, divided down from esysclk */ - .clk = { - .name = "camif-upll", /* same as 2440 name */ - .parent = &clk_esysclk.clk, - .ctrlbit = S3C2443_SCLKCON_CAMCLK, - .enable = s3c2443_clkcon_enable_s, - }, - .reg_div = { .reg = S3C2443_CLKDIV1, .size = 4, .shift = 26 }, - }, { - .clk = { - .name = "display-if", - .parent = &clk_esysclk.clk, - .ctrlbit = S3C2443_SCLKCON_DISPCLK, - .enable = s3c2443_clkcon_enable_s, - }, - .reg_div = { .reg = S3C2443_CLKDIV1, .size = 8, .shift = 16 }, - }, -}; - -static struct clksrc_clk clk_esys_uart = { - /* ART baud-rate clock sourced from esysclk via a divisor */ - .clk = { - .name = "uartclk", - .parent = &clk_esysclk.clk, - }, - .reg_div = { .reg = S3C2443_CLKDIV1, .size = 4, .shift = 8 }, -}; - -static struct clk clk_i2s_ext = { - .name = "i2s-ext", -}; - -/* i2s_eplldiv - * - * This clock is the output from the I2S divisor of ESYSCLK, and is separate - * from the mux that comes after it (cannot merge into one single clock) -*/ - -static struct clksrc_clk clk_i2s_eplldiv = { - .clk = { - .name = "i2s-eplldiv", - .parent = &clk_esysclk.clk, - }, - .reg_div = { .reg = S3C2443_CLKDIV1, .size = 4, .shift = 12, }, -}; - -/* i2s-ref - * - * i2s bus reference clock, selectable from external, esysclk or epllref - * - * Note, this used to be two clocks, but was compressed into one. -*/ - -static struct clk *clk_i2s_srclist[] = { - [0] = &clk_i2s_eplldiv.clk, - [1] = &clk_i2s_ext, - [2] = &clk_epllref.clk, - [3] = &clk_epllref.clk, -}; - -static struct clksrc_clk clk_i2s = { - .clk = { - .name = "i2s-if", - .ctrlbit = S3C2443_SCLKCON_I2SCLK, - .enable = s3c2443_clkcon_enable_s, - - }, - .sources = &(struct clksrc_sources) { - .sources = clk_i2s_srclist, - .nr_sources = ARRAY_SIZE(clk_i2s_srclist), - }, - .reg_src = { .reg = S3C2443_CLKSRC, .size = 2, .shift = 14 }, -}; - -static struct clk init_clocks_off[] = { - { - .name = "iis", - .parent = &clk_p, - .enable = s3c2443_clkcon_enable_p, - .ctrlbit = S3C2443_PCLKCON_IIS, - }, { - .name = "adc", - .parent = &clk_p, - .enable = s3c2443_clkcon_enable_p, - .ctrlbit = S3C2443_PCLKCON_ADC, - }, { - .name = "i2c", - .parent = &clk_p, - .enable = s3c2443_clkcon_enable_p, - .ctrlbit = S3C2443_PCLKCON_IIC, - } -}; - -static struct clk init_clocks[] = { - { - .name = "dma.0", - .parent = &clk_h, - .enable = s3c2443_clkcon_enable_h, - .ctrlbit = S3C2443_HCLKCON_DMA0, - }, { - .name = "dma.1", - .parent = &clk_h, - .enable = s3c2443_clkcon_enable_h, - .ctrlbit = S3C2443_HCLKCON_DMA1, - }, { - .name = "dma.2", - .parent = &clk_h, - .enable = s3c2443_clkcon_enable_h, - .ctrlbit = S3C2443_HCLKCON_DMA2, - }, { - .name = "dma.3", - .parent = &clk_h, - .enable = s3c2443_clkcon_enable_h, - .ctrlbit = S3C2443_HCLKCON_DMA3, - }, { - .name = "dma.4", - .parent = &clk_h, - .enable = s3c2443_clkcon_enable_h, - .ctrlbit = S3C2443_HCLKCON_DMA4, - }, { - .name = "dma.5", - .parent = &clk_h, - .enable = s3c2443_clkcon_enable_h, - .ctrlbit = S3C2443_HCLKCON_DMA5, - }, { - .name = "gpio", - .parent = &clk_p, - .enable = s3c2443_clkcon_enable_p, - .ctrlbit = S3C2443_PCLKCON_GPIO, - }, { - .name = "usb-host", - .parent = &clk_h, - .enable = s3c2443_clkcon_enable_h, - .ctrlbit = S3C2443_HCLKCON_USBH, - }, { - .name = "usb-device", - .parent = &clk_h, - .enable = s3c2443_clkcon_enable_h, - .ctrlbit = S3C2443_HCLKCON_USBD, - }, { - .name = "lcd", - .parent = &clk_h, - .enable = s3c2443_clkcon_enable_h, - .ctrlbit = S3C2443_HCLKCON_LCDC, - - }, { - .name = "timers", - .parent = &clk_p, - .enable = s3c2443_clkcon_enable_p, - .ctrlbit = S3C2443_PCLKCON_PWMT, - }, { - .name = "cfc", - .parent = &clk_h, - .enable = s3c2443_clkcon_enable_h, - .ctrlbit = S3C2443_HCLKCON_CFC, - }, { - .name = "ssmc", - .parent = &clk_h, - .enable = s3c2443_clkcon_enable_h, - .ctrlbit = S3C2443_HCLKCON_SSMC, - }, { - .name = "uart", - .devname = "s3c2440-uart.0", - .parent = &clk_p, - .enable = s3c2443_clkcon_enable_p, - .ctrlbit = S3C2443_PCLKCON_UART0, - }, { - .name = "uart", - .devname = "s3c2440-uart.1", - .parent = &clk_p, - .enable = s3c2443_clkcon_enable_p, - .ctrlbit = S3C2443_PCLKCON_UART1, - }, { - .name = "uart", - .devname = "s3c2440-uart.2", - .parent = &clk_p, - .enable = s3c2443_clkcon_enable_p, - .ctrlbit = S3C2443_PCLKCON_UART2, - }, { - .name = "uart", - .devname = "s3c2440-uart.3", - .parent = &clk_p, - .enable = s3c2443_clkcon_enable_p, - .ctrlbit = S3C2443_PCLKCON_UART3, - }, { - .name = "rtc", - .parent = &clk_p, - .enable = s3c2443_clkcon_enable_p, - .ctrlbit = S3C2443_PCLKCON_RTC, - }, { - .name = "watchdog", - .parent = &clk_p, - .ctrlbit = S3C2443_PCLKCON_WDT, - }, { - .name = "ac97", - .parent = &clk_p, - .ctrlbit = S3C2443_PCLKCON_AC97, - }, { - .name = "nand", - .parent = &clk_h, - }, { - .name = "usb-bus-host", - .parent = &clk_usb_bus_host.clk, - } -}; - -static struct clk hsmmc1_clk = { - .name = "hsmmc", - .devname = "s3c-sdhci.1", - .parent = &clk_h, - .enable = s3c2443_clkcon_enable_h, - .ctrlbit = S3C2443_HCLKCON_HSMMC, -}; - -static struct clk hsspi_clk = { - .name = "spi", - .devname = "s3c2443-spi.0", - .parent = &clk_p, - .enable = s3c2443_clkcon_enable_p, - .ctrlbit = S3C2443_PCLKCON_HSSPI, -}; - -/* EPLLCON compatible enough to get on/off information */ - -void __init_or_cpufreq s3c2443_common_setup_clocks(pll_fn get_mpll) -{ - unsigned long epllcon = __raw_readl(S3C2443_EPLLCON); - unsigned long mpllcon = __raw_readl(S3C2443_MPLLCON); - struct clk *xtal_clk; - unsigned long xtal; - unsigned long pll; - int ptr; - - xtal_clk = clk_get(NULL, "xtal"); - xtal = clk_get_rate(xtal_clk); - clk_put(xtal_clk); - - pll = get_mpll(mpllcon, xtal); - clk_msysclk.clk.rate = pll; - clk_mpll.rate = pll; - - printk("CPU: MPLL %s %ld.%03ld MHz, cpu %ld.%03ld MHz, mem %ld.%03ld MHz, pclk %ld.%03ld MHz\n", - (mpllcon & S3C2443_PLLCON_OFF) ? "off" : "on", - print_mhz(pll), print_mhz(clk_get_rate(&clk_armdiv)), - print_mhz(clk_get_rate(&clk_h)), - print_mhz(clk_get_rate(&clk_p))); - - for (ptr = 0; ptr < ARRAY_SIZE(clksrc_clks); ptr++) - s3c_set_clksrc(&clksrc_clks[ptr], true); - - /* ensure usb bus clock is within correct rate of 48MHz */ - - if (clk_get_rate(&clk_usb_bus_host.clk) != (48 * 1000 * 1000)) { - printk(KERN_INFO "Warning: USB host bus not at 48MHz\n"); - clk_set_rate(&clk_usb_bus_host.clk, 48*1000*1000); - } - - printk("CPU: EPLL %s %ld.%03ld MHz, usb-bus %ld.%03ld MHz\n", - (epllcon & S3C2443_PLLCON_OFF) ? "off" : "on", - print_mhz(clk_get_rate(&clk_epll)), - print_mhz(clk_get_rate(&clk_usb_bus))); -} - -static struct clk *clks[] __initdata = { - &clk_prediv, - &clk_mpllref, - &clk_mdivclk, - &clk_ext, - &clk_epll, - &clk_usb_bus, - &clk_armdiv, - &hsmmc1_clk, - &hsspi_clk, -}; - -static struct clksrc_clk *clksrcs[] __initdata = { - &clk_i2s_eplldiv, - &clk_i2s, - &clk_usb_bus_host, - &clk_epllref, - &clk_esysclk, - &clk_msysclk, - &clk_arm, -}; - -static struct clk_lookup s3c2443_clk_lookup[] = { - CLKDEV_INIT(NULL, "clk_uart_baud1", &s3c24xx_uclk), - CLKDEV_INIT(NULL, "clk_uart_baud2", &clk_p), - CLKDEV_INIT(NULL, "clk_uart_baud3", &clk_esys_uart.clk), - CLKDEV_INIT("s3c-sdhci.1", "mmc_busclk.0", &hsmmc1_clk), - CLKDEV_INIT("s3c2443-spi.0", "spi_busclk0", &hsspi_clk), -}; - -void __init s3c2443_common_init_clocks(int xtal, pll_fn get_mpll, - unsigned int *divs, int nr_divs, - int divmask) -{ - int ptr; - - armdiv = divs; - nr_armdiv = nr_divs; - armdivmask = divmask; - - /* s3c2443 parents h clock from prediv */ - clk_h.parent = &clk_prediv; - clk_h.ops = &clk_h_ops; - - /* and p clock from h clock */ - clk_p.parent = &clk_h; - clk_p.ops = &clk_p_ops; - - clk_usb_bus.parent = &clk_usb_bus_host.clk; - clk_epll.parent = &clk_epllref.clk; - - s3c24xx_register_baseclocks(xtal); - s3c24xx_register_clocks(clks, ARRAY_SIZE(clks)); - - for (ptr = 0; ptr < ARRAY_SIZE(clksrcs); ptr++) - s3c_register_clksrc(clksrcs[ptr], 1); - - s3c_register_clksrc(clksrc_clks, ARRAY_SIZE(clksrc_clks)); - s3c_register_clocks(init_clocks, ARRAY_SIZE(init_clocks)); - - /* See s3c2443/etc notes on disabling clocks at init time */ - s3c_register_clocks(init_clocks_off, ARRAY_SIZE(init_clocks_off)); - s3c_disable_clocks(init_clocks_off, ARRAY_SIZE(init_clocks_off)); - clkdev_add_table(s3c2443_clk_lookup, ARRAY_SIZE(s3c2443_clk_lookup)); - - s3c2443_common_setup_clocks(get_mpll); -} diff --git a/arch/arm/mach-s3c24xx/common.c b/arch/arm/mach-s3c24xx/common.c index 0fc6641ac57d..412ca006fcce 100644 --- a/arch/arm/mach-s3c24xx/common.c +++ b/arch/arm/mach-s3c24xx/common.c @@ -145,7 +145,6 @@ static struct cpu_table cpu_ids[] __initdata = { .idcode = 0x32450003, .idmask = 0xffffffff, .map_io = s3c2416_map_io, - .init_clocks = s3c2416_init_clocks, .init_uarts = s3c2416_init_uarts, .init = s3c2416_init, .name = name_s3c2416, @@ -154,7 +153,6 @@ static struct cpu_table cpu_ids[] __initdata = { .idcode = 0x32443001, .idmask = 0xffffffff, .map_io = s3c2443_map_io, - .init_clocks = s3c2443_init_clocks, .init_uarts = s3c2443_init_uarts, .init = s3c2443_init, .name = name_s3c2443, @@ -536,3 +534,17 @@ struct platform_device s3c2443_device_dma = { }, }; #endif + +#ifdef CONFIG_CPU_S3C2416 +void __init s3c2416_init_clocks(int xtal) +{ + s3c2443_common_clk_init(NULL, xtal, 0, S3C24XX_VA_CLKPWR); +} +#endif + +#ifdef CONFIG_CPU_S3C2443 +void __init s3c2443_init_clocks(int xtal) +{ + s3c2443_common_clk_init(NULL, xtal, 1, S3C24XX_VA_CLKPWR); +} +#endif diff --git a/arch/arm/mach-s3c24xx/common.h b/arch/arm/mach-s3c24xx/common.h index e46c10417216..d7323f16427f 100644 --- a/arch/arm/mach-s3c24xx/common.h +++ b/arch/arm/mach-s3c24xx/common.h @@ -114,4 +114,10 @@ extern struct platform_device s3c2412_device_dma; extern struct platform_device s3c2440_device_dma; extern struct platform_device s3c2443_device_dma; +#ifdef CONFIG_S3C2443_COMMON_CLK +void __init s3c2443_common_clk_init(struct device_node *np, unsigned long xti_f, + int current_soc, + void __iomem *reg_base); +#endif + #endif /* __ARCH_ARM_MACH_S3C24XX_COMMON_H */ diff --git a/arch/arm/mach-s3c24xx/mach-s3c2416-dt.c b/arch/arm/mach-s3c24xx/mach-s3c2416-dt.c index 70f0900d4bca..e4dcb9aa2ca2 100644 --- a/arch/arm/mach-s3c24xx/mach-s3c2416-dt.c +++ b/arch/arm/mach-s3c24xx/mach-s3c2416-dt.c @@ -18,7 +18,6 @@ #include #include #include -#include #include #include @@ -29,48 +28,14 @@ #include "common.h" -/* - * The following lookup table is used to override device names when devices - * are registered from device tree. This is temporarily added to enable - * device tree support addition for the S3C2416 architecture. - * - * For drivers that require platform data to be provided from the machine - * file, a platform data pointer can also be supplied along with the - * devices names. Usually, the platform data elements that cannot be parsed - * from the device tree by the drivers (example: function pointers) are - * supplied. But it should be noted that this is a temporary mechanism and - * at some point, the drivers should be capable of parsing all the platform - * data from the device tree. - */ -static const struct of_dev_auxdata s3c2416_auxdata_lookup[] __initconst = { - OF_DEV_AUXDATA("samsung,s3c2440-uart", S3C24XX_PA_UART, - "s3c2440-uart.0", NULL), - OF_DEV_AUXDATA("samsung,s3c2440-uart", S3C24XX_PA_UART + 0x4000, - "s3c2440-uart.1", NULL), - OF_DEV_AUXDATA("samsung,s3c2440-uart", S3C24XX_PA_UART + 0x8000, - "s3c2440-uart.2", NULL), - OF_DEV_AUXDATA("samsung,s3c2440-uart", S3C24XX_PA_UART + 0xC000, - "s3c2440-uart.3", NULL), - OF_DEV_AUXDATA("samsung,s3c6410-sdhci", S3C_PA_HSMMC0, - "s3c-sdhci.0", NULL), - OF_DEV_AUXDATA("samsung,s3c6410-sdhci", S3C_PA_HSMMC1, - "s3c-sdhci.1", NULL), - OF_DEV_AUXDATA("samsung,s3c2440-i2c", S3C_PA_IIC, - "s3c2440-i2c.0", NULL), - {}, -}; - static void __init s3c2416_dt_map_io(void) { s3c24xx_init_io(NULL, 0); - s3c24xx_init_clocks(12000000); } static void __init s3c2416_dt_machine_init(void) { - of_platform_populate(NULL, of_default_bus_match_table, - s3c2416_auxdata_lookup, NULL); - + of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL); s3c_pm_init(); } @@ -86,6 +51,5 @@ DT_MACHINE_START(S3C2416_DT, "Samsung S3C2416 (Flattened Device Tree)") .map_io = s3c2416_dt_map_io, .init_irq = irqchip_init, .init_machine = s3c2416_dt_machine_init, - .init_time = clocksource_of_init, .restart = s3c2416_restart, MACHINE_END diff --git a/arch/arm/mach-s3c24xx/mach-smdk2416.c b/arch/arm/mach-s3c24xx/mach-smdk2416.c index b3b54d8e1410..fa6f30d23601 100644 --- a/arch/arm/mach-s3c24xx/mach-smdk2416.c +++ b/arch/arm/mach-s3c24xx/mach-smdk2416.c @@ -219,10 +219,15 @@ static struct platform_device *smdk2416_devices[] __initdata = { &s3c2443_device_dma, }; +static void __init smdk2416_init_time(void) +{ + s3c2416_init_clocks(12000000); + samsung_timer_init(); +} + static void __init smdk2416_map_io(void) { s3c24xx_init_io(smdk2416_iodesc, ARRAY_SIZE(smdk2416_iodesc)); - s3c24xx_init_clocks(12000000); s3c24xx_init_uarts(smdk2416_uartcfgs, ARRAY_SIZE(smdk2416_uartcfgs)); samsung_set_timer_source(SAMSUNG_PWM3, SAMSUNG_PWM4); } @@ -257,6 +262,6 @@ MACHINE_START(SMDK2416, "SMDK2416") .init_irq = s3c2416_init_irq, .map_io = smdk2416_map_io, .init_machine = smdk2416_machine_init, - .init_time = samsung_timer_init, + .init_time = smdk2416_init_time, .restart = s3c2416_restart, MACHINE_END diff --git a/arch/arm/mach-s3c24xx/mach-smdk2443.c b/arch/arm/mach-s3c24xx/mach-smdk2443.c index 06c4d77de3a5..ef5d5ea33182 100644 --- a/arch/arm/mach-s3c24xx/mach-smdk2443.c +++ b/arch/arm/mach-s3c24xx/mach-smdk2443.c @@ -121,11 +121,16 @@ static struct platform_device *smdk2443_devices[] __initdata = { static void __init smdk2443_map_io(void) { s3c24xx_init_io(smdk2443_iodesc, ARRAY_SIZE(smdk2443_iodesc)); - s3c24xx_init_clocks(12000000); s3c24xx_init_uarts(smdk2443_uartcfgs, ARRAY_SIZE(smdk2443_uartcfgs)); samsung_set_timer_source(SAMSUNG_PWM3, SAMSUNG_PWM4); } +static void __init smdk2443_init_time(void) +{ + s3c2443_init_clocks(12000000); + samsung_timer_init(); +} + static void __init smdk2443_machine_init(void) { s3c_i2c0_set_platdata(NULL); @@ -145,6 +150,6 @@ MACHINE_START(SMDK2443, "SMDK2443") .init_irq = s3c2443_init_irq, .map_io = smdk2443_map_io, .init_machine = smdk2443_machine_init, - .init_time = samsung_timer_init, + .init_time = smdk2443_init_time, .restart = s3c2443_restart, MACHINE_END -- cgit v1.2.3 From 42637c59f36198a58069f94676007c62477321b7 Mon Sep 17 00:00:00 2001 From: Heiko Stuebner Date: Tue, 25 Feb 2014 09:50:43 +0900 Subject: ARM: S3C24XX: only store clock registers when old clock code is active The Samsung ccf driver already handles the save and restore of the clock registers on suspend and resume. The architecture code should not duplicate this when the ccf is active. Signed-off-by: Heiko Stuebner Reviewed-by: Tomasz Figa Signed-off-by: Kukjin Kim --- arch/arm/mach-s3c24xx/pm.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/arch/arm/mach-s3c24xx/pm.c b/arch/arm/mach-s3c24xx/pm.c index 68ea5b7e5dc7..16281bdc750a 100644 --- a/arch/arm/mach-s3c24xx/pm.c +++ b/arch/arm/mach-s3c24xx/pm.c @@ -51,9 +51,6 @@ #define PFX "s3c24xx-pm: " static struct sleep_save core_save[] = { - SAVE_ITEM(S3C2410_LOCKTIME), - SAVE_ITEM(S3C2410_CLKCON), - /* we restore the timings here, with the proviso that the board * brings the system up in an slower, or equal frequency setting * to the original system. @@ -70,6 +67,9 @@ static struct sleep_save core_save[] = { SAVE_ITEM(S3C2410_BANKCON4), SAVE_ITEM(S3C2410_BANKCON5), +#ifdef CONFIG_SAMSUNG_CLOCK + SAVE_ITEM(S3C2410_LOCKTIME), + SAVE_ITEM(S3C2410_CLKCON), #ifndef CONFIG_CPU_FREQ SAVE_ITEM(S3C2410_CLKDIVN), SAVE_ITEM(S3C2410_MPLLCON), @@ -77,11 +77,14 @@ static struct sleep_save core_save[] = { #endif SAVE_ITEM(S3C2410_UPLLCON), SAVE_ITEM(S3C2410_CLKSLOW), +#endif /* CONFIG_SAMSUNG_CLOCK */ }; +#ifdef CONFIG_SAMSUNG_CLOCK static struct sleep_save misc_save[] = { SAVE_ITEM(S3C2410_DCLKCON), }; +#endif /* s3c_pm_check_resume_pin * @@ -140,12 +143,16 @@ void s3c_pm_configure_extint(void) void s3c_pm_restore_core(void) { s3c_pm_do_restore_core(core_save, ARRAY_SIZE(core_save)); +#ifdef CONFIG_SAMSUNG_CLOCK s3c_pm_do_restore(misc_save, ARRAY_SIZE(misc_save)); +#endif } void s3c_pm_save_core(void) { +#ifdef CONFIG_SAMSUNG_CLOCK s3c_pm_do_save(misc_save, ARRAY_SIZE(misc_save)); +#endif s3c_pm_do_save(core_save, ARRAY_SIZE(core_save)); } -- cgit v1.2.3 From ea5d6a8d3ee606086118d3b4d4b3a49693e92960 Mon Sep 17 00:00:00 2001 From: Heiko Stuebner Date: Tue, 25 Feb 2014 09:50:43 +0900 Subject: clk: samsung: add plls used by the early s3c24xx cpus The manuals do not give them explicit names like in later socs, so more generic names with a s3c2410-prefix were used for them. As it was common to do so in the previous implementation, functionality to change the pll rate is already included. Signed-off-by: Heiko Stuebner Acked-by: Mike Turquette Acked-by: Tomasz Figa Signed-off-by: Kukjin Kim --- drivers/clk/samsung/clk-pll.c | 182 ++++++++++++++++++++++++++++++++++++++++++ drivers/clk/samsung/clk-pll.h | 3 + 2 files changed, 185 insertions(+) diff --git a/drivers/clk/samsung/clk-pll.c b/drivers/clk/samsung/clk-pll.c index 8c9c015a4538..7fb0a28e65d5 100644 --- a/drivers/clk/samsung/clk-pll.c +++ b/drivers/clk/samsung/clk-pll.c @@ -11,6 +11,7 @@ #include #include +#include #include "clk.h" #include "clk-pll.h" @@ -700,6 +701,169 @@ static const struct clk_ops samsung_pll6553_clk_ops = { .recalc_rate = samsung_pll6553_recalc_rate, }; +/* + * PLL Clock Type of S3C24XX before S3C2443 + */ + +#define PLLS3C2410_MDIV_MASK (0xff) +#define PLLS3C2410_PDIV_MASK (0x1f) +#define PLLS3C2410_SDIV_MASK (0x3) +#define PLLS3C2410_MDIV_SHIFT (12) +#define PLLS3C2410_PDIV_SHIFT (4) +#define PLLS3C2410_SDIV_SHIFT (0) + +#define PLLS3C2410_ENABLE_REG_OFFSET 0x10 + +static unsigned long samsung_s3c2410_pll_recalc_rate(struct clk_hw *hw, + unsigned long parent_rate) +{ + struct samsung_clk_pll *pll = to_clk_pll(hw); + u32 pll_con, mdiv, pdiv, sdiv; + u64 fvco = parent_rate; + + pll_con = __raw_readl(pll->con_reg); + mdiv = (pll_con >> PLLS3C2410_MDIV_SHIFT) & PLLS3C2410_MDIV_MASK; + pdiv = (pll_con >> PLLS3C2410_PDIV_SHIFT) & PLLS3C2410_PDIV_MASK; + sdiv = (pll_con >> PLLS3C2410_SDIV_SHIFT) & PLLS3C2410_SDIV_MASK; + + fvco *= (mdiv + 8); + do_div(fvco, (pdiv + 2) << sdiv); + + return (unsigned int)fvco; +} + +static unsigned long samsung_s3c2440_mpll_recalc_rate(struct clk_hw *hw, + unsigned long parent_rate) +{ + struct samsung_clk_pll *pll = to_clk_pll(hw); + u32 pll_con, mdiv, pdiv, sdiv; + u64 fvco = parent_rate; + + pll_con = __raw_readl(pll->con_reg); + mdiv = (pll_con >> PLLS3C2410_MDIV_SHIFT) & PLLS3C2410_MDIV_MASK; + pdiv = (pll_con >> PLLS3C2410_PDIV_SHIFT) & PLLS3C2410_PDIV_MASK; + sdiv = (pll_con >> PLLS3C2410_SDIV_SHIFT) & PLLS3C2410_SDIV_MASK; + + fvco *= (2 * (mdiv + 8)); + do_div(fvco, (pdiv + 2) << sdiv); + + return (unsigned int)fvco; +} + +static int samsung_s3c2410_pll_set_rate(struct clk_hw *hw, unsigned long drate, + unsigned long prate) +{ + struct samsung_clk_pll *pll = to_clk_pll(hw); + const struct samsung_pll_rate_table *rate; + u32 tmp; + + /* Get required rate settings from table */ + rate = samsung_get_pll_settings(pll, drate); + if (!rate) { + pr_err("%s: Invalid rate : %lu for pll clk %s\n", __func__, + drate, __clk_get_name(hw->clk)); + return -EINVAL; + } + + tmp = __raw_readl(pll->con_reg); + + /* Change PLL PMS values */ + tmp &= ~((PLLS3C2410_MDIV_MASK << PLLS3C2410_MDIV_SHIFT) | + (PLLS3C2410_PDIV_MASK << PLLS3C2410_PDIV_SHIFT) | + (PLLS3C2410_SDIV_MASK << PLLS3C2410_SDIV_SHIFT)); + tmp |= (rate->mdiv << PLLS3C2410_MDIV_SHIFT) | + (rate->pdiv << PLLS3C2410_PDIV_SHIFT) | + (rate->sdiv << PLLS3C2410_SDIV_SHIFT); + __raw_writel(tmp, pll->con_reg); + + /* Time to settle according to the manual */ + udelay(300); + + return 0; +} + +static int samsung_s3c2410_pll_enable(struct clk_hw *hw, int bit, bool enable) +{ + struct samsung_clk_pll *pll = to_clk_pll(hw); + u32 pll_en = __raw_readl(pll->lock_reg + PLLS3C2410_ENABLE_REG_OFFSET); + u32 pll_en_orig = pll_en; + + if (enable) + pll_en &= ~BIT(bit); + else + pll_en |= BIT(bit); + + __raw_writel(pll_en, pll->lock_reg + PLLS3C2410_ENABLE_REG_OFFSET); + + /* if we started the UPLL, then allow to settle */ + if (enable && (pll_en_orig & BIT(bit))) + udelay(300); + + return 0; +} + +static int samsung_s3c2410_mpll_enable(struct clk_hw *hw) +{ + return samsung_s3c2410_pll_enable(hw, 5, true); +} + +static void samsung_s3c2410_mpll_disable(struct clk_hw *hw) +{ + samsung_s3c2410_pll_enable(hw, 5, false); +} + +static int samsung_s3c2410_upll_enable(struct clk_hw *hw) +{ + return samsung_s3c2410_pll_enable(hw, 7, true); +} + +static void samsung_s3c2410_upll_disable(struct clk_hw *hw) +{ + samsung_s3c2410_pll_enable(hw, 7, false); +} + +static const struct clk_ops samsung_s3c2410_mpll_clk_min_ops = { + .recalc_rate = samsung_s3c2410_pll_recalc_rate, + .enable = samsung_s3c2410_mpll_enable, + .disable = samsung_s3c2410_mpll_disable, +}; + +static const struct clk_ops samsung_s3c2410_upll_clk_min_ops = { + .recalc_rate = samsung_s3c2410_pll_recalc_rate, + .enable = samsung_s3c2410_upll_enable, + .disable = samsung_s3c2410_upll_disable, +}; + +static const struct clk_ops samsung_s3c2440_mpll_clk_min_ops = { + .recalc_rate = samsung_s3c2440_mpll_recalc_rate, + .enable = samsung_s3c2410_mpll_enable, + .disable = samsung_s3c2410_mpll_disable, +}; + +static const struct clk_ops samsung_s3c2410_mpll_clk_ops = { + .recalc_rate = samsung_s3c2410_pll_recalc_rate, + .enable = samsung_s3c2410_mpll_enable, + .disable = samsung_s3c2410_mpll_disable, + .round_rate = samsung_pll_round_rate, + .set_rate = samsung_s3c2410_pll_set_rate, +}; + +static const struct clk_ops samsung_s3c2410_upll_clk_ops = { + .recalc_rate = samsung_s3c2410_pll_recalc_rate, + .enable = samsung_s3c2410_upll_enable, + .disable = samsung_s3c2410_upll_disable, + .round_rate = samsung_pll_round_rate, + .set_rate = samsung_s3c2410_pll_set_rate, +}; + +static const struct clk_ops samsung_s3c2440_mpll_clk_ops = { + .recalc_rate = samsung_s3c2440_mpll_recalc_rate, + .enable = samsung_s3c2410_mpll_enable, + .disable = samsung_s3c2410_mpll_disable, + .round_rate = samsung_pll_round_rate, + .set_rate = samsung_s3c2410_pll_set_rate, +}; + /* * PLL2550x Clock Type */ @@ -866,6 +1030,24 @@ static void __init _samsung_clk_register_pll(struct samsung_pll_clock *pll_clk, else init.ops = &samsung_pll46xx_clk_ops; break; + case pll_s3c2410_mpll: + if (!pll->rate_table) + init.ops = &samsung_s3c2410_mpll_clk_min_ops; + else + init.ops = &samsung_s3c2410_mpll_clk_ops; + break; + case pll_s3c2410_upll: + if (!pll->rate_table) + init.ops = &samsung_s3c2410_upll_clk_min_ops; + else + init.ops = &samsung_s3c2410_upll_clk_ops; + break; + case pll_s3c2440_mpll: + if (!pll->rate_table) + init.ops = &samsung_s3c2440_mpll_clk_min_ops; + else + init.ops = &samsung_s3c2440_mpll_clk_ops; + break; default: pr_warn("%s: Unknown pll type for pll clk %s\n", __func__, pll_clk->name); diff --git a/drivers/clk/samsung/clk-pll.h b/drivers/clk/samsung/clk-pll.h index 5b64bdbb0906..6428bcc6df6f 100644 --- a/drivers/clk/samsung/clk-pll.h +++ b/drivers/clk/samsung/clk-pll.h @@ -28,6 +28,9 @@ enum samsung_pll_type { pll_6552, pll_6552_s3c2416, pll_6553, + pll_s3c2410_mpll, + pll_s3c2410_upll, + pll_s3c2440_mpll, }; #define PLL_35XX_RATE(_rate, _m, _p, _s) \ -- cgit v1.2.3 From 7d03fed8e56ba5ffdae67c64d181a010a2a56d9b Mon Sep 17 00:00:00 2001 From: Heiko Stuebner Date: Tue, 25 Feb 2014 09:50:44 +0900 Subject: dt-bindings: add documentation for s3c2412 clock controller Describe the clock controller of the s3c2412. Signed-off-by: Heiko Stuebner Signed-off-by: Kukjin Kim --- .../bindings/clock/samsung,s3c2412-clock.txt | 50 ++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 Documentation/devicetree/bindings/clock/samsung,s3c2412-clock.txt diff --git a/Documentation/devicetree/bindings/clock/samsung,s3c2412-clock.txt b/Documentation/devicetree/bindings/clock/samsung,s3c2412-clock.txt new file mode 100644 index 000000000000..2b430960ba47 --- /dev/null +++ b/Documentation/devicetree/bindings/clock/samsung,s3c2412-clock.txt @@ -0,0 +1,50 @@ +* Samsung S3C2412 Clock Controller + +The S3C2412 clock controller generates and supplies clock to various controllers +within the SoC. The clock binding described here is applicable to the s3c2412 +and s3c2413 SoCs in the s3c24x family. + +Required Properties: + +- compatible: should be "samsung,s3c2412-clock" +- reg: physical base address of the controller and length of memory mapped + region. +- #clock-cells: should be 1. + +Each clock is assigned an identifier and client nodes can use this identifier +to specify the clock which they consume. Some of the clocks are available only +on a particular SoC. + +All available clocks are defined as preprocessor macros in +dt-bindings/clock/s3c2412.h header and can be used in device +tree sources. + +External clocks: + +There are several clocks that are generated outside the SoC. It is expected +that they are defined using standard clock bindings with following +clock-output-names: + - "xti" - crystal input - required, + - "ext" - external clock source - optional, + +Example: Clock controller node: + + clocks: clock-controller@4c000000 { + compatible = "samsung,s3c2412-clock"; + reg = <0x4c000000 0x20>; + #clock-cells = <1>; + }; + +Example: UART controller node that consumes the clock generated by the clock + controller (refer to the standard clock bindings for information about + "clocks" and "clock-names" properties): + + serial@50004000 { + compatible = "samsung,s3c2412-uart"; + reg = <0x50004000 0x4000>; + interrupts = <1 23 3 4>, <1 23 4 4>; + clock-names = "uart", "clk_uart_baud2", "clk_uart_baud3"; + clocks = <&clocks PCLK_UART0>, <&clocks PCLK_UART0>, + <&clocks SCLK_UART>; + status = "disabled"; + }; -- cgit v1.2.3 From ca2e90ac1809c49c2306df4e23e17dad67c785b6 Mon Sep 17 00:00:00 2001 From: Heiko Stuebner Date: Tue, 25 Feb 2014 09:50:44 +0900 Subject: clk: samsung: add clock controller driver for s3c2412 This driver can handle the clock controller in the s3c2412 soc. The clock structure is built according to the manuals of the included SoCs and might include changes in comparison to the previous clock structure. Signed-off-by: Heiko Stuebner Reviewed-by: Tomasz Figa Acked-by: Mike Turquette Signed-off-by: Kukjin Kim --- drivers/clk/samsung/Makefile | 1 + drivers/clk/samsung/clk-s3c2412.c | 269 ++++++++++++++++++++++++++++++++++++ include/dt-bindings/clock/s3c2412.h | 73 ++++++++++ 3 files changed, 343 insertions(+) create mode 100644 drivers/clk/samsung/clk-s3c2412.c create mode 100644 include/dt-bindings/clock/s3c2412.h diff --git a/drivers/clk/samsung/Makefile b/drivers/clk/samsung/Makefile index 4c892c63a8dd..77313e27bc39 100644 --- a/drivers/clk/samsung/Makefile +++ b/drivers/clk/samsung/Makefile @@ -8,5 +8,6 @@ obj-$(CONFIG_SOC_EXYNOS5250) += clk-exynos5250.o obj-$(CONFIG_SOC_EXYNOS5420) += clk-exynos5420.o obj-$(CONFIG_SOC_EXYNOS5440) += clk-exynos5440.o obj-$(CONFIG_ARCH_EXYNOS) += clk-exynos-audss.o +obj-$(CONFIG_S3C2412_COMMON_CLK)+= clk-s3c2412.o obj-$(CONFIG_S3C2443_COMMON_CLK)+= clk-s3c2443.o obj-$(CONFIG_ARCH_S3C64XX) += clk-s3c64xx.o diff --git a/drivers/clk/samsung/clk-s3c2412.c b/drivers/clk/samsung/clk-s3c2412.c new file mode 100644 index 000000000000..0f11a07d5c01 --- /dev/null +++ b/drivers/clk/samsung/clk-s3c2412.c @@ -0,0 +1,269 @@ +/* + * Copyright (c) 2013 Heiko Stuebner + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * Common Clock Framework support for S3C2412 and S3C2413. + */ + +#include +#include +#include +#include +#include +#include + +#include + +#include "clk.h" +#include "clk-pll.h" + +#define LOCKTIME 0x00 +#define MPLLCON 0x04 +#define UPLLCON 0x08 +#define CLKCON 0x0c +#define CLKDIVN 0x14 +#define CLKSRC 0x1c + +/* list of PLLs to be registered */ +enum s3c2412_plls { + mpll, upll, +}; + +static void __iomem *reg_base; + +#ifdef CONFIG_PM_SLEEP +static struct samsung_clk_reg_dump *s3c2412_save; + +/* + * list of controller registers to be saved and restored during a + * suspend/resume cycle. + */ +static unsigned long s3c2412_clk_regs[] __initdata = { + LOCKTIME, + MPLLCON, + UPLLCON, + CLKCON, + CLKDIVN, + CLKSRC, +}; + +static int s3c2412_clk_suspend(void) +{ + samsung_clk_save(reg_base, s3c2412_save, + ARRAY_SIZE(s3c2412_clk_regs)); + + return 0; +} + +static void s3c2412_clk_resume(void) +{ + samsung_clk_restore(reg_base, s3c2412_save, + ARRAY_SIZE(s3c2412_clk_regs)); +} + +static struct syscore_ops s3c2412_clk_syscore_ops = { + .suspend = s3c2412_clk_suspend, + .resume = s3c2412_clk_resume, +}; + +static void s3c2412_clk_sleep_init(void) +{ + s3c2412_save = samsung_clk_alloc_reg_dump(s3c2412_clk_regs, + ARRAY_SIZE(s3c2412_clk_regs)); + if (!s3c2412_save) { + pr_warn("%s: failed to allocate sleep save data, no sleep support!\n", + __func__); + return; + } + + register_syscore_ops(&s3c2412_clk_syscore_ops); + return; +} +#else +static void s3c2412_clk_sleep_init(void) {} +#endif + +static struct clk_div_table divxti_d[] = { + { .val = 0, .div = 1 }, + { .val = 1, .div = 2 }, + { .val = 2, .div = 4 }, + { .val = 3, .div = 6 }, + { .val = 4, .div = 8 }, + { .val = 5, .div = 10 }, + { .val = 6, .div = 12 }, + { .val = 7, .div = 14 }, + { /* sentinel */ }, +}; + +struct samsung_div_clock s3c2412_dividers[] __initdata = { + DIV_T(0, "div_xti", "xti", CLKSRC, 0, 3, divxti_d), + DIV(0, "div_cam", "mux_cam", CLKDIVN, 16, 4), + DIV(0, "div_i2s", "mux_i2s", CLKDIVN, 12, 4), + DIV(0, "div_uart", "mux_uart", CLKDIVN, 8, 4), + DIV(0, "div_usb", "mux_usb", CLKDIVN, 6, 1), + DIV(0, "div_hclk_half", "hclk", CLKDIVN, 5, 1), + DIV(ARMDIV, "armdiv", "msysclk", CLKDIVN, 3, 1), + DIV(PCLK, "pclk", "hclk", CLKDIVN, 2, 1), + DIV(HCLK, "hclk", "armdiv", CLKDIVN, 0, 2), +}; + +struct samsung_fixed_factor_clock s3c2412_ffactor[] __initdata = { + FFACTOR(0, "ff_hclk", "hclk", 2, 1, CLK_SET_RATE_PARENT), +}; + +/* + * The first two use the OM[4] setting, which is not readable from + * software, so assume it is set to xti. + */ +PNAME(erefclk_p) = { "xti", "xti", "xti", "ext" }; +PNAME(urefclk_p) = { "xti", "xti", "xti", "ext" }; + +PNAME(camclk_p) = { "usysclk", "hclk" }; +PNAME(usbclk_p) = { "usysclk", "hclk" }; +PNAME(i2sclk_p) = { "erefclk", "mpll" }; +PNAME(uartclk_p) = { "erefclk", "mpll" }; +PNAME(usysclk_p) = { "urefclk", "upll" }; +PNAME(msysclk_p) = { "mdivclk", "mpll" }; +PNAME(mdivclk_p) = { "xti", "div_xti" }; +PNAME(armclk_p) = { "armdiv", "hclk" }; + +struct samsung_mux_clock s3c2412_muxes[] __initdata = { + MUX(0, "erefclk", erefclk_p, CLKSRC, 14, 2), + MUX(0, "urefclk", urefclk_p, CLKSRC, 12, 2), + MUX(0, "mux_cam", camclk_p, CLKSRC, 11, 1), + MUX(0, "mux_usb", usbclk_p, CLKSRC, 10, 1), + MUX(0, "mux_i2s", i2sclk_p, CLKSRC, 9, 1), + MUX(0, "mux_uart", uartclk_p, CLKSRC, 8, 1), + MUX(USYSCLK, "usysclk", usysclk_p, CLKSRC, 5, 1), + MUX(MSYSCLK, "msysclk", msysclk_p, CLKSRC, 4, 1), + MUX(MDIVCLK, "mdivclk", mdivclk_p, CLKSRC, 3, 1), + MUX(ARMCLK, "armclk", armclk_p, CLKDIVN, 4, 1), +}; + +static struct samsung_pll_clock s3c2412_plls[] __initdata = { + [mpll] = PLL(pll_s3c2440_mpll, MPLL, "mpll", "xti", + LOCKTIME, MPLLCON, NULL), + [upll] = PLL(pll_s3c2410_upll, UPLL, "upll", "urefclk", + LOCKTIME, UPLLCON, NULL), +}; + +struct samsung_gate_clock s3c2412_gates[] __initdata = { + GATE(PCLK_WDT, "wdt", "pclk", CLKCON, 28, 0, 0), + GATE(PCLK_SPI, "spi", "pclk", CLKCON, 27, 0, 0), + GATE(PCLK_I2S, "i2s", "pclk", CLKCON, 26, 0, 0), + GATE(PCLK_I2C, "i2c", "pclk", CLKCON, 25, 0, 0), + GATE(PCLK_ADC, "adc", "pclk", CLKCON, 24, 0, 0), + GATE(PCLK_RTC, "rtc", "pclk", CLKCON, 23, 0, 0), + GATE(PCLK_GPIO, "gpio", "pclk", CLKCON, 22, CLK_IGNORE_UNUSED, 0), + GATE(PCLK_UART2, "uart2", "pclk", CLKCON, 21, 0, 0), + GATE(PCLK_UART1, "uart1", "pclk", CLKCON, 20, 0, 0), + GATE(PCLK_UART0, "uart0", "pclk", CLKCON, 19, 0, 0), + GATE(PCLK_SDI, "sdi", "pclk", CLKCON, 18, 0, 0), + GATE(PCLK_PWM, "pwm", "pclk", CLKCON, 17, 0, 0), + GATE(PCLK_USBD, "usb-device", "pclk", CLKCON, 16, 0, 0), + GATE(SCLK_CAM, "sclk_cam", "div_cam", CLKCON, 15, 0, 0), + GATE(SCLK_UART, "sclk_uart", "div_uart", CLKCON, 14, 0, 0), + GATE(SCLK_I2S, "sclk_i2s", "div_i2s", CLKCON, 13, 0, 0), + GATE(SCLK_USBH, "sclk_usbh", "div_usb", CLKCON, 12, 0, 0), + GATE(SCLK_USBD, "sclk_usbd", "div_usb", CLKCON, 11, 0, 0), + GATE(HCLK_HALF, "hclk_half", "div_hclk_half", CLKCON, 10, CLK_IGNORE_UNUSED, 0), + GATE(HCLK_X2, "hclkx2", "ff_hclk", CLKCON, 9, CLK_IGNORE_UNUSED, 0), + GATE(HCLK_SDRAM, "sdram", "hclk", CLKCON, 8, CLK_IGNORE_UNUSED, 0), + GATE(HCLK_USBH, "usb-host", "hclk", CLKCON, 6, 0, 0), + GATE(HCLK_LCD, "lcd", "hclk", CLKCON, 5, 0, 0), + GATE(HCLK_NAND, "nand", "hclk", CLKCON, 4, 0, 0), + GATE(HCLK_DMA3, "dma3", "hclk", CLKCON, 3, CLK_IGNORE_UNUSED, 0), + GATE(HCLK_DMA2, "dma2", "hclk", CLKCON, 2, CLK_IGNORE_UNUSED, 0), + GATE(HCLK_DMA1, "dma1", "hclk", CLKCON, 1, CLK_IGNORE_UNUSED, 0), + GATE(HCLK_DMA0, "dma0", "hclk", CLKCON, 0, CLK_IGNORE_UNUSED, 0), +}; + +struct samsung_clock_alias s3c2412_aliases[] __initdata = { + ALIAS(PCLK_UART0, "s3c2412-uart.0", "uart"), + ALIAS(PCLK_UART1, "s3c2412-uart.1", "uart"), + ALIAS(PCLK_UART2, "s3c2412-uart.2", "uart"), + ALIAS(PCLK_UART0, "s3c2412-uart.0", "clk_uart_baud2"), + ALIAS(PCLK_UART1, "s3c2412-uart.1", "clk_uart_baud2"), + ALIAS(PCLK_UART2, "s3c2412-uart.2", "clk_uart_baud2"), + ALIAS(SCLK_UART, NULL, "clk_uart_baud3"), + ALIAS(PCLK_I2C, "s3c2410-i2c.0", "i2c"), + ALIAS(PCLK_ADC, NULL, "adc"), + ALIAS(PCLK_RTC, NULL, "rtc"), + ALIAS(PCLK_PWM, NULL, "timers"), + ALIAS(HCLK_LCD, NULL, "lcd"), + ALIAS(PCLK_USBD, NULL, "usb-device"), + ALIAS(SCLK_USBD, NULL, "usb-bus-gadget"), + ALIAS(HCLK_USBH, NULL, "usb-host"), + ALIAS(SCLK_USBH, NULL, "usb-bus-host"), + ALIAS(ARMCLK, NULL, "armclk"), + ALIAS(HCLK, NULL, "hclk"), + ALIAS(MPLL, NULL, "mpll"), + ALIAS(MSYSCLK, NULL, "fclk"), +}; + +/* + * fixed rate clocks generated outside the soc + * Only necessary until the devicetree-move is complete + */ +#define XTI 1 +struct samsung_fixed_rate_clock s3c2412_common_frate_clks[] __initdata = { + FRATE(XTI, "xti", NULL, CLK_IS_ROOT, 0), + FRATE(0, "ext", NULL, CLK_IS_ROOT, 0), +}; + +static void __init s3c2412_common_clk_register_fixed_ext(unsigned long xti_f, + unsigned long ext_f) +{ + /* xtal alias is necessary for the current cpufreq driver */ + struct samsung_clock_alias xti_alias = ALIAS(XTI, NULL, "xtal"); + + s3c2412_common_frate_clks[0].fixed_rate = xti_f; + s3c2412_common_frate_clks[1].fixed_rate = ext_f; + samsung_clk_register_fixed_rate(s3c2412_common_frate_clks, + ARRAY_SIZE(s3c2412_common_frate_clks)); + + samsung_clk_register_alias(&xti_alias, 1); +} + +void __init s3c2412_common_clk_init(struct device_node *np, unsigned long xti_f, + unsigned long ext_f, void __iomem *base) +{ + reg_base = base; + + if (np) { + reg_base = of_iomap(np, 0); + if (!reg_base) + panic("%s: failed to map registers\n", __func__); + } + + samsung_clk_init(np, reg_base, NR_CLKS); + + /* Register external clocks only in non-dt cases */ + if (!np) + s3c2412_common_clk_register_fixed_ext(xti_f, ext_f); + + /* Register PLLs. */ + samsung_clk_register_pll(s3c2412_plls, ARRAY_SIZE(s3c2412_plls), + reg_base); + + /* Register common internal clocks. */ + samsung_clk_register_mux(s3c2412_muxes, ARRAY_SIZE(s3c2412_muxes)); + samsung_clk_register_div(s3c2412_dividers, + ARRAY_SIZE(s3c2412_dividers)); + samsung_clk_register_gate(s3c2412_gates, ARRAY_SIZE(s3c2412_gates)); + samsung_clk_register_fixed_factor(s3c2412_ffactor, + ARRAY_SIZE(s3c2412_ffactor)); + samsung_clk_register_alias(s3c2412_aliases, + ARRAY_SIZE(s3c2412_aliases)); + + s3c2412_clk_sleep_init(); +} + +static void __init s3c2412_clk_init(struct device_node *np) +{ + s3c2412_common_clk_init(np, 0, 0, 0); +} +CLK_OF_DECLARE(s3c2412_clk, "samsung,s3c2412-clock", s3c2412_clk_init); diff --git a/include/dt-bindings/clock/s3c2412.h b/include/dt-bindings/clock/s3c2412.h new file mode 100644 index 000000000000..aac1dcfda81c --- /dev/null +++ b/include/dt-bindings/clock/s3c2412.h @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2013 Heiko Stuebner + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * Device Tree binding constants clock controllers of Samsung S3C2412. + */ + +#ifndef _DT_BINDINGS_CLOCK_SAMSUNG_S3C2412_CLOCK_H +#define _DT_BINDINGS_CLOCK_SAMSUNG_S3C2412_CLOCK_H + +/* + * Let each exported clock get a unique index, which is used on DT-enabled + * platforms to lookup the clock from a clock specifier. These indices are + * therefore considered an ABI and so must not be changed. This implies + * that new clocks should be added either in free spaces between clock groups + * or at the end. + */ + +/* Core clocks. */ + +/* id 1 is reserved */ +#define MPLL 2 +#define UPLL 3 +#define MDIVCLK 4 +#define MSYSCLK 5 +#define USYSCLK 6 +#define HCLK 7 +#define PCLK 8 +#define ARMDIV 9 +#define ARMCLK 10 + + +/* Special clocks */ +#define SCLK_CAM 16 +#define SCLK_UART 17 +#define SCLK_I2S 18 +#define SCLK_USBD 19 +#define SCLK_USBH 20 + +/* pclk-gates */ +#define PCLK_WDT 32 +#define PCLK_SPI 33 +#define PCLK_I2S 34 +#define PCLK_I2C 35 +#define PCLK_ADC 36 +#define PCLK_RTC 37 +#define PCLK_GPIO 38 +#define PCLK_UART2 39 +#define PCLK_UART1 40 +#define PCLK_UART0 41 +#define PCLK_SDI 42 +#define PCLK_PWM 43 +#define PCLK_USBD 44 + +/* hclk-gates */ +#define HCLK_HALF 48 +#define HCLK_X2 49 +#define HCLK_SDRAM 50 +#define HCLK_USBH 51 +#define HCLK_LCD 52 +#define HCLK_NAND 53 +#define HCLK_DMA3 54 +#define HCLK_DMA2 55 +#define HCLK_DMA1 56 +#define HCLK_DMA0 57 + +/* Total number of clocks. */ +#define NR_CLKS (HCLK_DMA0 + 1) + +#endif /* _DT_BINDINGS_CLOCK_SAMSUNG_S3C2412_CLOCK_H */ -- cgit v1.2.3 From 3c27f314c676ee31eafd423ce2c640ed129cd5e0 Mon Sep 17 00:00:00 2001 From: Heiko Stuebner Date: Tue, 25 Feb 2014 09:50:44 +0900 Subject: ARM: S3C24XX: convert s3c2412 to common clock framework Convert all machines using these cpus to use the ccf clock driver instead of the legacy Samsung clock implementation. Signed-off-by: Heiko Stuebner Reviewed-by: Tomasz Figa Signed-off-by: Kukjin Kim --- arch/arm/mach-s3c24xx/Kconfig | 8 +- arch/arm/mach-s3c24xx/Makefile | 2 +- arch/arm/mach-s3c24xx/clock-s3c2412.c | 760 ---------------------------------- arch/arm/mach-s3c24xx/common.c | 9 +- arch/arm/mach-s3c24xx/common.h | 4 + arch/arm/mach-s3c24xx/mach-jive.c | 9 +- arch/arm/mach-s3c24xx/mach-smdk2413.c | 9 +- arch/arm/mach-s3c24xx/mach-vstms.c | 9 +- arch/arm/mach-s3c24xx/s3c2412.c | 43 -- 9 files changed, 40 insertions(+), 813 deletions(-) delete mode 100644 arch/arm/mach-s3c24xx/clock-s3c2412.c diff --git a/arch/arm/mach-s3c24xx/Kconfig b/arch/arm/mach-s3c24xx/Kconfig index 52f1c40ccf07..fbafb9a1975b 100644 --- a/arch/arm/mach-s3c24xx/Kconfig +++ b/arch/arm/mach-s3c24xx/Kconfig @@ -39,9 +39,10 @@ config CPU_S3C2410 config CPU_S3C2412 bool "SAMSUNG S3C2412" - depends on SAMSUNG_CLOCK + select COMMON_CLK select CPU_ARM926T select CPU_LLSERIAL_S3C2440 + select S3C2412_COMMON_CLK select S3C2412_DMA if S3C24XX_DMA select S3C2412_PM if PM help @@ -363,6 +364,11 @@ config S3C2412_PM_SLEEP if CPU_S3C2412 +config S3C2412_COMMON_CLK + bool + help + Build the s3c2412 clock driver based on the common clock framework. + config CPU_S3C2412_ONLY bool depends on !CPU_S3C2410 && !CPU_S3C2416 && !CPU_S3C2440 && \ diff --git a/arch/arm/mach-s3c24xx/Makefile b/arch/arm/mach-s3c24xx/Makefile index ba0e5475a807..f25479721dc9 100644 --- a/arch/arm/mach-s3c24xx/Makefile +++ b/arch/arm/mach-s3c24xx/Makefile @@ -21,7 +21,7 @@ obj-$(CONFIG_S3C2410_DMA) += dma-s3c2410.o obj-$(CONFIG_S3C2410_PLL) += pll-s3c2410.o obj-$(CONFIG_S3C2410_PM) += pm-s3c2410.o sleep-s3c2410.o -obj-$(CONFIG_CPU_S3C2412) += s3c2412.o clock-s3c2412.o +obj-$(CONFIG_CPU_S3C2412) += s3c2412.o obj-$(CONFIG_S3C2412_DMA) += dma-s3c2412.o obj-$(CONFIG_S3C2412_PM) += pm-s3c2412.o obj-$(CONFIG_S3C2412_PM_SLEEP) += sleep-s3c2412.o diff --git a/arch/arm/mach-s3c24xx/clock-s3c2412.c b/arch/arm/mach-s3c24xx/clock-s3c2412.c deleted file mode 100644 index 192a5b2550b0..000000000000 --- a/arch/arm/mach-s3c24xx/clock-s3c2412.c +++ /dev/null @@ -1,760 +0,0 @@ -/* linux/arch/arm/mach-s3c2412/clock.c - * - * Copyright (c) 2006 Simtec Electronics - * Ben Dooks - * - * S3C2412,S3C2413 Clock control support - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include -#include -#include - -#include -#include - -/* We currently have to assume that the system is running - * from the XTPll input, and that all ***REFCLKs are being - * fed from it, as we cannot read the state of OM[4] from - * software. - * - * It would be possible for each board initialisation to - * set the correct muxing at initialisation -*/ - -static int s3c2412_clkcon_enable(struct clk *clk, int enable) -{ - unsigned int clocks = clk->ctrlbit; - unsigned long clkcon; - - clkcon = __raw_readl(S3C2410_CLKCON); - - if (enable) - clkcon |= clocks; - else - clkcon &= ~clocks; - - __raw_writel(clkcon, S3C2410_CLKCON); - - return 0; -} - -static int s3c2412_upll_enable(struct clk *clk, int enable) -{ - unsigned long upllcon = __raw_readl(S3C2410_UPLLCON); - unsigned long orig = upllcon; - - if (!enable) - upllcon |= S3C2412_PLLCON_OFF; - else - upllcon &= ~S3C2412_PLLCON_OFF; - - __raw_writel(upllcon, S3C2410_UPLLCON); - - /* allow ~150uS for the PLL to settle and lock */ - - if (enable && (orig & S3C2412_PLLCON_OFF)) - udelay(150); - - return 0; -} - -/* clock selections */ - -static struct clk clk_erefclk = { - .name = "erefclk", -}; - -static struct clk clk_urefclk = { - .name = "urefclk", -}; - -static int s3c2412_setparent_usysclk(struct clk *clk, struct clk *parent) -{ - unsigned long clksrc = __raw_readl(S3C2412_CLKSRC); - - if (parent == &clk_urefclk) - clksrc &= ~S3C2412_CLKSRC_USYSCLK_UPLL; - else if (parent == &clk_upll) - clksrc |= S3C2412_CLKSRC_USYSCLK_UPLL; - else - return -EINVAL; - - clk->parent = parent; - - __raw_writel(clksrc, S3C2412_CLKSRC); - return 0; -} - -static struct clk clk_usysclk = { - .name = "usysclk", - .parent = &clk_xtal, - .ops = &(struct clk_ops) { - .set_parent = s3c2412_setparent_usysclk, - }, -}; - -static struct clk clk_mrefclk = { - .name = "mrefclk", - .parent = &clk_xtal, -}; - -static struct clk clk_mdivclk = { - .name = "mdivclk", - .parent = &clk_xtal, -}; - -static int s3c2412_setparent_usbsrc(struct clk *clk, struct clk *parent) -{ - unsigned long clksrc = __raw_readl(S3C2412_CLKSRC); - - if (parent == &clk_usysclk) - clksrc &= ~S3C2412_CLKSRC_USBCLK_HCLK; - else if (parent == &clk_h) - clksrc |= S3C2412_CLKSRC_USBCLK_HCLK; - else - return -EINVAL; - - clk->parent = parent; - - __raw_writel(clksrc, S3C2412_CLKSRC); - return 0; -} - -static unsigned long s3c2412_roundrate_usbsrc(struct clk *clk, - unsigned long rate) -{ - unsigned long parent_rate = clk_get_rate(clk->parent); - int div; - - if (rate > parent_rate) - return parent_rate; - - div = parent_rate / rate; - if (div > 2) - div = 2; - - return parent_rate / div; -} - -static unsigned long s3c2412_getrate_usbsrc(struct clk *clk) -{ - unsigned long parent_rate = clk_get_rate(clk->parent); - unsigned long div = __raw_readl(S3C2410_CLKDIVN); - - return parent_rate / ((div & S3C2412_CLKDIVN_USB48DIV) ? 2 : 1); -} - -static int s3c2412_setrate_usbsrc(struct clk *clk, unsigned long rate) -{ - unsigned long parent_rate = clk_get_rate(clk->parent); - unsigned long clkdivn = __raw_readl(S3C2410_CLKDIVN); - - rate = s3c2412_roundrate_usbsrc(clk, rate); - - if ((parent_rate / rate) == 2) - clkdivn |= S3C2412_CLKDIVN_USB48DIV; - else - clkdivn &= ~S3C2412_CLKDIVN_USB48DIV; - - __raw_writel(clkdivn, S3C2410_CLKDIVN); - return 0; -} - -static struct clk clk_usbsrc = { - .name = "usbsrc", - .ops = &(struct clk_ops) { - .get_rate = s3c2412_getrate_usbsrc, - .set_rate = s3c2412_setrate_usbsrc, - .round_rate = s3c2412_roundrate_usbsrc, - .set_parent = s3c2412_setparent_usbsrc, - }, -}; - -static int s3c2412_setparent_msysclk(struct clk *clk, struct clk *parent) -{ - unsigned long clksrc = __raw_readl(S3C2412_CLKSRC); - - if (parent == &clk_mdivclk) - clksrc &= ~S3C2412_CLKSRC_MSYSCLK_MPLL; - else if (parent == &clk_mpll) - clksrc |= S3C2412_CLKSRC_MSYSCLK_MPLL; - else - return -EINVAL; - - clk->parent = parent; - - __raw_writel(clksrc, S3C2412_CLKSRC); - return 0; -} - -static struct clk clk_msysclk = { - .name = "msysclk", - .ops = &(struct clk_ops) { - .set_parent = s3c2412_setparent_msysclk, - }, -}; - -static int s3c2412_setparent_armclk(struct clk *clk, struct clk *parent) -{ - unsigned long flags; - unsigned long clkdiv; - unsigned long dvs; - - /* Note, we current equate fclk andf msysclk for S3C2412 */ - - if (parent == &clk_msysclk || parent == &clk_f) - dvs = 0; - else if (parent == &clk_h) - dvs = S3C2412_CLKDIVN_DVSEN; - else - return -EINVAL; - - clk->parent = parent; - - /* update this under irq lockdown, clkdivn is not protected - * by the clock system. */ - - local_irq_save(flags); - - clkdiv = __raw_readl(S3C2410_CLKDIVN); - clkdiv &= ~S3C2412_CLKDIVN_DVSEN; - clkdiv |= dvs; - __raw_writel(clkdiv, S3C2410_CLKDIVN); - - local_irq_restore(flags); - - return 0; -} - -static struct clk clk_armclk = { - .name = "armclk", - .parent = &clk_msysclk, - .ops = &(struct clk_ops) { - .set_parent = s3c2412_setparent_armclk, - }, -}; - -/* these next clocks have an divider immediately after them, - * so we can register them with their divider and leave out the - * intermediate clock stage -*/ -static unsigned long s3c2412_roundrate_clksrc(struct clk *clk, - unsigned long rate) -{ - unsigned long parent_rate = clk_get_rate(clk->parent); - int div; - - if (rate > parent_rate) - return parent_rate; - - /* note, we remove the +/- 1 calculations as they cancel out */ - - div = (rate / parent_rate); - - if (div < 1) - div = 1; - else if (div > 16) - div = 16; - - return parent_rate / div; -} - -static int s3c2412_setparent_uart(struct clk *clk, struct clk *parent) -{ - unsigned long clksrc = __raw_readl(S3C2412_CLKSRC); - - if (parent == &clk_erefclk) - clksrc &= ~S3C2412_CLKSRC_UARTCLK_MPLL; - else if (parent == &clk_mpll) - clksrc |= S3C2412_CLKSRC_UARTCLK_MPLL; - else - return -EINVAL; - - clk->parent = parent; - - __raw_writel(clksrc, S3C2412_CLKSRC); - return 0; -} - -static unsigned long s3c2412_getrate_uart(struct clk *clk) -{ - unsigned long parent_rate = clk_get_rate(clk->parent); - unsigned long div = __raw_readl(S3C2410_CLKDIVN); - - div &= S3C2412_CLKDIVN_UARTDIV_MASK; - div >>= S3C2412_CLKDIVN_UARTDIV_SHIFT; - - return parent_rate / (div + 1); -} - -static int s3c2412_setrate_uart(struct clk *clk, unsigned long rate) -{ - unsigned long parent_rate = clk_get_rate(clk->parent); - unsigned long clkdivn = __raw_readl(S3C2410_CLKDIVN); - - rate = s3c2412_roundrate_clksrc(clk, rate); - - clkdivn &= ~S3C2412_CLKDIVN_UARTDIV_MASK; - clkdivn |= ((parent_rate / rate) - 1) << S3C2412_CLKDIVN_UARTDIV_SHIFT; - - __raw_writel(clkdivn, S3C2410_CLKDIVN); - return 0; -} - -static struct clk clk_uart = { - .name = "uartclk", - .ops = &(struct clk_ops) { - .get_rate = s3c2412_getrate_uart, - .set_rate = s3c2412_setrate_uart, - .set_parent = s3c2412_setparent_uart, - .round_rate = s3c2412_roundrate_clksrc, - }, -}; - -static int s3c2412_setparent_i2s(struct clk *clk, struct clk *parent) -{ - unsigned long clksrc = __raw_readl(S3C2412_CLKSRC); - - if (parent == &clk_erefclk) - clksrc &= ~S3C2412_CLKSRC_I2SCLK_MPLL; - else if (parent == &clk_mpll) - clksrc |= S3C2412_CLKSRC_I2SCLK_MPLL; - else - return -EINVAL; - - clk->parent = parent; - - __raw_writel(clksrc, S3C2412_CLKSRC); - return 0; -} - -static unsigned long s3c2412_getrate_i2s(struct clk *clk) -{ - unsigned long parent_rate = clk_get_rate(clk->parent); - unsigned long div = __raw_readl(S3C2410_CLKDIVN); - - div &= S3C2412_CLKDIVN_I2SDIV_MASK; - div >>= S3C2412_CLKDIVN_I2SDIV_SHIFT; - - return parent_rate / (div + 1); -} - -static int s3c2412_setrate_i2s(struct clk *clk, unsigned long rate) -{ - unsigned long parent_rate = clk_get_rate(clk->parent); - unsigned long clkdivn = __raw_readl(S3C2410_CLKDIVN); - - rate = s3c2412_roundrate_clksrc(clk, rate); - - clkdivn &= ~S3C2412_CLKDIVN_I2SDIV_MASK; - clkdivn |= ((parent_rate / rate) - 1) << S3C2412_CLKDIVN_I2SDIV_SHIFT; - - __raw_writel(clkdivn, S3C2410_CLKDIVN); - return 0; -} - -static struct clk clk_i2s = { - .name = "i2sclk", - .ops = &(struct clk_ops) { - .get_rate = s3c2412_getrate_i2s, - .set_rate = s3c2412_setrate_i2s, - .set_parent = s3c2412_setparent_i2s, - .round_rate = s3c2412_roundrate_clksrc, - }, -}; - -static int s3c2412_setparent_cam(struct clk *clk, struct clk *parent) -{ - unsigned long clksrc = __raw_readl(S3C2412_CLKSRC); - - if (parent == &clk_usysclk) - clksrc &= ~S3C2412_CLKSRC_CAMCLK_HCLK; - else if (parent == &clk_h) - clksrc |= S3C2412_CLKSRC_CAMCLK_HCLK; - else - return -EINVAL; - - clk->parent = parent; - - __raw_writel(clksrc, S3C2412_CLKSRC); - return 0; -} -static unsigned long s3c2412_getrate_cam(struct clk *clk) -{ - unsigned long parent_rate = clk_get_rate(clk->parent); - unsigned long div = __raw_readl(S3C2410_CLKDIVN); - - div &= S3C2412_CLKDIVN_CAMDIV_MASK; - div >>= S3C2412_CLKDIVN_CAMDIV_SHIFT; - - return parent_rate / (div + 1); -} - -static int s3c2412_setrate_cam(struct clk *clk, unsigned long rate) -{ - unsigned long parent_rate = clk_get_rate(clk->parent); - unsigned long clkdivn = __raw_readl(S3C2410_CLKDIVN); - - rate = s3c2412_roundrate_clksrc(clk, rate); - - clkdivn &= ~S3C2412_CLKDIVN_CAMDIV_MASK; - clkdivn |= ((parent_rate / rate) - 1) << S3C2412_CLKDIVN_CAMDIV_SHIFT; - - __raw_writel(clkdivn, S3C2410_CLKDIVN); - return 0; -} - -static struct clk clk_cam = { - .name = "camif-upll", /* same as 2440 name */ - .ops = &(struct clk_ops) { - .get_rate = s3c2412_getrate_cam, - .set_rate = s3c2412_setrate_cam, - .set_parent = s3c2412_setparent_cam, - .round_rate = s3c2412_roundrate_clksrc, - }, -}; - -/* standard clock definitions */ - -static struct clk init_clocks_disable[] = { - { - .name = "nand", - .parent = &clk_h, - .enable = s3c2412_clkcon_enable, - .ctrlbit = S3C2412_CLKCON_NAND, - }, { - .name = "sdi", - .parent = &clk_p, - .enable = s3c2412_clkcon_enable, - .ctrlbit = S3C2412_CLKCON_SDI, - }, { - .name = "adc", - .parent = &clk_p, - .enable = s3c2412_clkcon_enable, - .ctrlbit = S3C2412_CLKCON_ADC, - }, { - .name = "i2c", - .parent = &clk_p, - .enable = s3c2412_clkcon_enable, - .ctrlbit = S3C2412_CLKCON_IIC, - }, { - .name = "iis", - .parent = &clk_p, - .enable = s3c2412_clkcon_enable, - .ctrlbit = S3C2412_CLKCON_IIS, - }, { - .name = "spi", - .parent = &clk_p, - .enable = s3c2412_clkcon_enable, - .ctrlbit = S3C2412_CLKCON_SPI, - } -}; - -static struct clk init_clocks[] = { - { - .name = "dma.0", - .parent = &clk_h, - .enable = s3c2412_clkcon_enable, - .ctrlbit = S3C2412_CLKCON_DMA0, - }, { - .name = "dma.1", - .parent = &clk_h, - .enable = s3c2412_clkcon_enable, - .ctrlbit = S3C2412_CLKCON_DMA1, - }, { - .name = "dma.2", - .parent = &clk_h, - .enable = s3c2412_clkcon_enable, - .ctrlbit = S3C2412_CLKCON_DMA2, - }, { - .name = "dma.3", - .parent = &clk_h, - .enable = s3c2412_clkcon_enable, - .ctrlbit = S3C2412_CLKCON_DMA3, - }, { - .name = "lcd", - .parent = &clk_h, - .enable = s3c2412_clkcon_enable, - .ctrlbit = S3C2412_CLKCON_LCDC, - }, { - .name = "gpio", - .parent = &clk_p, - .enable = s3c2412_clkcon_enable, - .ctrlbit = S3C2412_CLKCON_GPIO, - }, { - .name = "usb-host", - .parent = &clk_h, - .enable = s3c2412_clkcon_enable, - .ctrlbit = S3C2412_CLKCON_USBH, - }, { - .name = "usb-device", - .parent = &clk_h, - .enable = s3c2412_clkcon_enable, - .ctrlbit = S3C2412_CLKCON_USBD, - }, { - .name = "timers", - .parent = &clk_p, - .enable = s3c2412_clkcon_enable, - .ctrlbit = S3C2412_CLKCON_PWMT, - }, { - .name = "uart", - .devname = "s3c2412-uart.0", - .parent = &clk_p, - .enable = s3c2412_clkcon_enable, - .ctrlbit = S3C2412_CLKCON_UART0, - }, { - .name = "uart", - .devname = "s3c2412-uart.1", - .parent = &clk_p, - .enable = s3c2412_clkcon_enable, - .ctrlbit = S3C2412_CLKCON_UART1, - }, { - .name = "uart", - .devname = "s3c2412-uart.2", - .parent = &clk_p, - .enable = s3c2412_clkcon_enable, - .ctrlbit = S3C2412_CLKCON_UART2, - }, { - .name = "rtc", - .parent = &clk_p, - .enable = s3c2412_clkcon_enable, - .ctrlbit = S3C2412_CLKCON_RTC, - }, { - .name = "watchdog", - .parent = &clk_p, - .ctrlbit = 0, - }, { - .name = "usb-bus-gadget", - .parent = &clk_usb_bus, - .enable = s3c2412_clkcon_enable, - .ctrlbit = S3C2412_CLKCON_USB_DEV48, - }, { - .name = "usb-bus-host", - .parent = &clk_usb_bus, - .enable = s3c2412_clkcon_enable, - .ctrlbit = S3C2412_CLKCON_USB_HOST48, - } -}; - -/* clocks to add where we need to check their parentage */ - -struct clk_init { - struct clk *clk; - unsigned int bit; - struct clk *src_0; - struct clk *src_1; -}; - -static struct clk_init clks_src[] __initdata = { - { - .clk = &clk_usysclk, - .bit = S3C2412_CLKSRC_USBCLK_HCLK, - .src_0 = &clk_urefclk, - .src_1 = &clk_upll, - }, { - .clk = &clk_i2s, - .bit = S3C2412_CLKSRC_I2SCLK_MPLL, - .src_0 = &clk_erefclk, - .src_1 = &clk_mpll, - }, { - .clk = &clk_cam, - .bit = S3C2412_CLKSRC_CAMCLK_HCLK, - .src_0 = &clk_usysclk, - .src_1 = &clk_h, - }, { - .clk = &clk_msysclk, - .bit = S3C2412_CLKSRC_MSYSCLK_MPLL, - .src_0 = &clk_mdivclk, - .src_1 = &clk_mpll, - }, { - .clk = &clk_uart, - .bit = S3C2412_CLKSRC_UARTCLK_MPLL, - .src_0 = &clk_erefclk, - .src_1 = &clk_mpll, - }, { - .clk = &clk_usbsrc, - .bit = S3C2412_CLKSRC_USBCLK_HCLK, - .src_0 = &clk_usysclk, - .src_1 = &clk_h, - /* here we assume OM[4] select xtal */ - }, { - .clk = &clk_erefclk, - .bit = S3C2412_CLKSRC_EREFCLK_EXTCLK, - .src_0 = &clk_xtal, - .src_1 = &clk_ext, - }, { - .clk = &clk_urefclk, - .bit = S3C2412_CLKSRC_UREFCLK_EXTCLK, - .src_0 = &clk_xtal, - .src_1 = &clk_ext, - }, -}; - -/* s3c2412_clk_initparents - * - * Initialise the parents for the clocks that we get at start-time -*/ - -static void __init s3c2412_clk_initparents(void) -{ - unsigned long clksrc = __raw_readl(S3C2412_CLKSRC); - struct clk_init *cip = clks_src; - struct clk *src; - int ptr; - int ret; - - for (ptr = 0; ptr < ARRAY_SIZE(clks_src); ptr++, cip++) { - ret = s3c24xx_register_clock(cip->clk); - if (ret < 0) { - printk(KERN_ERR "Failed to register clock %s (%d)\n", - cip->clk->name, ret); - } - - src = (clksrc & cip->bit) ? cip->src_1 : cip->src_0; - - printk(KERN_INFO "%s: parent %s\n", cip->clk->name, src->name); - clk_set_parent(cip->clk, src); - } -} - -/* clocks to add straight away */ - -static struct clk *clks[] __initdata = { - &clk_ext, - &clk_usb_bus, - &clk_mrefclk, - &clk_armclk, -}; - -static struct clk_lookup s3c2412_clk_lookup[] = { - CLKDEV_INIT(NULL, "clk_uart_baud1", &s3c24xx_uclk), - CLKDEV_INIT(NULL, "clk_uart_baud2", &clk_p), - CLKDEV_INIT(NULL, "clk_uart_baud3", &clk_usysclk), -}; - -int __init s3c2412_baseclk_add(void) -{ - unsigned long clkcon = __raw_readl(S3C2410_CLKCON); - unsigned int dvs; - struct clk *clkp; - int ret; - int ptr; - - clk_upll.enable = s3c2412_upll_enable; - clk_usb_bus.parent = &clk_usbsrc; - clk_usb_bus.rate = 0x0; - - clk_f.parent = &clk_msysclk; - - s3c2412_clk_initparents(); - - for (ptr = 0; ptr < ARRAY_SIZE(clks); ptr++) { - clkp = clks[ptr]; - - ret = s3c24xx_register_clock(clkp); - if (ret < 0) { - printk(KERN_ERR "Failed to register clock %s (%d)\n", - clkp->name, ret); - } - } - - /* set the dvs state according to what we got at boot time */ - - dvs = __raw_readl(S3C2410_CLKDIVN) & S3C2412_CLKDIVN_DVSEN; - - if (dvs) - clk_armclk.parent = &clk_h; - - printk(KERN_INFO "S3C2412: DVS is %s\n", dvs ? "on" : "off"); - - /* ensure usb bus clock is within correct rate of 48MHz */ - - if (clk_get_rate(&clk_usb_bus) != (48 * 1000 * 1000)) { - printk(KERN_INFO "Warning: USB bus clock not at 48MHz\n"); - - /* for the moment, let's use the UPLL, and see if we can - * get 48MHz */ - - clk_set_parent(&clk_usysclk, &clk_upll); - clk_set_parent(&clk_usbsrc, &clk_usysclk); - clk_set_rate(&clk_usbsrc, 48*1000*1000); - } - - printk("S3C2412: upll %s, %ld.%03ld MHz, usb-bus %ld.%03ld MHz\n", - (__raw_readl(S3C2410_UPLLCON) & S3C2412_PLLCON_OFF) ? "off":"on", - print_mhz(clk_get_rate(&clk_upll)), - print_mhz(clk_get_rate(&clk_usb_bus))); - - /* register clocks from clock array */ - - clkp = init_clocks; - for (ptr = 0; ptr < ARRAY_SIZE(init_clocks); ptr++, clkp++) { - /* ensure that we note the clock state */ - - clkp->usage = clkcon & clkp->ctrlbit ? 1 : 0; - - ret = s3c24xx_register_clock(clkp); - if (ret < 0) { - printk(KERN_ERR "Failed to register clock %s (%d)\n", - clkp->name, ret); - } - } - - /* We must be careful disabling the clocks we are not intending to - * be using at boot time, as subsystems such as the LCD which do - * their own DMA requests to the bus can cause the system to lockup - * if they where in the middle of requesting bus access. - * - * Disabling the LCD clock if the LCD is active is very dangerous, - * and therefore the bootloader should be careful to not enable - * the LCD clock if it is not needed. - */ - - /* install (and disable) the clocks we do not need immediately */ - - clkp = init_clocks_disable; - for (ptr = 0; ptr < ARRAY_SIZE(init_clocks_disable); ptr++, clkp++) { - - ret = s3c24xx_register_clock(clkp); - if (ret < 0) { - printk(KERN_ERR "Failed to register clock %s (%d)\n", - clkp->name, ret); - } - - s3c2412_clkcon_enable(clkp, 0); - } - - clkdev_add_table(s3c2412_clk_lookup, ARRAY_SIZE(s3c2412_clk_lookup)); - return 0; -} diff --git a/arch/arm/mach-s3c24xx/common.c b/arch/arm/mach-s3c24xx/common.c index 412ca006fcce..ad5b76bf4d51 100644 --- a/arch/arm/mach-s3c24xx/common.c +++ b/arch/arm/mach-s3c24xx/common.c @@ -127,7 +127,6 @@ static struct cpu_table cpu_ids[] __initdata = { .idcode = 0x32412001, .idmask = 0xffffffff, .map_io = s3c2412_map_io, - .init_clocks = s3c2412_init_clocks, .init_uarts = s3c2412_init_uarts, .init = s3c2412_init, .name = name_s3c2412, @@ -136,7 +135,6 @@ static struct cpu_table cpu_ids[] __initdata = { .idcode = 0x32412003, .idmask = 0xffffffff, .map_io = s3c2412_map_io, - .init_clocks = s3c2412_init_clocks, .init_uarts = s3c2412_init_uarts, .init = s3c2412_init, .name = name_s3c2412, @@ -535,6 +533,13 @@ struct platform_device s3c2443_device_dma = { }; #endif +#ifdef CONFIG_CPU_S3C2412 +void __init s3c2412_init_clocks(int xtal) +{ + s3c2412_common_clk_init(NULL, xtal, 0, S3C24XX_VA_CLKPWR); +} +#endif + #ifdef CONFIG_CPU_S3C2416 void __init s3c2416_init_clocks(int xtal) { diff --git a/arch/arm/mach-s3c24xx/common.h b/arch/arm/mach-s3c24xx/common.h index d7323f16427f..3fade6d796f9 100644 --- a/arch/arm/mach-s3c24xx/common.h +++ b/arch/arm/mach-s3c24xx/common.h @@ -114,6 +114,10 @@ extern struct platform_device s3c2412_device_dma; extern struct platform_device s3c2440_device_dma; extern struct platform_device s3c2443_device_dma; +#ifdef CONFIG_S3C2412_COMMON_CLK +void __init s3c2412_common_clk_init(struct device_node *np, unsigned long xti_f, + unsigned long ext_f, void __iomem *reg_base); +#endif #ifdef CONFIG_S3C2443_COMMON_CLK void __init s3c2443_common_clk_init(struct device_node *np, unsigned long xti_f, int current_soc, diff --git a/arch/arm/mach-s3c24xx/mach-jive.c b/arch/arm/mach-s3c24xx/mach-jive.c index 5faa7239e7d6..e81ea82c55f9 100644 --- a/arch/arm/mach-s3c24xx/mach-jive.c +++ b/arch/arm/mach-s3c24xx/mach-jive.c @@ -507,11 +507,16 @@ static struct syscore_ops jive_pm_syscore_ops = { static void __init jive_map_io(void) { s3c24xx_init_io(jive_iodesc, ARRAY_SIZE(jive_iodesc)); - s3c24xx_init_clocks(12000000); s3c24xx_init_uarts(jive_uartcfgs, ARRAY_SIZE(jive_uartcfgs)); samsung_set_timer_source(SAMSUNG_PWM3, SAMSUNG_PWM4); } +static void __init jive_init_time(void) +{ + s3c2412_init_clocks(12000000); + samsung_timer_init(); +} + static void jive_power_off(void) { printk(KERN_INFO "powering system down...\n"); @@ -665,6 +670,6 @@ MACHINE_START(JIVE, "JIVE") .init_irq = s3c2412_init_irq, .map_io = jive_map_io, .init_machine = jive_machine_init, - .init_time = samsung_timer_init, + .init_time = jive_init_time, .restart = s3c2412_restart, MACHINE_END diff --git a/arch/arm/mach-s3c24xx/mach-smdk2413.c b/arch/arm/mach-s3c24xx/mach-smdk2413.c index 233fe52d2015..a38f8a049e22 100644 --- a/arch/arm/mach-s3c24xx/mach-smdk2413.c +++ b/arch/arm/mach-s3c24xx/mach-smdk2413.c @@ -106,11 +106,16 @@ static void __init smdk2413_fixup(struct tag *tags, char **cmdline, static void __init smdk2413_map_io(void) { s3c24xx_init_io(smdk2413_iodesc, ARRAY_SIZE(smdk2413_iodesc)); - s3c24xx_init_clocks(12000000); s3c24xx_init_uarts(smdk2413_uartcfgs, ARRAY_SIZE(smdk2413_uartcfgs)); samsung_set_timer_source(SAMSUNG_PWM3, SAMSUNG_PWM4); } +static void __init smdk2413_init_time(void) +{ + s3c2412_init_clocks(12000000); + samsung_timer_init(); +} + static void __init smdk2413_machine_init(void) { /* Turn off suspend on both USB ports, and switch the * selectable USB port to USB device mode. */ @@ -159,6 +164,6 @@ MACHINE_START(SMDK2413, "SMDK2413") .init_irq = s3c2412_init_irq, .map_io = smdk2413_map_io, .init_machine = smdk2413_machine_init, - .init_time = samsung_timer_init, + .init_time = smdk2413_init_time, .restart = s3c2412_restart, MACHINE_END diff --git a/arch/arm/mach-s3c24xx/mach-vstms.c b/arch/arm/mach-s3c24xx/mach-vstms.c index 40868c0e0a68..6b706c915387 100644 --- a/arch/arm/mach-s3c24xx/mach-vstms.c +++ b/arch/arm/mach-s3c24xx/mach-vstms.c @@ -142,11 +142,16 @@ static void __init vstms_fixup(struct tag *tags, char **cmdline, static void __init vstms_map_io(void) { s3c24xx_init_io(vstms_iodesc, ARRAY_SIZE(vstms_iodesc)); - s3c24xx_init_clocks(12000000); s3c24xx_init_uarts(vstms_uartcfgs, ARRAY_SIZE(vstms_uartcfgs)); samsung_set_timer_source(SAMSUNG_PWM3, SAMSUNG_PWM4); } +static void __init vstms_init_time(void) +{ + s3c2412_init_clocks(12000000); + samsung_timer_init(); +} + static void __init vstms_init(void) { s3c_i2c0_set_platdata(NULL); @@ -162,6 +167,6 @@ MACHINE_START(VSTMS, "VSTMS") .init_irq = s3c2412_init_irq, .init_machine = vstms_init, .map_io = vstms_map_io, - .init_time = samsung_timer_init, + .init_time = vstms_init_time, .restart = s3c2412_restart, MACHINE_END diff --git a/arch/arm/mach-s3c24xx/s3c2412.c b/arch/arm/mach-s3c24xx/s3c2412.c index 657cbaca80ac..d49f52fbc842 100644 --- a/arch/arm/mach-s3c24xx/s3c2412.c +++ b/arch/arm/mach-s3c24xx/s3c2412.c @@ -173,49 +173,6 @@ void __init s3c2412_map_io(void) void __init_or_cpufreq s3c2412_setup_clocks(void) { - struct clk *xtal_clk; - unsigned long tmp; - unsigned long xtal; - unsigned long fclk; - unsigned long hclk; - unsigned long pclk; - - xtal_clk = clk_get(NULL, "xtal"); - xtal = clk_get_rate(xtal_clk); - clk_put(xtal_clk); - - /* now we've got our machine bits initialised, work out what - * clocks we've got */ - - fclk = s3c24xx_get_pll(__raw_readl(S3C2410_MPLLCON), xtal * 2); - - clk_mpll.rate = fclk; - - tmp = __raw_readl(S3C2410_CLKDIVN); - - /* work out clock scalings */ - - hclk = fclk / ((tmp & S3C2412_CLKDIVN_HDIVN_MASK) + 1); - hclk /= ((tmp & S3C2412_CLKDIVN_ARMDIVN) ? 2 : 1); - pclk = hclk / ((tmp & S3C2412_CLKDIVN_PDIVN) ? 2 : 1); - - /* print brieft summary of clocks, etc */ - - printk("S3C2412: core %ld.%03ld MHz, memory %ld.%03ld MHz, peripheral %ld.%03ld MHz\n", - print_mhz(fclk), print_mhz(hclk), print_mhz(pclk)); - - s3c24xx_setup_clocks(fclk, hclk, pclk); -} - -void __init s3c2412_init_clocks(int xtal) -{ - /* initialise the clocks here, to allow other things like the - * console to use them - */ - - s3c24xx_register_baseclocks(xtal); - s3c2412_setup_clocks(); - s3c2412_baseclk_add(); } /* need to register the subsystem before we actually register the device, and -- cgit v1.2.3 From 24e4a0f3de21ad715c9235367e241554c64b9adb Mon Sep 17 00:00:00 2001 From: Fabian Frederick Date: Mon, 14 Apr 2014 09:39:01 +0200 Subject: fs/jfs/jfs_inode.c: atomically set inode->i_flags According to commit 5f16f3225b0624 ext4: atomically set inode->i_flags in ext4_set_inode_flags() Signed-off-by: Fabian Frederick Signed-off-by: Dave Kleikamp Cc: "Theodore Ts'o" --- fs/jfs/jfs_inode.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/fs/jfs/jfs_inode.c b/fs/jfs/jfs_inode.c index 7f464c513ba0..6b0f816201a2 100644 --- a/fs/jfs/jfs_inode.c +++ b/fs/jfs/jfs_inode.c @@ -29,20 +29,20 @@ void jfs_set_inode_flags(struct inode *inode) { unsigned int flags = JFS_IP(inode)->mode2; - - inode->i_flags &= ~(S_IMMUTABLE | S_APPEND | - S_NOATIME | S_DIRSYNC | S_SYNC); + unsigned int new_fl = 0; if (flags & JFS_IMMUTABLE_FL) - inode->i_flags |= S_IMMUTABLE; + new_fl |= S_IMMUTABLE; if (flags & JFS_APPEND_FL) - inode->i_flags |= S_APPEND; + new_fl |= S_APPEND; if (flags & JFS_NOATIME_FL) - inode->i_flags |= S_NOATIME; + new_fl |= S_NOATIME; if (flags & JFS_DIRSYNC_FL) - inode->i_flags |= S_DIRSYNC; + new_fl |= S_DIRSYNC; if (flags & JFS_SYNC_FL) - inode->i_flags |= S_SYNC; + new_fl |= S_SYNC; + inode_set_flags(inode, new_fl, S_IMMUTABLE | S_APPEND | S_NOATIME | + S_DIRSYNC | S_SYNC); } void jfs_get_inode_flags(struct jfs_inode_info *jfs_ip) -- cgit v1.2.3 From ccffbd27af95700f6e46f5300fcc96c0cda9f178 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Fri, 4 Apr 2014 11:29:08 +0530 Subject: ASoC: pcm512x: Use CONFIG_PM_RUNTIME macro MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes the following compilation warnings: sound/soc/codecs/pcm512x.c:520:12: warning: ‘pcm512x_suspend’ defined but not used [-Wunused-function] sound/soc/codecs/pcm512x.c:545:12: warning: ‘pcm512x_resume’ defined but not used [-Wunused-function] Signed-off-by: Sachin Kamat Signed-off-by: Mark Brown --- sound/soc/codecs/pcm512x.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sound/soc/codecs/pcm512x.c b/sound/soc/codecs/pcm512x.c index 4b4c0c7bb918..51124202f765 100644 --- a/sound/soc/codecs/pcm512x.c +++ b/sound/soc/codecs/pcm512x.c @@ -517,6 +517,7 @@ void pcm512x_remove(struct device *dev) } EXPORT_SYMBOL_GPL(pcm512x_remove); +#ifdef CONFIG_PM_RUNTIME static int pcm512x_suspend(struct device *dev) { struct pcm512x_priv *pcm512x = dev_get_drvdata(dev); @@ -578,6 +579,7 @@ static int pcm512x_resume(struct device *dev) return 0; } +#endif const struct dev_pm_ops pcm512x_pm_ops = { SET_RUNTIME_PM_OPS(pcm512x_suspend, pcm512x_resume, NULL) -- cgit v1.2.3 From a6b34312b027833de87c31e63a5d06b07186bacf Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Fri, 4 Apr 2014 11:29:09 +0530 Subject: ASoC: hdmi: Include of.h of_match_ptr is defined in of.h. Include it explicitly. Signed-off-by: Sachin Kamat Signed-off-by: Mark Brown --- sound/soc/codecs/hdmi.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sound/soc/codecs/hdmi.c b/sound/soc/codecs/hdmi.c index 9cb1c7d3e1dc..1087fd5f9917 100644 --- a/sound/soc/codecs/hdmi.c +++ b/sound/soc/codecs/hdmi.c @@ -20,6 +20,7 @@ */ #include #include +#include #include #define DRV_NAME "hdmi-audio-codec" -- cgit v1.2.3 From 6e1f29d4ef1c13ab87fe785fe6e1213d57232a31 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Fri, 4 Apr 2014 11:29:10 +0530 Subject: ASoC: max98090: Include of.h of_match_ptr is defined in of.h. Include it explicitly. Signed-off-by: Sachin Kamat Signed-off-by: Mark Brown --- sound/soc/codecs/max98090.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sound/soc/codecs/max98090.c b/sound/soc/codecs/max98090.c index f7b0b37aa858..4959e762f88a 100644 --- a/sound/soc/codecs/max98090.c +++ b/sound/soc/codecs/max98090.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include -- cgit v1.2.3 From affb74ad299631666e5bf1f455e3baa7035ea58f Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Fri, 4 Apr 2014 11:29:11 +0530 Subject: ASoC: rt5640: Include of.h of_match_ptr is defined in of.h. Include it explicitly. Signed-off-by: Sachin Kamat Signed-off-by: Mark Brown --- sound/soc/codecs/rt5640.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sound/soc/codecs/rt5640.c b/sound/soc/codecs/rt5640.c index 68b4dd622b87..635363cb73e9 100644 --- a/sound/soc/codecs/rt5640.c +++ b/sound/soc/codecs/rt5640.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include -- cgit v1.2.3 From 0faabc4f4c31deb73077e9f77989406e2fc49c77 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Fri, 4 Apr 2014 11:29:12 +0530 Subject: ASoC: tlv320aic23: Include of.h of_match_ptr is defined in of.h. Include it explicitly. Signed-off-by: Sachin Kamat Signed-off-by: Mark Brown --- sound/soc/codecs/tlv320aic23-i2c.c | 1 + sound/soc/codecs/tlv320aic31xx.c | 1 + 2 files changed, 2 insertions(+) diff --git a/sound/soc/codecs/tlv320aic23-i2c.c b/sound/soc/codecs/tlv320aic23-i2c.c index b73c94ebcc2a..f13701995482 100644 --- a/sound/soc/codecs/tlv320aic23-i2c.c +++ b/sound/soc/codecs/tlv320aic23-i2c.c @@ -13,6 +13,7 @@ #include #include +#include #include #include diff --git a/sound/soc/codecs/tlv320aic31xx.c b/sound/soc/codecs/tlv320aic31xx.c index fa158cfe9b32..b93d500e960b 100644 --- a/sound/soc/codecs/tlv320aic31xx.c +++ b/sound/soc/codecs/tlv320aic31xx.c @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #include -- cgit v1.2.3 From ee5e4534f7b39aaf1256d3de14f412489d5879df Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Fri, 4 Apr 2014 11:29:13 +0530 Subject: ASoC: tpa6130a2: Include of.h of_match_ptr is defined in of.h. Include it explicitly. Signed-off-by: Sachin Kamat Signed-off-by: Mark Brown --- sound/soc/codecs/tpa6130a2.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sound/soc/codecs/tpa6130a2.c b/sound/soc/codecs/tpa6130a2.c index b27c396037d4..8fc5a647453b 100644 --- a/sound/soc/codecs/tpa6130a2.c +++ b/sound/soc/codecs/tpa6130a2.c @@ -30,6 +30,7 @@ #include #include #include +#include #include #include "tpa6130a2.h" -- cgit v1.2.3 From 12023a9af8f6602e09d9276d3476f6861ca0f127 Mon Sep 17 00:00:00 2001 From: Misael Lopez Cruz Date: Fri, 21 Mar 2014 16:27:25 +0100 Subject: ASoC: core: Add helpers for codec and codec_dai search Add dedicated helpers for codec and codec_dai search in preparation for DAI-multicodec. It will help reducing the extra indentation that will be introduced by the iteration over multiple codecs. Previous implementation unnecessarily kept searching for a matching codec in the remaining register codecs even if it was already found. Fix that by returning in case of matching. Signed-off-by: Misael Lopez Cruz [fparent@baylibre.com: Adapt to 3.14+] Signed-off-by: Fabien Parent Signed-off-by: Benoit Cousson Signed-off-by: Mark Brown --- sound/soc/soc-core.c | 79 +++++++++++++++++++++++++++++++--------------------- 1 file changed, 47 insertions(+), 32 deletions(-) diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 051c006281f5..674da7049db4 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -854,14 +854,47 @@ EXPORT_SYMBOL_GPL(snd_soc_resume); static const struct snd_soc_dai_ops null_dai_ops = { }; +static struct snd_soc_codec *soc_find_codec(const struct device_node *codec_of_node, + const char *codec_name) +{ + struct snd_soc_codec *codec; + + list_for_each_entry(codec, &codec_list, list) { + if (codec_of_node) { + if (codec->dev->of_node != codec_of_node) + continue; + } else { + if (strcmp(codec->name, codec_name)) + continue; + } + + return codec; + } + + return NULL; +} + +static struct snd_soc_dai *soc_find_codec_dai(struct snd_soc_codec *codec, + const char *codec_dai_name) +{ + struct snd_soc_dai *codec_dai; + + list_for_each_entry(codec_dai, &codec->component.dai_list, list) { + if (!strcmp(codec_dai->name, codec_dai_name)) { + return codec_dai; + } + } + + return NULL; +} + static int soc_bind_dai_link(struct snd_soc_card *card, int num) { struct snd_soc_dai_link *dai_link = &card->dai_link[num]; struct snd_soc_pcm_runtime *rtd = &card->rtd[num]; struct snd_soc_component *component; - struct snd_soc_codec *codec; struct snd_soc_platform *platform; - struct snd_soc_dai *codec_dai, *cpu_dai; + struct snd_soc_dai *cpu_dai; const char *platform_name; dev_dbg(card->dev, "ASoC: binding %s at idx %d\n", dai_link->name, num); @@ -889,42 +922,24 @@ static int soc_bind_dai_link(struct snd_soc_card *card, int num) return -EPROBE_DEFER; } - /* Find CODEC from registered CODECs */ - list_for_each_entry(codec, &codec_list, list) { - if (dai_link->codec_of_node) { - if (codec->dev->of_node != dai_link->codec_of_node) - continue; - } else { - if (strcmp(codec->name, dai_link->codec_name)) - continue; - } - - rtd->codec = codec; - - /* - * CODEC found, so find CODEC DAI from registered DAIs from - * this CODEC - */ - list_for_each_entry(codec_dai, &codec->component.dai_list, list) { - if (!strcmp(codec_dai->name, dai_link->codec_dai_name)) { - rtd->codec_dai = codec_dai; - break; - } - } - - if (!rtd->codec_dai) { - dev_err(card->dev, "ASoC: CODEC DAI %s not registered\n", - dai_link->codec_dai_name); - return -EPROBE_DEFER; - } - } - + /* Find CODEC from registered list */ + rtd->codec = soc_find_codec(dai_link->codec_of_node, + dai_link->codec_name); if (!rtd->codec) { dev_err(card->dev, "ASoC: CODEC %s not registered\n", dai_link->codec_name); return -EPROBE_DEFER; } + /* Find CODEC DAI from registered list */ + rtd->codec_dai = soc_find_codec_dai(rtd->codec, + dai_link->codec_dai_name); + if (!rtd->codec_dai) { + dev_err(card->dev, "ASoC: CODEC DAI %s not registered\n", + dai_link->codec_dai_name); + return -EPROBE_DEFER; + } + /* if there's no platform we match on the empty platform */ platform_name = dai_link->platform_name; if (!platform_name && !dai_link->platform_of_node) -- cgit v1.2.3 From b0aa88af23155b18efb8c18ace963fa75778561a Mon Sep 17 00:00:00 2001 From: Misael Lopez Cruz Date: Fri, 21 Mar 2014 16:27:26 +0100 Subject: ASoC: core: Add helpers for codec DAI probe & remove Add helper functions for codec DAI probe and remove in preparation for DAI-multicodec support. No functional change. Signed-off-by: Misael Lopez Cruz [fparent@baylibre.com: Adapt to 3.14+] Signed-off-by: Fabien Parent Signed-off-by: Benoit Cousson Signed-off-by: Mark Brown --- sound/soc/soc-core.c | 74 +++++++++++++++++++++++++++++++++------------------- 1 file changed, 47 insertions(+), 27 deletions(-) diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 674da7049db4..1e4945d614a4 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -1010,21 +1010,10 @@ static void soc_remove_codec(struct snd_soc_codec *codec) module_put(codec->dev->driver->owner); } -static void soc_remove_link_dais(struct snd_soc_card *card, int num, int order) +static void soc_remove_codec_dai(struct snd_soc_dai *codec_dai, int order) { - struct snd_soc_pcm_runtime *rtd = &card->rtd[num]; - struct snd_soc_dai *codec_dai = rtd->codec_dai, *cpu_dai = rtd->cpu_dai; int err; - /* unregister the rtd device */ - if (rtd->dev_registered) { - device_remove_file(rtd->dev, &dev_attr_pmdown_time); - device_remove_file(rtd->dev, &dev_attr_codec_reg); - device_unregister(rtd->dev); - rtd->dev_registered = 0; - } - - /* remove the CODEC DAI */ if (codec_dai && codec_dai->probed && codec_dai->driver->remove_order == order) { if (codec_dai->driver->remove) { @@ -1037,6 +1026,24 @@ static void soc_remove_link_dais(struct snd_soc_card *card, int num, int order) codec_dai->probed = 0; list_del(&codec_dai->card_list); } +} + +static void soc_remove_link_dais(struct snd_soc_card *card, int num, int order) +{ + struct snd_soc_pcm_runtime *rtd = &card->rtd[num]; + struct snd_soc_dai *codec_dai = rtd->codec_dai, *cpu_dai = rtd->cpu_dai; + int err; + + /* unregister the rtd device */ + if (rtd->dev_registered) { + device_remove_file(rtd->dev, &dev_attr_pmdown_time); + device_remove_file(rtd->dev, &dev_attr_codec_reg); + device_unregister(rtd->dev); + rtd->dev_registered = 0; + } + + /* remove the CODEC DAI */ + soc_remove_codec_dai(codec_dai, order); /* remove the cpu_dai */ if (cpu_dai && cpu_dai->probed && @@ -1381,6 +1388,31 @@ static int soc_probe_link_components(struct snd_soc_card *card, int num, return 0; } +static int soc_probe_codec_dai(struct snd_soc_card *card, + struct snd_soc_dai *codec_dai, + int order) +{ + int ret; + + if (!codec_dai->probed && codec_dai->driver->probe_order == order) { + if (codec_dai->driver->probe) { + ret = codec_dai->driver->probe(codec_dai); + if (ret < 0) { + dev_err(codec_dai->dev, + "ASoC: failed to probe CODEC DAI %s: %d\n", + codec_dai->name, ret); + return ret; + } + } + + /* mark codec_dai as probed and add to card dai list */ + codec_dai->probed = 1; + list_add(&codec_dai->card_list, &card->dai_dev_list); + } + + return 0; +} + static int soc_probe_link_dais(struct snd_soc_card *card, int num, int order) { struct snd_soc_dai_link *dai_link = &card->dai_link[num]; @@ -1430,21 +1462,9 @@ static int soc_probe_link_dais(struct snd_soc_card *card, int num, int order) } /* probe the CODEC DAI */ - if (!codec_dai->probed && codec_dai->driver->probe_order == order) { - if (codec_dai->driver->probe) { - ret = codec_dai->driver->probe(codec_dai); - if (ret < 0) { - dev_err(codec_dai->dev, - "ASoC: failed to probe CODEC DAI %s: %d\n", - codec_dai->name, ret); - return ret; - } - } - - /* mark codec_dai as probed and add to card dai list */ - codec_dai->probed = 1; - list_add(&codec_dai->card_list, &card->dai_dev_list); - } + ret = soc_probe_codec_dai(card, codec_dai, order); + if (ret) + return ret; /* complete DAI probe during last probe */ if (order != SND_SOC_COMP_ORDER_LAST) -- cgit v1.2.3 From 2436a723f3e1fbca517c9318efe9af5ecf7cbcbb Mon Sep 17 00:00:00 2001 From: Misael Lopez Cruz Date: Fri, 21 Mar 2014 16:27:27 +0100 Subject: ASoC: core: Add helper for DAI widgets linking Add a helper for DAI widgets linking in preparation for DAI-multicodec support. No functional change. Signed-off-by: Misael Lopez Cruz [fparent@baylibre.com: Adapt to 3.14+] Signed-off-by: Fabien Parent Signed-off-by: Benoit Cousson Signed-off-by: Mark Brown --- sound/soc/soc-core.c | 64 ++++++++++++++++++++++++++++++++-------------------- 1 file changed, 40 insertions(+), 24 deletions(-) diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 1e4945d614a4..4c0f7dccbd83 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -1413,6 +1413,42 @@ static int soc_probe_codec_dai(struct snd_soc_card *card, return 0; } +static int soc_link_dai_widgets(struct snd_soc_card *card, + struct snd_soc_dai_link *dai_link, + struct snd_soc_dai *cpu_dai, + struct snd_soc_dai *codec_dai) +{ + struct snd_soc_dapm_widget *play_w, *capture_w; + int ret; + + /* link the DAI widgets */ + play_w = codec_dai->playback_widget; + capture_w = cpu_dai->capture_widget; + if (play_w && capture_w) { + ret = snd_soc_dapm_new_pcm(card, dai_link->params, + capture_w, play_w); + if (ret != 0) { + dev_err(card->dev, "ASoC: Can't link %s to %s: %d\n", + play_w->name, capture_w->name, ret); + return ret; + } + } + + play_w = cpu_dai->playback_widget; + capture_w = codec_dai->capture_widget; + if (play_w && capture_w) { + ret = snd_soc_dapm_new_pcm(card, dai_link->params, + capture_w, play_w); + if (ret != 0) { + dev_err(card->dev, "ASoC: Can't link %s to %s: %d\n", + play_w->name, capture_w->name, ret); + return ret; + } + } + + return 0; +} + static int soc_probe_link_dais(struct snd_soc_card *card, int num, int order) { struct snd_soc_dai_link *dai_link = &card->dai_link[num]; @@ -1421,7 +1457,6 @@ static int soc_probe_link_dais(struct snd_soc_card *card, int num, int order) struct snd_soc_platform *platform = rtd->platform; struct snd_soc_dai *codec_dai = rtd->codec_dai; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; - struct snd_soc_dapm_widget *play_w, *capture_w; int ret; dev_dbg(card->dev, "ASoC: probe %s dai link %d late %d\n", @@ -1502,29 +1537,10 @@ static int soc_probe_link_dais(struct snd_soc_card *card, int num, int order) codec2codec_close_delayed_work); /* link the DAI widgets */ - play_w = codec_dai->playback_widget; - capture_w = cpu_dai->capture_widget; - if (play_w && capture_w) { - ret = snd_soc_dapm_new_pcm(card, dai_link->params, - capture_w, play_w); - if (ret != 0) { - dev_err(card->dev, "ASoC: Can't link %s to %s: %d\n", - play_w->name, capture_w->name, ret); - return ret; - } - } - - play_w = cpu_dai->playback_widget; - capture_w = codec_dai->capture_widget; - if (play_w && capture_w) { - ret = snd_soc_dapm_new_pcm(card, dai_link->params, - capture_w, play_w); - if (ret != 0) { - dev_err(card->dev, "ASoC: Can't link %s to %s: %d\n", - play_w->name, capture_w->name, ret); - return ret; - } - } + ret = soc_link_dai_widgets(card, dai_link, + cpu_dai, codec_dai); + if (ret) + return ret; } } -- cgit v1.2.3 From 02c9c7b91c2831b7f4e43c9931007e46f856b659 Mon Sep 17 00:00:00 2001 From: Misael Lopez Cruz Date: Fri, 21 Mar 2014 16:27:28 +0100 Subject: ASoC: core: Add function for ac97 codec registration Add codec registration specific function in preparation for DAI-multicodec support. No functional change. Signed-off-by: Misael Lopez Cruz [fparent@baylibre.com: Adapt to 3.14+] Signed-off-by: Fabien Parent Signed-off-by: Benoit Cousson Signed-off-by: Mark Brown --- sound/soc/soc-core.c | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 4c0f7dccbd83..42c5835ba92f 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -1552,14 +1552,15 @@ static int soc_probe_link_dais(struct snd_soc_card *card, int num, int order) } #ifdef CONFIG_SND_SOC_AC97_BUS -static int soc_register_ac97_dai_link(struct snd_soc_pcm_runtime *rtd) +static int soc_register_ac97_codec(struct snd_soc_codec *codec, + struct snd_soc_dai *codec_dai) { int ret; /* Only instantiate AC97 if not already done by the adaptor * for the generic AC97 subsystem. */ - if (rtd->codec_dai->driver->ac97_control && !rtd->codec->ac97_registered) { + if (codec_dai->driver->ac97_control && !codec->ac97_registered) { /* * It is possible that the AC97 device is already registered to * the device subsystem. This happens when the device is created @@ -1568,28 +1569,38 @@ static int soc_register_ac97_dai_link(struct snd_soc_pcm_runtime *rtd) * * In those cases we don't try to register the device again. */ - if (!rtd->codec->ac97_created) + if (!codec->ac97_created) return 0; - ret = soc_ac97_dev_register(rtd->codec); + ret = soc_ac97_dev_register(codec); if (ret < 0) { - dev_err(rtd->codec->dev, + dev_err(codec->dev, "ASoC: AC97 device register failed: %d\n", ret); return ret; } - rtd->codec->ac97_registered = 1; + codec->ac97_registered = 1; } return 0; } -static void soc_unregister_ac97_dai_link(struct snd_soc_codec *codec) +static int soc_register_ac97_dai_link(struct snd_soc_pcm_runtime *rtd) +{ + return soc_register_ac97_codec(rtd->codec, rtd->codec_dai); +} + +static void soc_unregister_ac97_codec(struct snd_soc_codec *codec) { if (codec->ac97_registered) { soc_ac97_dev_unregister(codec); codec->ac97_registered = 0; } } + +static void soc_unregister_ac97_dai_link(struct snd_soc_pcm_runtime *rtd) +{ + soc_unregister_ac97_codec(rtd->codec); +} #endif static int soc_check_aux_dev(struct snd_soc_card *card, int num) @@ -1888,7 +1899,7 @@ static int snd_soc_instantiate_card(struct snd_soc_card *card) dev_err(card->dev, "ASoC: failed to register AC97: %d\n", ret); while (--i >= 0) - soc_unregister_ac97_dai_link(card->rtd[i].codec); + soc_unregister_ac97_dai_link(&card->rtd[i]); goto probe_aux_dev_err; } } @@ -2324,7 +2335,7 @@ void snd_soc_free_ac97_codec(struct snd_soc_codec *codec) { mutex_lock(&codec->mutex); #ifdef CONFIG_SND_SOC_AC97_BUS - soc_unregister_ac97_dai_link(codec); + soc_unregister_ac97_codec(codec); #endif kfree(codec->ac97->bus); kfree(codec->ac97); -- cgit v1.2.3 From 84bd187996777924b70fe6fb39ccaa34e0b57565 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Mon, 14 Apr 2014 21:30:56 +0200 Subject: ASoC: adau1373: Replace usage deprecated MUX/ENUM macros SOC_VALUE_ENUM, SND_SOC_DAPM_VIRT_MUX and SOC_DAPM_ENUM_VIRT are deprecated and merely an alias for SOC_ENUM, SND_SOC_DAPM_MUX and SOC_DAPM_ENUM. Replace the deprecated macros so we can eventually remove their definition. Signed-off-by: Lars-Peter Clausen Signed-off-by: Mark Brown --- sound/soc/codecs/adau1373.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/sound/soc/codecs/adau1373.c b/sound/soc/codecs/adau1373.c index 877f5737bb6b..1ff7d4d027e9 100644 --- a/sound/soc/codecs/adau1373.c +++ b/sound/soc/codecs/adau1373.c @@ -519,8 +519,7 @@ static const struct snd_kcontrol_new adau1373_controls[] = { SOC_ENUM("HPF Channel", adau1373_hpf_channel_enum), SOC_ENUM("Bass HPF Cutoff", adau1373_bass_hpf_cutoff_enum), - SOC_VALUE_ENUM("Bass Clip Level Threshold", - adau1373_bass_clip_level_enum), + SOC_ENUM("Bass Clip Level Threshold", adau1373_bass_clip_level_enum), SOC_ENUM("Bass LPF Cutoff", adau1373_bass_lpf_cutoff_enum), SOC_DOUBLE("Bass Playback Switch", ADAU1373_BASS2, 0, 1, 1, 0), SOC_SINGLE_TLV("Bass Playback Volume", ADAU1373_BASS2, 2, 7, 0, @@ -580,7 +579,7 @@ static SOC_ENUM_SINGLE_VIRT_DECL(adau1373_decimator_enum, adau1373_decimator_text); static const struct snd_kcontrol_new adau1373_decimator_mux = - SOC_DAPM_ENUM_VIRT("Decimator Mux", adau1373_decimator_enum); + SOC_DAPM_ENUM("Decimator Mux", adau1373_decimator_enum); static const struct snd_kcontrol_new adau1373_left_adc_mixer_controls[] = { SOC_DAPM_SINGLE("DAC1 Switch", ADAU1373_LADC_MIXER, 4, 1, 0), @@ -694,7 +693,7 @@ static const struct snd_soc_dapm_widget adau1373_dapm_widgets[] = { SND_SOC_DAPM_ADC("DMIC1", NULL, ADAU1373_DIGMICCTRL, 0, 0), SND_SOC_DAPM_ADC("DMIC2", NULL, ADAU1373_DIGMICCTRL, 2, 0), - SND_SOC_DAPM_VIRT_MUX("Decimator Mux", SND_SOC_NOPM, 0, 0, + SND_SOC_DAPM_MUX("Decimator Mux", SND_SOC_NOPM, 0, 0, &adau1373_decimator_mux), SND_SOC_DAPM_SUPPLY("MICBIAS2", ADAU1373_PWDN_CTRL1, 5, 0, NULL, 0), -- cgit v1.2.3 From 48fa3636340f78d10352dd333e79946de0a96fe6 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Mon, 14 Apr 2014 21:30:57 +0200 Subject: ASoC: adav80x: Replace usage deprecated MUX/ENUM macros SND_SOC_DAPM_VALUE_MUX and SOC_DAPM_VALUE_ENUM are deprecated and merely an alias for SND_SOC_DAPM_MUX and SOC_DAPM_ENUM. Replace the deprecated macros so we can eventually remove their definition. Signed-off-by: Lars-Peter Clausen Signed-off-by: Mark Brown --- sound/soc/codecs/adav80x.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sound/soc/codecs/adav80x.c b/sound/soc/codecs/adav80x.c index 5062e34ee8dc..4d41bbc611e0 100644 --- a/sound/soc/codecs/adav80x.c +++ b/sound/soc/codecs/adav80x.c @@ -172,14 +172,14 @@ static ADAV80X_MUX_ENUM_DECL(adav80x_capture_enum, ADAV80X_DPATH_CTRL1, 3); static ADAV80X_MUX_ENUM_DECL(adav80x_dac_enum, ADAV80X_DPATH_CTRL2, 3); static const struct snd_kcontrol_new adav80x_aux_capture_mux_ctrl = - SOC_DAPM_VALUE_ENUM("Route", adav80x_aux_capture_enum); + SOC_DAPM_ENUM("Route", adav80x_aux_capture_enum); static const struct snd_kcontrol_new adav80x_capture_mux_ctrl = - SOC_DAPM_VALUE_ENUM("Route", adav80x_capture_enum); + SOC_DAPM_ENUM("Route", adav80x_capture_enum); static const struct snd_kcontrol_new adav80x_dac_mux_ctrl = - SOC_DAPM_VALUE_ENUM("Route", adav80x_dac_enum); + SOC_DAPM_ENUM("Route", adav80x_dac_enum); #define ADAV80X_MUX(name, ctrl) \ - SND_SOC_DAPM_VALUE_MUX(name, SND_SOC_NOPM, 0, 0, ctrl) + SND_SOC_DAPM_MUX(name, SND_SOC_NOPM, 0, 0, ctrl) static const struct snd_soc_dapm_widget adav80x_dapm_widgets[] = { SND_SOC_DAPM_DAC("DAC", NULL, ADAV80X_DAC_CTRL1, 7, 1), -- cgit v1.2.3 From 355e3a08485249868d892c82e9250c0f6e4d0ceb Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Mon, 14 Apr 2014 21:30:58 +0200 Subject: ASoC: arizona: Replace usage deprecated MUX/ENUM macros SND_SOC_DAPM_VALUE_MUX and SOC_DAPM_VALUE_ENUM are deprecated and merely an alias for SND_SOC_DAPM_MUX and SOC_DAPM_ENUM. Replace the deprecated macros so we can eventually remove their definition. Signed-off-by: Lars-Peter Clausen Signed-off-by: Mark Brown --- sound/soc/codecs/arizona.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sound/soc/codecs/arizona.h b/sound/soc/codecs/arizona.h index 16df0f913353..05ae17f5bca3 100644 --- a/sound/soc/codecs/arizona.h +++ b/sound/soc/codecs/arizona.h @@ -107,7 +107,7 @@ extern int arizona_mixer_values[ARIZONA_NUM_MIXER_INPUTS]; #define ARIZONA_MUX_CTL_DECL(name) \ const struct snd_kcontrol_new name##_mux = \ - SOC_DAPM_VALUE_ENUM("Route", name##_enum) + SOC_DAPM_ENUM("Route", name##_enum) #define ARIZONA_MUX_ENUMS(name, base_reg) \ static ARIZONA_MUX_ENUM_DECL(name##_enum, base_reg); \ @@ -128,7 +128,7 @@ extern int arizona_mixer_values[ARIZONA_NUM_MIXER_INPUTS]; ARIZONA_MUX_ENUMS(name##_aux6, base_reg + 40) #define ARIZONA_MUX(name, ctrl) \ - SND_SOC_DAPM_VALUE_MUX(name, SND_SOC_NOPM, 0, 0, ctrl) + SND_SOC_DAPM_MUX(name, SND_SOC_NOPM, 0, 0, ctrl) #define ARIZONA_MUX_WIDGETS(name, name_str) \ ARIZONA_MUX(name_str " Input", &name##_mux) -- cgit v1.2.3 From aae1137b998a1a4508a2f2b27604351a5ced2427 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Mon, 14 Apr 2014 21:30:59 +0200 Subject: ASoC: max98090: Replace usage deprecated MUX/ENUM macros SND_SOC_DAPM_VIRT_MUX and SOC_DAPM_ENUM_VIRT are deprecated and merely an alias for SND_SOC_DAPM_MUX and SOC_DAPM_ENUM. Replace the deprecated macros so we can eventually remove their definition. Signed-off-by: Lars-Peter Clausen Signed-off-by: Mark Brown --- sound/soc/codecs/max98090.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/sound/soc/codecs/max98090.c b/sound/soc/codecs/max98090.c index f7b0b37aa858..1fd31efa6664 100644 --- a/sound/soc/codecs/max98090.c +++ b/sound/soc/codecs/max98090.c @@ -875,7 +875,7 @@ static const char *dmic_mux_text[] = { "ADC", "DMIC" }; static SOC_ENUM_SINGLE_VIRT_DECL(dmic_mux_enum, dmic_mux_text); static const struct snd_kcontrol_new max98090_dmic_mux = - SOC_DAPM_ENUM_VIRT("DMIC Mux", dmic_mux_enum); + SOC_DAPM_ENUM("DMIC Mux", dmic_mux_enum); static const char *max98090_micpre_text[] = { "Off", "On" }; @@ -1175,8 +1175,7 @@ static const struct snd_soc_dapm_widget max98090_dapm_widgets[] = { SND_SOC_DAPM_MUX("MIC2 Mux", SND_SOC_NOPM, 0, 0, &max98090_mic2_mux), - SND_SOC_DAPM_VIRT_MUX("DMIC Mux", SND_SOC_NOPM, - 0, 0, &max98090_dmic_mux), + SND_SOC_DAPM_MUX("DMIC Mux", SND_SOC_NOPM, 0, 0, &max98090_dmic_mux), SND_SOC_DAPM_PGA_E("MIC1 Input", M98090_REG_MIC1_INPUT_LEVEL, M98090_MIC_PA1EN_SHIFT, 0, NULL, 0, max98090_micinput_event, -- cgit v1.2.3 From 36bc38a7c1c6869a71739c4f9bf1c16e8168ae88 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Mon, 14 Apr 2014 21:31:00 +0200 Subject: ASoC: mc13783: Replace usage deprecated MUX/ENUM macros SND_SOC_DAPM_VIRT_MUX and SOC_DAPM_ENUM_VIRT are deprecated and merely an alias for SND_SOC_DAPM_MUX and SOC_DAPM_ENUM. Replace the deprecated macros so we can eventually remove their definition. Signed-off-by: Lars-Peter Clausen Signed-off-by: Mark Brown --- sound/soc/codecs/mc13783.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sound/soc/codecs/mc13783.c b/sound/soc/codecs/mc13783.c index 2c59b1fb69dc..ed5c5a41169b 100644 --- a/sound/soc/codecs/mc13783.c +++ b/sound/soc/codecs/mc13783.c @@ -409,7 +409,7 @@ static const char * const adcl_enum_text[] = { static SOC_ENUM_SINGLE_VIRT_DECL(adcl_enum, adcl_enum_text); static const struct snd_kcontrol_new left_input_mux = - SOC_DAPM_ENUM_VIRT("Route", adcl_enum); + SOC_DAPM_ENUM("Route", adcl_enum); static const char * const adcr_enum_text[] = { "MC1R", "MC2", "RXINR", "TXIN", @@ -418,7 +418,7 @@ static const char * const adcr_enum_text[] = { static SOC_ENUM_SINGLE_VIRT_DECL(adcr_enum, adcr_enum_text); static const struct snd_kcontrol_new right_input_mux = - SOC_DAPM_ENUM_VIRT("Route", adcr_enum); + SOC_DAPM_ENUM("Route", adcr_enum); static const struct snd_kcontrol_new samp_ctl = SOC_DAPM_SINGLE("Switch", MC13783_AUDIO_RX0, 3, 1, 0); @@ -478,9 +478,9 @@ static const struct snd_soc_dapm_widget mc13783_dapm_widgets[] = { SND_SOC_DAPM_SWITCH("MC2 Amp", MC13783_AUDIO_TX, 9, 0, &mc2_amp_ctl), SND_SOC_DAPM_SWITCH("TXIN Amp", MC13783_AUDIO_TX, 11, 0, &atx_amp_ctl), - SND_SOC_DAPM_VIRT_MUX("PGA Left Input Mux", SND_SOC_NOPM, 0, 0, + SND_SOC_DAPM_MUX("PGA Left Input Mux", SND_SOC_NOPM, 0, 0, &left_input_mux), - SND_SOC_DAPM_VIRT_MUX("PGA Right Input Mux", SND_SOC_NOPM, 0, 0, + SND_SOC_DAPM_MUX("PGA Right Input Mux", SND_SOC_NOPM, 0, 0, &right_input_mux), SND_SOC_DAPM_MUX("Speaker Amp Source MUX", SND_SOC_NOPM, 0, 0, -- cgit v1.2.3 From 54581be7da3d50aab8322fcfeff14c1aa1dafa86 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Mon, 14 Apr 2014 21:31:01 +0200 Subject: ASoC: pcm512x: Replace usage deprecated SOC_VALUE_ENUM macro SOC_VALUE_ENUM is deprecated and merely an alias for SOC_ENUM. Replace the deprecated macro so we can eventually remove their definition. Signed-off-by: Lars-Peter Clausen Signed-off-by: Mark Brown --- sound/soc/codecs/pcm512x.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/soc/codecs/pcm512x.c b/sound/soc/codecs/pcm512x.c index 4b4c0c7bb918..381d22ce6f76 100644 --- a/sound/soc/codecs/pcm512x.c +++ b/sound/soc/codecs/pcm512x.c @@ -269,7 +269,7 @@ SOC_DOUBLE("Playback Digital Switch", PCM512x_MUTE, PCM512x_RQML_SHIFT, PCM512x_RQMR_SHIFT, 1, 1), SOC_SINGLE("Deemphasis Switch", PCM512x_DSP, PCM512x_DEMP_SHIFT, 1, 1), -SOC_VALUE_ENUM("DSP Program", pcm512x_dsp_program), +SOC_ENUM("DSP Program", pcm512x_dsp_program), SOC_ENUM("Clock Missing Period", pcm512x_clk_missing), SOC_ENUM("Auto Mute Time Left", pcm512x_autom_l), -- cgit v1.2.3 From 712fb1c27dce4e3fe9338f27ed0f8684fe9d5597 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Mon, 14 Apr 2014 21:31:02 +0200 Subject: ASoC: rt5640: Replace usage deprecated MUX/ENUM macros SND_SOC_DAPM_VALUE_MUX and SOC_DAPM_VALUE_ENUM are deprecated and merely an alias for SND_SOC_DAPM_MUX and SOC_DAPM_ENUM. Replace the deprecated macros so we can eventually remove their definition. Signed-off-by: Lars-Peter Clausen Signed-off-by: Mark Brown --- sound/soc/codecs/rt5640.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sound/soc/codecs/rt5640.c b/sound/soc/codecs/rt5640.c index 68b4dd622b87..1b452e3b449a 100644 --- a/sound/soc/codecs/rt5640.c +++ b/sound/soc/codecs/rt5640.c @@ -824,7 +824,7 @@ static SOC_VALUE_ENUM_SINGLE_DECL(rt5640_dac_l2_enum, 0x3, rt5640_dac_l2_src, rt5640_dac_l2_values); static const struct snd_kcontrol_new rt5640_dac_l2_mux = - SOC_DAPM_VALUE_ENUM("DAC2 left channel source", rt5640_dac_l2_enum); + SOC_DAPM_ENUM("DAC2 left channel source", rt5640_dac_l2_enum); static const char * const rt5640_dac_r2_src[] = { "IF2", @@ -859,7 +859,7 @@ static SOC_VALUE_ENUM_SINGLE_DECL(rt5640_dai_iis_map_enum, rt5640_dai_iis_map_values); static const struct snd_kcontrol_new rt5640_dai_mux = - SOC_DAPM_VALUE_ENUM("DAI select", rt5640_dai_iis_map_enum); + SOC_DAPM_ENUM("DAI select", rt5640_dai_iis_map_enum); /* SDI select */ static const char * const rt5640_sdi_sel[] = { -- cgit v1.2.3 From 7eb364ab196d522cdde744010c4e02c2fe62f6fc Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Mon, 14 Apr 2014 21:31:03 +0200 Subject: ASoC: wm2200: Replace usage deprecated MUX/ENUM macros SND_SOC_DAPM_VALUE_MUX and SOC_DAPM_VALUE_ENUM are deprecated and merely an alias for SND_SOC_DAPM_MUX and SOC_DAPM_ENUM. Replace the deprecated macros so we can eventually remove their definition. Signed-off-by: Lars-Peter Clausen Signed-off-by: Mark Brown --- sound/soc/codecs/wm2200.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sound/soc/codecs/wm2200.c b/sound/soc/codecs/wm2200.c index 2e721e06671b..cdea9d9c1631 100644 --- a/sound/soc/codecs/wm2200.c +++ b/sound/soc/codecs/wm2200.c @@ -1083,7 +1083,7 @@ static int wm2200_mixer_values[] = { #define WM2200_MUX_CTL_DECL(name) \ const struct snd_kcontrol_new name##_mux = \ - SOC_DAPM_VALUE_ENUM("Route", name##_enum) + SOC_DAPM_ENUM("Route", name##_enum) #define WM2200_MIXER_ENUMS(name, base_reg) \ static WM2200_MUX_ENUM_DECL(name##_in1_enum, base_reg); \ @@ -1207,7 +1207,7 @@ WM2200_MIXER_ENUMS(LHPF1, WM2200_LHPF1MIX_INPUT_1_SOURCE); WM2200_MIXER_ENUMS(LHPF2, WM2200_LHPF2MIX_INPUT_1_SOURCE); #define WM2200_MUX(name, ctrl) \ - SND_SOC_DAPM_VALUE_MUX(name, SND_SOC_NOPM, 0, 0, ctrl) + SND_SOC_DAPM_MUX(name, SND_SOC_NOPM, 0, 0, ctrl) #define WM2200_MIXER_WIDGETS(name, name_str) \ WM2200_MUX(name_str " Input 1", &name##_in1_mux), \ -- cgit v1.2.3 From cda8866952f209d5e9de077c9ea7cb20a22e41ea Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Mon, 14 Apr 2014 21:31:04 +0200 Subject: ASoC: wm5100: Replace usage deprecated MUX/ENUM macros SND_SOC_DAPM_VALUE_MUX and SOC_DAPM_VALUE_ENUM are deprecated and merely an alias for SND_SOC_DAPM_MUX and SOC_DAPM_ENUM. Replace the deprecated macros so we can eventually remove their definition. Signed-off-by: Lars-Peter Clausen Signed-off-by: Mark Brown --- sound/soc/codecs/wm5100.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sound/soc/codecs/wm5100.c b/sound/soc/codecs/wm5100.c index eca983fad891..91a9ea2a2056 100644 --- a/sound/soc/codecs/wm5100.c +++ b/sound/soc/codecs/wm5100.c @@ -390,7 +390,7 @@ static int wm5100_mixer_values[] = { #define WM5100_MUX_CTL_DECL(name) \ const struct snd_kcontrol_new name##_mux = \ - SOC_DAPM_VALUE_ENUM("Route", name##_enum) + SOC_DAPM_ENUM("Route", name##_enum) #define WM5100_MIXER_ENUMS(name, base_reg) \ static WM5100_MUX_ENUM_DECL(name##_in1_enum, base_reg); \ @@ -448,7 +448,7 @@ WM5100_MIXER_ENUMS(LHPF3, WM5100_HPLP3MIX_INPUT_1_SOURCE); WM5100_MIXER_ENUMS(LHPF4, WM5100_HPLP4MIX_INPUT_1_SOURCE); #define WM5100_MUX(name, ctrl) \ - SND_SOC_DAPM_VALUE_MUX(name, SND_SOC_NOPM, 0, 0, ctrl) + SND_SOC_DAPM_MUX(name, SND_SOC_NOPM, 0, 0, ctrl) #define WM5100_MIXER_WIDGETS(name, name_str) \ WM5100_MUX(name_str " Input 1", &name##_in1_mux), \ -- cgit v1.2.3 From 6b2cab02a39d2d1badf93c44e989ffcb9c3c1363 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Mon, 14 Apr 2014 21:31:05 +0200 Subject: ASoC: wm5102: Replace usage deprecated MUX/ENUM macros SND_SOC_DAPM_VALUE_MUX and SOC_DAPM_VALUE_ENUM are deprecated and merely an alias for SND_SOC_DAPM_MUX and SOC_DAPM_ENUM. Replace the deprecated macros so we can eventually remove their definition. Signed-off-by: Lars-Peter Clausen Signed-off-by: Mark Brown --- sound/soc/codecs/wm5102.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sound/soc/codecs/wm5102.c b/sound/soc/codecs/wm5102.c index dcf1d12cfef8..12d244b8f281 100644 --- a/sound/soc/codecs/wm5102.c +++ b/sound/soc/codecs/wm5102.c @@ -970,7 +970,7 @@ static const struct soc_enum wm5102_aec_loopback = wm5102_aec_loopback_values); static const struct snd_kcontrol_new wm5102_aec_loopback_mux = - SOC_DAPM_VALUE_ENUM("AEC Loopback", wm5102_aec_loopback); + SOC_DAPM_ENUM("AEC Loopback", wm5102_aec_loopback); static const struct snd_soc_dapm_widget wm5102_dapm_widgets[] = { SND_SOC_DAPM_SUPPLY("SYSCLK", ARIZONA_SYSTEM_CLOCK_1, ARIZONA_SYSCLK_ENA_SHIFT, @@ -1204,7 +1204,7 @@ SND_SOC_DAPM_AIF_IN("SLIMRX8", NULL, 0, ARIZONA_DSP_WIDGETS(DSP1, "DSP1"), -SND_SOC_DAPM_VALUE_MUX("AEC Loopback", ARIZONA_DAC_AEC_CONTROL_1, +SND_SOC_DAPM_MUX("AEC Loopback", ARIZONA_DAC_AEC_CONTROL_1, ARIZONA_AEC_LOOPBACK_ENA_SHIFT, 0, &wm5102_aec_loopback_mux), -- cgit v1.2.3 From 696d3affa012a439f9e6be1e60cc68ce06d736d1 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Mon, 14 Apr 2014 21:31:06 +0200 Subject: ASoC: wm5110: Replace usage deprecated MUX/ENUM macros SOC_VALUE_ENUM, SND_SOC_DAPM_VALUE_MUX and SOC_DAPM_VALUE_ENUM are deprecated and merely an alias for SOC_ENUM, SND_SOC_DAPM_MUX and SOC_DAPM_ENUM. Replace the deprecated macros so we can eventually remove their definition. Signed-off-by: Lars-Peter Clausen Signed-off-by: Mark Brown --- sound/soc/codecs/wm5110.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/sound/soc/codecs/wm5110.c b/sound/soc/codecs/wm5110.c index df5a38dd8328..32e503211eec 100644 --- a/sound/soc/codecs/wm5110.c +++ b/sound/soc/codecs/wm5110.c @@ -324,13 +324,13 @@ SOC_ENUM("LHPF2 Mode", arizona_lhpf2_mode), SOC_ENUM("LHPF3 Mode", arizona_lhpf3_mode), SOC_ENUM("LHPF4 Mode", arizona_lhpf4_mode), -SOC_VALUE_ENUM("ISRC1 FSL", arizona_isrc_fsl[0]), -SOC_VALUE_ENUM("ISRC2 FSL", arizona_isrc_fsl[1]), -SOC_VALUE_ENUM("ISRC3 FSL", arizona_isrc_fsl[2]), -SOC_VALUE_ENUM("ISRC1 FSH", arizona_isrc_fsh[0]), -SOC_VALUE_ENUM("ISRC2 FSH", arizona_isrc_fsh[1]), -SOC_VALUE_ENUM("ISRC3 FSH", arizona_isrc_fsh[2]), -SOC_VALUE_ENUM("ASRC RATE 1", arizona_asrc_rate1), +SOC_ENUM("ISRC1 FSL", arizona_isrc_fsl[0]), +SOC_ENUM("ISRC2 FSL", arizona_isrc_fsl[1]), +SOC_ENUM("ISRC3 FSL", arizona_isrc_fsl[2]), +SOC_ENUM("ISRC1 FSH", arizona_isrc_fsh[0]), +SOC_ENUM("ISRC2 FSH", arizona_isrc_fsh[1]), +SOC_ENUM("ISRC3 FSH", arizona_isrc_fsh[2]), +SOC_ENUM("ASRC RATE 1", arizona_asrc_rate1), ARIZONA_MIXER_CONTROLS("DSP1L", ARIZONA_DSP1LMIX_INPUT_1_SOURCE), ARIZONA_MIXER_CONTROLS("DSP1R", ARIZONA_DSP1RMIX_INPUT_1_SOURCE), @@ -592,7 +592,7 @@ static const struct soc_enum wm5110_aec_loopback = wm5110_aec_loopback_values); static const struct snd_kcontrol_new wm5110_aec_loopback_mux = - SOC_DAPM_VALUE_ENUM("AEC Loopback", wm5110_aec_loopback); + SOC_DAPM_ENUM("AEC Loopback", wm5110_aec_loopback); static const struct snd_soc_dapm_widget wm5110_dapm_widgets[] = { SND_SOC_DAPM_SUPPLY("SYSCLK", ARIZONA_SYSTEM_CLOCK_1, ARIZONA_SYSCLK_ENA_SHIFT, @@ -774,7 +774,7 @@ SND_SOC_DAPM_PGA("ISRC3DEC3", ARIZONA_ISRC_3_CTRL_3, SND_SOC_DAPM_PGA("ISRC3DEC4", ARIZONA_ISRC_3_CTRL_3, ARIZONA_ISRC3_DEC3_ENA_SHIFT, 0, NULL, 0), -SND_SOC_DAPM_VALUE_MUX("AEC Loopback", ARIZONA_DAC_AEC_CONTROL_1, +SND_SOC_DAPM_MUX("AEC Loopback", ARIZONA_DAC_AEC_CONTROL_1, ARIZONA_AEC_LOOPBACK_ENA_SHIFT, 0, &wm5110_aec_loopback_mux), -- cgit v1.2.3 From fb7d79e56f6b0b7ce2d0ae3366d6a0e59145e37d Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Mon, 14 Apr 2014 21:31:07 +0200 Subject: ASoC: wm8988: Replace usage deprecated MUX/ENUM macros SND_SOC_DAPM_VALUE_MUX and SOC_DAPM_VALUE_ENUM are deprecated and merely an alias for SND_SOC_DAPM_MUX and SOC_DAPM_ENUM. Replace the deprecated macros so we can eventually remove their definition. Signed-off-by: Lars-Peter Clausen Signed-off-by: Mark Brown --- sound/soc/codecs/wm8988.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sound/soc/codecs/wm8988.c b/sound/soc/codecs/wm8988.c index 3a1ae4f5164d..d3fea46d58e8 100644 --- a/sound/soc/codecs/wm8988.c +++ b/sound/soc/codecs/wm8988.c @@ -268,7 +268,7 @@ static const struct soc_enum wm8988_lline_enum = wm8988_line_texts, wm8988_line_values); static const struct snd_kcontrol_new wm8988_left_line_controls = - SOC_DAPM_VALUE_ENUM("Route", wm8988_lline_enum); + SOC_DAPM_ENUM("Route", wm8988_lline_enum); static const struct soc_enum wm8988_rline_enum = SOC_VALUE_ENUM_SINGLE(WM8988_ROUTM1, 0, 7, @@ -276,7 +276,7 @@ static const struct soc_enum wm8988_rline_enum = wm8988_line_texts, wm8988_line_values); static const struct snd_kcontrol_new wm8988_right_line_controls = - SOC_DAPM_VALUE_ENUM("Route", wm8988_lline_enum); + SOC_DAPM_ENUM("Route", wm8988_lline_enum); /* Left Mixer */ static const struct snd_kcontrol_new wm8988_left_mixer_controls[] = { @@ -304,7 +304,7 @@ static const struct soc_enum wm8988_lpga_enum = wm8988_pga_sel, wm8988_pga_val); static const struct snd_kcontrol_new wm8988_left_pga_controls = - SOC_DAPM_VALUE_ENUM("Route", wm8988_lpga_enum); + SOC_DAPM_ENUM("Route", wm8988_lpga_enum); /* Right PGA Mux */ static const struct soc_enum wm8988_rpga_enum = @@ -313,7 +313,7 @@ static const struct soc_enum wm8988_rpga_enum = wm8988_pga_sel, wm8988_pga_val); static const struct snd_kcontrol_new wm8988_right_pga_controls = - SOC_DAPM_VALUE_ENUM("Route", wm8988_rpga_enum); + SOC_DAPM_ENUM("Route", wm8988_rpga_enum); /* Differential Mux */ static const char *wm8988_diff_sel[] = {"Line 1", "Line 2"}; -- cgit v1.2.3 From 0a822c1e3bfd00e7a9a5d81ac5887defdd5d4e64 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Mon, 14 Apr 2014 21:31:08 +0200 Subject: ASoC: wm5102: Replace usage deprecated SOC_VALUE_ENUM macro SOC_VALUE_ENUM is deprecated and merely an alias for SOC_EMUM. Replace the deprecated macros so we can eventually remove their definition. Signed-off-by: Lars-Peter Clausen Signed-off-by: Mark Brown --- sound/soc/codecs/wm5102.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/sound/soc/codecs/wm5102.c b/sound/soc/codecs/wm5102.c index 12d244b8f281..cbe52861b19b 100644 --- a/sound/soc/codecs/wm5102.c +++ b/sound/soc/codecs/wm5102.c @@ -764,8 +764,8 @@ SOC_ENUM("LHPF2 Mode", arizona_lhpf2_mode), SOC_ENUM("LHPF3 Mode", arizona_lhpf3_mode), SOC_ENUM("LHPF4 Mode", arizona_lhpf4_mode), -SOC_VALUE_ENUM("ISRC1 FSL", arizona_isrc_fsl[0]), -SOC_VALUE_ENUM("ISRC2 FSL", arizona_isrc_fsl[1]), +SOC_ENUM("ISRC1 FSL", arizona_isrc_fsl[0]), +SOC_ENUM("ISRC2 FSL", arizona_isrc_fsl[1]), ARIZONA_MIXER_CONTROLS("Mic", ARIZONA_MICMIX_INPUT_1_SOURCE), ARIZONA_MIXER_CONTROLS("Noise", ARIZONA_NOISEMIX_INPUT_1_SOURCE), @@ -814,9 +814,9 @@ SOC_DOUBLE_R_TLV("SPKDAT1 Digital Volume", ARIZONA_DAC_DIGITAL_VOLUME_5L, ARIZONA_DAC_DIGITAL_VOLUME_5R, ARIZONA_OUT5L_VOL_SHIFT, 0xbf, 0, digital_tlv), -SOC_VALUE_ENUM("HPOUT1 OSR", wm5102_hpout_osr[0]), -SOC_VALUE_ENUM("HPOUT2 OSR", wm5102_hpout_osr[1]), -SOC_VALUE_ENUM("EPOUT OSR", wm5102_hpout_osr[2]), +SOC_ENUM("HPOUT1 OSR", wm5102_hpout_osr[0]), +SOC_ENUM("HPOUT2 OSR", wm5102_hpout_osr[1]), +SOC_ENUM("EPOUT OSR", wm5102_hpout_osr[2]), SOC_DOUBLE("HPOUT1 DRE Switch", ARIZONA_DRE_ENABLE, ARIZONA_DRE1L_ENA_SHIFT, ARIZONA_DRE1R_ENA_SHIFT, 1, 0), -- cgit v1.2.3 From 37d203055e3516e891fb23a40d61a54b65a60d81 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Mon, 14 Apr 2014 21:31:09 +0200 Subject: ASoC: wm8994: Replace usage deprecated MUX/ENUM macros SND_SOC_DAPM_VIRT_MUX, SND_SOC_DAPM_VIRT_MUX_E and SOC_DAPM_ENUM_VIRT are deprecated and merely an alias for SND_SOC_DAPM_MUX, SND_SOC_DAPM_MUX_E and SOC_DAPM_ENUM. Replace the deprecated macros so we can eventually remove their definition. Signed-off-by: Lars-Peter Clausen Signed-off-by: Mark Brown --- sound/soc/codecs/wm8994.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/sound/soc/codecs/wm8994.c b/sound/soc/codecs/wm8994.c index 6303537f54c6..309c97d89dbb 100644 --- a/sound/soc/codecs/wm8994.c +++ b/sound/soc/codecs/wm8994.c @@ -1347,10 +1347,10 @@ static const char *adc_mux_text[] = { static SOC_ENUM_SINGLE_VIRT_DECL(adc_enum, adc_mux_text); static const struct snd_kcontrol_new adcl_mux = - SOC_DAPM_ENUM_VIRT("ADCL Mux", adc_enum); + SOC_DAPM_ENUM("ADCL Mux", adc_enum); static const struct snd_kcontrol_new adcr_mux = - SOC_DAPM_ENUM_VIRT("ADCR Mux", adc_enum); + SOC_DAPM_ENUM("ADCR Mux", adc_enum); static const struct snd_kcontrol_new left_speaker_mixer[] = { SOC_DAPM_SINGLE("DAC2 Switch", WM8994_SPEAKER_MIXER, 9, 1, 0), @@ -1651,15 +1651,15 @@ SND_SOC_DAPM_DAC("DAC1R", NULL, WM8994_POWER_MANAGEMENT_5, 0, 0), }; static const struct snd_soc_dapm_widget wm8994_adc_revd_widgets[] = { -SND_SOC_DAPM_VIRT_MUX_E("ADCL Mux", WM8994_POWER_MANAGEMENT_4, 1, 0, &adcl_mux, +SND_SOC_DAPM_MUX_E("ADCL Mux", WM8994_POWER_MANAGEMENT_4, 1, 0, &adcl_mux, adc_mux_ev, SND_SOC_DAPM_PRE_PMU), -SND_SOC_DAPM_VIRT_MUX_E("ADCR Mux", WM8994_POWER_MANAGEMENT_4, 0, 0, &adcr_mux, +SND_SOC_DAPM_MUX_E("ADCR Mux", WM8994_POWER_MANAGEMENT_4, 0, 0, &adcr_mux, adc_mux_ev, SND_SOC_DAPM_PRE_PMU), }; static const struct snd_soc_dapm_widget wm8994_adc_widgets[] = { -SND_SOC_DAPM_VIRT_MUX("ADCL Mux", WM8994_POWER_MANAGEMENT_4, 1, 0, &adcl_mux), -SND_SOC_DAPM_VIRT_MUX("ADCR Mux", WM8994_POWER_MANAGEMENT_4, 0, 0, &adcr_mux), +SND_SOC_DAPM_MUX("ADCL Mux", WM8994_POWER_MANAGEMENT_4, 1, 0, &adcl_mux), +SND_SOC_DAPM_MUX("ADCR Mux", WM8994_POWER_MANAGEMENT_4, 0, 0, &adcr_mux), }; static const struct snd_soc_dapm_widget wm8994_dapm_widgets[] = { -- cgit v1.2.3 From b8eecc19708dcf36b30058a1e86206480c09efc4 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Mon, 14 Apr 2014 21:31:10 +0200 Subject: ASoC: wm8995: Replace usage deprecated MUX/ENUM macros SND_SOC_DAPM_VIRT_MUX and SOC_DAPM_ENUM_VIRT are deprecated and merely an alias for SND_SOC_DAPM_MUX and SOC_DAPM_ENUM. Replace the deprecated macros so we can eventually remove their definition. Signed-off-by: Lars-Peter Clausen Signed-off-by: Mark Brown --- sound/soc/codecs/wm8995.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/sound/soc/codecs/wm8995.c b/sound/soc/codecs/wm8995.c index d3152cf5bd56..863a2c38bcb5 100644 --- a/sound/soc/codecs/wm8995.c +++ b/sound/soc/codecs/wm8995.c @@ -885,10 +885,10 @@ static const char *adc_mux_text[] = { static SOC_ENUM_SINGLE_VIRT_DECL(adc_enum, adc_mux_text); static const struct snd_kcontrol_new adcl_mux = - SOC_DAPM_ENUM_VIRT("ADCL Mux", adc_enum); + SOC_DAPM_ENUM("ADCL Mux", adc_enum); static const struct snd_kcontrol_new adcr_mux = - SOC_DAPM_ENUM_VIRT("ADCR Mux", adc_enum); + SOC_DAPM_ENUM("ADCR Mux", adc_enum); static const char *spk_src_text[] = { "DAC1L", "DAC1R", "DAC2L", "DAC2R" @@ -948,10 +948,8 @@ static const struct snd_soc_dapm_widget wm8995_dapm_widgets[] = { SND_SOC_DAPM_AIF_OUT("AIF1ADC2R", "AIF1 Capture", 0, WM8995_POWER_MANAGEMENT_3, 10, 0), - SND_SOC_DAPM_VIRT_MUX("ADCL Mux", SND_SOC_NOPM, 1, 0, - &adcl_mux), - SND_SOC_DAPM_VIRT_MUX("ADCR Mux", SND_SOC_NOPM, 0, 0, - &adcr_mux), + SND_SOC_DAPM_MUX("ADCL Mux", SND_SOC_NOPM, 1, 0, &adcl_mux), + SND_SOC_DAPM_MUX("ADCR Mux", SND_SOC_NOPM, 0, 0, &adcr_mux), SND_SOC_DAPM_ADC("DMIC2L", NULL, WM8995_POWER_MANAGEMENT_3, 5, 0), SND_SOC_DAPM_ADC("DMIC2R", NULL, WM8995_POWER_MANAGEMENT_3, 4, 0), -- cgit v1.2.3 From e13dd8ce39a89c7a7d8ec025b266337b42eeaafc Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Mon, 14 Apr 2014 21:31:11 +0200 Subject: ASoC: wm8997: Replace usage deprecated MUX/ENUM macros SOC_VALUE_ENUM, SND_SOC_DAPM_VALUE_MUX and SOC_DAPM_VALUE_ENUM are deprecated and merely an alias for SOC_ENUM, SND_SOC_DAPM_MUX and SOC_DAPM_ENUM. Replace the deprecated macros so we can eventually remove their definition. Signed-off-by: Lars-Peter Clausen Signed-off-by: Mark Brown --- sound/soc/codecs/wm8997.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/sound/soc/codecs/wm8997.c b/sound/soc/codecs/wm8997.c index 004186b6bd48..e45bbc0f15b2 100644 --- a/sound/soc/codecs/wm8997.c +++ b/sound/soc/codecs/wm8997.c @@ -245,8 +245,8 @@ SND_SOC_BYTES("LHPF2 Coefficients", ARIZONA_HPLPF2_2, 1), SND_SOC_BYTES("LHPF3 Coefficients", ARIZONA_HPLPF3_2, 1), SND_SOC_BYTES("LHPF4 Coefficients", ARIZONA_HPLPF4_2, 1), -SOC_VALUE_ENUM("ISRC1 FSL", arizona_isrc_fsl[0]), -SOC_VALUE_ENUM("ISRC2 FSL", arizona_isrc_fsl[1]), +SOC_VALUE("ISRC1 FSL", arizona_isrc_fsl[0]), +SOC_VALUE("ISRC2 FSL", arizona_isrc_fsl[1]), ARIZONA_MIXER_CONTROLS("Mic", ARIZONA_MICMIX_INPUT_1_SOURCE), ARIZONA_MIXER_CONTROLS("Noise", ARIZONA_NOISEMIX_INPUT_1_SOURCE), @@ -286,8 +286,8 @@ SOC_DOUBLE_R_TLV("SPKDAT1 Digital Volume", ARIZONA_DAC_DIGITAL_VOLUME_5L, ARIZONA_DAC_DIGITAL_VOLUME_5R, ARIZONA_OUT5L_VOL_SHIFT, 0xbf, 0, digital_tlv), -SOC_VALUE_ENUM("HPOUT1 OSR", wm8997_hpout_osr[0]), -SOC_VALUE_ENUM("EPOUT OSR", wm8997_hpout_osr[1]), +SOC_VALUE("HPOUT1 OSR", wm8997_hpout_osr[0]), +SOC_VALUE("EPOUT OSR", wm8997_hpout_osr[1]), SOC_ENUM("Output Ramp Up", arizona_out_vi_ramp), SOC_ENUM("Output Ramp Down", arizona_out_vd_ramp), @@ -405,7 +405,7 @@ static const struct soc_enum wm8997_aec_loopback = wm8997_aec_loopback_values); static const struct snd_kcontrol_new wm8997_aec_loopback_mux = - SOC_DAPM_VALUE_ENUM("AEC Loopback", wm8997_aec_loopback); + SOC_DAPM_ENUM("AEC Loopback", wm8997_aec_loopback); static const struct snd_soc_dapm_widget wm8997_dapm_widgets[] = { SND_SOC_DAPM_SUPPLY("SYSCLK", ARIZONA_SYSTEM_CLOCK_1, ARIZONA_SYSCLK_ENA_SHIFT, @@ -604,7 +604,7 @@ SND_SOC_DAPM_AIF_IN("SLIMRX8", NULL, 0, ARIZONA_SLIMBUS_RX_CHANNEL_ENABLE, ARIZONA_SLIMRX8_ENA_SHIFT, 0), -SND_SOC_DAPM_VALUE_MUX("AEC Loopback", ARIZONA_DAC_AEC_CONTROL_1, +SND_SOC_DAPM_MUX("AEC Loopback", ARIZONA_DAC_AEC_CONTROL_1, ARIZONA_AEC_LOOPBACK_ENA_SHIFT, 0, &wm8997_aec_loopback_mux), -- cgit v1.2.3 From 785b3c4e0951252cdbc0cd902292bf5c9f08897a Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Mon, 14 Apr 2014 21:31:12 +0200 Subject: ASoC: Remove deprecated ENUM/MUX macros Since there are no users left, we can remove the deprecated ENUM and MUX macros which are just alias for other macros. Signed-off-by: Lars-Peter Clausen Signed-off-by: Mark Brown --- include/sound/soc-dapm.h | 12 ------------ include/sound/soc.h | 2 -- 2 files changed, 14 deletions(-) diff --git a/include/sound/soc-dapm.h b/include/sound/soc-dapm.h index ef78f562f4a8..5ec03b5e2054 100644 --- a/include/sound/soc-dapm.h +++ b/include/sound/soc-dapm.h @@ -107,10 +107,6 @@ struct device; { .id = snd_soc_dapm_mux, .name = wname, \ SND_SOC_DAPM_INIT_REG_VAL(wreg, wshift, winvert), \ .kcontrol_news = wcontrols, .num_kcontrols = 1} -#define SND_SOC_DAPM_VIRT_MUX(wname, wreg, wshift, winvert, wcontrols) \ - SND_SOC_DAPM_MUX(wname, wreg, wshift, winvert, wcontrols) -#define SND_SOC_DAPM_VALUE_MUX(wname, wreg, wshift, winvert, wcontrols) \ - SND_SOC_DAPM_MUX(wname, wreg, wshift, winvert, wcontrols) /* Simplified versions of above macros, assuming wncontrols = ARRAY_SIZE(wcontrols) */ #define SOC_PGA_ARRAY(wname, wreg, wshift, winvert,\ @@ -166,10 +162,6 @@ struct device; SND_SOC_DAPM_INIT_REG_VAL(wreg, wshift, winvert), \ .kcontrol_news = wcontrols, .num_kcontrols = 1, \ .event = wevent, .event_flags = wflags} -#define SND_SOC_DAPM_VIRT_MUX_E(wname, wreg, wshift, winvert, wcontrols, \ - wevent, wflags) \ - SND_SOC_DAPM_MUX_E(wname, wreg, wshift, winvert, wcontrols, wevent, \ - wflags) /* additional sequencing control within an event type */ #define SND_SOC_DAPM_PGA_S(wname, wsubseq, wreg, wshift, winvert, \ @@ -305,16 +297,12 @@ struct device; .get = snd_soc_dapm_get_enum_double, \ .put = snd_soc_dapm_put_enum_double, \ .private_value = (unsigned long)&xenum } -#define SOC_DAPM_ENUM_VIRT(xname, xenum) \ - SOC_DAPM_ENUM(xname, xenum) #define SOC_DAPM_ENUM_EXT(xname, xenum, xget, xput) \ { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \ .info = snd_soc_info_enum_double, \ .get = xget, \ .put = xput, \ .private_value = (unsigned long)&xenum } -#define SOC_DAPM_VALUE_ENUM(xname, xenum) \ - SOC_DAPM_ENUM(xname, xenum) #define SOC_DAPM_PIN_SWITCH(xname) \ { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname " Switch", \ .info = snd_soc_dapm_info_pin_switch, \ diff --git a/include/sound/soc.h b/include/sound/soc.h index 0b83168d8ff4..98e85a4796b6 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h @@ -196,8 +196,6 @@ .info = snd_soc_info_enum_double, \ .get = snd_soc_get_enum_double, .put = snd_soc_put_enum_double, \ .private_value = (unsigned long)&xenum } -#define SOC_VALUE_ENUM(xname, xenum) \ - SOC_ENUM(xname, xenum) #define SOC_SINGLE_EXT(xname, xreg, xshift, xmax, xinvert,\ xhandler_get, xhandler_put) \ { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \ -- cgit v1.2.3 From 40448e5e977b59a4753fce3619f537b63fcedc02 Mon Sep 17 00:00:00 2001 From: Peter Ujfalusi Date: Fri, 4 Apr 2014 15:56:30 +0300 Subject: ASoC: davinci-mcasp: Do not touch 0x04 register above McASP_VERSION_2 This register is not defined in TI81xx and on AM335x/AM437x it is the SYSCONFIG register which should not be touched by drivers since it is related to PM and handled by the generic PM code. This register write was there since the first time the davinci-mcasp driver was appeared in the kernel. The reason why it did not caused any issues on AM335x/AM437x is that it sets bit 1 in SYSCONFIG register which in turn will enable the smart-idle mode. This is the default mode and this is the mode McASP should be in also when in use. On TI81xx the register is not defined. Signed-off-by: Peter Ujfalusi Signed-off-by: Mark Brown --- sound/soc/davinci/davinci-mcasp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/soc/davinci/davinci-mcasp.c b/sound/soc/davinci/davinci-mcasp.c index 8007fcf428d9..af92d3e8671d 100644 --- a/sound/soc/davinci/davinci-mcasp.c +++ b/sound/soc/davinci/davinci-mcasp.c @@ -502,7 +502,7 @@ static int mcasp_common_hw_param(struct davinci_mcasp *mcasp, int stream, int active_serializers, numevt, n; u32 reg; /* Default configuration */ - if (mcasp->version != MCASP_VERSION_4) + if (mcasp->version < MCASP_VERSION_3) mcasp_set_bits(mcasp, DAVINCI_MCASP_PWREMUMGT_REG, MCASP_SOFT); /* All PINS as McASP */ -- cgit v1.2.3 From c474b38665463d9017cd60cd3a8f8226cf8d562f Mon Sep 17 00:00:00 2001 From: Harini Katakam Date: Mon, 14 Apr 2014 14:36:53 +0530 Subject: spi: Add driver for Cadence SPI controller Add driver for Cadence SPI controller. This is used in Xilinx Zynq. Signed-off-by: Harini Katakam Signed-off-by: Mark Brown --- drivers/spi/Kconfig | 7 + drivers/spi/Makefile | 1 + drivers/spi/spi-cadence.c | 673 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 681 insertions(+) create mode 100644 drivers/spi/spi-cadence.c diff --git a/drivers/spi/Kconfig b/drivers/spi/Kconfig index 60f2b41c7310..5f11568660c6 100644 --- a/drivers/spi/Kconfig +++ b/drivers/spi/Kconfig @@ -148,6 +148,13 @@ config SPI_BUTTERFLY inexpensive battery powered microcontroller evaluation board. This same cable can be used to flash new firmware. +config SPI_CADENCE + tristate "Cadence SPI controller" + depends on SPI_MASTER + help + This selects the Cadence SPI controller master driver + used by Xilinx Zynq. + config SPI_CLPS711X tristate "CLPS711X host SPI controller" depends on ARCH_CLPS711X || COMPILE_TEST diff --git a/drivers/spi/Makefile b/drivers/spi/Makefile index bd792669e563..3e503d6d3df3 100644 --- a/drivers/spi/Makefile +++ b/drivers/spi/Makefile @@ -22,6 +22,7 @@ obj-$(CONFIG_SPI_BFIN_V3) += spi-bfin-v3.o obj-$(CONFIG_SPI_BFIN_SPORT) += spi-bfin-sport.o obj-$(CONFIG_SPI_BITBANG) += spi-bitbang.o obj-$(CONFIG_SPI_BUTTERFLY) += spi-butterfly.o +obj-$(CONFIG_SPI_CADENCE) += spi-cadence.o obj-$(CONFIG_SPI_CLPS711X) += spi-clps711x.o obj-$(CONFIG_SPI_COLDFIRE_QSPI) += spi-coldfire-qspi.o obj-$(CONFIG_SPI_DAVINCI) += spi-davinci.o diff --git a/drivers/spi/spi-cadence.c b/drivers/spi/spi-cadence.c new file mode 100644 index 000000000000..bb758978465d --- /dev/null +++ b/drivers/spi/spi-cadence.c @@ -0,0 +1,673 @@ +/* + * Cadence SPI controller driver (master mode only) + * + * Copyright (C) 2008 - 2014 Xilinx, Inc. + * + * based on Blackfin On-Chip SPI Driver (spi_bfin5xx.c) + * + * This program is free software; you can redistribute it and/or modify it under + * the terms of the GNU General Public License version 2 as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* Name of this driver */ +#define CDNS_SPI_NAME "cdns-spi" + +/* Register offset definitions */ +#define CDNS_SPI_CR_OFFSET 0x00 /* Configuration Register, RW */ +#define CDNS_SPI_ISR_OFFSET 0x04 /* Interrupt Status Register, RO */ +#define CDNS_SPI_IER_OFFSET 0x08 /* Interrupt Enable Register, WO */ +#define CDNS_SPI_IDR_OFFSET 0x0c /* Interrupt Disable Register, WO */ +#define CDNS_SPI_IMR_OFFSET 0x10 /* Interrupt Enabled Mask Register, RO */ +#define CDNS_SPI_ER_OFFSET 0x14 /* Enable/Disable Register, RW */ +#define CDNS_SPI_DR_OFFSET 0x18 /* Delay Register, RW */ +#define CDNS_SPI_TXD_OFFSET 0x1C /* Data Transmit Register, WO */ +#define CDNS_SPI_RXD_OFFSET 0x20 /* Data Receive Register, RO */ +#define CDNS_SPI_SICR_OFFSET 0x24 /* Slave Idle Count Register, RW */ +#define CDNS_SPI_THLD_OFFSET 0x28 /* Transmit FIFO Watermark Register,RW */ + +/* + * SPI Configuration Register bit Masks + * + * This register contains various control bits that affect the operation + * of the SPI controller + */ +#define CDNS_SPI_CR_MANSTRT_MASK 0x00010000 /* Manual TX Start */ +#define CDNS_SPI_CR_CPHA_MASK 0x00000004 /* Clock Phase Control */ +#define CDNS_SPI_CR_CPOL_MASK 0x00000002 /* Clock Polarity Control */ +#define CDNS_SPI_CR_SSCTRL_MASK 0x00003C00 /* Slave Select Mask */ +#define CDNS_SPI_CR_BAUD_DIV_MASK 0x00000038 /* Baud Rate Divisor Mask */ +#define CDNS_SPI_CR_MSTREN_MASK 0x00000001 /* Master Enable Mask */ +#define CDNS_SPI_CR_MANSTRTEN_MASK 0x00008000 /* Manual TX Enable Mask */ +#define CDNS_SPI_CR_SSFORCE_MASK 0x00004000 /* Manual SS Enable Mask */ +#define CDNS_SPI_CR_BAUD_DIV_4_MASK 0x00000008 /* Default Baud Div Mask */ +#define CDNS_SPI_CR_DEFAULT_MASK (CDNS_SPI_CR_MSTREN_MASK | \ + CDNS_SPI_CR_SSCTRL_MASK | \ + CDNS_SPI_CR_SSFORCE_MASK | \ + CDNS_SPI_CR_BAUD_DIV_4_MASK) + +/* + * SPI Configuration Register - Baud rate and slave select + * + * These are the values used in the calculation of baud rate divisor and + * setting the slave select. + */ + +#define CDNS_SPI_BAUD_DIV_MAX 7 /* Baud rate divisor maximum */ +#define CDNS_SPI_BAUD_DIV_MIN 1 /* Baud rate divisor minimum */ +#define CDNS_SPI_BAUD_DIV_SHIFT 3 /* Baud rate divisor shift in CR */ +#define CDNS_SPI_SS_SHIFT 10 /* Slave Select field shift in CR */ +#define CDNS_SPI_SS0 0x1 /* Slave Select zero */ + +/* + * SPI Interrupt Registers bit Masks + * + * All the four interrupt registers (Status/Mask/Enable/Disable) have the same + * bit definitions. + */ +#define CDNS_SPI_IXR_TXOW_MASK 0x00000004 /* SPI TX FIFO Overwater */ +#define CDNS_SPI_IXR_MODF_MASK 0x00000002 /* SPI Mode Fault */ +#define CDNS_SPI_IXR_RXNEMTY_MASK 0x00000010 /* SPI RX FIFO Not Empty */ +#define CDNS_SPI_IXR_DEFAULT_MASK (CDNS_SPI_IXR_TXOW_MASK | \ + CDNS_SPI_IXR_MODF_MASK) +#define CDNS_SPI_IXR_TXFULL_MASK 0x00000008 /* SPI TX Full */ +#define CDNS_SPI_IXR_ALL_MASK 0x0000007F /* SPI all interrupts */ + +/* + * SPI Enable Register bit Masks + * + * This register is used to enable or disable the SPI controller + */ +#define CDNS_SPI_ER_ENABLE_MASK 0x00000001 /* SPI Enable Bit Mask */ +#define CDNS_SPI_ER_DISABLE_MASK 0x0 /* SPI Disable Bit Mask */ + +/* SPI FIFO depth in bytes */ +#define CDNS_SPI_FIFO_DEPTH 128 + +/* Default number of chip select lines */ +#define CDNS_SPI_DEFAULT_NUM_CS 4 + +/** + * struct cdns_spi - This definition defines spi driver instance + * @regs: Virtual address of the SPI controller registers + * @ref_clk: Pointer to the peripheral clock + * @pclk: Pointer to the APB clock + * @speed_hz: Current SPI bus clock speed in Hz + * @txbuf: Pointer to the TX buffer + * @rxbuf: Pointer to the RX buffer + * @tx_bytes: Number of bytes left to transfer + * @rx_bytes: Number of bytes requested + * @dev_busy: Device busy flag + * @is_decoded_cs: Flag for decoder property set or not + */ +struct cdns_spi { + void __iomem *regs; + struct clk *ref_clk; + struct clk *pclk; + u32 speed_hz; + const u8 *txbuf; + u8 *rxbuf; + int tx_bytes; + int rx_bytes; + u8 dev_busy; + u32 is_decoded_cs; +}; + +/* Macros for the SPI controller read/write */ +static inline u32 cdns_spi_read(struct cdns_spi *xspi, u32 offset) +{ + return readl_relaxed(xspi->regs + offset); +} + +static inline void cdns_spi_write(struct cdns_spi *xspi, u32 offset, u32 val) +{ + writel_relaxed(val, xspi->regs + offset); +} + +/** + * cdns_spi_init_hw - Initialize the hardware and configure the SPI controller + * @xspi: Pointer to the cdns_spi structure + * + * On reset the SPI controller is configured to be in master mode, baud rate + * divisor is set to 4, threshold value for TX FIFO not full interrupt is set + * to 1 and size of the word to be transferred as 8 bit. + * This function initializes the SPI controller to disable and clear all the + * interrupts, enable manual slave select and manual start, deselect all the + * chip select lines, and enable the SPI controller. + */ +static void cdns_spi_init_hw(struct cdns_spi *xspi) +{ + cdns_spi_write(xspi, CDNS_SPI_ER_OFFSET, + CDNS_SPI_ER_DISABLE_MASK); + cdns_spi_write(xspi, CDNS_SPI_IDR_OFFSET, + CDNS_SPI_IXR_ALL_MASK); + + /* Clear the RX FIFO */ + while (cdns_spi_read(xspi, CDNS_SPI_ISR_OFFSET) & + CDNS_SPI_IXR_RXNEMTY_MASK) + cdns_spi_read(xspi, CDNS_SPI_RXD_OFFSET); + + cdns_spi_write(xspi, CDNS_SPI_ISR_OFFSET, + CDNS_SPI_IXR_ALL_MASK); + cdns_spi_write(xspi, CDNS_SPI_CR_OFFSET, + CDNS_SPI_CR_DEFAULT_MASK); + cdns_spi_write(xspi, CDNS_SPI_ER_OFFSET, + CDNS_SPI_ER_ENABLE_MASK); +} + +/** + * cdns_spi_chipselect - Select or deselect the chip select line + * @spi: Pointer to the spi_device structure + * @is_on: Select(0) or deselect (1) the chip select line + */ +static void cdns_spi_chipselect(struct spi_device *spi, bool is_high) +{ + struct cdns_spi *xspi = spi_master_get_devdata(spi->master); + u32 ctrl_reg; + + ctrl_reg = cdns_spi_read(xspi, CDNS_SPI_CR_OFFSET); + + if (is_high) { + /* Deselect the slave */ + ctrl_reg |= CDNS_SPI_CR_SSCTRL_MASK; + } else { + /* Select the slave */ + ctrl_reg &= ~CDNS_SPI_CR_SSCTRL_MASK; + if (!(xspi->is_decoded_cs)) + ctrl_reg |= ((~(CDNS_SPI_SS0 << spi->chip_select)) << + CDNS_SPI_SS_SHIFT) & + CDNS_SPI_CR_SSCTRL_MASK; + else + ctrl_reg |= (spi->chip_select << CDNS_SPI_SS_SHIFT) & + CDNS_SPI_CR_SSCTRL_MASK; + } + + cdns_spi_write(xspi, CDNS_SPI_CR_OFFSET, ctrl_reg); +} + +/** + * cdns_spi_config_clock_mode - Sets clock polarity and phase + * @spi: Pointer to the spi_device structure + * + * Sets the requested clock polarity and phase. + */ +static void cdns_spi_config_clock_mode(struct spi_device *spi) +{ + struct cdns_spi *xspi = spi_master_get_devdata(spi->master); + u32 ctrl_reg; + + ctrl_reg = cdns_spi_read(xspi, CDNS_SPI_CR_OFFSET); + + /* Set the SPI clock phase and clock polarity */ + ctrl_reg &= ~(CDNS_SPI_CR_CPHA_MASK | CDNS_SPI_CR_CPOL_MASK); + if (spi->mode & SPI_CPHA) + ctrl_reg |= CDNS_SPI_CR_CPHA_MASK; + if (spi->mode & SPI_CPOL) + ctrl_reg |= CDNS_SPI_CR_CPOL_MASK; + + cdns_spi_write(xspi, CDNS_SPI_CR_OFFSET, ctrl_reg); +} + +/** + * cdns_spi_config_clock_freq - Sets clock frequency + * @spi: Pointer to the spi_device structure + * @transfer: Pointer to the spi_transfer structure which provides + * information about next transfer setup parameters + * + * Sets the requested clock frequency. + * Note: If the requested frequency is not an exact match with what can be + * obtained using the prescalar value the driver sets the clock frequency which + * is lower than the requested frequency (maximum lower) for the transfer. If + * the requested frequency is higher or lower than that is supported by the SPI + * controller the driver will set the highest or lowest frequency supported by + * controller. + */ +static void cdns_spi_config_clock_freq(struct spi_device *spi, + struct spi_transfer *transfer) +{ + struct cdns_spi *xspi = spi_master_get_devdata(spi->master); + u32 ctrl_reg, baud_rate_val; + unsigned long frequency; + + frequency = clk_get_rate(xspi->ref_clk); + + ctrl_reg = cdns_spi_read(xspi, CDNS_SPI_CR_OFFSET); + + /* Set the clock frequency */ + if (xspi->speed_hz != transfer->speed_hz) { + /* first valid value is 1 */ + baud_rate_val = CDNS_SPI_BAUD_DIV_MIN; + while ((baud_rate_val < CDNS_SPI_BAUD_DIV_MAX) && + (frequency / (2 << baud_rate_val)) > transfer->speed_hz) + baud_rate_val++; + + ctrl_reg &= ~CDNS_SPI_CR_BAUD_DIV_MASK; + ctrl_reg |= baud_rate_val << CDNS_SPI_BAUD_DIV_SHIFT; + + xspi->speed_hz = frequency / (2 << baud_rate_val); + } + cdns_spi_write(xspi, CDNS_SPI_CR_OFFSET, ctrl_reg); +} + +/** + * cdns_spi_setup_transfer - Configure SPI controller for specified transfer + * @spi: Pointer to the spi_device structure + * @transfer: Pointer to the spi_transfer structure which provides + * information about next transfer setup parameters + * + * Sets the operational mode of SPI controller for the next SPI transfer and + * sets the requested clock frequency. + * + * Return: Always 0 + */ +static int cdns_spi_setup_transfer(struct spi_device *spi, + struct spi_transfer *transfer) +{ + struct cdns_spi *xspi = spi_master_get_devdata(spi->master); + + cdns_spi_config_clock_freq(spi, transfer); + + dev_dbg(&spi->dev, "%s, mode %d, %u bits/w, %u clock speed\n", + __func__, spi->mode, spi->bits_per_word, + xspi->speed_hz); + + return 0; +} + +/** + * cdns_spi_fill_tx_fifo - Fills the TX FIFO with as many bytes as possible + * @xspi: Pointer to the cdns_spi structure + */ +static void cdns_spi_fill_tx_fifo(struct cdns_spi *xspi) +{ + unsigned long trans_cnt = 0; + + while ((trans_cnt < CDNS_SPI_FIFO_DEPTH) && + (xspi->tx_bytes > 0)) { + if (xspi->txbuf) + cdns_spi_write(xspi, CDNS_SPI_TXD_OFFSET, + *xspi->txbuf++); + else + cdns_spi_write(xspi, CDNS_SPI_TXD_OFFSET, 0); + + xspi->tx_bytes--; + trans_cnt++; + } +} + +/** + * cdns_spi_irq - Interrupt service routine of the SPI controller + * @irq: IRQ number + * @dev_id: Pointer to the xspi structure + * + * This function handles TX empty and Mode Fault interrupts only. + * On TX empty interrupt this function reads the received data from RX FIFO and + * fills the TX FIFO if there is any data remaining to be transferred. + * On Mode Fault interrupt this function indicates that transfer is completed, + * the SPI subsystem will identify the error as the remaining bytes to be + * transferred is non-zero. + * + * Return: IRQ_HANDLED when handled; IRQ_NONE otherwise. + */ +static irqreturn_t cdns_spi_irq(int irq, void *dev_id) +{ + struct spi_master *master = dev_id; + struct cdns_spi *xspi = spi_master_get_devdata(master); + u32 intr_status, status; + + status = IRQ_NONE; + intr_status = cdns_spi_read(xspi, CDNS_SPI_ISR_OFFSET); + cdns_spi_write(xspi, CDNS_SPI_ISR_OFFSET, intr_status); + + if (intr_status & CDNS_SPI_IXR_MODF_MASK) { + /* Indicate that transfer is completed, the SPI subsystem will + * identify the error as the remaining bytes to be + * transferred is non-zero + */ + cdns_spi_write(xspi, CDNS_SPI_IDR_OFFSET, + CDNS_SPI_IXR_DEFAULT_MASK); + spi_finalize_current_transfer(master); + status = IRQ_HANDLED; + } else if (intr_status & CDNS_SPI_IXR_TXOW_MASK) { + unsigned long trans_cnt; + + trans_cnt = xspi->rx_bytes - xspi->tx_bytes; + + /* Read out the data from the RX FIFO */ + while (trans_cnt) { + u8 data; + + data = cdns_spi_read(xspi, CDNS_SPI_RXD_OFFSET); + if (xspi->rxbuf) + *xspi->rxbuf++ = data; + + xspi->rx_bytes--; + trans_cnt--; + } + + if (xspi->tx_bytes) { + /* There is more data to send */ + cdns_spi_fill_tx_fifo(xspi); + } else { + /* Transfer is completed */ + cdns_spi_write(xspi, CDNS_SPI_IDR_OFFSET, + CDNS_SPI_IXR_DEFAULT_MASK); + spi_finalize_current_transfer(master); + } + status = IRQ_HANDLED; + } + + return status; +} + +/** + * cdns_transfer_one - Initiates the SPI transfer + * @master: Pointer to spi_master structure + * @spi: Pointer to the spi_device structure + * @transfer: Pointer to the spi_transfer structure which provides + * information about next transfer parameters + * + * This function fills the TX FIFO, starts the SPI transfer and + * returns a positive transfer count so that core will wait for completion. + * + * Return: Number of bytes transferred in the last transfer + */ +static int cdns_transfer_one(struct spi_master *master, + struct spi_device *spi, + struct spi_transfer *transfer) +{ + struct cdns_spi *xspi = spi_master_get_devdata(master); + + xspi->txbuf = transfer->tx_buf; + xspi->rxbuf = transfer->rx_buf; + xspi->tx_bytes = transfer->len; + xspi->rx_bytes = transfer->len; + + cdns_spi_setup_transfer(spi, transfer); + + cdns_spi_fill_tx_fifo(xspi); + + cdns_spi_write(xspi, CDNS_SPI_IER_OFFSET, + CDNS_SPI_IXR_DEFAULT_MASK); + return transfer->len; +} + +/** + * cdns_prepare_transfer_hardware - Prepares hardware for transfer. + * @master: Pointer to the spi_master structure which provides + * information about the controller. + * + * This function enables SPI master controller. + * + * Return: 0 always + */ +static int cdns_prepare_transfer_hardware(struct spi_master *master) +{ + struct cdns_spi *xspi = spi_master_get_devdata(master); + + cdns_spi_config_clock_mode(master->cur_msg->spi); + + cdns_spi_write(xspi, CDNS_SPI_ER_OFFSET, + CDNS_SPI_ER_ENABLE_MASK); + + return 0; +} + +/** + * cdns_unprepare_transfer_hardware - Relaxes hardware after transfer + * @master: Pointer to the spi_master structure which provides + * information about the controller. + * + * This function disables the SPI master controller. + * + * Return: 0 always + */ +static int cdns_unprepare_transfer_hardware(struct spi_master *master) +{ + struct cdns_spi *xspi = spi_master_get_devdata(master); + + cdns_spi_write(xspi, CDNS_SPI_ER_OFFSET, + CDNS_SPI_ER_DISABLE_MASK); + + return 0; +} + +/** + * cdns_spi_probe - Probe method for the SPI driver + * @pdev: Pointer to the platform_device structure + * + * This function initializes the driver data structures and the hardware. + * + * Return: 0 on success and error value on error + */ +static int cdns_spi_probe(struct platform_device *pdev) +{ + int ret = 0, irq; + struct spi_master *master; + struct cdns_spi *xspi; + struct resource *res; + u32 num_cs; + + master = spi_alloc_master(&pdev->dev, sizeof(*xspi)); + if (master == NULL) + return -ENOMEM; + + xspi = spi_master_get_devdata(master); + master->dev.of_node = pdev->dev.of_node; + platform_set_drvdata(pdev, master); + + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + xspi->regs = devm_ioremap_resource(&pdev->dev, res); + if (IS_ERR(xspi->regs)) { + ret = PTR_ERR(xspi->regs); + goto remove_master; + } + + xspi->pclk = devm_clk_get(&pdev->dev, "pclk"); + if (IS_ERR(xspi->pclk)) { + dev_err(&pdev->dev, "pclk clock not found.\n"); + ret = PTR_ERR(xspi->pclk); + goto remove_master; + } + + xspi->ref_clk = devm_clk_get(&pdev->dev, "ref_clk"); + if (IS_ERR(xspi->ref_clk)) { + dev_err(&pdev->dev, "ref_clk clock not found.\n"); + ret = PTR_ERR(xspi->ref_clk); + goto remove_master; + } + + ret = clk_prepare_enable(xspi->pclk); + if (ret) { + dev_err(&pdev->dev, "Unable to enable APB clock.\n"); + goto remove_master; + } + + ret = clk_prepare_enable(xspi->ref_clk); + if (ret) { + dev_err(&pdev->dev, "Unable to enable device clock.\n"); + goto clk_dis_apb; + } + + /* SPI controller initializations */ + cdns_spi_init_hw(xspi); + + irq = platform_get_irq(pdev, 0); + if (irq <= 0) { + ret = -ENXIO; + dev_err(&pdev->dev, "irq number is invalid\n"); + goto remove_master; + } + + ret = devm_request_irq(&pdev->dev, irq, cdns_spi_irq, + 0, pdev->name, master); + if (ret != 0) { + ret = -ENXIO; + dev_err(&pdev->dev, "request_irq failed\n"); + goto remove_master; + } + + ret = of_property_read_u32(pdev->dev.of_node, "num-cs", &num_cs); + + if (ret < 0) + master->num_chipselect = CDNS_SPI_DEFAULT_NUM_CS; + else + master->num_chipselect = num_cs; + + ret = of_property_read_u32(pdev->dev.of_node, "is-decoded-cs", + &xspi->is_decoded_cs); + + if (ret < 0) + xspi->is_decoded_cs = 0; + + master->prepare_transfer_hardware = cdns_prepare_transfer_hardware; + master->transfer_one = cdns_transfer_one; + master->unprepare_transfer_hardware = cdns_unprepare_transfer_hardware; + master->set_cs = cdns_spi_chipselect; + master->mode_bits = SPI_CPOL | SPI_CPHA; + + /* Set to default valid value */ + master->max_speed_hz = clk_get_rate(xspi->ref_clk) / 4; + xspi->speed_hz = master->max_speed_hz; + + master->bits_per_word_mask = SPI_BPW_MASK(8); + + ret = spi_register_master(master); + if (ret) { + dev_err(&pdev->dev, "spi_register_master failed\n"); + goto clk_dis_all; + } + + return ret; + +clk_dis_all: + clk_disable_unprepare(xspi->ref_clk); +clk_dis_apb: + clk_disable_unprepare(xspi->pclk); +remove_master: + spi_master_put(master); + return ret; +} + +/** + * cdns_spi_remove - Remove method for the SPI driver + * @pdev: Pointer to the platform_device structure + * + * This function is called if a device is physically removed from the system or + * if the driver module is being unloaded. It frees all resources allocated to + * the device. + * + * Return: 0 on success and error value on error + */ +static int cdns_spi_remove(struct platform_device *pdev) +{ + struct spi_master *master = platform_get_drvdata(pdev); + struct cdns_spi *xspi = spi_master_get_devdata(master); + + cdns_spi_write(xspi, CDNS_SPI_ER_OFFSET, + CDNS_SPI_ER_DISABLE_MASK); + + clk_disable_unprepare(xspi->ref_clk); + clk_disable_unprepare(xspi->pclk); + + spi_unregister_master(master); + + return 0; +} + +/** + * cdns_spi_suspend - Suspend method for the SPI driver + * @dev: Address of the platform_device structure + * + * This function disables the SPI controller and + * changes the driver state to "suspend" + * + * Return: Always 0 + */ +static int __maybe_unused cdns_spi_suspend(struct device *dev) +{ + struct platform_device *pdev = container_of(dev, + struct platform_device, dev); + struct spi_master *master = platform_get_drvdata(pdev); + struct cdns_spi *xspi = spi_master_get_devdata(master); + + spi_master_suspend(master); + + clk_disable_unprepare(xspi->ref_clk); + + clk_disable_unprepare(xspi->pclk); + + return 0; +} + +/** + * cdns_spi_resume - Resume method for the SPI driver + * @dev: Address of the platform_device structure + * + * This function changes the driver state to "ready" + * + * Return: 0 on success and error value on error + */ +static int __maybe_unused cdns_spi_resume(struct device *dev) +{ + struct platform_device *pdev = container_of(dev, + struct platform_device, dev); + struct spi_master *master = platform_get_drvdata(pdev); + struct cdns_spi *xspi = spi_master_get_devdata(master); + int ret = 0; + + ret = clk_prepare_enable(xspi->pclk); + if (ret) { + dev_err(dev, "Cannot enable APB clock.\n"); + return ret; + } + + ret = clk_prepare_enable(xspi->ref_clk); + if (ret) { + dev_err(dev, "Cannot enable device clock.\n"); + clk_disable(xspi->pclk); + return ret; + } + spi_master_resume(master); + + return 0; +} + +static SIMPLE_DEV_PM_OPS(cdns_spi_dev_pm_ops, cdns_spi_suspend, + cdns_spi_resume); + +static struct of_device_id cdns_spi_of_match[] = { + { .compatible = "xlnx,zynq-spi-r1p6" }, + { .compatible = "cdns,spi-r1p6" }, + { /* end of table */ } +}; +MODULE_DEVICE_TABLE(of, cdns_spi_of_match); + +/* cdns_spi_driver - This structure defines the SPI subsystem platform driver */ +static struct platform_driver cdns_spi_driver = { + .probe = cdns_spi_probe, + .remove = cdns_spi_remove, + .driver = { + .name = CDNS_SPI_NAME, + .owner = THIS_MODULE, + .of_match_table = cdns_spi_of_match, + .pm = &cdns_spi_dev_pm_ops, + }, +}; + +module_platform_driver(cdns_spi_driver); + +MODULE_AUTHOR("Xilinx, Inc."); +MODULE_DESCRIPTION("Cadence SPI driver"); +MODULE_LICENSE("GPL"); -- cgit v1.2.3 From 205d52756f4091ffcf526f9d14853b18e3ca8d6f Mon Sep 17 00:00:00 2001 From: Harini Katakam Date: Mon, 14 Apr 2014 14:36:54 +0530 Subject: spi: Add devicetree bindings documentation for Cadence SPI Add spi-cadence bindings documentation. Signed-off-by: Harini Katakam Signed-off-by: Mark Brown --- .../devicetree/bindings/spi/spi-cadence.txt | 31 ++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 Documentation/devicetree/bindings/spi/spi-cadence.txt diff --git a/Documentation/devicetree/bindings/spi/spi-cadence.txt b/Documentation/devicetree/bindings/spi/spi-cadence.txt new file mode 100644 index 000000000000..94f09141a4f0 --- /dev/null +++ b/Documentation/devicetree/bindings/spi/spi-cadence.txt @@ -0,0 +1,31 @@ +Cadence SPI controller Device Tree Bindings +------------------------------------------- + +Required properties: +- compatible : Should be "cdns,spi-r1p6" or "xlnx,zynq-spi-r1p6". +- reg : Physical base address and size of SPI registers map. +- interrupts : Property with a value describing the interrupt + number. +- interrupt-parent : Must be core interrupt controller +- clock-names : List of input clock names - "ref_clk", "pclk" + (See clock bindings for details). +- clocks : Clock phandles (see clock bindings for details). + +Optional properties: +- num-cs : Number of chip selects used. + If a decoder is used, this will be the number of + chip selects after the decoder. +- is-decoded-cs : Flag to indicate whether decoder is used or not. + +Example: + + spi@e0007000 { + compatible = "xlnx,zynq-spi-r1p6"; + clock-names = "ref_clk", "pclk"; + clocks = <&clkc 26>, <&clkc 35>; + interrupt-parent = <&intc>; + interrupts = <0 49 4>; + num-cs = <4>; + is-decoded-cs = <0>; + reg = <0xe0007000 0x1000>; + } ; -- cgit v1.2.3 From d77ec5df47696300b9498e6973dcc34b40de8d27 Mon Sep 17 00:00:00 2001 From: Qipan Li Date: Mon, 14 Apr 2014 14:30:00 +0800 Subject: spi: sirf: fix line over 80 characters style issue fix a lot of "line over 80 characters" checkpatch issues, on which the users of the driver, key customers care about this very much. Signed-off-by: Qipan Li Signed-off-by: Barry Song Signed-off-by: Mark Brown --- drivers/spi/spi-sirf.c | 51 +++++++++++++++++++++++++++++++------------------- 1 file changed, 32 insertions(+), 19 deletions(-) diff --git a/drivers/spi/spi-sirf.c b/drivers/spi/spi-sirf.c index 67d8909dcf39..3c12f396d96a 100644 --- a/drivers/spi/spi-sirf.c +++ b/drivers/spi/spi-sirf.c @@ -382,14 +382,16 @@ static int spi_sirfsoc_transfer(struct spi_device *spi, struct spi_transfer *t) if (IS_DMA_VALID(t)) { struct dma_async_tx_descriptor *rx_desc, *tx_desc; - sspi->dst_start = dma_map_single(&spi->dev, sspi->rx, t->len, DMA_FROM_DEVICE); + sspi->dst_start = dma_map_single(&spi->dev, + sspi->rx, t->len, DMA_FROM_DEVICE); rx_desc = dmaengine_prep_slave_single(sspi->rx_chan, sspi->dst_start, t->len, DMA_DEV_TO_MEM, DMA_PREP_INTERRUPT | DMA_CTRL_ACK); rx_desc->callback = spi_sirfsoc_dma_fini_callback; rx_desc->callback_param = &sspi->rx_done; - sspi->src_start = dma_map_single(&spi->dev, (void *)sspi->tx, t->len, DMA_TO_DEVICE); + sspi->src_start = dma_map_single(&spi->dev, + (void *)sspi->tx, t->len, DMA_TO_DEVICE); tx_desc = dmaengine_prep_slave_single(sspi->tx_chan, sspi->src_start, t->len, DMA_MEM_TO_DEV, DMA_PREP_INTERRUPT | DMA_CTRL_ACK); @@ -404,13 +406,18 @@ static int spi_sirfsoc_transfer(struct spi_device *spi, struct spi_transfer *t) /* Send the first word to trigger the whole tx/rx process */ sspi->tx_word(sspi); - writel(SIRFSOC_SPI_RX_OFLOW_INT_EN | SIRFSOC_SPI_TX_UFLOW_INT_EN | - SIRFSOC_SPI_RXFIFO_THD_INT_EN | SIRFSOC_SPI_TXFIFO_THD_INT_EN | - SIRFSOC_SPI_FRM_END_INT_EN | SIRFSOC_SPI_RXFIFO_FULL_INT_EN | - SIRFSOC_SPI_TXFIFO_EMPTY_INT_EN, sspi->base + SIRFSOC_SPI_INT_EN); + writel(SIRFSOC_SPI_RX_OFLOW_INT_EN | + SIRFSOC_SPI_TX_UFLOW_INT_EN | + SIRFSOC_SPI_RXFIFO_THD_INT_EN | + SIRFSOC_SPI_TXFIFO_THD_INT_EN | + SIRFSOC_SPI_FRM_END_INT_EN | + SIRFSOC_SPI_RXFIFO_FULL_INT_EN | + SIRFSOC_SPI_TXFIFO_EMPTY_INT_EN, + sspi->base + SIRFSOC_SPI_INT_EN); } - writel(SIRFSOC_SPI_RX_EN | SIRFSOC_SPI_TX_EN, sspi->base + SIRFSOC_SPI_TX_RX_EN); + writel(SIRFSOC_SPI_RX_EN | SIRFSOC_SPI_TX_EN, + sspi->base + SIRFSOC_SPI_TX_RX_EN); if (!IS_DMA_VALID(t)) { /* for PIO */ if (wait_for_completion_timeout(&sspi->rx_done, timeout) == 0) @@ -434,8 +441,10 @@ static int spi_sirfsoc_transfer(struct spi_device *spi, struct spi_transfer *t) } if (IS_DMA_VALID(t)) { - dma_unmap_single(&spi->dev, sspi->src_start, t->len, DMA_TO_DEVICE); - dma_unmap_single(&spi->dev, sspi->dst_start, t->len, DMA_FROM_DEVICE); + dma_unmap_single(&spi->dev, + sspi->src_start, t->len, DMA_TO_DEVICE); + dma_unmap_single(&spi->dev, + sspi->dst_start, t->len, DMA_FROM_DEVICE); } /* TX, RX FIFO stop */ @@ -512,7 +521,8 @@ spi_sirfsoc_setup_transfer(struct spi_device *spi, struct spi_transfer *t) break; case 12: case 16: - regval |= (bits_per_word == 12) ? SIRFSOC_SPI_TRAN_DAT_FORMAT_12 : + regval |= (bits_per_word == 12) ? + SIRFSOC_SPI_TRAN_DAT_FORMAT_12 : SIRFSOC_SPI_TRAN_DAT_FORMAT_16; sspi->rx_word = spi_sirfsoc_rx_word_u16; sspi->tx_word = spi_sirfsoc_tx_word_u16; @@ -540,8 +550,8 @@ spi_sirfsoc_setup_transfer(struct spi_device *spi, struct spi_transfer *t) regval |= SIRFSOC_SPI_CLK_IDLE_STAT; /* - * Data should be driven at least 1/2 cycle before the fetch edge to make - * sure that data gets stable at the fetch edge. + * Data should be driven at least 1/2 cycle before the fetch edge + * to make sure that data gets stable at the fetch edge. */ if (((spi->mode & SPI_CPOL) && (spi->mode & SPI_CPHA)) || (!(spi->mode & SPI_CPOL) && !(spi->mode & SPI_CPHA))) @@ -578,11 +588,14 @@ spi_sirfsoc_setup_transfer(struct spi_device *spi, struct spi_transfer *t) if (IS_DMA_VALID(t)) { /* Enable DMA mode for RX, TX */ writel(0, sspi->base + SIRFSOC_SPI_TX_DMA_IO_CTRL); - writel(SIRFSOC_SPI_RX_DMA_FLUSH, sspi->base + SIRFSOC_SPI_RX_DMA_IO_CTRL); + writel(SIRFSOC_SPI_RX_DMA_FLUSH, + sspi->base + SIRFSOC_SPI_RX_DMA_IO_CTRL); } else { /* Enable IO mode for RX, TX */ - writel(SIRFSOC_SPI_IO_MODE_SEL, sspi->base + SIRFSOC_SPI_TX_DMA_IO_CTRL); - writel(SIRFSOC_SPI_IO_MODE_SEL, sspi->base + SIRFSOC_SPI_RX_DMA_IO_CTRL); + writel(SIRFSOC_SPI_IO_MODE_SEL, + sspi->base + SIRFSOC_SPI_TX_DMA_IO_CTRL); + writel(SIRFSOC_SPI_IO_MODE_SEL, + sspi->base + SIRFSOC_SPI_RX_DMA_IO_CTRL); } return 0; @@ -612,7 +625,8 @@ static int spi_sirfsoc_probe(struct platform_device *pdev) goto err_cs; } - master = spi_alloc_master(&pdev->dev, sizeof(*sspi) + sizeof(int) * num_cs); + master = spi_alloc_master(&pdev->dev, + sizeof(*sspi) + sizeof(int) * num_cs); if (!master) { dev_err(&pdev->dev, "Unable to allocate SPI master\n"); return -ENOMEM; @@ -808,8 +822,7 @@ static struct platform_driver spi_sirfsoc_driver = { .remove = spi_sirfsoc_remove, }; module_platform_driver(spi_sirfsoc_driver); - MODULE_DESCRIPTION("SiRF SoC SPI master driver"); -MODULE_AUTHOR("Zhiwu Song , " - "Barry Song "); +MODULE_AUTHOR("Zhiwu Song "); +MODULE_AUTHOR("Barry Song "); MODULE_LICENSE("GPL v2"); -- cgit v1.2.3 From bf83fd6402a856eeb9a22c364c50ccf9bbdf9b17 Mon Sep 17 00:00:00 2001 From: Qipan Li Date: Mon, 14 Apr 2014 14:30:01 +0800 Subject: spi: sirf: fix spi full-duplex DMA transferring issue sometimes t->tx can be equal with t->rx. for example, spidev will make tx and rx point to spidev->buffer at the same time. currently, for this case, we map the buffer BIDIRECTION to fix the cache consistency. Signed-off-by: Qipan Li Signed-off-by: Barry Song Signed-off-by: Mark Brown --- drivers/spi/spi-sirf.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/spi/spi-sirf.c b/drivers/spi/spi-sirf.c index 3c12f396d96a..0c039d4542a5 100644 --- a/drivers/spi/spi-sirf.c +++ b/drivers/spi/spi-sirf.c @@ -383,7 +383,8 @@ static int spi_sirfsoc_transfer(struct spi_device *spi, struct spi_transfer *t) struct dma_async_tx_descriptor *rx_desc, *tx_desc; sspi->dst_start = dma_map_single(&spi->dev, - sspi->rx, t->len, DMA_FROM_DEVICE); + sspi->rx, t->len, (t->tx_buf != t->rx_buf) ? + DMA_FROM_DEVICE : DMA_BIDIRECTIONAL); rx_desc = dmaengine_prep_slave_single(sspi->rx_chan, sspi->dst_start, t->len, DMA_DEV_TO_MEM, DMA_PREP_INTERRUPT | DMA_CTRL_ACK); @@ -391,7 +392,9 @@ static int spi_sirfsoc_transfer(struct spi_device *spi, struct spi_transfer *t) rx_desc->callback_param = &sspi->rx_done; sspi->src_start = dma_map_single(&spi->dev, - (void *)sspi->tx, t->len, DMA_TO_DEVICE); + (void *)sspi->tx, t->len, + (t->tx_buf != t->rx_buf) ? + DMA_TO_DEVICE : DMA_BIDIRECTIONAL); tx_desc = dmaengine_prep_slave_single(sspi->tx_chan, sspi->src_start, t->len, DMA_MEM_TO_DEV, DMA_PREP_INTERRUPT | DMA_CTRL_ACK); -- cgit v1.2.3 From f84526cfae46672308a361333c76b724384b61ee Mon Sep 17 00:00:00 2001 From: Nicolin Chen Date: Fri, 11 Apr 2014 22:10:00 +0800 Subject: ASoC: fsl_sai: Fix incorrect condition check in trigger() Patch ASoC: fsl_sai: Fix buggy configurations in trigger() doesn't entirely fix the condition: FRDE of the current substream direction is being cleared while the code is still using the non-updated one. Thus this patch fixes this issue by checking the opposite one's FRDE alone since the current one's is absolutely disabled. Signed-off-by: Nicolin Chen Signed-off-by: Mark Brown --- sound/soc/fsl/fsl_sai.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sound/soc/fsl/fsl_sai.c b/sound/soc/fsl/fsl_sai.c index 1c93282fbd26..a25e8884b09d 100644 --- a/sound/soc/fsl/fsl_sai.c +++ b/sound/soc/fsl/fsl_sai.c @@ -409,7 +409,8 @@ static int fsl_sai_trigger(struct snd_pcm_substream *substream, int cmd, regmap_update_bits(sai->regmap, FSL_SAI_xCSR(tx), FSL_SAI_CSR_xIE_MASK, 0); - if (!(tcsr & FSL_SAI_CSR_FRDE || rcsr & FSL_SAI_CSR_FRDE)) { + /* Check if the opposite FRDE is also disabled */ + if (!(tx ? rcsr & FSL_SAI_CSR_FRDE : tcsr & FSL_SAI_CSR_FRDE)) { regmap_update_bits(sai->regmap, FSL_SAI_TCSR, FSL_SAI_CSR_TERE, 0); regmap_update_bits(sai->regmap, FSL_SAI_RCSR, -- cgit v1.2.3 From 3e185238a37d1f0a37a1d910344cdcff578bf333 Mon Sep 17 00:00:00 2001 From: Xiubo Li Date: Fri, 4 Apr 2014 15:10:26 +0800 Subject: ASoC: esai: use the precise definition of 'ret'. Use the precise definition of 'ret', which will be used for the error check. Signed-off-by: Xiubo Li Acked-by: Nicolin Chen Signed-off-by: Mark Brown --- sound/soc/fsl/fsl_esai.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/sound/soc/fsl/fsl_esai.c b/sound/soc/fsl/fsl_esai.c index c8e5db1414d7..67d5417e0933 100644 --- a/sound/soc/fsl/fsl_esai.c +++ b/sound/soc/fsl/fsl_esai.c @@ -209,8 +209,9 @@ static int fsl_esai_set_dai_sysclk(struct snd_soc_dai *dai, int clk_id, struct clk *clksrc = esai_priv->extalclk; bool tx = clk_id <= ESAI_HCKT_EXTAL; bool in = dir == SND_SOC_CLOCK_IN; - u32 ret, ratio, ecr = 0; + u32 ratio, ecr = 0; unsigned long clk_rate; + int ret; /* sck_div can be only bypassed if ETO/ERO=0 and SNC_SOC_CLOCK_OUT */ esai_priv->sck_div[tx] = true; @@ -432,8 +433,8 @@ static int fsl_esai_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) static int fsl_esai_startup(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { - int ret; struct fsl_esai *esai_priv = snd_soc_dai_get_drvdata(dai); + int ret; /* * Some platforms might use the same bit to gate all three or two of @@ -491,7 +492,8 @@ static int fsl_esai_hw_params(struct snd_pcm_substream *substream, bool tx = substream->stream == SNDRV_PCM_STREAM_PLAYBACK; u32 width = snd_pcm_format_width(params_format(params)); u32 channels = params_channels(params); - u32 bclk, mask, val, ret; + u32 bclk, mask, val; + int ret; bclk = params_rate(params) * esai_priv->slot_width * 2; -- cgit v1.2.3 From add180ed780e9031d65e7c94cad936e719401acf Mon Sep 17 00:00:00 2001 From: Xiubo Li Date: Fri, 4 Apr 2014 15:10:27 +0800 Subject: ASoC: spdif: Sort the header files alphabetically. Signed-off-by: Xiubo Li Acked-by: Nicolin Chen Signed-off-by: Mark Brown --- sound/soc/fsl/fsl_spdif.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sound/soc/fsl/fsl_spdif.c b/sound/soc/fsl/fsl_spdif.c index 6452ca83d889..173553c6dc55 100644 --- a/sound/soc/fsl/fsl_spdif.c +++ b/sound/soc/fsl/fsl_spdif.c @@ -13,18 +13,18 @@ * kind, whether express or implied. */ -#include +#include #include #include -#include -#include +#include #include #include #include +#include #include -#include #include +#include #include "fsl_spdif.h" #include "imx-pcm.h" -- cgit v1.2.3 From b21cc2f5fdfe22429501cd7040db0b2b2a9b29de Mon Sep 17 00:00:00 2001 From: Xiubo Li Date: Fri, 4 Apr 2014 15:10:28 +0800 Subject: ASoC: esai: Add VF610+ compatibles support. Signed-off-by: Xiubo Li Acked-by: Nicolin Chen Signed-off-by: Mark Brown --- sound/soc/fsl/fsl_esai.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sound/soc/fsl/fsl_esai.c b/sound/soc/fsl/fsl_esai.c index 67d5417e0933..b49b78df2f5b 100644 --- a/sound/soc/fsl/fsl_esai.c +++ b/sound/soc/fsl/fsl_esai.c @@ -818,6 +818,7 @@ static int fsl_esai_probe(struct platform_device *pdev) static const struct of_device_id fsl_esai_dt_ids[] = { { .compatible = "fsl,imx35-esai", }, + { .compatible = "fsl,vf610-esai", }, {} }; MODULE_DEVICE_TABLE(of, fsl_esai_dt_ids); -- cgit v1.2.3 From 1014fad0fca91181acc68396d84573e4ae301380 Mon Sep 17 00:00:00 2001 From: Xiubo Li Date: Fri, 4 Apr 2014 15:10:29 +0800 Subject: ASoC: spdif: Add VF610+ compatibles support. Signed-off-by: Xiubo Li Acked-by: Nicolin Chen Signed-off-by: Mark Brown --- sound/soc/fsl/fsl_spdif.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sound/soc/fsl/fsl_spdif.c b/sound/soc/fsl/fsl_spdif.c index 173553c6dc55..daa6198ae41f 100644 --- a/sound/soc/fsl/fsl_spdif.c +++ b/sound/soc/fsl/fsl_spdif.c @@ -1186,6 +1186,7 @@ static int fsl_spdif_probe(struct platform_device *pdev) static const struct of_device_id fsl_spdif_dt_ids[] = { { .compatible = "fsl,imx35-spdif", }, + { .compatible = "fsl,vf610-spdif", }, {} }; MODULE_DEVICE_TABLE(of, fsl_spdif_dt_ids); -- cgit v1.2.3 From 2a266f8b2ae790454edb79cb8c707c9305e0307a Mon Sep 17 00:00:00 2001 From: Nicolin Chen Date: Fri, 11 Apr 2014 18:30:09 +0800 Subject: ASoC: fsl_sai: Use FSL_SAI_xXR() and regmap_update_bits() to simplify code By doing this, the driver can drop around 50 lines and become neater. Signed-off-by: Nicolin Chen Signed-off-by: Mark Brown --- sound/soc/fsl/fsl_sai.c | 101 ++++++++++++------------------------------------ 1 file changed, 25 insertions(+), 76 deletions(-) diff --git a/sound/soc/fsl/fsl_sai.c b/sound/soc/fsl/fsl_sai.c index a25e8884b09d..c5a0e8af8226 100644 --- a/sound/soc/fsl/fsl_sai.c +++ b/sound/soc/fsl/fsl_sai.c @@ -119,16 +119,8 @@ static int fsl_sai_set_dai_sysclk_tr(struct snd_soc_dai *cpu_dai, int clk_id, unsigned int freq, int fsl_dir) { struct fsl_sai *sai = snd_soc_dai_get_drvdata(cpu_dai); - u32 val_cr2, reg_cr2; - - if (fsl_dir == FSL_FMT_TRANSMITTER) - reg_cr2 = FSL_SAI_TCR2; - else - reg_cr2 = FSL_SAI_RCR2; - - regmap_read(sai->regmap, reg_cr2, &val_cr2); - - val_cr2 &= ~FSL_SAI_CR2_MSEL_MASK; + bool tx = fsl_dir == FSL_FMT_TRANSMITTER; + u32 val_cr2 = 0; switch (clk_id) { case FSL_SAI_CLK_BUS: @@ -147,7 +139,8 @@ static int fsl_sai_set_dai_sysclk_tr(struct snd_soc_dai *cpu_dai, return -EINVAL; } - regmap_write(sai->regmap, reg_cr2, val_cr2); + regmap_update_bits(sai->regmap, FSL_SAI_xCR2(tx), + FSL_SAI_CR2_MSEL_MASK, val_cr2); return 0; } @@ -179,22 +172,10 @@ static int fsl_sai_set_dai_fmt_tr(struct snd_soc_dai *cpu_dai, unsigned int fmt, int fsl_dir) { struct fsl_sai *sai = snd_soc_dai_get_drvdata(cpu_dai); - u32 val_cr2, val_cr4, reg_cr2, reg_cr4; - - if (fsl_dir == FSL_FMT_TRANSMITTER) { - reg_cr2 = FSL_SAI_TCR2; - reg_cr4 = FSL_SAI_TCR4; - } else { - reg_cr2 = FSL_SAI_RCR2; - reg_cr4 = FSL_SAI_RCR4; - } + bool tx = fsl_dir == FSL_FMT_TRANSMITTER; + u32 val_cr2 = 0, val_cr4 = 0; - regmap_read(sai->regmap, reg_cr2, &val_cr2); - regmap_read(sai->regmap, reg_cr4, &val_cr4); - - if (sai->big_endian_data) - val_cr4 &= ~FSL_SAI_CR4_MF; - else + if (!sai->big_endian_data) val_cr4 |= FSL_SAI_CR4_MF; /* DAI mode */ @@ -215,7 +196,6 @@ static int fsl_sai_set_dai_fmt_tr(struct snd_soc_dai *cpu_dai, * frame sync asserts with the first bit of the frame. */ val_cr2 |= FSL_SAI_CR2_BCP; - val_cr4 &= ~(FSL_SAI_CR4_FSE | FSL_SAI_CR4_FSP); break; case SND_SOC_DAIFMT_DSP_A: /* @@ -225,7 +205,6 @@ static int fsl_sai_set_dai_fmt_tr(struct snd_soc_dai *cpu_dai, * data word. */ val_cr2 |= FSL_SAI_CR2_BCP; - val_cr4 &= ~FSL_SAI_CR4_FSP; val_cr4 |= FSL_SAI_CR4_FSE; sai->is_dsp_mode = true; break; @@ -235,7 +214,6 @@ static int fsl_sai_set_dai_fmt_tr(struct snd_soc_dai *cpu_dai, * frame sync asserts with the first bit of the frame. */ val_cr2 |= FSL_SAI_CR2_BCP; - val_cr4 &= ~(FSL_SAI_CR4_FSE | FSL_SAI_CR4_FSP); sai->is_dsp_mode = true; break; case SND_SOC_DAIFMT_RIGHT_J: @@ -273,23 +251,22 @@ static int fsl_sai_set_dai_fmt_tr(struct snd_soc_dai *cpu_dai, val_cr4 |= FSL_SAI_CR4_FSD_MSTR; break; case SND_SOC_DAIFMT_CBM_CFM: - val_cr2 &= ~FSL_SAI_CR2_BCD_MSTR; - val_cr4 &= ~FSL_SAI_CR4_FSD_MSTR; break; case SND_SOC_DAIFMT_CBS_CFM: val_cr2 |= FSL_SAI_CR2_BCD_MSTR; - val_cr4 &= ~FSL_SAI_CR4_FSD_MSTR; break; case SND_SOC_DAIFMT_CBM_CFS: - val_cr2 &= ~FSL_SAI_CR2_BCD_MSTR; val_cr4 |= FSL_SAI_CR4_FSD_MSTR; break; default: return -EINVAL; } - regmap_write(sai->regmap, reg_cr2, val_cr2); - regmap_write(sai->regmap, reg_cr4, val_cr4); + regmap_update_bits(sai->regmap, FSL_SAI_xCR2(tx), + FSL_SAI_CR2_BCP | FSL_SAI_CR2_BCD_MSTR, val_cr2); + regmap_update_bits(sai->regmap, FSL_SAI_xCR4(tx), + FSL_SAI_CR4_MF | FSL_SAI_CR4_FSE | + FSL_SAI_CR4_FSP | FSL_SAI_CR4_FSD_MSTR, val_cr4); return 0; } @@ -316,29 +293,10 @@ static int fsl_sai_hw_params(struct snd_pcm_substream *substream, struct snd_soc_dai *cpu_dai) { struct fsl_sai *sai = snd_soc_dai_get_drvdata(cpu_dai); - u32 val_cr4, val_cr5, val_mr, reg_cr4, reg_cr5, reg_mr; + bool tx = substream->stream == SNDRV_PCM_STREAM_PLAYBACK; unsigned int channels = params_channels(params); u32 word_width = snd_pcm_format_width(params_format(params)); - - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { - reg_cr4 = FSL_SAI_TCR4; - reg_cr5 = FSL_SAI_TCR5; - reg_mr = FSL_SAI_TMR; - } else { - reg_cr4 = FSL_SAI_RCR4; - reg_cr5 = FSL_SAI_RCR5; - reg_mr = FSL_SAI_RMR; - } - - regmap_read(sai->regmap, reg_cr4, &val_cr4); - regmap_read(sai->regmap, reg_cr4, &val_cr5); - - val_cr4 &= ~FSL_SAI_CR4_SYWD_MASK; - val_cr4 &= ~FSL_SAI_CR4_FRSZ_MASK; - - val_cr5 &= ~FSL_SAI_CR5_WNW_MASK; - val_cr5 &= ~FSL_SAI_CR5_W0W_MASK; - val_cr5 &= ~FSL_SAI_CR5_FBT_MASK; + u32 val_cr4 = 0, val_cr5 = 0; if (!sai->is_dsp_mode) val_cr4 |= FSL_SAI_CR4_SYWD(word_width); @@ -346,18 +304,20 @@ static int fsl_sai_hw_params(struct snd_pcm_substream *substream, val_cr5 |= FSL_SAI_CR5_WNW(word_width); val_cr5 |= FSL_SAI_CR5_W0W(word_width); - val_cr5 &= ~FSL_SAI_CR5_FBT_MASK; if (sai->big_endian_data) val_cr5 |= FSL_SAI_CR5_FBT(0); else val_cr5 |= FSL_SAI_CR5_FBT(word_width - 1); val_cr4 |= FSL_SAI_CR4_FRSZ(channels); - val_mr = ~0UL - ((1 << channels) - 1); - regmap_write(sai->regmap, reg_cr4, val_cr4); - regmap_write(sai->regmap, reg_cr5, val_cr5); - regmap_write(sai->regmap, reg_mr, val_mr); + regmap_update_bits(sai->regmap, FSL_SAI_xCR4(tx), + FSL_SAI_CR4_SYWD_MASK | FSL_SAI_CR4_FRSZ_MASK, + val_cr4); + regmap_update_bits(sai->regmap, FSL_SAI_xCR5(tx), + FSL_SAI_CR5_WNW_MASK | FSL_SAI_CR5_W0W_MASK | + FSL_SAI_CR5_FBT_MASK, val_cr5); + regmap_write(sai->regmap, FSL_SAI_xMR(tx), ~0UL - ((1 << channels) - 1)); return 0; } @@ -428,8 +388,8 @@ static int fsl_sai_startup(struct snd_pcm_substream *substream, struct snd_soc_dai *cpu_dai) { struct fsl_sai *sai = snd_soc_dai_get_drvdata(cpu_dai); + bool tx = substream->stream == SNDRV_PCM_STREAM_PLAYBACK; struct device *dev = &sai->pdev->dev; - u32 reg; int ret; ret = clk_prepare_enable(sai->bus_clk); @@ -438,12 +398,7 @@ static int fsl_sai_startup(struct snd_pcm_substream *substream, return ret; } - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) - reg = FSL_SAI_TCR3; - else - reg = FSL_SAI_RCR3; - - regmap_update_bits(sai->regmap, reg, FSL_SAI_CR3_TRCE, + regmap_update_bits(sai->regmap, FSL_SAI_xCR3(tx), FSL_SAI_CR3_TRCE, FSL_SAI_CR3_TRCE); return 0; @@ -453,15 +408,9 @@ static void fsl_sai_shutdown(struct snd_pcm_substream *substream, struct snd_soc_dai *cpu_dai) { struct fsl_sai *sai = snd_soc_dai_get_drvdata(cpu_dai); - u32 reg; - - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) - reg = FSL_SAI_TCR3; - else - reg = FSL_SAI_RCR3; + bool tx = substream->stream == SNDRV_PCM_STREAM_PLAYBACK; - regmap_update_bits(sai->regmap, reg, FSL_SAI_CR3_TRCE, - ~FSL_SAI_CR3_TRCE); + regmap_update_bits(sai->regmap, FSL_SAI_xCR3(tx), FSL_SAI_CR3_TRCE, 0); clk_disable_unprepare(sai->bus_clk); } -- cgit v1.2.3 From 011703835f83626048ab75d4ada9ab8ed269b193 Mon Sep 17 00:00:00 2001 From: Krzysztof Kozlowski Date: Mon, 14 Apr 2014 10:09:06 +0200 Subject: regulator: s2mps11: Move DTS parsing code to separate function Refactor code for parsing DTS to increase a little code readability. The behaviour should not change. Signed-off-by: Krzysztof Kozlowski Signed-off-by: Mark Brown --- drivers/regulator/s2mps11.c | 35 +++++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/drivers/regulator/s2mps11.c b/drivers/regulator/s2mps11.c index e713c162fbd4..3aba0331fb5d 100644 --- a/drivers/regulator/s2mps11.c +++ b/drivers/regulator/s2mps11.c @@ -565,12 +565,28 @@ static const struct regulator_desc s2mps14_regulators[] = { regulator_desc_s2mps14_buck1235(5), }; +static int s2mps11_pmic_dt_parse(struct platform_device *pdev, + struct of_regulator_match *rdata, struct s2mps11_info *s2mps11) +{ + struct device_node *reg_np; + + reg_np = of_get_child_by_name(pdev->dev.parent->of_node, "regulators"); + if (!reg_np) { + dev_err(&pdev->dev, "could not find regulators sub-node\n"); + return -EINVAL; + } + + of_regulator_match(&pdev->dev, reg_np, rdata, s2mps11->rdev_num); + of_node_put(reg_np); + + return 0; +} + static int s2mps11_pmic_probe(struct platform_device *pdev) { struct sec_pmic_dev *iodev = dev_get_drvdata(pdev->dev.parent); - struct sec_platform_data *pdata = iodev->pdata; + struct sec_platform_data *pdata = NULL; struct of_regulator_match *rdata = NULL; - struct device_node *reg_np = NULL; struct regulator_config config = { }; struct s2mps11_info *s2mps11; int i, ret = 0; @@ -598,7 +614,8 @@ static int s2mps11_pmic_probe(struct platform_device *pdev) }; if (!iodev->dev->of_node) { - if (pdata) { + if (iodev->pdata) { + pdata = iodev->pdata; goto common_reg; } else { dev_err(pdev->dev.parent, @@ -614,15 +631,9 @@ static int s2mps11_pmic_probe(struct platform_device *pdev) for (i = 0; i < s2mps11->rdev_num; i++) rdata[i].name = regulators[i].name; - reg_np = of_get_child_by_name(iodev->dev->of_node, "regulators"); - if (!reg_np) { - dev_err(&pdev->dev, "could not find regulators sub-node\n"); - ret = -EINVAL; + ret = s2mps11_pmic_dt_parse(pdev, rdata, s2mps11); + if (ret) goto out; - } - - of_regulator_match(&pdev->dev, reg_np, rdata, s2mps11->rdev_num); - of_node_put(reg_np); common_reg: platform_set_drvdata(pdev, s2mps11); @@ -633,7 +644,7 @@ common_reg: for (i = 0; i < s2mps11->rdev_num; i++) { struct regulator_dev *regulator; - if (!reg_np) { + if (pdata) { config.init_data = pdata->regulators[i].initdata; config.of_node = pdata->regulators[i].reg_node; } else { -- cgit v1.2.3 From 97f53d710b9f63cbef1c86ee39d9ecfdda6e674c Mon Sep 17 00:00:00 2001 From: Krzysztof Kozlowski Date: Mon, 14 Apr 2014 10:09:07 +0200 Subject: regulator: s2mps11: Add external GPIO control for S2MPS14 Add support for external control over GPIO for LDO10, LDO11 and LDO12 S2MPS14 regulators. External control can be turned on by writing 0x0 to control register which in case of other regulators is used for disabling them. These LDO10-LDO12 regulators can be disabled only by I2C GPIO or PWREN pin so the patch actually allows proper way of disabling them. Additionally the GPIO control has two benefits: - It is faster than toggling it over I2C bus. - It allows disabling the regulator during suspend to RAM; The AP will enable it during resume. Signed-off-by: Krzysztof Kozlowski Signed-off-by: Mark Brown --- drivers/regulator/s2mps11.c | 67 +++++++++++++++++++++++++++++++++++-- include/linux/mfd/samsung/s2mps14.h | 2 ++ 2 files changed, 67 insertions(+), 2 deletions(-) diff --git a/drivers/regulator/s2mps11.c b/drivers/regulator/s2mps11.c index 3aba0331fb5d..6dad0aa74a47 100644 --- a/drivers/regulator/s2mps11.c +++ b/drivers/regulator/s2mps11.c @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -44,6 +45,8 @@ struct s2mps11_info { * was enabled. */ unsigned int s2mps14_suspend_state:30; + /* Array of size rdev_num with GPIO-s for external sleep control */ + int *ext_control_gpio; }; static int get_ramp_delay(int ramp_delay) @@ -409,6 +412,8 @@ static int s2mps14_regulator_enable(struct regulator_dev *rdev) if (s2mps11->s2mps14_suspend_state & (1 << rdev_get_id(rdev))) val = S2MPS14_ENABLE_SUSPEND; + else if (s2mps11->ext_control_gpio[rdev_get_id(rdev)]) + val = S2MPS14_ENABLE_EXT_CONTROL; else val = rdev->desc->enable_mask; @@ -565,8 +570,40 @@ static const struct regulator_desc s2mps14_regulators[] = { regulator_desc_s2mps14_buck1235(5), }; -static int s2mps11_pmic_dt_parse(struct platform_device *pdev, +static int s2mps14_pmic_enable_ext_control(struct s2mps11_info *s2mps11, + struct regulator_dev *rdev) +{ + return regmap_update_bits(rdev->regmap, rdev->desc->enable_reg, + rdev->desc->enable_mask, S2MPS14_ENABLE_EXT_CONTROL); +} + +static void s2mps14_pmic_dt_parse_ext_control_gpio(struct platform_device *pdev, struct of_regulator_match *rdata, struct s2mps11_info *s2mps11) +{ + int *gpio = s2mps11->ext_control_gpio; + unsigned int i; + unsigned int valid_regulators[3] = { S2MPS14_LDO10, S2MPS14_LDO11, + S2MPS14_LDO12 }; + + for (i = 0; i < ARRAY_SIZE(valid_regulators); i++) { + unsigned int reg = valid_regulators[i]; + + if (!rdata[reg].init_data || !rdata[reg].of_node) + continue; + + gpio[reg] = of_get_named_gpio(rdata[reg].of_node, + "samsung,ext-control-gpios", 0); + if (!gpio_is_valid(gpio[reg])) + gpio[reg] = 0; + else + dev_dbg(&pdev->dev, "Using GPIO %d for ext-control over %d/%s\n", + gpio[reg], reg, rdata[reg].name); + } +} + +static int s2mps11_pmic_dt_parse(struct platform_device *pdev, + struct of_regulator_match *rdata, struct s2mps11_info *s2mps11, + enum sec_device_type dev_type) { struct device_node *reg_np; @@ -577,6 +614,9 @@ static int s2mps11_pmic_dt_parse(struct platform_device *pdev, } of_regulator_match(&pdev->dev, reg_np, rdata, s2mps11->rdev_num); + if (dev_type == S2MPS14X) + s2mps14_pmic_dt_parse_ext_control_gpio(pdev, rdata, s2mps11); + of_node_put(reg_np); return 0; @@ -613,6 +653,12 @@ static int s2mps11_pmic_probe(struct platform_device *pdev) return -EINVAL; }; + s2mps11->ext_control_gpio = devm_kzalloc(&pdev->dev, + sizeof(*s2mps11->ext_control_gpio) * s2mps11->rdev_num, + GFP_KERNEL); + if (!s2mps11->ext_control_gpio) + return -ENOMEM; + if (!iodev->dev->of_node) { if (iodev->pdata) { pdata = iodev->pdata; @@ -631,7 +677,7 @@ static int s2mps11_pmic_probe(struct platform_device *pdev) for (i = 0; i < s2mps11->rdev_num; i++) rdata[i].name = regulators[i].name; - ret = s2mps11_pmic_dt_parse(pdev, rdata, s2mps11); + ret = s2mps11_pmic_dt_parse(pdev, rdata, s2mps11, dev_type); if (ret) goto out; @@ -652,6 +698,12 @@ common_reg: config.of_node = rdata[i].of_node; } + if (s2mps11->ext_control_gpio[i]) { + config.ena_gpio = s2mps11->ext_control_gpio[i]; + config.ena_gpio_flags = GPIOF_OUT_INIT_HIGH; + } else + config.ena_gpio = config.ena_gpio_flags = 0; + regulator = devm_regulator_register(&pdev->dev, ®ulators[i], &config); if (IS_ERR(regulator)) { @@ -660,6 +712,17 @@ common_reg: i); goto out; } + + if (s2mps11->ext_control_gpio[i]) { + ret = s2mps14_pmic_enable_ext_control(s2mps11, + regulator); + if (ret < 0) { + dev_err(&pdev->dev, + "failed to enable GPIO control over %s: %d\n", + regulator->desc->name, ret); + goto out; + } + } } out: diff --git a/include/linux/mfd/samsung/s2mps14.h b/include/linux/mfd/samsung/s2mps14.h index 4b449b8ac548..900cd7a04314 100644 --- a/include/linux/mfd/samsung/s2mps14.h +++ b/include/linux/mfd/samsung/s2mps14.h @@ -148,6 +148,8 @@ enum s2mps14_regulators { #define S2MPS14_ENABLE_SHIFT 6 /* On/Off controlled by PWREN */ #define S2MPS14_ENABLE_SUSPEND (0x01 << S2MPS14_ENABLE_SHIFT) +/* On/Off controlled by LDO10EN or EMMCEN */ +#define S2MPS14_ENABLE_EXT_CONTROL (0x00 << S2MPS14_ENABLE_SHIFT) #define S2MPS14_LDO_N_VOLTAGES (S2MPS14_LDO_VSEL_MASK + 1) #define S2MPS14_BUCK_N_VOLTAGES (S2MPS14_BUCK_VSEL_MASK + 1) -- cgit v1.2.3 From 9b63cfbfd13b609e8d496852b6714ac686e31901 Mon Sep 17 00:00:00 2001 From: Krzysztof Kozlowski Date: Mon, 14 Apr 2014 10:09:08 +0200 Subject: regulator: s2mps11: Document external GPIO control Add documentation for new property for controlling (enable/disable) some of the S2MPS14 regulators by GPIO. Signed-off-by: Krzysztof Kozlowski Signed-off-by: Mark Brown --- Documentation/devicetree/bindings/mfd/s2mps11.txt | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Documentation/devicetree/bindings/mfd/s2mps11.txt b/Documentation/devicetree/bindings/mfd/s2mps11.txt index 802e839b0829..d81ba30c0d8b 100644 --- a/Documentation/devicetree/bindings/mfd/s2mps11.txt +++ b/Documentation/devicetree/bindings/mfd/s2mps11.txt @@ -56,6 +56,20 @@ for a particular group of BUCKs. So provide same regulator-ramp-delay. Grouping of BUCKs sharing ramp rate setting is as follow : BUCK[1, 6], BUCK[3, 4], and BUCK[7, 8, 10] +On S2MPS14 the LDO10, LDO11 and LDO12 can be configured to external control +over GPIO. To turn this feature on this property must be added to the regulator +sub-node: + - samsung,ext-control-gpios: GPIO specifier for one GPIO + controlling this regulator (enable/disable); +Example: + LDO12 { + regulator-name = "V_EMMC_2.8V"; + regulator-min-microvolt = <2800000>; + regulator-max-microvolt = <2800000>; + samsung,ext-control-gpios = <&gpk0 2 0>; + }; + + The regulator constraints inside the regulator nodes use the standard regulator bindings which are documented elsewhere. -- cgit v1.2.3 From 9ada07b1100a9c7d3107c47673664194574b02a0 Mon Sep 17 00:00:00 2001 From: Alexander Gordeev Date: Thu, 6 Mar 2014 21:11:22 +0100 Subject: PCI/portdrv: Use pci_enable_msix_exact() instead of pci_enable_msix() As result of deprecation of MSI-X/MSI enablement functions pci_enable_msix() and pci_enable_msi_block() all drivers using these two interfaces need to be updated to use the new pci_enable_msi_range() or pci_enable_msi_exact() and pci_enable_msix_range() or pci_enable_msix_exact() interfaces. Signed-off-by: Alexander Gordeev Signed-off-by: Bjorn Helgaas --- drivers/pci/pcie/portdrv_core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/pci/pcie/portdrv_core.c b/drivers/pci/pcie/portdrv_core.c index 986f8eadfd39..0b1efb2760d1 100644 --- a/drivers/pci/pcie/portdrv_core.c +++ b/drivers/pci/pcie/portdrv_core.c @@ -99,7 +99,7 @@ static int pcie_port_enable_msix(struct pci_dev *dev, int *vectors, int mask) for (i = 0; i < nr_entries; i++) msix_entries[i].entry = i; - status = pci_enable_msix(dev, msix_entries, nr_entries); + status = pci_enable_msix_exact(dev, msix_entries, nr_entries); if (status) goto Exit; @@ -171,7 +171,7 @@ static int pcie_port_enable_msix(struct pci_dev *dev, int *vectors, int mask) pci_disable_msix(dev); /* Now allocate the MSI-X vectors for real */ - status = pci_enable_msix(dev, msix_entries, nvec); + status = pci_enable_msix_exact(dev, msix_entries, nvec); if (status) goto Exit; } -- cgit v1.2.3 From 1406276c1254d761da7c16b30aa32e3af2b3612a Mon Sep 17 00:00:00 2001 From: Jan Beulich Date: Mon, 14 Apr 2014 14:59:50 -0600 Subject: PCI/MSI: Simplify populate_msi_sysfs() Simplify populate_msi_sysfs() by - Swapping the order of the two allocations and storing the msi_dev_attr-derived pointer right after allocation, allowing the cleanup code to pick things up without extra effort. - Using kasprintf() instead of the kmalloc()/sprintf() pair. Signed-off-by: Jan Beulich Signed-off-by: Bjorn Helgaas Acked-by: Greg Kroah-Hartman --- drivers/pci/msi.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c index 955ab7990c5b..04130c3f9cf6 100644 --- a/drivers/pci/msi.c +++ b/drivers/pci/msi.c @@ -544,22 +544,18 @@ static int populate_msi_sysfs(struct pci_dev *pdev) if (!msi_attrs) return -ENOMEM; list_for_each_entry(entry, &pdev->msi_list, list) { - char *name = kmalloc(20, GFP_KERNEL); - if (!name) - goto error_attrs; - msi_dev_attr = kzalloc(sizeof(*msi_dev_attr), GFP_KERNEL); - if (!msi_dev_attr) { - kfree(name); + if (!msi_dev_attr) goto error_attrs; - } + msi_attrs[count] = &msi_dev_attr->attr; - sprintf(name, "%d", entry->irq); sysfs_attr_init(&msi_dev_attr->attr); - msi_dev_attr->attr.name = name; + msi_dev_attr->attr.name = kasprintf(GFP_KERNEL, "%d", + entry->irq); + if (!msi_dev_attr->attr.name) + goto error_attrs; msi_dev_attr->attr.mode = S_IRUGO; msi_dev_attr->show = msi_mode_show; - msi_attrs[count] = &msi_dev_attr->attr; ++count; } -- cgit v1.2.3 From 8e56aed0b0579b667489bcb1d94c223726f0eaa1 Mon Sep 17 00:00:00 2001 From: Bjorn Helgaas Date: Mon, 14 Apr 2014 16:04:55 -0600 Subject: PCI: hotplug: Remove unnecessary "dev->bus" test Every pci_dev is on a valid pci_bus, so we don't need to test whether dev->bus is NULL or not. The only exceptions are a few legacy cases like alpha_core_agp_setup(), parisc_agp_setup(), and megaraid's make_local_pdev(), where we allocate a pci_dev with a NULL bus pointer. These are dubious uses (especially the megaraid one), and I don't think it's possible to exercise this pci_configure_slot() path with any of them. Found by Coverity (CID 146446). Signed-off-by: Bjorn Helgaas --- drivers/pci/hotplug/pcihp_slot.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/pci/hotplug/pcihp_slot.c b/drivers/pci/hotplug/pcihp_slot.c index 16f920352317..e246a10a0d2c 100644 --- a/drivers/pci/hotplug/pcihp_slot.c +++ b/drivers/pci/hotplug/pcihp_slot.c @@ -160,8 +160,7 @@ void pci_configure_slot(struct pci_dev *dev) (dev->class >> 8) == PCI_CLASS_BRIDGE_PCI))) return; - if (dev->bus) - pcie_bus_configure_settings(dev->bus); + pcie_bus_configure_settings(dev->bus); memset(&hpp, 0, sizeof(hpp)); ret = pci_get_hp_params(dev, &hpp); -- cgit v1.2.3 From 17f830bb83ff64533f02cfd4b114d4a5957c2ee7 Mon Sep 17 00:00:00 2001 From: Bjorn Helgaas Date: Sat, 5 Apr 2014 15:05:07 -0600 Subject: PCI: pciehp: Use PCI_EXP_SLTCAP_PSN define Use PCI_EXP_SLTCAP_PSN to make it easier to find code that uses the Physical Slot Number field in the PCIe Slot Capabilities register. No functional change. Signed-off-by: Bjorn Helgaas --- drivers/pci/hotplug/pciehp.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/pci/hotplug/pciehp.h b/drivers/pci/hotplug/pciehp.h index 8a66866b8cf1..8e9012dca450 100644 --- a/drivers/pci/hotplug/pciehp.h +++ b/drivers/pci/hotplug/pciehp.h @@ -127,7 +127,7 @@ struct controller { #define HP_SUPR_RM(ctrl) ((ctrl)->slot_cap & PCI_EXP_SLTCAP_HPS) #define EMI(ctrl) ((ctrl)->slot_cap & PCI_EXP_SLTCAP_EIP) #define NO_CMD_CMPL(ctrl) ((ctrl)->slot_cap & PCI_EXP_SLTCAP_NCCS) -#define PSN(ctrl) ((ctrl)->slot_cap >> 19) +#define PSN(ctrl) (((ctrl)->slot_cap & PCI_EXP_SLTCAP_PSN) >> 19) int pciehp_sysfs_enable_slot(struct slot *slot); int pciehp_sysfs_disable_slot(struct slot *slot); -- cgit v1.2.3 From ff0c41b2df1577f3354f788af4f6bb5dbdfd26da Mon Sep 17 00:00:00 2001 From: Mike Qiu Date: Mon, 14 Apr 2014 16:12:35 -0600 Subject: powerpc/PCI: Fix NULL dereference in sys_pciconfig_iobase() list traversal 3bc955987fb3 ("powerpc/PCI: Use list_for_each_entry() for bus traversal") caused a NULL pointer dereference because the loop body set the iterator to NULL: Unable to handle kernel paging request for data at address 0x00000000 Faulting instruction address: 0xc000000000041d78 Oops: Kernel access of bad area, sig: 11 [#1] ... NIP [c000000000041d78] .sys_pciconfig_iobase+0x68/0x1f0 LR [c000000000041e0c] .sys_pciconfig_iobase+0xfc/0x1f0 Call Trace: [c0000003b4787db0] [c000000000041e0c] .sys_pciconfig_iobase+0xfc/0x1f0 (unreliable) [c0000003b4787e30] [c000000000009ed8] syscall_exit+0x0/0x98 Fix it by using a temporary variable for the iterator. [bhelgaas: changelog, drop tmp_bus initialization] Fixes: 3bc955987fb3 powerpc/PCI: Use list_for_each_entry() for bus traversal Signed-off-by: Mike Qiu Signed-off-by: Bjorn Helgaas --- arch/powerpc/kernel/pci_64.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/arch/powerpc/kernel/pci_64.c b/arch/powerpc/kernel/pci_64.c index 2a4779091a58..155013da27e0 100644 --- a/arch/powerpc/kernel/pci_64.c +++ b/arch/powerpc/kernel/pci_64.c @@ -208,7 +208,7 @@ long sys_pciconfig_iobase(long which, unsigned long in_bus, unsigned long in_devfn) { struct pci_controller* hose; - struct pci_bus *bus = NULL; + struct pci_bus *tmp_bus, *bus = NULL; struct device_node *hose_node; /* Argh ! Please forgive me for that hack, but that's the @@ -229,10 +229,12 @@ long sys_pciconfig_iobase(long which, unsigned long in_bus, * used on pre-domains setup. We return the first match */ - list_for_each_entry(bus, &pci_root_buses, node) { - if (in_bus >= bus->number && in_bus <= bus->busn_res.end) + list_for_each_entry(tmp_bus, &pci_root_buses, node) { + if (in_bus >= tmp_bus->number && + in_bus <= tmp_bus->busn_res.end) { + bus = tmp_bus; break; - bus = NULL; + } } if (bus == NULL || bus->dev.of_node == NULL) return -ENODEV; -- cgit v1.2.3 From 56a3d18279f00c7ccbcdc193ceaf1a2f88c51457 Mon Sep 17 00:00:00 2001 From: Paul Gortmaker Date: Sat, 5 Apr 2014 15:13:33 -0600 Subject: PCI: Remove unnecessary includes of None of these files are actually using any __init type directives and hence don't need to include . Most are just a left over from __devinit and __cpuinit removal, or simply due to code getting copied from one driver to the next. Signed-off-by: Paul Gortmaker Signed-off-by: Bjorn Helgaas --- drivers/pci/bus.c | 1 - drivers/pci/host-bridge.c | 1 - drivers/pci/hotplug/acpiphp_glue.c | 1 - drivers/pci/hotplug/cpqphp_nvram.c | 1 - drivers/pci/hotplug/s390_pci_hpc.c | 1 - drivers/pci/msi.c | 1 - drivers/pci/search.c | 1 - drivers/pci/setup-irq.c | 1 - drivers/pci/setup-res.c | 1 - 9 files changed, 9 deletions(-) diff --git a/drivers/pci/bus.c b/drivers/pci/bus.c index fb8aed307c28..ba2bf55a38df 100644 --- a/drivers/pci/bus.c +++ b/drivers/pci/bus.c @@ -13,7 +13,6 @@ #include #include #include -#include #include #include "pci.h" diff --git a/drivers/pci/host-bridge.c b/drivers/pci/host-bridge.c index 47aaf22d814e..0e5f3c95af5b 100644 --- a/drivers/pci/host-bridge.c +++ b/drivers/pci/host-bridge.c @@ -3,7 +3,6 @@ */ #include -#include #include #include diff --git a/drivers/pci/hotplug/acpiphp_glue.c b/drivers/pci/hotplug/acpiphp_glue.c index bccc27ee1030..0238a02b4cb3 100644 --- a/drivers/pci/hotplug/acpiphp_glue.c +++ b/drivers/pci/hotplug/acpiphp_glue.c @@ -41,7 +41,6 @@ #define pr_fmt(fmt) "acpiphp_glue: " fmt -#include #include #include diff --git a/drivers/pci/hotplug/cpqphp_nvram.c b/drivers/pci/hotplug/cpqphp_nvram.c index 76ba8a1c774d..9600a392eaae 100644 --- a/drivers/pci/hotplug/cpqphp_nvram.c +++ b/drivers/pci/hotplug/cpqphp_nvram.c @@ -34,7 +34,6 @@ #include #include #include -#include #include #include "cpqphp.h" #include "cpqphp_nvram.h" diff --git a/drivers/pci/hotplug/s390_pci_hpc.c b/drivers/pci/hotplug/s390_pci_hpc.c index 8d2ce22151eb..d1332d2f8730 100644 --- a/drivers/pci/hotplug/s390_pci_hpc.c +++ b/drivers/pci/hotplug/s390_pci_hpc.c @@ -15,7 +15,6 @@ #include #include #include -#include #include #include diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c index 955ab7990c5b..aaf8d3243cd6 100644 --- a/drivers/pci/msi.c +++ b/drivers/pci/msi.c @@ -10,7 +10,6 @@ #include #include #include -#include #include #include #include diff --git a/drivers/pci/search.c b/drivers/pci/search.c index 4a1b972efe7f..8e495bda678f 100644 --- a/drivers/pci/search.c +++ b/drivers/pci/search.c @@ -7,7 +7,6 @@ * Copyright (C) 2003 -- 2004 Greg Kroah-Hartman */ -#include #include #include #include diff --git a/drivers/pci/setup-irq.c b/drivers/pci/setup-irq.c index 9bd6864ec5d3..dbc4ffcf42de 100644 --- a/drivers/pci/setup-irq.c +++ b/drivers/pci/setup-irq.c @@ -10,7 +10,6 @@ */ -#include #include #include #include diff --git a/drivers/pci/setup-res.c b/drivers/pci/setup-res.c index 7eed671d5586..1e37c590a183 100644 --- a/drivers/pci/setup-res.c +++ b/drivers/pci/setup-res.c @@ -16,7 +16,6 @@ * Resource sorting */ -#include #include #include #include -- cgit v1.2.3 From 44ae903b96b1e5f9ff3103cd86918619c188003f Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Thu, 20 Mar 2014 15:16:54 +0100 Subject: ARM: 8008/1: topology: Coding style fixes Use kcalloc() and ULONG_MAX rather than open coding them. Signed-off-by: Mark Brown Signed-off-by: Russell King --- arch/arm/kernel/topology.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/arch/arm/kernel/topology.c b/arch/arm/kernel/topology.c index 0bc94b1fd1ae..0fa8825cea04 100644 --- a/arch/arm/kernel/topology.c +++ b/arch/arm/kernel/topology.c @@ -91,13 +91,13 @@ static void __init parse_dt_topology(void) { const struct cpu_efficiency *cpu_eff; struct device_node *cn = NULL; - unsigned long min_capacity = (unsigned long)(-1); + unsigned long min_capacity = ULONG_MAX; unsigned long max_capacity = 0; unsigned long capacity = 0; - int alloc_size, cpu = 0; + int cpu = 0; - alloc_size = nr_cpu_ids * sizeof(*__cpu_capacity); - __cpu_capacity = kzalloc(alloc_size, GFP_NOWAIT); + __cpu_capacity = kcalloc(nr_cpu_ids, sizeof(*__cpu_capacity), + GFP_NOWAIT); for_each_possible_cpu(cpu) { const u32 *rate; -- cgit v1.2.3 From 4d4a0ff30c39b82c1dc549f2cc7a62b514431e64 Mon Sep 17 00:00:00 2001 From: Geert Uytterhoeven Date: Mon, 14 Apr 2014 19:35:57 +0200 Subject: ARM: shmobile: koelsch legacy: Enable Quad SPI transfers for the SPI FLASH Signed-off-by: Geert Uytterhoeven Signed-off-by: Simon Horman --- arch/arm/mach-shmobile/board-koelsch.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm/mach-shmobile/board-koelsch.c b/arch/arm/mach-shmobile/board-koelsch.c index 5a034ff405d0..a12a9d3b4b6e 100644 --- a/arch/arm/mach-shmobile/board-koelsch.c +++ b/arch/arm/mach-shmobile/board-koelsch.c @@ -216,7 +216,7 @@ static const struct spi_board_info spi_info[] __initconst = { { .modalias = "m25p80", .platform_data = &spi_flash_data, - .mode = SPI_MODE_0, + .mode = SPI_MODE_0 | SPI_TX_QUAD | SPI_RX_QUAD, .max_speed_hz = 30000000, .bus_num = 0, .chip_select = 0, -- cgit v1.2.3 From ed56083acfe7c872318b8321c7d0e25a6b520371 Mon Sep 17 00:00:00 2001 From: Geert Uytterhoeven Date: Mon, 14 Apr 2014 19:35:58 +0200 Subject: ARM: shmobile: koelsch dts: Enable Quad SPI transfers for the SPI FLASH Signed-off-by: Geert Uytterhoeven Signed-off-by: Simon Horman --- arch/arm/boot/dts/r8a7791-koelsch.dts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/arm/boot/dts/r8a7791-koelsch.dts b/arch/arm/boot/dts/r8a7791-koelsch.dts index 2a0569d93b6e..22edf3efe4c8 100644 --- a/arch/arm/boot/dts/r8a7791-koelsch.dts +++ b/arch/arm/boot/dts/r8a7791-koelsch.dts @@ -354,6 +354,8 @@ compatible = "spansion,s25fl512s"; reg = <0>; spi-max-frequency = <30000000>; + spi-tx-bus-width = <4>; + spi-rx-bus-width = <4>; m25p,fast-read; partition@0 { -- cgit v1.2.3 From 9909d2cb41a9c752cbbef5d9fb57d80a7196e951 Mon Sep 17 00:00:00 2001 From: Geert Uytterhoeven Date: Mon, 14 Apr 2014 19:36:00 +0200 Subject: ARM: shmobile: lager dts: Enable Quad SPI transfers for the SPI FLASH Signed-off-by: Geert Uytterhoeven Acked-by: Magnus Damm Signed-off-by: Simon Horman --- arch/arm/boot/dts/r8a7790-lager.dts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/arm/boot/dts/r8a7790-lager.dts b/arch/arm/boot/dts/r8a7790-lager.dts index 265cba1d53dc..d350d7c6e9f5 100644 --- a/arch/arm/boot/dts/r8a7790-lager.dts +++ b/arch/arm/boot/dts/r8a7790-lager.dts @@ -243,6 +243,8 @@ compatible = "spansion,s25fl512s"; reg = <0>; spi-max-frequency = <30000000>; + spi-tx-bus-width = <4>; + spi-rx-bus-width = <4>; m25p,fast-read; partition@0 { -- cgit v1.2.3 From a09b2f0ba170dc89a67d6c4c4f027b37a085dad9 Mon Sep 17 00:00:00 2001 From: Geert Uytterhoeven Date: Mon, 14 Apr 2014 19:35:59 +0200 Subject: ARM: shmobile: lager legacy: Enable Quad SPI transfers for the SPI FLASH Signed-off-by: Geert Uytterhoeven Acked-by: Magnus Damm Signed-off-by: Simon Horman --- arch/arm/mach-shmobile/board-lager.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/arch/arm/mach-shmobile/board-lager.c b/arch/arm/mach-shmobile/board-lager.c index 6af09e1e0841..6c4fcfe5d9db 100644 --- a/arch/arm/mach-shmobile/board-lager.c +++ b/arch/arm/mach-shmobile/board-lager.c @@ -325,12 +325,12 @@ static const struct rspi_plat_data qspi_pdata __initconst = { static const struct spi_board_info spi_info[] __initconst = { { - .modalias = "m25p80", - .platform_data = &spi_flash_data, - .mode = SPI_MODE_0, - .max_speed_hz = 30000000, - .bus_num = 0, - .chip_select = 0, + .modalias = "m25p80", + .platform_data = &spi_flash_data, + .mode = SPI_MODE_0 | SPI_TX_QUAD | SPI_RX_QUAD, + .max_speed_hz = 30000000, + .bus_num = 0, + .chip_select = 0, }, }; -- cgit v1.2.3 From 1a30fd0dba778f7ef1a6254989060a141fca8e23 Mon Sep 17 00:00:00 2001 From: Alex Williamson Date: Mon, 31 Mar 2014 12:21:38 -0600 Subject: PCI: Add Patsburg (X79) to Intel PCH root port ACS quirk Intel has updated Red Hat bz1037684 to note that X79 PCH root ports also provide isolation and the same ACS quirks apply. Some sources indicate additional device IDs for X79, but this patch includes only the ones specifically identified by Intel: https://bugzilla.redhat.com/show_bug.cgi?id=1037684#c11 Signed-off-by: Alex Williamson Signed-off-by: Bjorn Helgaas Acked-by: Don Dugger --- drivers/pci/quirks.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c index e7292065a1b1..5e4ac635368f 100644 --- a/drivers/pci/quirks.c +++ b/drivers/pci/quirks.c @@ -3453,6 +3453,8 @@ static const u16 pci_quirk_intel_pch_acs_ids[] = { /* Wildcat PCH */ 0x9c90, 0x9c91, 0x9c92, 0x9c93, 0x9c94, 0x9c95, 0x9c96, 0x9c97, 0x9c98, 0x9c99, 0x9c9a, 0x9c9b, + /* Patsburg (X79) PCH */ + 0x1d10, 0x1d12, 0x1d14, 0x1d16, 0x1d18, 0x1d1a, 0x1d1c, 0x1d1e, }; static bool pci_quirk_intel_pch_acs_match(struct pci_dev *dev) -- cgit v1.2.3 From 2023d18e6b38c5490df0cd6f17a8e0f2ec6dae0f Mon Sep 17 00:00:00 2001 From: Mark Hounschell Date: Mon, 14 Apr 2014 16:42:43 -0400 Subject: staging: dgap: remove uchar typedef and replace use with u8 This patch removes the uchar typedef in dgap.h and changes all uses of it to u8. Signed-off-by: Mark Hounschell Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgap/dgap.c | 100 ++++++++++++++++++++++---------------------- drivers/staging/dgap/dgap.h | 65 ++++++++++++++-------------- 2 files changed, 81 insertions(+), 84 deletions(-) diff --git a/drivers/staging/dgap/dgap.c b/drivers/staging/dgap/dgap.c index 34693dc5d8c4..3c9278a224e2 100644 --- a/drivers/staging/dgap/dgap.c +++ b/drivers/staging/dgap/dgap.c @@ -135,9 +135,9 @@ static void dgap_cmdw_ext(struct channel_t *ch, u16 cmd, u16 word, uint ncmds); static int dgap_event(struct board_t *bd); static void dgap_poll_tasklet(unsigned long data); -static void dgap_cmdb(struct channel_t *ch, uchar cmd, uchar byte1, - uchar byte2, uint ncmds); -static void dgap_cmdw(struct channel_t *ch, uchar cmd, u16 word, uint ncmds); +static void dgap_cmdb(struct channel_t *ch, u8 cmd, u8 byte1, + u8 byte2, uint ncmds); +static void dgap_cmdw(struct channel_t *ch, u8 cmd, u16 word, uint ncmds); static void dgap_wmove(struct channel_t *ch, char *buf, uint cnt); static int dgap_param(struct tty_struct *tty); static void dgap_parity_scan(struct channel_t *ch, unsigned char *cbuf, @@ -184,10 +184,10 @@ static uint dgap_config_get_useintr(struct board_t *bd); static uint dgap_config_get_altpin(struct board_t *bd); static int dgap_ms_sleep(ulong ms); -static void dgap_do_bios_load(struct board_t *brd, const uchar *ubios, int len); -static void dgap_do_fep_load(struct board_t *brd, const uchar *ufep, int len); +static void dgap_do_bios_load(struct board_t *brd, const u8 *ubios, int len); +static void dgap_do_fep_load(struct board_t *brd, const u8 *ufep, int len); #ifdef DIGI_CONCENTRATORS_SUPPORTED -static void dgap_do_conc_load(struct board_t *brd, uchar *uaddr, int len); +static void dgap_do_conc_load(struct board_t *brd, u8 *uaddr, int len); #endif static int dgap_after_config_loaded(int board); static int dgap_finalize_board_init(struct board_t *brd); @@ -275,7 +275,7 @@ MODULE_DEVICE_TABLE(pci, dgap_pci_tbl); */ struct board_id { uint config_type; - uchar *name; + u8 *name; uint maxports; uint dpatype; }; @@ -307,10 +307,10 @@ static struct pci_driver dgap_driver = { }; struct firmware_info { - uchar *conf_name; /* dgap.conf */ - uchar *bios_name; /* BIOS filename */ - uchar *fep_name; /* FEP filename */ - uchar *con_name; /* Concentrator filename FIXME*/ + u8 *conf_name; /* dgap.conf */ + u8 *bios_name; /* BIOS filename */ + u8 *fep_name; /* FEP filename */ + u8 *con_name; /* Concentrator filename FIXME*/ int num; /* sequence number */ }; @@ -1293,8 +1293,8 @@ static int dgap_tty_init(struct board_t *brd) int i; int tlw; uint true_count = 0; - uchar *vaddr; - uchar modem = 0; + u8 *vaddr; + u8 modem = 0; struct channel_t *ch; struct bs_t *bs; struct cm_t *cm; @@ -1505,8 +1505,8 @@ static void dgap_tty_uninit(struct board_t *brd) * dgap_sniff - Dump data out to the "sniff" buffer if the * proc sniff file is opened... */ -static void dgap_sniff_nowait_nolock(struct channel_t *ch, uchar *text, - uchar *buf, int len) +static void dgap_sniff_nowait_nolock(struct channel_t *ch, u8 *text, + u8 *buf, int len) { struct timeval tv; int n; @@ -1640,8 +1640,8 @@ static void dgap_input(struct channel_t *ch) int flip_len; int len = 0; int n = 0; - uchar *buf; - uchar tmpchar; + u8 *buf; + u8 tmpchar; int s = 0; if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) @@ -2410,7 +2410,7 @@ static int dgap_tty_chars_in_buffer(struct tty_struct *tty) struct channel_t *ch = NULL; struct un_t *un = NULL; struct bs_t *bs = NULL; - uchar tbusy; + u8 tbusy; uint chars = 0; u16 thead, ttail, tmask, chead, ctail; ulong lock_flags = 0; @@ -2843,8 +2843,8 @@ static int dgap_tty_write(struct tty_struct *tty, const unsigned char *buf, n -= remain; vaddr = ch->ch_taddr + head; - memcpy_toio(vaddr, (uchar *) buf, remain); - dgap_sniff_nowait_nolock(ch, "USER WRITE", (uchar *) buf, + memcpy_toio(vaddr, (u8 *) buf, remain); + dgap_sniff_nowait_nolock(ch, "USER WRITE", (u8 *) buf, remain); head = ch->ch_tstart; @@ -2859,8 +2859,8 @@ static int dgap_tty_write(struct tty_struct *tty, const unsigned char *buf, vaddr = ch->ch_taddr + head; remain = n; - memcpy_toio(vaddr, (uchar *) buf, remain); - dgap_sniff_nowait_nolock(ch, "USER WRITE", (uchar *)buf, + memcpy_toio(vaddr, (u8 *) buf, remain); + dgap_sniff_nowait_nolock(ch, "USER WRITE", (u8 *)buf, remain); head += remain; @@ -2915,7 +2915,7 @@ static int dgap_tty_tiocmget(struct tty_struct *tty) struct channel_t *ch; struct un_t *un; int result = -EIO; - uchar mstat = 0; + u8 mstat = 0; ulong lock_flags; if (!tty || tty->magic != TTY_MAGIC) @@ -3141,7 +3141,7 @@ static void dgap_tty_send_xchar(struct tty_struct *tty, char c) static int dgap_get_modem_info(struct channel_t *ch, unsigned int __user *value) { int result = 0; - uchar mstat = 0; + u8 mstat = 0; ulong lock_flags; int rc = 0; @@ -4301,9 +4301,9 @@ static int dgap_tty_register_ports(struct board_t *brd) * Copies the BIOS code from the user to the board, * and starts the BIOS running. */ -static void dgap_do_bios_load(struct board_t *brd, const uchar *ubios, int len) +static void dgap_do_bios_load(struct board_t *brd, const u8 *ubios, int len) { - uchar *addr; + u8 *addr; uint offset; int i; @@ -4336,7 +4336,7 @@ static void dgap_do_bios_load(struct board_t *brd, const uchar *ubios, int len) */ static int dgap_test_bios(struct board_t *brd) { - uchar *addr; + u8 *addr; u16 word; u16 err1; u16 err2; @@ -4377,9 +4377,9 @@ static int dgap_test_bios(struct board_t *brd) * Copies the FEP code from the user to the board, * and starts the FEP running. */ -static void dgap_do_fep_load(struct board_t *brd, const uchar *ufep, int len) +static void dgap_do_fep_load(struct board_t *brd, const u8 *ufep, int len) { - uchar *addr; + u8 *addr; uint offset; if (!brd || (brd->magic != DGAP_BOARD_MAGIC) || !brd->re_map_membase) @@ -4398,8 +4398,8 @@ static void dgap_do_fep_load(struct board_t *brd, const uchar *ufep, int len) * it its config string describing how the concentrators look. */ if ((brd->type == PCX) || (brd->type == PEPC)) { - uchar string[100]; - uchar *config, *xconfig; + u8 string[100]; + u8 *config, *xconfig; int i = 0; xconfig = dgap_create_config_string(brd, string); @@ -4423,7 +4423,7 @@ static void dgap_do_fep_load(struct board_t *brd, const uchar *ufep, int len) */ static int dgap_test_fep(struct board_t *brd) { - uchar *addr; + u8 *addr; u16 word; u16 err1; u16 err2; @@ -4472,7 +4472,7 @@ static int dgap_test_fep(struct board_t *brd) */ static void dgap_do_reset_board(struct board_t *brd) { - uchar check; + u8 check; u32 check1; u32 check2; int i = 0; @@ -4520,7 +4520,7 @@ static void dgap_do_reset_board(struct board_t *brd) /* * Sends a concentrator image into the FEP5 board. */ -static void dgap_do_conc_load(struct board_t *brd, uchar *uaddr, int len) +static void dgap_do_conc_load(struct board_t *brd, u8 *uaddr, int len) { char *vaddr; u16 offset = 0; @@ -4553,8 +4553,8 @@ static void dgap_get_vpd(struct board_t *brd) u16 vpd_offset; u16 image_length; u16 i; - uchar byte1; - uchar byte2; + u8 byte1; + u8 byte2; /* * Poke the magic number at the PCI Rom Address location. @@ -4733,8 +4733,8 @@ out: * in the cmd buffer before returning. * *=======================================================================*/ -static void dgap_cmdb(struct channel_t *ch, uchar cmd, uchar byte1, - uchar byte2, uint ncmds) +static void dgap_cmdb(struct channel_t *ch, u8 cmd, u8 byte1, + u8 byte2, uint ncmds) { char *vaddr = NULL; struct cm_t *cm_addr = NULL; @@ -4776,7 +4776,7 @@ static void dgap_cmdb(struct channel_t *ch, uchar cmd, uchar byte1, * Put the data in the circular command buffer. */ writeb(cmd, (char *) (vaddr + head + CMDSTART + 0)); - writeb((uchar) ch->ch_portnum, (char *) (vaddr + head + CMDSTART + 1)); + writeb((u8) ch->ch_portnum, (char *) (vaddr + head + CMDSTART + 1)); writeb(byte1, (char *) (vaddr + head + CMDSTART + 2)); writeb(byte2, (char *) (vaddr + head + CMDSTART + 3)); @@ -4819,7 +4819,7 @@ static void dgap_cmdb(struct channel_t *ch, uchar cmd, uchar byte1, * in the cmd buffer before returning. * *=======================================================================*/ -static void dgap_cmdw(struct channel_t *ch, uchar cmd, u16 word, uint ncmds) +static void dgap_cmdw(struct channel_t *ch, u8 cmd, u16 word, uint ncmds) { char *vaddr = NULL; struct cm_t *cm_addr = NULL; @@ -4860,7 +4860,7 @@ static void dgap_cmdw(struct channel_t *ch, uchar cmd, u16 word, uint ncmds) * Put the data in the circular command buffer. */ writeb(cmd, (char *) (vaddr + head + CMDSTART + 0)); - writeb((uchar) ch->ch_portnum, (char *) (vaddr + head + CMDSTART + 1)); + writeb((u8) ch->ch_portnum, (char *) (vaddr + head + CMDSTART + 1)); writew((u16) word, (char *) (vaddr + head + CMDSTART + 2)); head = (head + 4) & (CMDMAX - CMDSTART - 4); @@ -4944,9 +4944,9 @@ static void dgap_cmdw_ext(struct channel_t *ch, u16 cmd, u16 word, uint ncmds) */ /* Write an FF to tell the FEP that we want an extended command */ - writeb((uchar) 0xff, (char *) (vaddr + head + CMDSTART + 0)); + writeb((u8) 0xff, (char *) (vaddr + head + CMDSTART + 0)); - writeb((uchar) ch->ch_portnum, (uchar *) (vaddr + head + CMDSTART + 1)); + writeb((u8) ch->ch_portnum, (u8 *) (vaddr + head + CMDSTART + 1)); writew((u16) cmd, (char *) (vaddr + head + CMDSTART + 2)); /* @@ -5051,7 +5051,7 @@ static void dgap_wmove(struct channel_t *ch, char *buf, uint cnt) */ static uint dgap_get_custom_baud(struct channel_t *ch) { - uchar *vaddr; + u8 *vaddr; ulong offset = 0; uint value = 0; @@ -5123,8 +5123,8 @@ static int dgap_param(struct tty_struct *tty) u16 head; u16 cflag; u16 iflag; - uchar mval; - uchar hflow; + u8 mval; + u8 hflow; if (!tty || tty->magic != TTY_MAGIC) return -ENXIO; @@ -5390,7 +5390,7 @@ static int dgap_param(struct tty_struct *tty) ch->ch_hflow = hflow; /* Okay to have channel and board locks held calling this */ - dgap_cmdb(ch, SHFLOW, (uchar) hflow, 0xff, 0); + dgap_cmdb(ch, SHFLOW, (u8) hflow, 0xff, 0); } @@ -5418,7 +5418,7 @@ static int dgap_param(struct tty_struct *tty) ch->ch_mostat = mval; /* Okay to have channel and board locks held calling this */ - dgap_cmdb(ch, SMODEM, (uchar) mval, D_RTS(ch)|D_DTR(ch), 0); + dgap_cmdb(ch, SMODEM, (u8) mval, D_RTS(ch)|D_DTR(ch), 0); } /* @@ -5572,8 +5572,8 @@ static int dgap_event(struct board_t *bd) ulong lock_flags; ulong lock_flags2; struct bs_t *bs; - uchar *event; - uchar *vaddr = NULL; + u8 *event; + u8 *vaddr = NULL; struct ev_t *eaddr = NULL; uint head; uint tail; diff --git a/drivers/staging/dgap/dgap.h b/drivers/staging/dgap/dgap.h index 2fce41c31cf7..b23570bd183d 100644 --- a/drivers/staging/dgap/dgap.h +++ b/drivers/staging/dgap/dgap.h @@ -39,9 +39,6 @@ # define FALSE 0 #endif -/* Required for our shared headers! */ -typedef unsigned char uchar; - #if !defined(TTY_FLIPBUF_SIZE) # define TTY_FLIPBUF_SIZE 512 #endif @@ -541,11 +538,11 @@ struct board_t { u16 device; /* PCI device ID */ u16 subvendor; /* PCI subsystem vendor ID */ u16 subdevice; /* PCI subsystem device ID */ - uchar rev; /* PCI revision ID */ + u8 rev; /* PCI revision ID */ uint pci_bus; /* PCI bus value */ uint pci_slot; /* PCI slot value */ u16 maxports; /* MAX ports this board can handle */ - uchar vpd[VPDSIZE]; /* VPD of board, if found */ + u8 vpd[VPDSIZE]; /* VPD of board, if found */ u32 bd_flags; /* Board flags */ spinlock_t bd_lock; /* Used to protect board */ @@ -574,11 +571,11 @@ struct board_t { ulong membase; /* Start of base memory of the card */ ulong membase_end; /* End of base memory of the card */ - uchar *re_map_port; /* Remapped io port of the card */ - uchar *re_map_membase;/* Remapped memory of the card */ + u8 *re_map_port; /* Remapped io port of the card */ + u8 *re_map_membase;/* Remapped memory of the card */ - uchar runwait; /* # Processes waiting for FEP */ - uchar inhibit_poller; /* Tells the poller to leave us alone */ + u8 runwait; /* # Processes waiting for FEP */ + u8 inhibit_poller; /* Tells the poller to leave us alone */ struct channel_t *channels[MAXPORTS]; /* array of pointers to our */ /* channels. */ @@ -985,7 +982,7 @@ struct channel_t { wait_queue_head_t ch_flags_wait; u32 pscan_state; - uchar pscan_savechar; + u8 pscan_savechar; u32 ch_portnum; /* Port number, 0 offset. */ u32 ch_open_count; /* open count */ @@ -1015,27 +1012,27 @@ struct channel_t { u16 ch_cook; /* Output character mask */ - uchar ch_card; /* Card channel is on */ - uchar ch_stopc; /* Stop character */ - uchar ch_startc; /* Start character */ - - uchar ch_mostat; /* FEP output modem status */ - uchar ch_mistat; /* FEP input modem status */ - uchar ch_mforce; /* Modem values to be forced */ - uchar ch_mval; /* Force values */ - uchar ch_fepstopc; /* FEP stop character */ - uchar ch_fepstartc; /* FEP start character */ - - uchar ch_astopc; /* Auxiliary Stop character */ - uchar ch_astartc; /* Auxiliary Start character */ - uchar ch_fepastopc; /* Auxiliary FEP stop char */ - uchar ch_fepastartc; /* Auxiliary FEP start char */ - - uchar ch_hflow; /* FEP hardware handshake */ - uchar ch_dsr; /* stores real dsr value */ - uchar ch_cd; /* stores real cd value */ - uchar ch_tx_win; /* channel tx buffer window */ - uchar ch_rx_win; /* channel rx buffer window */ + u8 ch_card; /* Card channel is on */ + u8 ch_stopc; /* Stop character */ + u8 ch_startc; /* Start character */ + + u8 ch_mostat; /* FEP output modem status */ + u8 ch_mistat; /* FEP input modem status */ + u8 ch_mforce; /* Modem values to be forced */ + u8 ch_mval; /* Force values */ + u8 ch_fepstopc; /* FEP stop character */ + u8 ch_fepstartc; /* FEP start character */ + + u8 ch_astopc; /* Auxiliary Stop character */ + u8 ch_astartc; /* Auxiliary Start character */ + u8 ch_fepastopc; /* Auxiliary FEP stop char */ + u8 ch_fepastartc; /* Auxiliary FEP start char */ + + u8 ch_hflow; /* FEP hardware handshake */ + u8 ch_dsr; /* stores real dsr value */ + u8 ch_cd; /* stores real cd value */ + u8 ch_tx_win; /* channel tx buffer window */ + u8 ch_rx_win; /* channel rx buffer window */ uint ch_custom_speed; /* Custom baud, if set */ uint ch_baud_info; /* Current baud info for /proc output */ ulong ch_rxcount; /* total of data received so far */ @@ -1076,14 +1073,14 @@ struct ev_t { * Download buffer structure. ************************************************************************/ struct downld_t { - uchar dl_type; /* Header */ - uchar dl_seq; /* Download sequence */ + u8 dl_type; /* Header */ + u8 dl_seq; /* Download sequence */ ushort dl_srev; /* Software revision number */ ushort dl_lrev; /* Low revision number */ ushort dl_hrev; /* High revision number */ ushort dl_seg; /* Start segment address */ ushort dl_size; /* Number of bytes to download */ - uchar dl_data[1024]; /* Download data */ + u8 dl_data[1024]; /* Download data */ }; /************************************************************************ -- cgit v1.2.3 From 9de98da2a7531ec9dedfbe95d69ee55237bbd9d5 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Tue, 15 Apr 2014 07:46:05 +0200 Subject: ASoC: wm8997: Fix compile error The macro's name is SOC_ENUM, not SOC_VALUE. Fixes: e13dd8ce ("ASoC: wm8997: Replace usage deprecated MUX/ENUM macros") Reported-by: Stephen Rothwell Signed-off-by: Lars-Peter Clausen Signed-off-by: Mark Brown --- sound/soc/codecs/wm8997.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sound/soc/codecs/wm8997.c b/sound/soc/codecs/wm8997.c index e45bbc0f15b2..a5dcdcb3ee24 100644 --- a/sound/soc/codecs/wm8997.c +++ b/sound/soc/codecs/wm8997.c @@ -245,8 +245,8 @@ SND_SOC_BYTES("LHPF2 Coefficients", ARIZONA_HPLPF2_2, 1), SND_SOC_BYTES("LHPF3 Coefficients", ARIZONA_HPLPF3_2, 1), SND_SOC_BYTES("LHPF4 Coefficients", ARIZONA_HPLPF4_2, 1), -SOC_VALUE("ISRC1 FSL", arizona_isrc_fsl[0]), -SOC_VALUE("ISRC2 FSL", arizona_isrc_fsl[1]), +SOC_ENUM("ISRC1 FSL", arizona_isrc_fsl[0]), +SOC_ENUM("ISRC2 FSL", arizona_isrc_fsl[1]), ARIZONA_MIXER_CONTROLS("Mic", ARIZONA_MICMIX_INPUT_1_SOURCE), ARIZONA_MIXER_CONTROLS("Noise", ARIZONA_NOISEMIX_INPUT_1_SOURCE), @@ -286,8 +286,8 @@ SOC_DOUBLE_R_TLV("SPKDAT1 Digital Volume", ARIZONA_DAC_DIGITAL_VOLUME_5L, ARIZONA_DAC_DIGITAL_VOLUME_5R, ARIZONA_OUT5L_VOL_SHIFT, 0xbf, 0, digital_tlv), -SOC_VALUE("HPOUT1 OSR", wm8997_hpout_osr[0]), -SOC_VALUE("EPOUT OSR", wm8997_hpout_osr[1]), +SOC_ENUM("HPOUT1 OSR", wm8997_hpout_osr[0]), +SOC_ENUM("EPOUT OSR", wm8997_hpout_osr[1]), SOC_ENUM("Output Ramp Up", arizona_out_vi_ramp), SOC_ENUM("Output Ramp Down", arizona_out_vd_ramp), -- cgit v1.2.3 From 75dbf0a0f96b0fda180676af51375f5d008b6c9c Mon Sep 17 00:00:00 2001 From: Axel Lin Date: Tue, 15 Apr 2014 12:02:08 +0800 Subject: regulator: pbias: Convert to use regulator_[enable|is_enabled]_regmap Since commit ca5d1b3524b4d "regulator: helpers: Modify helpers enabling multi-bit control", we can set enable_val setting for device that use multiple bits for control when using regmap enable/disable/bypass ops. Signed-off-by: Axel Lin Tested-by: Balaji T K Signed-off-by: Mark Brown --- drivers/regulator/pbias-regulator.c | 25 +++---------------------- 1 file changed, 3 insertions(+), 22 deletions(-) diff --git a/drivers/regulator/pbias-regulator.c b/drivers/regulator/pbias-regulator.c index 6d38be3d970c..708ddbb83e29 100644 --- a/drivers/regulator/pbias-regulator.c +++ b/drivers/regulator/pbias-regulator.c @@ -49,33 +49,13 @@ static const unsigned int pbias_volt_table[] = { 3000000 }; -static int pbias_regulator_enable(struct regulator_dev *rdev) -{ - struct pbias_regulator_data *data = rdev_get_drvdata(rdev); - const struct pbias_reg_info *info = data->info; - - return regmap_update_bits(data->syscon, rdev->desc->enable_reg, - info->enable_mask, info->enable); -} - -static int pbias_regulator_is_enable(struct regulator_dev *rdev) -{ - struct pbias_regulator_data *data = rdev_get_drvdata(rdev); - const struct pbias_reg_info *info = data->info; - int value; - - regmap_read(data->syscon, rdev->desc->enable_reg, &value); - - return (value & info->enable_mask) == info->enable; -} - static struct regulator_ops pbias_regulator_voltage_ops = { .list_voltage = regulator_list_voltage_table, .get_voltage_sel = regulator_get_voltage_sel_regmap, .set_voltage_sel = regulator_set_voltage_sel_regmap, - .enable = pbias_regulator_enable, + .enable = regulator_enable_regmap, .disable = regulator_disable_regmap, - .is_enabled = pbias_regulator_is_enable, + .is_enabled = regulator_is_enabled_regmap, }; static const struct pbias_reg_info pbias_mmc_omap2430 = { @@ -180,6 +160,7 @@ static int pbias_regulator_probe(struct platform_device *pdev) drvdata[data_idx].desc.vsel_mask = info->vmode; drvdata[data_idx].desc.enable_reg = res->start; drvdata[data_idx].desc.enable_mask = info->enable_mask; + drvdata[data_idx].desc.enable_val = info->enable; cfg.init_data = pbias_matches[idx].init_data; cfg.driver_data = &drvdata[data_idx]; -- cgit v1.2.3 From 9c72a04ca78606bf10211efa93b3332c710afc65 Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Tue, 15 Apr 2014 12:02:02 +0100 Subject: ASoC: fsl: Add explicit include of of.h Hopefully fixing a build failure reported by Stephen Rothwell - though quite why the other OF headers don't include this as well I'm not sure. Signed-off-by: Mark Brown --- sound/soc/fsl/fsl_ssi.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c index 5428a1fda260..2fbbd8416c00 100644 --- a/sound/soc/fsl/fsl_ssi.c +++ b/sound/soc/fsl/fsl_ssi.c @@ -40,6 +40,7 @@ #include #include #include +#include #include #include #include -- cgit v1.2.3 From f3046f86b8a455ae55b8d465cd34938006361096 Mon Sep 17 00:00:00 2001 From: Christian Engelmayer Date: Sun, 13 Apr 2014 19:56:36 +0200 Subject: ASoC: Intel: Fix incorrect sizeof() in sst_hsw_stream_get_volume() Fix an incorrect sizeof() usage in sst_hsw_stream_get_volume(). sst_dsp_read() is called to read into a variable of type u32, but is passed sizeof(u32 *) for argument 'size_t bytes'. Detected by Coverity: CID 1195260. Signed-off-by: Christian Engelmayer Signed-off-by: Mark Brown --- sound/soc/intel/sst-haswell-ipc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sound/soc/intel/sst-haswell-ipc.c b/sound/soc/intel/sst-haswell-ipc.c index f46bb4ddde6f..455a1857c441 100644 --- a/sound/soc/intel/sst-haswell-ipc.c +++ b/sound/soc/intel/sst-haswell-ipc.c @@ -991,7 +991,8 @@ int sst_hsw_stream_get_volume(struct sst_hsw *hsw, struct sst_hsw_stream *stream return -EINVAL; sst_dsp_read(hsw->dsp, volume, - stream->reply.volume_register_address[channel], sizeof(volume)); + stream->reply.volume_register_address[channel], + sizeof(*volume)); return 0; } -- cgit v1.2.3 From dd1b94bf4920cc12545883faa43c014efbf61b1e Mon Sep 17 00:00:00 2001 From: Christian Engelmayer Date: Sun, 13 Apr 2014 22:46:31 +0200 Subject: ASoC: Intel: Fix a self assignment in sst_mem_block_alloc_scratch() Remove a self assignment in sst_mem_block_alloc_scratch(). When calculating buffer sizes there is no need for statements without effect. Detected by Coverity: CID 1195249. Signed-off-by: Christian Engelmayer Signed-off-by: Mark Brown --- sound/soc/intel/sst-firmware.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/sound/soc/intel/sst-firmware.c b/sound/soc/intel/sst-firmware.c index f7687107cf7f..f24619adc3d1 100644 --- a/sound/soc/intel/sst-firmware.c +++ b/sound/soc/intel/sst-firmware.c @@ -505,9 +505,7 @@ struct sst_module *sst_mem_block_alloc_scratch(struct sst_dsp *dsp) /* calculate required scratch size */ list_for_each_entry(sst_module, &dsp->module_list, list) { - if (scratch->s.size > sst_module->s.size) - scratch->s.size = scratch->s.size; - else + if (scratch->s.size < sst_module->s.size) scratch->s.size = sst_module->s.size; } -- cgit v1.2.3 From 25dbe04a24516cdfd6bd215c1caaf28916b91a82 Mon Sep 17 00:00:00 2001 From: Harini Katakam Date: Tue, 15 Apr 2014 16:42:09 +0530 Subject: spi: cadence: Add dependency on ARM Add dependency on ARM in Kconfig. This is to fix the build error related to _relaxed IO. Remove dependency on SPI_MASTER because this is already defined under if SPI_MASTER in Kconfig. Signed-off-by: Harini Katakam Signed-off-by: Mark Brown --- drivers/spi/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/spi/Kconfig b/drivers/spi/Kconfig index 5f11568660c6..32b1d0f1416c 100644 --- a/drivers/spi/Kconfig +++ b/drivers/spi/Kconfig @@ -150,7 +150,7 @@ config SPI_BUTTERFLY config SPI_CADENCE tristate "Cadence SPI controller" - depends on SPI_MASTER + depends on ARM help This selects the Cadence SPI controller master driver used by Xilinx Zynq. -- cgit v1.2.3 From c908ef345d2c314ec25cfac113a8f9bb2b6b3a25 Mon Sep 17 00:00:00 2001 From: Qipan Li Date: Tue, 15 Apr 2014 15:24:59 +0800 Subject: spi: sirf: refactor spi transfer functions split sirfsoc_spi_transfer function into 3 sub-functions: spi_sirfsoc_cmd_transfer, spi_sirfsoc_pio_transfer and spi_sirfsoc_dma_transfer. Signed-off-by: Qipan Li Signed-off-by: Barry Song Signed-off-by: Mark Brown --- drivers/spi/spi-sirf.c | 232 ++++++++++++++++++++++++++----------------------- 1 file changed, 123 insertions(+), 109 deletions(-) diff --git a/drivers/spi/spi-sirf.c b/drivers/spi/spi-sirf.c index 0c039d4542a5..2d238990115c 100644 --- a/drivers/spi/spi-sirf.c +++ b/drivers/spi/spi-sirf.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -309,59 +310,51 @@ static void spi_sirfsoc_dma_fini_callback(void *data) complete(dma_complete); } -static int spi_sirfsoc_transfer(struct spi_device *spi, struct spi_transfer *t) +static int spi_sirfsoc_cmd_transfer(struct spi_device *spi, + struct spi_transfer *t) { struct sirfsoc_spi *sspi; int timeout = t->len * 10; - sspi = spi_master_get_devdata(spi->master); + u32 cmd; - sspi->tx = t->tx_buf ? t->tx_buf : sspi->dummypage; - sspi->rx = t->rx_buf ? t->rx_buf : sspi->dummypage; - sspi->left_tx_word = sspi->left_rx_word = t->len / sspi->word_width; - reinit_completion(&sspi->rx_done); - reinit_completion(&sspi->tx_done); - - writel(SIRFSOC_SPI_INT_MASK_ALL, sspi->base + SIRFSOC_SPI_INT_STATUS); - - /* - * fill tx_buf into command register and wait for its completion - */ - if (sspi->tx_by_cmd) { - u32 cmd; - memcpy(&cmd, sspi->tx, t->len); - - if (sspi->word_width == 1 && !(spi->mode & SPI_LSB_FIRST)) - cmd = cpu_to_be32(cmd) >> - ((SIRFSOC_MAX_CMD_BYTES - t->len) * 8); - if (sspi->word_width == 2 && t->len == 4 && - (!(spi->mode & SPI_LSB_FIRST))) - cmd = ((cmd & 0xffff) << 16) | (cmd >> 16); - - writel(cmd, sspi->base + SIRFSOC_SPI_CMD); - writel(SIRFSOC_SPI_FRM_END_INT_EN, - sspi->base + SIRFSOC_SPI_INT_EN); - writel(SIRFSOC_SPI_CMD_TX_EN, - sspi->base + SIRFSOC_SPI_TX_RX_EN); + sspi = spi_master_get_devdata(spi->master); + memcpy(&cmd, sspi->tx, t->len); + if (sspi->word_width == 1 && !(spi->mode & SPI_LSB_FIRST)) + cmd = cpu_to_be32(cmd) >> + ((SIRFSOC_MAX_CMD_BYTES - t->len) * 8); + if (sspi->word_width == 2 && t->len == 4 && + (!(spi->mode & SPI_LSB_FIRST))) + cmd = ((cmd & 0xffff) << 16) | (cmd >> 16); + writel(cmd, sspi->base + SIRFSOC_SPI_CMD); + writel(SIRFSOC_SPI_FRM_END_INT_EN, + sspi->base + SIRFSOC_SPI_INT_EN); + writel(SIRFSOC_SPI_CMD_TX_EN, + sspi->base + SIRFSOC_SPI_TX_RX_EN); + if (wait_for_completion_timeout(&sspi->tx_done, timeout) == 0) { + dev_err(&spi->dev, "cmd transfer timeout\n"); + return 0; + } - if (wait_for_completion_timeout(&sspi->tx_done, timeout) == 0) { - dev_err(&spi->dev, "transfer timeout\n"); - return 0; - } + return t->len; +} - return t->len; - } +static void spi_sirfsoc_dma_transfer(struct spi_device *spi, + struct spi_transfer *t) +{ + struct sirfsoc_spi *sspi; + struct dma_async_tx_descriptor *rx_desc, *tx_desc; + int timeout = t->len * 10; - if (sspi->left_tx_word == 1) { - writel(readl(sspi->base + SIRFSOC_SPI_CTRL) | - SIRFSOC_SPI_ENA_AUTO_CLR, - sspi->base + SIRFSOC_SPI_CTRL); - writel(0, sspi->base + SIRFSOC_SPI_TX_DMA_IO_LEN); - writel(0, sspi->base + SIRFSOC_SPI_RX_DMA_IO_LEN); - } else if ((sspi->left_tx_word > 1) && (sspi->left_tx_word < - SIRFSOC_SPI_DAT_FRM_LEN_MAX)) { + sspi = spi_master_get_devdata(spi->master); + writel(SIRFSOC_SPI_FIFO_RESET, sspi->base + SIRFSOC_SPI_RXFIFO_OP); + writel(SIRFSOC_SPI_FIFO_RESET, sspi->base + SIRFSOC_SPI_TXFIFO_OP); + writel(SIRFSOC_SPI_FIFO_START, sspi->base + SIRFSOC_SPI_RXFIFO_OP); + writel(SIRFSOC_SPI_FIFO_START, sspi->base + SIRFSOC_SPI_TXFIFO_OP); + writel(0, sspi->base + SIRFSOC_SPI_INT_EN); + writel(SIRFSOC_SPI_INT_MASK_ALL, sspi->base + SIRFSOC_SPI_INT_STATUS); + if (sspi->left_tx_word < SIRFSOC_SPI_DAT_FRM_LEN_MAX) { writel(readl(sspi->base + SIRFSOC_SPI_CTRL) | - SIRFSOC_SPI_MUL_DAT_MODE | - SIRFSOC_SPI_ENA_AUTO_CLR, + SIRFSOC_SPI_ENA_AUTO_CLR | SIRFSOC_SPI_MUL_DAT_MODE, sspi->base + SIRFSOC_SPI_CTRL); writel(sspi->left_tx_word - 1, sspi->base + SIRFSOC_SPI_TX_DMA_IO_LEN); @@ -373,88 +366,109 @@ static int spi_sirfsoc_transfer(struct spi_device *spi, struct spi_transfer *t) writel(0, sspi->base + SIRFSOC_SPI_TX_DMA_IO_LEN); writel(0, sspi->base + SIRFSOC_SPI_RX_DMA_IO_LEN); } - - writel(SIRFSOC_SPI_FIFO_RESET, sspi->base + SIRFSOC_SPI_RXFIFO_OP); - writel(SIRFSOC_SPI_FIFO_RESET, sspi->base + SIRFSOC_SPI_TXFIFO_OP); - writel(SIRFSOC_SPI_FIFO_START, sspi->base + SIRFSOC_SPI_RXFIFO_OP); - writel(SIRFSOC_SPI_FIFO_START, sspi->base + SIRFSOC_SPI_TXFIFO_OP); - - if (IS_DMA_VALID(t)) { - struct dma_async_tx_descriptor *rx_desc, *tx_desc; - - sspi->dst_start = dma_map_single(&spi->dev, - sspi->rx, t->len, (t->tx_buf != t->rx_buf) ? - DMA_FROM_DEVICE : DMA_BIDIRECTIONAL); - rx_desc = dmaengine_prep_slave_single(sspi->rx_chan, - sspi->dst_start, t->len, DMA_DEV_TO_MEM, - DMA_PREP_INTERRUPT | DMA_CTRL_ACK); - rx_desc->callback = spi_sirfsoc_dma_fini_callback; - rx_desc->callback_param = &sspi->rx_done; - - sspi->src_start = dma_map_single(&spi->dev, - (void *)sspi->tx, t->len, - (t->tx_buf != t->rx_buf) ? - DMA_TO_DEVICE : DMA_BIDIRECTIONAL); - tx_desc = dmaengine_prep_slave_single(sspi->tx_chan, - sspi->src_start, t->len, DMA_MEM_TO_DEV, - DMA_PREP_INTERRUPT | DMA_CTRL_ACK); - tx_desc->callback = spi_sirfsoc_dma_fini_callback; - tx_desc->callback_param = &sspi->tx_done; - - dmaengine_submit(tx_desc); - dmaengine_submit(rx_desc); - dma_async_issue_pending(sspi->tx_chan); - dma_async_issue_pending(sspi->rx_chan); - } else { - /* Send the first word to trigger the whole tx/rx process */ - sspi->tx_word(sspi); - - writel(SIRFSOC_SPI_RX_OFLOW_INT_EN | - SIRFSOC_SPI_TX_UFLOW_INT_EN | - SIRFSOC_SPI_RXFIFO_THD_INT_EN | - SIRFSOC_SPI_TXFIFO_THD_INT_EN | - SIRFSOC_SPI_FRM_END_INT_EN | - SIRFSOC_SPI_RXFIFO_FULL_INT_EN | - SIRFSOC_SPI_TXFIFO_EMPTY_INT_EN, - sspi->base + SIRFSOC_SPI_INT_EN); - } - + sspi->dst_start = dma_map_single(&spi->dev, sspi->rx, t->len, + (t->tx_buf != t->rx_buf) ? + DMA_FROM_DEVICE : DMA_BIDIRECTIONAL); + rx_desc = dmaengine_prep_slave_single(sspi->rx_chan, + sspi->dst_start, t->len, DMA_DEV_TO_MEM, + DMA_PREP_INTERRUPT | DMA_CTRL_ACK); + rx_desc->callback = spi_sirfsoc_dma_fini_callback; + rx_desc->callback_param = &sspi->rx_done; + + sspi->src_start = dma_map_single(&spi->dev, (void *)sspi->tx, t->len, + (t->tx_buf != t->rx_buf) ? + DMA_TO_DEVICE : DMA_BIDIRECTIONAL); + tx_desc = dmaengine_prep_slave_single(sspi->tx_chan, + sspi->src_start, t->len, DMA_MEM_TO_DEV, + DMA_PREP_INTERRUPT | DMA_CTRL_ACK); + tx_desc->callback = spi_sirfsoc_dma_fini_callback; + tx_desc->callback_param = &sspi->tx_done; + + dmaengine_submit(tx_desc); + dmaengine_submit(rx_desc); + dma_async_issue_pending(sspi->tx_chan); + dma_async_issue_pending(sspi->rx_chan); writel(SIRFSOC_SPI_RX_EN | SIRFSOC_SPI_TX_EN, sspi->base + SIRFSOC_SPI_TX_RX_EN); - - if (!IS_DMA_VALID(t)) { /* for PIO */ - if (wait_for_completion_timeout(&sspi->rx_done, timeout) == 0) - dev_err(&spi->dev, "transfer timeout\n"); - } else if (wait_for_completion_timeout(&sspi->rx_done, timeout) == 0) { + if (wait_for_completion_timeout(&sspi->rx_done, timeout) == 0) { dev_err(&spi->dev, "transfer timeout\n"); dmaengine_terminate_all(sspi->rx_chan); } else sspi->left_rx_word = 0; - /* * we only wait tx-done event if transferring by DMA. for PIO, * we get rx data by writing tx data, so if rx is done, tx has * done earlier */ - if (IS_DMA_VALID(t)) { - if (wait_for_completion_timeout(&sspi->tx_done, timeout) == 0) { - dev_err(&spi->dev, "transfer timeout\n"); - dmaengine_terminate_all(sspi->tx_chan); - } + if (wait_for_completion_timeout(&sspi->tx_done, timeout) == 0) { + dev_err(&spi->dev, "transfer timeout\n"); + dmaengine_terminate_all(sspi->tx_chan); } + dma_unmap_single(&spi->dev, sspi->src_start, t->len, DMA_TO_DEVICE); + dma_unmap_single(&spi->dev, sspi->dst_start, t->len, DMA_FROM_DEVICE); + /* TX, RX FIFO stop */ + writel(0, sspi->base + SIRFSOC_SPI_RXFIFO_OP); + writel(0, sspi->base + SIRFSOC_SPI_TXFIFO_OP); + if (sspi->left_tx_word >= SIRFSOC_SPI_DAT_FRM_LEN_MAX) + writel(0, sspi->base + SIRFSOC_SPI_TX_RX_EN); +} - if (IS_DMA_VALID(t)) { - dma_unmap_single(&spi->dev, - sspi->src_start, t->len, DMA_TO_DEVICE); - dma_unmap_single(&spi->dev, - sspi->dst_start, t->len, DMA_FROM_DEVICE); - } +static void spi_sirfsoc_pio_transfer(struct spi_device *spi, + struct spi_transfer *t) +{ + struct sirfsoc_spi *sspi; + int timeout = t->len * 10; - /* TX, RX FIFO stop */ + sspi = spi_master_get_devdata(spi->master); + writel(SIRFSOC_SPI_FIFO_RESET, sspi->base + SIRFSOC_SPI_RXFIFO_OP); + writel(SIRFSOC_SPI_FIFO_RESET, sspi->base + SIRFSOC_SPI_TXFIFO_OP); + writel(SIRFSOC_SPI_FIFO_START, sspi->base + SIRFSOC_SPI_RXFIFO_OP); + writel(SIRFSOC_SPI_FIFO_START, sspi->base + SIRFSOC_SPI_TXFIFO_OP); + writel(0, sspi->base + SIRFSOC_SPI_INT_EN); + writel(SIRFSOC_SPI_INT_MASK_ALL, sspi->base + SIRFSOC_SPI_INT_STATUS); + writel(readl(sspi->base + SIRFSOC_SPI_CTRL) | SIRFSOC_SPI_MUL_DAT_MODE | + SIRFSOC_SPI_ENA_AUTO_CLR, sspi->base + SIRFSOC_SPI_CTRL); + writel(sspi->left_tx_word - 1, + sspi->base + SIRFSOC_SPI_TX_DMA_IO_LEN); + writel(sspi->left_rx_word - 1, + sspi->base + SIRFSOC_SPI_RX_DMA_IO_LEN); + sspi->tx_word(sspi); + writel(SIRFSOC_SPI_TXFIFO_EMPTY_INT_EN | SIRFSOC_SPI_TX_UFLOW_INT_EN | + SIRFSOC_SPI_RX_OFLOW_INT_EN | SIRFSOC_SPI_RXFIFO_THD_INT_EN | + SIRFSOC_SPI_TXFIFO_THD_INT_EN | SIRFSOC_SPI_FRM_END_INT_EN| + SIRFSOC_SPI_RXFIFO_FULL_INT_EN, + sspi->base + SIRFSOC_SPI_INT_EN); + writel(SIRFSOC_SPI_RX_EN | SIRFSOC_SPI_TX_EN, + sspi->base + SIRFSOC_SPI_TX_RX_EN); + if (wait_for_completion_timeout(&sspi->rx_done, timeout) == 0) + dev_err(&spi->dev, "transfer timeout\n"); writel(0, sspi->base + SIRFSOC_SPI_RXFIFO_OP); writel(0, sspi->base + SIRFSOC_SPI_TXFIFO_OP); writel(0, sspi->base + SIRFSOC_SPI_TX_RX_EN); writel(0, sspi->base + SIRFSOC_SPI_INT_EN); +} + +static int spi_sirfsoc_transfer(struct spi_device *spi, struct spi_transfer *t) +{ + struct sirfsoc_spi *sspi; + sspi = spi_master_get_devdata(spi->master); + + sspi->tx = t->tx_buf ? t->tx_buf : sspi->dummypage; + sspi->rx = t->rx_buf ? t->rx_buf : sspi->dummypage; + sspi->left_tx_word = sspi->left_rx_word = t->len / sspi->word_width; + reinit_completion(&sspi->rx_done); + reinit_completion(&sspi->tx_done); + /* + * in the transfer, if transfer data using command register with rx_buf + * null, just fill command data into command register and wait for its + * completion. + */ + if (sspi->tx_by_cmd) + spi_sirfsoc_cmd_transfer(spi, t); + else if (IS_DMA_VALID(t)) + spi_sirfsoc_dma_transfer(spi, t); + else + spi_sirfsoc_pio_transfer(spi, t); return t->len - sspi->left_rx_word * sspi->word_width; } -- cgit v1.2.3 From 21200ad10aba00943f9aa832fab04b8926dc7a52 Mon Sep 17 00:00:00 2001 From: Vivien Didelot Date: Mon, 14 Apr 2014 16:50:17 -0400 Subject: HID: thingm: remove the "play" sysfs attribute When the thingm driver registers an instance of LED class, it creates a "play" sysfs attribute for this blink(1) specific feature. Since this feature is not specific to the RGB chip but to the HID device itself, let's remove this attribute from the LED instance and only implement what is useful to switch on and off the LED. This feature is still easily accessible through hidraw. Signed-off-by: Vivien Didelot Signed-off-by: Jiri Kosina --- Documentation/ABI/testing/sysfs-driver-hid-thingm | 7 ----- drivers/hid/hid-thingm.c | 33 ----------------------- 2 files changed, 40 deletions(-) diff --git a/Documentation/ABI/testing/sysfs-driver-hid-thingm b/Documentation/ABI/testing/sysfs-driver-hid-thingm index abcffeedd20a..fda6185b9292 100644 --- a/Documentation/ABI/testing/sysfs-driver-hid-thingm +++ b/Documentation/ABI/testing/sysfs-driver-hid-thingm @@ -14,10 +14,3 @@ Description: This attribute allows to set a fade time in milliseconds for the next color change. Read the attribute to know the current fade time. The default value is set to 0 (no fade time). For instance, set a fade time of 2 seconds with: echo 2000 > fade - -What: /sys/class/leds/blink1::/play -Date: January 2013 -Contact: Vivien Didelot -Description: This attribute is used to play/pause the light patterns. Write 1 - to start playing, 0 to stop. Reading this attribute returns the - current playing status. diff --git a/drivers/hid/hid-thingm.c b/drivers/hid/hid-thingm.c index a97c78845f7b..7e376b855632 100644 --- a/drivers/hid/hid-thingm.c +++ b/drivers/hid/hid-thingm.c @@ -28,7 +28,6 @@ * @rgb: 8-bit per channel RGB notation. * @fade: fade time in hundredths of a second. * @brightness: brightness coefficient. - * @play: play/pause in-memory patterns. */ struct blink1_data { struct hid_device *hdev; @@ -36,7 +35,6 @@ struct blink1_data { u32 rgb; u16 fade; u8 brightness; - bool play; }; static int blink1_send_command(struct blink1_data *data, @@ -155,41 +153,10 @@ static ssize_t blink1_store_fade(struct device *dev, static DEVICE_ATTR(fade, S_IRUGO | S_IWUSR, blink1_show_fade, blink1_store_fade); -static ssize_t blink1_show_play(struct device *dev, - struct device_attribute *attr, char *buf) -{ - struct blink1_data *data = dev_get_drvdata(dev->parent); - - return sprintf(buf, "%d\n", data->play); -} - -static ssize_t blink1_store_play(struct device *dev, - struct device_attribute *attr, const char *buf, size_t count) -{ - struct blink1_data *data = dev_get_drvdata(dev->parent); - u8 cmd[BLINK1_CMD_SIZE] = { 1, 'p', 0, 0, 0, 0, 0, 0, 0 }; - long unsigned int play; - int ret; - - ret = kstrtoul(buf, 10, &play); - if (ret) - return ret; - - data->play = !!play; - cmd[2] = data->play; - ret = blink1_send_command(data, cmd); - - return ret ? ret : count; -} - -static DEVICE_ATTR(play, S_IRUGO | S_IWUSR, - blink1_show_play, blink1_store_play); - static const struct attribute_group blink1_sysfs_group = { .attrs = (struct attribute *[]) { &dev_attr_rgb.attr, &dev_attr_fade.attr, - &dev_attr_play.attr, NULL }, }; -- cgit v1.2.3 From aee114fd3c94f1be0f95af84d6ed25cd47702c41 Mon Sep 17 00:00:00 2001 From: Vivien Didelot Date: Mon, 14 Apr 2014 16:50:18 -0400 Subject: HID: thingm: remove the "fade" sysfs attribute As for the "play" sysfs attribute, remove this other non-standard attribute, so the driver only implements what is required to switch the LED on and off. Thus, a fade time won't be ideal for some fast-changing triggers. Signed-off-by: Vivien Didelot Signed-off-by: Jiri Kosina --- Documentation/ABI/testing/sysfs-driver-hid-thingm | 8 ----- drivers/hid/hid-thingm.c | 41 ----------------------- 2 files changed, 49 deletions(-) diff --git a/Documentation/ABI/testing/sysfs-driver-hid-thingm b/Documentation/ABI/testing/sysfs-driver-hid-thingm index fda6185b9292..735c5cb0bb07 100644 --- a/Documentation/ABI/testing/sysfs-driver-hid-thingm +++ b/Documentation/ABI/testing/sysfs-driver-hid-thingm @@ -6,11 +6,3 @@ Description: The ThingM blink1 is an USB RGB LED. The color notation is color. Write the 24-bit hexadecimal color to change the current LED color. The default color is full white (0xFFFFFF). For instance, set the color to green with: echo 00FF00 > rgb - -What: /sys/class/leds/blink1::/fade -Date: January 2013 -Contact: Vivien Didelot -Description: This attribute allows to set a fade time in milliseconds for - the next color change. Read the attribute to know the current - fade time. The default value is set to 0 (no fade time). For - instance, set a fade time of 2 seconds with: echo 2000 > fade diff --git a/drivers/hid/hid-thingm.c b/drivers/hid/hid-thingm.c index 7e376b855632..e3b6647e00ce 100644 --- a/drivers/hid/hid-thingm.c +++ b/drivers/hid/hid-thingm.c @@ -26,14 +26,12 @@ * @hdev: HID device. * @led_cdev: LED class instance. * @rgb: 8-bit per channel RGB notation. - * @fade: fade time in hundredths of a second. * @brightness: brightness coefficient. */ struct blink1_data { struct hid_device *hdev; struct led_classdev led_cdev; u32 rgb; - u16 fade; u8 brightness; }; @@ -64,12 +62,6 @@ static int blink1_update_color(struct blink1_data *data) buf[4] = DIV_ROUND_CLOSEST(blink1_rgb_to_b(data->rgb), coef); } - if (data->fade) { - buf[1] = 'c'; - buf[5] = (data->fade & 0xFF00) >> 8; - buf[6] = (data->fade & 0x00FF); - } - return blink1_send_command(data, buf); } @@ -121,42 +113,9 @@ static ssize_t blink1_store_rgb(struct device *dev, static DEVICE_ATTR(rgb, S_IRUGO | S_IWUSR, blink1_show_rgb, blink1_store_rgb); -static ssize_t blink1_show_fade(struct device *dev, - struct device_attribute *attr, char *buf) -{ - struct blink1_data *data = dev_get_drvdata(dev->parent); - - return sprintf(buf, "%d\n", data->fade * 10); -} - -static ssize_t blink1_store_fade(struct device *dev, - struct device_attribute *attr, const char *buf, size_t count) -{ - struct blink1_data *data = dev_get_drvdata(dev->parent); - long unsigned int fade; - int ret; - - ret = kstrtoul(buf, 10, &fade); - if (ret) - return ret; - - /* blink(1) accepts 16-bit fade time, number of 10ms ticks */ - fade = DIV_ROUND_CLOSEST(fade, 10); - if (fade > 65535) - return -EINVAL; - - data->fade = fade; - - return count; -} - -static DEVICE_ATTR(fade, S_IRUGO | S_IWUSR, - blink1_show_fade, blink1_store_fade); - static const struct attribute_group blink1_sysfs_group = { .attrs = (struct attribute *[]) { &dev_attr_rgb.attr, - &dev_attr_fade.attr, NULL }, }; -- cgit v1.2.3 From f70ed8a6f7cd9c55cc16287c584cb26efb53cbd7 Mon Sep 17 00:00:00 2001 From: Vivien Didelot Date: Mon, 14 Apr 2014 16:50:19 -0400 Subject: HID: thingm: refactor blink(1) support This patch refactors the way the thingm driver registers a blink(1) LED. In order to make the driver simpler and more standard, drop the "rgb" sysfs attribute and create one instance of LED class per RGB channel. Actually, the name of the LED class instance registered for a blink(1) device is "blink1::ABCD", where ABCD is the last 4 chars of the serial number. The driver now registers 3 instances per RGB chip, named "thingmX:{red,green,blue}:ledY" where X is the hidraw minor number and Y is the RGB chip number (as seen by the firmware). This patch also uses work queues to defer calls with the device, which now allows triggers to work as expected with this LED device. Also remove the brightness structure field and the brightness_get backend, as it is already handled by the LED class, and changes the prefix of functions and structures to thingm_ to match the driver name. Signed-off-by: Vivien Didelot Signed-off-by: Jiri Kosina --- Documentation/ABI/testing/sysfs-driver-hid-thingm | 8 - drivers/hid/hid-thingm.c | 304 +++++++++++++++------- drivers/leds/Kconfig | 2 + 3 files changed, 209 insertions(+), 105 deletions(-) delete mode 100644 Documentation/ABI/testing/sysfs-driver-hid-thingm diff --git a/Documentation/ABI/testing/sysfs-driver-hid-thingm b/Documentation/ABI/testing/sysfs-driver-hid-thingm deleted file mode 100644 index 735c5cb0bb07..000000000000 --- a/Documentation/ABI/testing/sysfs-driver-hid-thingm +++ /dev/null @@ -1,8 +0,0 @@ -What: /sys/class/leds/blink1::/rgb -Date: January 2013 -Contact: Vivien Didelot -Description: The ThingM blink1 is an USB RGB LED. The color notation is - 3-byte hexadecimal. Read this attribute to get the last set - color. Write the 24-bit hexadecimal color to change the current - LED color. The default color is full white (0xFFFFFF). - For instance, set the color to green with: echo 00FF00 > rgb diff --git a/drivers/hid/hid-thingm.c b/drivers/hid/hid-thingm.c index e3b6647e00ce..0af0eb446636 100644 --- a/drivers/hid/hid-thingm.c +++ b/drivers/hid/hid-thingm.c @@ -1,7 +1,7 @@ /* * ThingM blink(1) USB RGB LED driver * - * Copyright 2013 Savoir-faire Linux Inc. + * Copyright 2013-2014 Savoir-faire Linux Inc. * Vivien Didelot * * This program is free software; you can redistribute it and/or @@ -10,170 +10,280 @@ */ #include +#include #include #include +#include +#include #include "hid-ids.h" -#define BLINK1_CMD_SIZE 9 +#define REPORT_ID 1 +#define REPORT_SIZE 9 -#define blink1_rgb_to_r(rgb) ((rgb & 0xFF0000) >> 16) -#define blink1_rgb_to_g(rgb) ((rgb & 0x00FF00) >> 8) -#define blink1_rgb_to_b(rgb) ((rgb & 0x0000FF) >> 0) +/* Firmware major number of supported devices */ +#define THINGM_MAJOR_MK1 '1' -/** - * struct blink1_data - blink(1) device specific data - * @hdev: HID device. - * @led_cdev: LED class instance. - * @rgb: 8-bit per channel RGB notation. - * @brightness: brightness coefficient. - */ -struct blink1_data { +struct thingm_fwinfo { + char major; + unsigned numrgb; + unsigned first; +}; + +const struct thingm_fwinfo thingm_fwinfo[] = { + { + .major = THINGM_MAJOR_MK1, + .numrgb = 1, + .first = 0, + } +}; + +/* A red, green or blue channel, part of an RGB chip */ +struct thingm_led { + struct thingm_rgb *rgb; + struct led_classdev ldev; + char name[32]; +}; + +/* Basically a WS2812 5050 RGB LED chip */ +struct thingm_rgb { + struct thingm_device *tdev; + struct thingm_led red; + struct thingm_led green; + struct thingm_led blue; + struct work_struct work; + u8 num; +}; + +struct thingm_device { struct hid_device *hdev; - struct led_classdev led_cdev; - u32 rgb; - u8 brightness; + struct { + char major; + char minor; + } version; + const struct thingm_fwinfo *fwinfo; + struct mutex lock; + struct thingm_rgb *rgb; }; -static int blink1_send_command(struct blink1_data *data, - u8 buf[BLINK1_CMD_SIZE]) +static int thingm_send(struct thingm_device *tdev, u8 buf[REPORT_SIZE]) { int ret; - hid_dbg(data->hdev, "command: %d%c%.2x%.2x%.2x%.2x%.2x%.2x%.2x\n", + hid_dbg(tdev->hdev, "-> %d %c %02hhx %02hhx %02hhx %02hhx %02hhx %02hhx %02hhx\n", buf[0], buf[1], buf[2], buf[3], buf[4], buf[5], buf[6], buf[7], buf[8]); - ret = hid_hw_raw_request(data->hdev, buf[0], buf, BLINK1_CMD_SIZE, - HID_FEATURE_REPORT, HID_REQ_SET_REPORT); + ret = hid_hw_raw_request(tdev->hdev, buf[0], buf, REPORT_SIZE, + HID_FEATURE_REPORT, HID_REQ_SET_REPORT); return ret < 0 ? ret : 0; } -static int blink1_update_color(struct blink1_data *data) +static int thingm_recv(struct thingm_device *tdev, u8 buf[REPORT_SIZE]) { - u8 buf[BLINK1_CMD_SIZE] = { 1, 'n', 0, 0, 0, 0, 0, 0, 0 }; + int ret; - if (data->brightness) { - unsigned int coef = DIV_ROUND_CLOSEST(255, data->brightness); + ret = hid_hw_raw_request(tdev->hdev, buf[0], buf, REPORT_SIZE, + HID_FEATURE_REPORT, HID_REQ_GET_REPORT); + if (ret < 0) + return ret; - buf[2] = DIV_ROUND_CLOSEST(blink1_rgb_to_r(data->rgb), coef); - buf[3] = DIV_ROUND_CLOSEST(blink1_rgb_to_g(data->rgb), coef); - buf[4] = DIV_ROUND_CLOSEST(blink1_rgb_to_b(data->rgb), coef); - } + hid_dbg(tdev->hdev, "<- %d %c %02hhx %02hhx %02hhx %02hhx %02hhx %02hhx %02hhx\n", + buf[0], buf[1], buf[2], buf[3], buf[4], + buf[5], buf[6], buf[7], buf[8]); - return blink1_send_command(data, buf); + return 0; } -static void blink1_led_set(struct led_classdev *led_cdev, - enum led_brightness brightness) +static int thingm_version(struct thingm_device *tdev) { - struct blink1_data *data = dev_get_drvdata(led_cdev->dev->parent); + u8 buf[REPORT_SIZE] = { REPORT_ID, 'v', 0, 0, 0, 0, 0, 0, 0 }; + int err; + + err = thingm_send(tdev, buf); + if (err) + return err; + + err = thingm_recv(tdev, buf); + if (err) + return err; - data->brightness = brightness; - if (blink1_update_color(data)) - hid_err(data->hdev, "failed to update color\n"); + tdev->version.major = buf[3]; + tdev->version.minor = buf[4]; + + return 0; } -static enum led_brightness blink1_led_get(struct led_classdev *led_cdev) +static int thingm_write_color(struct thingm_rgb *rgb) { - struct blink1_data *data = dev_get_drvdata(led_cdev->dev->parent); + u8 buf[REPORT_SIZE] = { REPORT_ID, 'n', 0, 0, 0, 0, 0, 0, 0 }; + + buf[2] = rgb->red.ldev.brightness; + buf[3] = rgb->green.ldev.brightness; + buf[4] = rgb->blue.ldev.brightness; - return data->brightness; + return thingm_send(rgb->tdev, buf); } -static ssize_t blink1_show_rgb(struct device *dev, - struct device_attribute *attr, char *buf) +static void thingm_work(struct work_struct *work) { - struct blink1_data *data = dev_get_drvdata(dev->parent); + struct thingm_rgb *rgb = container_of(work, struct thingm_rgb, work); - return sprintf(buf, "%.6X\n", data->rgb); + mutex_lock(&rgb->tdev->lock); + + if (thingm_write_color(rgb)) + hid_err(rgb->tdev->hdev, "failed to write color\n"); + + mutex_unlock(&rgb->tdev->lock); } -static ssize_t blink1_store_rgb(struct device *dev, - struct device_attribute *attr, const char *buf, size_t count) +static void thingm_led_set(struct led_classdev *ldev, + enum led_brightness brightness) { - struct blink1_data *data = dev_get_drvdata(dev->parent); - long unsigned int rgb; - int ret; + struct thingm_led *led = container_of(ldev, struct thingm_led, ldev); - ret = kstrtoul(buf, 16, &rgb); - if (ret) - return ret; + /* the ledclass has already stored the brightness value */ + schedule_work(&led->rgb->work); +} - /* RGB triplet notation is 24-bit hexadecimal */ - if (rgb > 0xFFFFFF) - return -EINVAL; +static int thingm_init_rgb(struct thingm_rgb *rgb) +{ + const int minor = ((struct hidraw *) rgb->tdev->hdev->hidraw)->minor; + int err; + + /* Register the red diode */ + snprintf(rgb->red.name, sizeof(rgb->red.name), + "thingm%d:red:led%d", minor, rgb->num); + rgb->red.ldev.name = rgb->red.name; + rgb->red.ldev.max_brightness = 255; + rgb->red.ldev.brightness_set = thingm_led_set; + rgb->red.rgb = rgb; + + err = led_classdev_register(&rgb->tdev->hdev->dev, &rgb->red.ldev); + if (err) + return err; + + /* Register the green diode */ + snprintf(rgb->green.name, sizeof(rgb->green.name), + "thingm%d:green:led%d", minor, rgb->num); + rgb->green.ldev.name = rgb->green.name; + rgb->green.ldev.max_brightness = 255; + rgb->green.ldev.brightness_set = thingm_led_set; + rgb->green.rgb = rgb; + + err = led_classdev_register(&rgb->tdev->hdev->dev, &rgb->green.ldev); + if (err) + goto unregister_red; + + /* Register the blue diode */ + snprintf(rgb->blue.name, sizeof(rgb->blue.name), + "thingm%d:blue:led%d", minor, rgb->num); + rgb->blue.ldev.name = rgb->blue.name; + rgb->blue.ldev.max_brightness = 255; + rgb->blue.ldev.brightness_set = thingm_led_set; + rgb->blue.rgb = rgb; + + err = led_classdev_register(&rgb->tdev->hdev->dev, &rgb->blue.ldev); + if (err) + goto unregister_green; + + INIT_WORK(&rgb->work, thingm_work); - data->rgb = rgb; - ret = blink1_update_color(data); + return 0; - return ret ? ret : count; -} +unregister_green: + led_classdev_unregister(&rgb->green.ldev); -static DEVICE_ATTR(rgb, S_IRUGO | S_IWUSR, blink1_show_rgb, blink1_store_rgb); +unregister_red: + led_classdev_unregister(&rgb->red.ldev); -static const struct attribute_group blink1_sysfs_group = { - .attrs = (struct attribute *[]) { - &dev_attr_rgb.attr, - NULL - }, -}; + return err; +} + +static void thingm_remove_rgb(struct thingm_rgb *rgb) +{ + flush_work(&rgb->work); + led_classdev_unregister(&rgb->red.ldev); + led_classdev_unregister(&rgb->green.ldev); + led_classdev_unregister(&rgb->blue.ldev); +} static int thingm_probe(struct hid_device *hdev, const struct hid_device_id *id) { - struct blink1_data *data; - struct led_classdev *led; - char led_name[13]; - int ret; + struct thingm_device *tdev; + int i, err; - data = devm_kzalloc(&hdev->dev, sizeof(struct blink1_data), GFP_KERNEL); - if (!data) + tdev = devm_kzalloc(&hdev->dev, sizeof(struct thingm_device), + GFP_KERNEL); + if (!tdev) return -ENOMEM; - hid_set_drvdata(hdev, data); - data->hdev = hdev; - data->rgb = 0xFFFFFF; /* set a default white color */ + tdev->hdev = hdev; + hid_set_drvdata(hdev, tdev); - ret = hid_parse(hdev); - if (ret) + err = hid_parse(hdev); + if (err) goto error; - ret = hid_hw_start(hdev, HID_CONNECT_HIDRAW); - if (ret) + err = hid_hw_start(hdev, HID_CONNECT_HIDRAW); + if (err) goto error; - /* blink(1) serial numbers range is 0x1A001000 to 0x1A002FFF */ - led = &data->led_cdev; - snprintf(led_name, sizeof(led_name), "blink1::%s", hdev->uniq + 4); - led->name = led_name; - led->brightness_set = blink1_led_set; - led->brightness_get = blink1_led_get; - ret = led_classdev_register(&hdev->dev, led); - if (ret) + mutex_init(&tdev->lock); + + err = thingm_version(tdev); + if (err) goto stop; - ret = sysfs_create_group(&led->dev->kobj, &blink1_sysfs_group); - if (ret) - goto remove_led; + hid_dbg(hdev, "firmware version: %c.%c\n", + tdev->version.major, tdev->version.minor); - return 0; + for (i = 0; i < ARRAY_SIZE(thingm_fwinfo) && !tdev->fwinfo; ++i) + if (thingm_fwinfo[i].major == tdev->version.major) + tdev->fwinfo = &thingm_fwinfo[i]; + + if (!tdev->fwinfo) { + hid_err(hdev, "unsupported firmware %c\n", tdev->version.major); + goto stop; + } + + tdev->rgb = devm_kzalloc(&hdev->dev, + sizeof(struct thingm_rgb) * tdev->fwinfo->numrgb, + GFP_KERNEL); + if (!tdev->rgb) { + err = -ENOMEM; + goto stop; + } + + for (i = 0; i < tdev->fwinfo->numrgb; ++i) { + struct thingm_rgb *rgb = tdev->rgb + i; + + rgb->tdev = tdev; + rgb->num = tdev->fwinfo->first + i; + err = thingm_init_rgb(rgb); + if (err) { + while (--i >= 0) + thingm_remove_rgb(tdev->rgb + i); + goto stop; + } + } -remove_led: - led_classdev_unregister(led); + return 0; stop: hid_hw_stop(hdev); error: - return ret; + return err; } static void thingm_remove(struct hid_device *hdev) { - struct blink1_data *data = hid_get_drvdata(hdev); - struct led_classdev *led = &data->led_cdev; + struct thingm_device *tdev = hid_get_drvdata(hdev); + int i; + + for (i = 0; i < tdev->fwinfo->numrgb; ++i) + thingm_remove_rgb(tdev->rgb + i); - sysfs_remove_group(&led->dev->kobj, &blink1_sysfs_group); - led_classdev_unregister(led); hid_hw_stop(hdev); } diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig index 72156c123033..46c7d79b6913 100644 --- a/drivers/leds/Kconfig +++ b/drivers/leds/Kconfig @@ -479,6 +479,8 @@ config LEDS_OT200 This option enables support for the LEDs on the Bachmann OT200. Say Y to enable LEDs on the Bachmann OT200. +comment "LED driver for blink(1) USB RGB LED is under Special HID drivers (HID_THINGM)" + config LEDS_BLINKM tristate "LED support for the BlinkM I2C RGB LED" depends on LEDS_CLASS -- cgit v1.2.3 From 3121b1c44d0748f0286fd05b89a76232f40d1091 Mon Sep 17 00:00:00 2001 From: Vivien Didelot Date: Mon, 14 Apr 2014 16:50:20 -0400 Subject: HID: thingm: add support for blink(1) mk2 The blink(1) mk2 is a new version of the blink(1) USB RGB LED. The new generation has 2 individually-controllable RGB chips. This patch adds support for this device to the thingm driver, which registers 3 new standard LED class instances for the second RGB chip. Note that the 'n' (set) command does not support setting a color for a single RGB chip, so it was changed to 'c' (fade) with a timeout of 0. Signed-off-by: Vivien Didelot Signed-off-by: Jiri Kosina --- drivers/hid/hid-thingm.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/hid/hid-thingm.c b/drivers/hid/hid-thingm.c index 0af0eb446636..31de890d14cf 100644 --- a/drivers/hid/hid-thingm.c +++ b/drivers/hid/hid-thingm.c @@ -23,6 +23,7 @@ /* Firmware major number of supported devices */ #define THINGM_MAJOR_MK1 '1' +#define THINGM_MAJOR_MK2 '2' struct thingm_fwinfo { char major; @@ -35,6 +36,10 @@ const struct thingm_fwinfo thingm_fwinfo[] = { .major = THINGM_MAJOR_MK1, .numrgb = 1, .first = 0, + }, { + .major = THINGM_MAJOR_MK2, + .numrgb = 2, + .first = 1, } }; @@ -117,7 +122,7 @@ static int thingm_version(struct thingm_device *tdev) static int thingm_write_color(struct thingm_rgb *rgb) { - u8 buf[REPORT_SIZE] = { REPORT_ID, 'n', 0, 0, 0, 0, 0, 0, 0 }; + u8 buf[REPORT_SIZE] = { REPORT_ID, 'c', 0, 0, 0, 0, 0, rgb->num, 0 }; buf[2] = rgb->red.ldev.brightness; buf[3] = rgb->green.ldev.brightness; -- cgit v1.2.3 From 30ece903f5470cf80971a5f2dc6924dd62d5d96c Mon Sep 17 00:00:00 2001 From: Robert Butora Date: Mon, 24 Mar 2014 19:41:38 -0300 Subject: [media] media/usb/gspca: Add support for Scopium astro webcam (0547:7303) This patch does not modify existing drivers. It adds subdriver to gspca for DTCS033 (Scopium) webcam for astrophotography. The patch adds dtcs033.c and modifies Kconfig and Makefile. Signed-off-by: Robert Butora Signed-off-by: Hans de Goede Signed-off-by: Mauro Carvalho Chehab --- drivers/media/usb/gspca/Kconfig | 10 + drivers/media/usb/gspca/Makefile | 2 + drivers/media/usb/gspca/dtcs033.c | 434 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 446 insertions(+) create mode 100644 drivers/media/usb/gspca/dtcs033.c diff --git a/drivers/media/usb/gspca/Kconfig b/drivers/media/usb/gspca/Kconfig index 4f0c6d566c85..eed10d782535 100644 --- a/drivers/media/usb/gspca/Kconfig +++ b/drivers/media/usb/gspca/Kconfig @@ -50,6 +50,16 @@ config USB_GSPCA_CPIA1 To compile this driver as a module, choose M here: the module will be called gspca_cpia1. +config USB_GSPCA_DTCS033 + tristate "DTCS033 (Scopium) USB Astro-Camera Driver" + depends on VIDEO_V4L2 && USB_GSPCA + help + Say Y here if you want support for the Scopium camera + for planetary astrophotography. + + To compile this driver as a module, choose M here: the + module will be called gspca_dtcs033. + config USB_GSPCA_ETOMS tristate "Etoms USB Camera Driver" depends on VIDEO_V4L2 && USB_GSPCA diff --git a/drivers/media/usb/gspca/Makefile b/drivers/media/usb/gspca/Makefile index 5855131ab8b6..f46975e4c82d 100644 --- a/drivers/media/usb/gspca/Makefile +++ b/drivers/media/usb/gspca/Makefile @@ -2,6 +2,7 @@ obj-$(CONFIG_USB_GSPCA) += gspca_main.o obj-$(CONFIG_USB_GSPCA_BENQ) += gspca_benq.o obj-$(CONFIG_USB_GSPCA_CONEX) += gspca_conex.o obj-$(CONFIG_USB_GSPCA_CPIA1) += gspca_cpia1.o +obj-$(CONFIG_USB_GSPCA_DTCS033) += gspca_dtcs033.o obj-$(CONFIG_USB_GSPCA_ETOMS) += gspca_etoms.o obj-$(CONFIG_USB_GSPCA_FINEPIX) += gspca_finepix.o obj-$(CONFIG_USB_GSPCA_JEILINJ) += gspca_jeilinj.o @@ -48,6 +49,7 @@ gspca_main-objs := gspca.o autogain_functions.o gspca_benq-objs := benq.o gspca_conex-objs := conex.o gspca_cpia1-objs := cpia1.o +gspca_dtcs033-objs := dtcs033.o gspca_etoms-objs := etoms.o gspca_finepix-objs := finepix.o gspca_jeilinj-objs := jeilinj.o diff --git a/drivers/media/usb/gspca/dtcs033.c b/drivers/media/usb/gspca/dtcs033.c new file mode 100644 index 000000000000..5e42c711b98d --- /dev/null +++ b/drivers/media/usb/gspca/dtcs033.c @@ -0,0 +1,434 @@ +/* + * Subdriver for Scopium astro-camera (DTCS033, 0547:7303) + * + * Copyright (C) 2014 Robert Butora (robert.butora.fi@gmail.com) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt +#define MODULE_NAME "dtcs033" +#include "gspca.h" + +MODULE_AUTHOR("Robert Butora "); +MODULE_DESCRIPTION("Scopium DTCS033 astro-cam USB Camera Driver"); +MODULE_LICENSE("GPL"); + + +/* send a usb request */ +static void reg_rw(struct gspca_dev *gspca_dev, + u8 bRequestType, u8 bRequest, + u16 wValue, u16 wIndex, u16 wLength) +{ + struct usb_device *udev = gspca_dev->dev; + int ret; + + if (gspca_dev->usb_err < 0) + return; + + ret = usb_control_msg(udev, + usb_rcvctrlpipe(udev, 0), + bRequest, + bRequestType, + wValue, wIndex, + gspca_dev->usb_buf, wLength, 500); + + if (ret < 0) { + gspca_dev->usb_err = ret; + pr_err("usb_control_msg error %d\n", ret); + } + + return; +} +/* send several usb in/out requests */ +static int reg_reqs(struct gspca_dev *gspca_dev, + const struct usb_ctrlrequest *preqs, int n_reqs) +{ + int i = 0; + const struct usb_ctrlrequest *preq; + + while ((i < n_reqs) && (gspca_dev->usb_err >= 0)) { + + preq = &preqs[i]; + + reg_rw(gspca_dev, preq->bRequestType, preq->bRequest, + preq->wValue, preq->wIndex, preq->wLength); + + if (gspca_dev->usb_err < 0) { + + PERR("usb error request no: %d / %d\n", + i, n_reqs); + } else if (preq->bRequestType & USB_DIR_IN) { + + PDEBUG(D_STREAM, + "USB IN (%d) returned[%d] %02X %02X %02X %s", + i, + preq->wLength, + gspca_dev->usb_buf[0], + gspca_dev->usb_buf[1], + gspca_dev->usb_buf[2], + preq->wLength > 3 ? "...\n" : "\n"); + } + + i++; + } + return gspca_dev->usb_err; +} + +/* -- subdriver interface implementation -- */ + +#define DT_COLS (640) +static const struct v4l2_pix_format dtcs033_mode[] = { + /* raw Bayer patterned output */ + {DT_COLS, 480, V4L2_PIX_FMT_GREY, V4L2_FIELD_NONE, + .bytesperline = DT_COLS, + .sizeimage = DT_COLS*480, + .colorspace = V4L2_COLORSPACE_SRGB, + }, + /* this mode will demosaic the Bayer pattern */ + {DT_COLS, 480, V4L2_PIX_FMT_SRGGB8, V4L2_FIELD_NONE, + .bytesperline = DT_COLS, + .sizeimage = DT_COLS*480, + .colorspace = V4L2_COLORSPACE_SRGB, + } +}; + +/* config called at probe time */ +static int sd_config(struct gspca_dev *gspca_dev, + const struct usb_device_id *id) +{ + gspca_dev->cam.cam_mode = dtcs033_mode; + gspca_dev->cam.nmodes = ARRAY_SIZE(dtcs033_mode); + + gspca_dev->cam.bulk = 1; + gspca_dev->cam.bulk_nurbs = 1; + gspca_dev->cam.bulk_size = DT_COLS*512; + + return 0; +} + +/* init called at probe and resume time */ +static int sd_init(struct gspca_dev *gspca_dev) +{ + return 0; +} + +/* start stop the camera */ +static int dtcs033_start(struct gspca_dev *gspca_dev); +static void dtcs033_stopN(struct gspca_dev *gspca_dev); + +/* intercept camera image data */ +static void dtcs033_pkt_scan(struct gspca_dev *gspca_dev, + u8 *data, /* packet data */ + int len) /* packet data length */ +{ + /* drop incomplete frames */ + if (len != DT_COLS*512) { + gspca_dev->last_packet_type = DISCARD_PACKET; + /* gspca.c: discard invalidates the whole frame. */ + return; + } + + /* forward complete frames */ + gspca_frame_add(gspca_dev, FIRST_PACKET, NULL, 0); + gspca_frame_add(gspca_dev, INTER_PACKET, + data + 16*DT_COLS, + len - 32*DT_COLS); /* skip first & last 16 lines */ + gspca_frame_add(gspca_dev, LAST_PACKET, NULL, 0); + + return; +} + +/* -- controls: exposure and gain -- */ + +static void dtcs033_setexposure(struct gspca_dev *gspca_dev, + s32 expo, s32 gain) +{ + /* gain [dB] encoding */ + u16 sGain = (u16)gain; + u16 gainVal = 224+(sGain-14)*(768-224)/(33-14); + u16 wIndex = 0x0100|(0x00FF&gainVal); + u16 wValue = (0xFF00&gainVal)>>8; + + /* exposure time [msec] encoding */ + u16 sXTime = (u16)expo; + u16 xtimeVal = (524*(150-(sXTime-1)))/150; + + const u8 bRequestType = + USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE; + const u8 bRequest = 0x18; + + reg_rw(gspca_dev, + bRequestType, bRequest, wValue, wIndex, 0); + if (gspca_dev->usb_err < 0) + PERR("usb error in setexposure(gain) sequence.\n"); + + reg_rw(gspca_dev, + bRequestType, bRequest, (xtimeVal<<4), 0x6300, 0); + if (gspca_dev->usb_err < 0) + PERR("usb error in setexposure(time) sequence.\n"); +} + +/* specific webcam descriptor */ +struct sd { + struct gspca_dev gspca_dev;/* !! must be the first item */ + + /* exposure & gain controls */ + struct { + struct v4l2_ctrl *exposure; + struct v4l2_ctrl *gain; + }; +}; + +static int sd_s_ctrl(struct v4l2_ctrl *ctrl) +{ + struct gspca_dev *gspca_dev = + container_of(ctrl->handler, + struct gspca_dev, ctrl_handler); + struct sd *sd = (struct sd *) gspca_dev; + + gspca_dev->usb_err = 0; + + if (!gspca_dev->streaming) + return 0; + + switch (ctrl->id) { + case V4L2_CID_EXPOSURE: + dtcs033_setexposure(gspca_dev, + ctrl->val, sd->gain->val); + break; + case V4L2_CID_GAIN: + dtcs033_setexposure(gspca_dev, + sd->exposure->val, ctrl->val); + break; + } + return gspca_dev->usb_err; +} + +static const struct v4l2_ctrl_ops sd_ctrl_ops = { + .s_ctrl = sd_s_ctrl, +}; + +static int dtcs033_init_controls(struct gspca_dev *gspca_dev) +{ + struct v4l2_ctrl_handler *hdl = &gspca_dev->ctrl_handler; + struct sd *sd = (struct sd *) gspca_dev; + + gspca_dev->vdev.ctrl_handler = hdl; + v4l2_ctrl_handler_init(hdl, 2); + /* min max step default */ + sd->exposure = v4l2_ctrl_new_std(hdl, &sd_ctrl_ops, + V4L2_CID_EXPOSURE, + 1, 150, 1, 75);/* [msec] */ + sd->gain = v4l2_ctrl_new_std(hdl, &sd_ctrl_ops, + V4L2_CID_GAIN, + 14, 33, 1, 24);/* [dB] */ + if (hdl->error) { + PERR("Could not initialize controls: %d\n", + hdl->error); + return hdl->error; + } + + v4l2_ctrl_cluster(2, &sd->exposure); + return 0; +} + +/* sub-driver description */ +static const struct sd_desc sd_desc = { + .name = MODULE_NAME, + .config = sd_config, + .init = sd_init, + .start = dtcs033_start, + .stopN = dtcs033_stopN, + .pkt_scan = dtcs033_pkt_scan, + .init_controls = dtcs033_init_controls, +}; + +/* -- module initialisation -- */ + +static const struct usb_device_id device_table[] = { + {USB_DEVICE(0x0547, 0x7303)}, + {} +}; +MODULE_DEVICE_TABLE(usb, device_table); + +/* device connect */ +static int sd_probe(struct usb_interface *intf, + const struct usb_device_id *id) +{ + return gspca_dev_probe(intf, id, + &sd_desc, sizeof(struct sd), + THIS_MODULE); +} + +static struct usb_driver sd_driver = { + .name = MODULE_NAME, + .id_table = device_table, + .probe = sd_probe, + .disconnect = gspca_disconnect, +#ifdef CONFIG_PM + .suspend = gspca_suspend, + .resume = gspca_resume, + .reset_resume = gspca_resume, +#endif +}; +module_usb_driver(sd_driver); + + +/* --------------------------------------------------------- + USB requests to start/stop the camera [USB 2.0 spec Ch.9]. + + bRequestType : + 0x40 = USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, + 0xC0 = USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE, +*/ +static const struct usb_ctrlrequest dtcs033_start_reqs[] = { +/* -- bRequest,wValue,wIndex,wLength */ +{ 0x40, 0x01, 0x0001, 0x000F, 0x0000 }, +{ 0x40, 0x01, 0x0000, 0x000F, 0x0000 }, +{ 0x40, 0x01, 0x0001, 0x000F, 0x0000 }, +{ 0x40, 0x18, 0x0000, 0x7F00, 0x0000 }, +{ 0x40, 0x18, 0x0000, 0x1001, 0x0000 }, +{ 0x40, 0x18, 0x0000, 0x0004, 0x0000 }, +{ 0x40, 0x18, 0x0000, 0x7F01, 0x0000 }, +{ 0x40, 0x18, 0x30E0, 0x0009, 0x0000 }, +{ 0x40, 0x18, 0x0500, 0x012C, 0x0000 }, +{ 0x40, 0x18, 0x0380, 0x0200, 0x0000 }, +{ 0x40, 0x18, 0x0000, 0x035C, 0x0000 }, +{ 0x40, 0x18, 0x05C0, 0x0438, 0x0000 }, +{ 0x40, 0x18, 0x0440, 0x0500, 0x0000 }, +{ 0x40, 0x18, 0x0000, 0x0668, 0x0000 }, +{ 0x40, 0x18, 0x0000, 0x0700, 0x0000 }, +{ 0x40, 0x18, 0x0000, 0x0800, 0x0000 }, +{ 0x40, 0x18, 0x0000, 0x0900, 0x0000 }, +{ 0x40, 0x18, 0x0000, 0x0A00, 0x0000 }, +{ 0x40, 0x18, 0x0000, 0x0B00, 0x0000 }, +{ 0x40, 0x18, 0x30E0, 0x6009, 0x0000 }, +{ 0x40, 0x18, 0x0500, 0x612C, 0x0000 }, +{ 0x40, 0x18, 0x2090, 0x6274, 0x0000 }, +{ 0x40, 0x18, 0x05C0, 0x6338, 0x0000 }, +{ 0x40, 0x18, 0x0000, 0x6400, 0x0000 }, +{ 0x40, 0x18, 0x05C0, 0x6538, 0x0000 }, +{ 0x40, 0x18, 0x0000, 0x6600, 0x0000 }, +{ 0x40, 0x18, 0x0680, 0x6744, 0x0000 }, +{ 0x40, 0x18, 0x0000, 0x6800, 0x0000 }, +{ 0x40, 0x18, 0x0000, 0x6900, 0x0000 }, +{ 0x40, 0x18, 0x0000, 0x6A00, 0x0000 }, +{ 0x40, 0x18, 0x0000, 0x6B00, 0x0000 }, +{ 0x40, 0x18, 0x0000, 0x6C00, 0x0000 }, +{ 0x40, 0x18, 0x0000, 0x6D00, 0x0000 }, +{ 0x40, 0x18, 0x0000, 0x6E00, 0x0000 }, +{ 0x40, 0x18, 0x0000, 0x808C, 0x0000 }, +{ 0x40, 0x18, 0x0010, 0x8101, 0x0000 }, +{ 0x40, 0x18, 0x30E0, 0x8200, 0x0000 }, +{ 0x40, 0x18, 0x0810, 0x832C, 0x0000 }, +{ 0x40, 0x18, 0x0680, 0x842B, 0x0000 }, +{ 0x40, 0x18, 0x0000, 0x8500, 0x0000 }, +{ 0x40, 0x18, 0x0000, 0x8600, 0x0000 }, +{ 0x40, 0x18, 0x0280, 0x8715, 0x0000 }, +{ 0x40, 0x18, 0x0000, 0x880C, 0x0000 }, +{ 0x40, 0x18, 0x0010, 0x8901, 0x0000 }, +{ 0x40, 0x18, 0x30E0, 0x8A00, 0x0000 }, +{ 0x40, 0x18, 0x0810, 0x8B2C, 0x0000 }, +{ 0x40, 0x18, 0x0680, 0x8C2B, 0x0000 }, +{ 0x40, 0x18, 0x0000, 0x8D00, 0x0000 }, +{ 0x40, 0x18, 0x0000, 0x8E00, 0x0000 }, +{ 0x40, 0x18, 0x0280, 0x8F15, 0x0000 }, +{ 0x40, 0x18, 0x0010, 0xD040, 0x0000 }, +{ 0x40, 0x18, 0x0000, 0xD100, 0x0000 }, +{ 0x40, 0x18, 0x00B0, 0xD20A, 0x0000 }, +{ 0x40, 0x18, 0x0000, 0xD300, 0x0000 }, +{ 0x40, 0x18, 0x30E2, 0xD40D, 0x0000 }, +{ 0x40, 0x18, 0x0001, 0xD5C0, 0x0000 }, +{ 0x40, 0x18, 0x00A0, 0xD60A, 0x0000 }, +{ 0x40, 0x18, 0x0000, 0xD700, 0x0000 }, +{ 0x40, 0x18, 0x0000, 0x7F00, 0x0000 }, +{ 0x40, 0x18, 0x0000, 0x1501, 0x0000 }, +{ 0x40, 0x18, 0x0001, 0x01FF, 0x0000 }, +{ 0x40, 0x18, 0x0000, 0x0200, 0x0000 }, +{ 0x40, 0x18, 0x0000, 0x0304, 0x0000 }, +{ 0x40, 0x18, 0x0000, 0x1101, 0x0000 }, +{ 0x40, 0x18, 0x0000, 0x1201, 0x0000 }, +{ 0x40, 0x18, 0x0000, 0x1300, 0x0000 }, +{ 0x40, 0x18, 0x0000, 0x1400, 0x0000 }, +{ 0x40, 0x18, 0x0000, 0x1601, 0x0000 }, +{ 0x40, 0x18, 0x0000, 0x1800, 0x0000 }, +{ 0x40, 0x18, 0x0000, 0x1900, 0x0000 }, +{ 0x40, 0x18, 0x0000, 0x1A00, 0x0000 }, +{ 0x40, 0x18, 0x2000, 0x1B00, 0x0000 }, +{ 0x40, 0x18, 0x0000, 0x1C00, 0x0000 }, +{ 0x40, 0x18, 0x0000, 0x2100, 0x0000 }, +{ 0x40, 0x18, 0x00C0, 0x228E, 0x0000 }, +{ 0x40, 0x18, 0x0000, 0x3001, 0x0000 }, +{ 0x40, 0x18, 0x0010, 0x3101, 0x0000 }, +{ 0x40, 0x18, 0x0008, 0x3301, 0x0000 }, +{ 0x40, 0x18, 0x0000, 0x3400, 0x0000 }, +{ 0x40, 0x18, 0x0012, 0x3549, 0x0000 }, +{ 0x40, 0x18, 0x0000, 0x3620, 0x0000 }, +{ 0x40, 0x18, 0x0001, 0x3700, 0x0000 }, +{ 0x40, 0x18, 0x0000, 0x4000, 0x0000 }, +{ 0x40, 0x18, 0xFFFF, 0x41FF, 0x0000 }, +{ 0x40, 0x18, 0xFFFF, 0x42FF, 0x0000 }, +{ 0x40, 0x18, 0x0000, 0x500F, 0x0000 }, +{ 0x40, 0x18, 0x2272, 0x5108, 0x0000 }, +{ 0x40, 0x18, 0x2272, 0x5208, 0x0000 }, +{ 0x40, 0x18, 0xFFFF, 0x53FF, 0x0000 }, +{ 0x40, 0x18, 0xFFFF, 0x54FF, 0x0000 }, +{ 0x40, 0x18, 0x0000, 0x6000, 0x0000 }, +{ 0x40, 0x18, 0x0000, 0x6102, 0x0000 }, +{ 0x40, 0x18, 0x0010, 0x6214, 0x0000 }, +{ 0x40, 0x18, 0x0C80, 0x6300, 0x0000 }, +{ 0x40, 0x18, 0x0000, 0x6401, 0x0000 }, +{ 0x40, 0x18, 0x0680, 0x6551, 0x0000 }, +{ 0x40, 0x18, 0xFFFF, 0x66FF, 0x0000 }, +{ 0x40, 0x18, 0x0000, 0x6702, 0x0000 }, +{ 0x40, 0x18, 0x0010, 0x6800, 0x0000 }, +{ 0x40, 0x18, 0x0000, 0x6900, 0x0000 }, +{ 0x40, 0x18, 0x0000, 0x6A00, 0x0000 }, +{ 0x40, 0x18, 0x0000, 0x6B00, 0x0000 }, +{ 0x40, 0x18, 0x0000, 0x6C00, 0x0000 }, +{ 0x40, 0x18, 0x0000, 0x6D01, 0x0000 }, +{ 0x40, 0x18, 0x0000, 0x6E00, 0x0000 }, +{ 0x40, 0x18, 0x0000, 0x6F00, 0x0000 }, +{ 0x40, 0x18, 0x0000, 0x7000, 0x0000 }, +{ 0x40, 0x18, 0x0001, 0x7118, 0x0000 }, +{ 0x40, 0x18, 0x0000, 0x2001, 0x0000 }, +{ 0x40, 0x18, 0x0000, 0x1101, 0x0000 }, +{ 0x40, 0x18, 0x0000, 0x1301, 0x0000 }, +{ 0x40, 0x18, 0x0000, 0x1300, 0x0000 }, +{ 0x40, 0x18, 0x0000, 0x1501, 0x0000 }, +{ 0xC0, 0x11, 0x0000, 0x24C0, 0x0003 }, +{ 0x40, 0x18, 0x0000, 0x3000, 0x0000 }, +{ 0x40, 0x18, 0x0000, 0x3620, 0x0000 }, +{ 0x40, 0x18, 0x0000, 0x1501, 0x0000 }, +{ 0x40, 0x18, 0x0010, 0x6300, 0x0000 }, +{ 0x40, 0x18, 0x0002, 0x01F0, 0x0000 }, +{ 0x40, 0x01, 0x0003, 0x000F, 0x0000 } +}; + +static const struct usb_ctrlrequest dtcs033_stop_reqs[] = { +/* -- bRequest,wValue,wIndex,wLength */ +{ 0x40, 0x01, 0x0001, 0x000F, 0x0000 }, +{ 0x40, 0x01, 0x0000, 0x000F, 0x0000 }, +{ 0x40, 0x18, 0x0000, 0x0003, 0x0000 } +}; +static int dtcs033_start(struct gspca_dev *gspca_dev) +{ + return reg_reqs(gspca_dev, dtcs033_start_reqs, + ARRAY_SIZE(dtcs033_start_reqs)); +} + +static void dtcs033_stopN(struct gspca_dev *gspca_dev) +{ + reg_reqs(gspca_dev, dtcs033_stop_reqs, + ARRAY_SIZE(dtcs033_stop_reqs)); + return; +} -- cgit v1.2.3 From 73679e50820123ebdedc67ebcda4562d1d6e4aba Mon Sep 17 00:00:00 2001 From: Pranith Kumar Date: Tue, 15 Apr 2014 12:05:22 -0400 Subject: compiler-intel.h: Remove duplicate definition barrier is already defined as __memory_barrier in compiler.h Remove this unnecessary redefinition. Signed-off-by: Pranith Kumar Link: http://lkml.kernel.org/r/CAJhHMCAnYPy0%2BqD-1KBnJPLt3XgAjdR12j%2BySSnPgmZcpbE7HQ@mail.gmail.com Signed-off-by: H. Peter Anvin --- include/linux/compiler-intel.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/include/linux/compiler-intel.h b/include/linux/compiler-intel.h index 5529c5239421..ba147a1727e6 100644 --- a/include/linux/compiler-intel.h +++ b/include/linux/compiler-intel.h @@ -13,12 +13,9 @@ /* Intel ECC compiler doesn't support gcc specific asm stmts. * It uses intrinsics to do the equivalent things. */ -#undef barrier #undef RELOC_HIDE #undef OPTIMIZER_HIDE_VAR -#define barrier() __memory_barrier() - #define RELOC_HIDE(ptr, off) \ ({ unsigned long __ptr; \ __ptr = (unsigned long) (ptr); \ -- cgit v1.2.3 From b9bfe1bca8ecccf3d1f015fd18fad52ed95f8033 Mon Sep 17 00:00:00 2001 From: Lucas Stach Date: Mon, 7 Apr 2014 11:30:20 +0200 Subject: PCI: rcar: Use new OF interrupt mapping when possible Use new OF interrupt mapping (of_irq_parse_and_map_pci()) when possible. This is the recommended method of doing the IRQ mapping. For old devicetrees we fall back to the previous practice. This allows interrupts to be remapped across bridges. Signed-off-by: Lucas Stach Signed-off-by: Bjorn Helgaas Acked-by: Simon Horman --- drivers/pci/host/pci-rcar-gen2.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/pci/host/pci-rcar-gen2.c b/drivers/pci/host/pci-rcar-gen2.c index fd3e3ab56509..4fe349dcaf59 100644 --- a/drivers/pci/host/pci-rcar-gen2.c +++ b/drivers/pci/host/pci-rcar-gen2.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -180,8 +181,13 @@ static int rcar_pci_map_irq(const struct pci_dev *dev, u8 slot, u8 pin) { struct pci_sys_data *sys = dev->bus->sysdata; struct rcar_pci_priv *priv = sys->private_data; + int irq; + + irq = of_irq_parse_and_map_pci(dev, slot, pin); + if (!irq) + irq = priv->irq; - return priv->irq; + return irq; } #ifdef CONFIG_PCI_DEBUG -- cgit v1.2.3 From 597baaff65b68d58ee035d556ddd6e2387c63c6d Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:43:20 +0200 Subject: staging: rtl8723au: Fix buffer overflow in rtw_get_wfd_ie() Add bounds checking to not allow WFD Information Elements larger than 128, and make sure we use the correct buffer size MAX_WFD_IE_LEN instea of hardcoding the size. This also simplifies rtw_get_wfd_ie() by using the cfg80211 infrastructure. Reported-by: Dan Carpenter Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_ieee80211.c | 46 +++++++------------------- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 2 +- drivers/staging/rtl8723au/core/rtw_p2p.c | 4 +-- drivers/staging/rtl8723au/core/rtw_wlan_util.c | 2 +- 4 files changed, 16 insertions(+), 38 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_ieee80211.c b/drivers/staging/rtl8723au/core/rtw_ieee80211.c index 780631fd3b6d..a48ab25a7d8a 100644 --- a/drivers/staging/rtl8723au/core/rtw_ieee80211.c +++ b/drivers/staging/rtl8723au/core/rtw_ieee80211.c @@ -1496,45 +1496,23 @@ void rtw_wlan_bssid_ex_remove_p2p_attr23a(struct wlan_bssid_ex *bss_ex, u8 attr_ int rtw_get_wfd_ie(u8 *in_ie, int in_len, u8 *wfd_ie, uint *wfd_ielen) { int match; - uint cnt = 0; - u8 eid, wfd_oui[4] = {0x50, 0x6F, 0x9A, 0x0A}; + const u8 *ie; - match = false; + match = 0; - if (in_len < 0) { + if (in_len < 0) return match; - } - - while (cnt < in_len) - { - eid = in_ie[cnt]; - if ((eid == _VENDOR_SPECIFIC_IE_) && - !memcmp(&in_ie[cnt+2], wfd_oui, 4)) { - if (wfd_ie != NULL) { - memcpy(wfd_ie, &in_ie[cnt], in_ie[cnt + 1] + 2); - - } else { - if (wfd_ielen != NULL) { - *wfd_ielen = 0; - } - } - - if (wfd_ielen != NULL) { - *wfd_ielen = in_ie[cnt + 1] + 2; - } - - cnt += in_ie[cnt + 1] + 2; - - match = true; - break; - } else { - cnt += in_ie[cnt + 1] +2; /* goto next */ - } - } + ie = cfg80211_find_vendor_ie(0x506F9A, 0x0A, in_ie, in_len); + if (ie && (ie[1] <= (MAX_WFD_IE_LEN - 2))) { + if (wfd_ie) { + *wfd_ielen = ie[1] + 2; + memcpy(wfd_ie, ie, ie[1] + 2); + } else + if (wfd_ielen) + *wfd_ielen = 0; - if (match == true) { - match = cnt; + match = 1; } return match; diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index be593989aec7..07493bc70539 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -1280,7 +1280,7 @@ unsigned int OnAssocReq23a(struct rtw_adapter *padapter, struct recv_frame *prec u8 p2p_status_code = P2P_STATUS_SUCCESS; u8 *p2pie; u32 p2pielen = 0; - u8 wfd_ie[ 128 ] = { 0x00 }; + u8 wfd_ie[MAX_WFD_IE_LEN] = { 0x00 }; u32 wfd_ielen = 0; #endif /* CONFIG_8723AU_P2P */ diff --git a/drivers/staging/rtl8723au/core/rtw_p2p.c b/drivers/staging/rtl8723au/core/rtw_p2p.c index ba851cf4f992..a3bf031ee738 100644 --- a/drivers/staging/rtl8723au/core/rtw_p2p.c +++ b/drivers/staging/rtl8723au/core/rtw_p2p.c @@ -2536,7 +2536,7 @@ u8 process_p2p_group_negotation_req23a(struct wifidirect_info *pwdinfo, u8 *pfra u16 wps_devicepassword_id = 0x0000; uint wps_devicepassword_id_len = 0; #ifdef CONFIG_8723AU_P2P - u8 wfd_ie[ 128 ] = { 0x00 }; + u8 wfd_ie[MAX_WFD_IE_LEN] = { 0x00 }; u32 wfd_ielen = 0; #endif /* CONFIG_8723AU_P2P */ @@ -2742,7 +2742,7 @@ u8 process_p2p_group_negotation_resp23a(struct wifidirect_info *pwdinfo, u8 *pfr u32 ies_len; u8 * p2p_ie; #ifdef CONFIG_8723AU_P2P - u8 wfd_ie[ 128 ] = { 0x00 }; + u8 wfd_ie[MAX_WFD_IE_LEN] = { 0x00 }; u32 wfd_ielen = 0; #endif /* CONFIG_8723AU_P2P */ diff --git a/drivers/staging/rtl8723au/core/rtw_wlan_util.c b/drivers/staging/rtl8723au/core/rtw_wlan_util.c index e364d7afc08d..f54021ceba5c 100644 --- a/drivers/staging/rtl8723au/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8723au/core/rtw_wlan_util.c @@ -502,7 +502,7 @@ void flush_all_cam_entry23a(struct rtw_adapter *padapter) int WFD_info_handler(struct rtw_adapter *padapter, struct ndis_802_11_var_ies * pIE) { struct wifidirect_info *pwdinfo; - u8 wfd_ie[128] = {0x00}; + u8 wfd_ie[MAX_WFD_IE_LEN] = {0x00}; u32 wfd_ielen = 0; pwdinfo = &padapter->wdinfo; -- cgit v1.2.3 From 9300c94b8a817f3b96cf00d2bdeed6751c2744d8 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:43:21 +0200 Subject: staging: rtl8723au: Remove duplicate #defines for WLAN_EID_VENDOR_SPECIFIC Lets not keep one local copy ... no lets keep two ... no lets keep three! Rip them all out and use the kernel provided one. Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_ap.c | 6 +-- drivers/staging/rtl8723au/core/rtw_ieee80211.c | 22 +++++---- drivers/staging/rtl8723au/core/rtw_mlme.c | 9 ++-- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 51 +++++++++++--------- drivers/staging/rtl8723au/core/rtw_p2p.c | 58 +++++++++++++++-------- drivers/staging/rtl8723au/core/rtw_wlan_util.c | 8 ++-- drivers/staging/rtl8723au/include/rtw_security.h | 1 - drivers/staging/rtl8723au/include/wifi.h | 2 - drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c | 16 +++---- 9 files changed, 99 insertions(+), 74 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_ap.c b/drivers/staging/rtl8723au/core/rtw_ap.c index 131d787dac78..fc8b7b2c4443 100644 --- a/drivers/staging/rtl8723au/core/rtw_ap.c +++ b/drivers/staging/rtl8723au/core/rtw_ap.c @@ -927,7 +927,7 @@ int rtw_check_beacon_data23a(struct rtw_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_ie23a(p, _SSN_IE_1_, &ie_len, + p = rtw_get_ie23a(p, WLAN_EID_VENDOR_SPECIFIC, &ie_len, (pbss_network->IELength - _BEACON_IE_OFFSET_ - (ie_len + 2))); if ((p) && (!memcmp(p+2, OUI1, 4))) { @@ -955,7 +955,7 @@ int rtw_check_beacon_data23a(struct rtw_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_ie23a(p, _VENDOR_SPECIFIC_IE_, &ie_len, + p = rtw_get_ie23a(p, WLAN_EID_VENDOR_SPECIFIC, &ie_len, (pbss_network->IELength - _BEACON_IE_OFFSET_ - (ie_len + 2))); if ((p) && !memcmp(p+2, WMM_PARA_IE, 6)) { @@ -1374,7 +1374,7 @@ void update_beacon23a(struct rtw_adapter *padapter, u8 ie_id, u8 *oui, u8 tx) update_bcn_htinfo_ie(padapter); break; - case _VENDOR_SPECIFIC_IE_: + case WLAN_EID_VENDOR_SPECIFIC: update_bcn_vendor_spec_ie(padapter, oui); break; diff --git a/drivers/staging/rtl8723au/core/rtw_ieee80211.c b/drivers/staging/rtl8723au/core/rtw_ieee80211.c index a48ab25a7d8a..b01dd008e913 100644 --- a/drivers/staging/rtl8723au/core/rtw_ieee80211.c +++ b/drivers/staging/rtl8723au/core/rtw_ieee80211.c @@ -469,7 +469,8 @@ unsigned char *rtw_get_wpa_ie23a(unsigned char *pie, int *wpa_ie_len, int limit) int limit_new = limit; while(1) { - pbuf = rtw_get_ie23a(pbuf, _WPA_IE_ID_, &len, limit_new); + pbuf = rtw_get_ie23a(pbuf, WLAN_EID_VENDOR_SPECIFIC, + &len, limit_new); if (pbuf) { /* check if oui matches... */ @@ -557,7 +558,8 @@ int rtw_parse_wpa_ie23a(u8* wpa_ie, int wpa_ie_len, int *group_cipher, int *pair 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_OUI23A_TYPE, WPA_SELECTOR_LEN)) { return _FAIL; } @@ -719,7 +721,7 @@ int rtw_get_sec_ie23a(u8 *in_ie, uint in_len, u8 *rsn_ie, u16 *rsn_len, while(cnt < in_len) { authmode = in_ie[cnt]; - if ((authmode == _WPA_IE_ID_) && + 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_ie23a: sec_idx =%d " @@ -788,7 +790,8 @@ u8 rtw_is_wps_ie23a(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_8723A("==> found WPS_IE.....\n"); */ *wps_ielen = ie_ptr[1] + 2; match = true; @@ -824,7 +827,8 @@ u8 *rtw_get_wps_ie23a(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) @@ -866,7 +870,7 @@ u8 *rtw_get_wps_attr23a(u8 *wps_ie, uint wps_ielen, u16 target_attr_id, 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; } @@ -1305,7 +1309,7 @@ u8 *rtw_get_p2p_ie23a(u8 *in_ie, int in_len, u8 *p2p_ie, uint *p2p_ielen) dump_stack(); return NULL; } - if ((eid == _VENDOR_SPECIFIC_IE_) && + if ((eid == WLAN_EID_VENDOR_SPECIFIC) && !memcmp(&in_ie[cnt + 2], p2p_oui, 4)) { p2p_ie_ptr = in_ie + cnt; @@ -1351,7 +1355,7 @@ u8 *rtw_get_p2p_attr23a(u8 *p2p_ie, uint p2p_ielen, u8 target_attr_id, if (len_attr) *len_attr = 0; - if (!p2p_ie || (p2p_ie[0] != _VENDOR_SPECIFIC_IE_) || + if (!p2p_ie || (p2p_ie[0] != WLAN_EID_VENDOR_SPECIFIC) || memcmp(p2p_ie + 2, p2p_oui, 4)) { return attr_ptr; } @@ -1531,7 +1535,7 @@ int rtw_get_wfd_attr_content(u8 *wfd_ie, uint wfd_ielen, u8 target_attr_id, match = false; - if ((wfd_ie[0] != _VENDOR_SPECIFIC_IE_) || + if ((wfd_ie[0] != WLAN_EID_VENDOR_SPECIFIC) || memcmp(wfd_ie + 2, wfd_oui, 4)) { return match; } diff --git a/drivers/staging/rtl8723au/core/rtw_mlme.c b/drivers/staging/rtl8723au/core/rtw_mlme.c index 1060a9fab64f..d94cff681ad4 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme.c @@ -2014,7 +2014,7 @@ _rtw_report_sec_ie(struct rtw_adapter *adapter, u8 authmode, u8 *sec_ie) ("+_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)); @@ -2064,7 +2064,7 @@ int rtw_restruct_sec_ie23a(struct rtw_adapter *adapter, u8 *in_ie, u8 *out_ie, 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_; @@ -2074,7 +2074,8 @@ int rtw_restruct_sec_ie23a(struct rtw_adapter *adapter, u8 *in_ie, u8 *out_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); @@ -2242,7 +2243,7 @@ unsigned int rtw_restructure_ht_ie23a(struct rtw_adapter *padapter, u8 *in_ie, if (pqospriv->qos_option == 0) { out_len = *pout_len; pframe = rtw_set_ie23a(out_ie + out_len, - _VENDOR_SPECIFIC_IE_, + WLAN_EID_VENDOR_SPECIFIC, _WMM_IE_Length_, WMM_IE, pout_len); pqospriv->qos_option = 1; diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index 07493bc70539..423f3956d063 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -1543,7 +1543,10 @@ unsigned int OnAssocReq23a(struct rtw_adapter *padapter, struct recv_frame *prec p = pframe + sizeof(struct ieee80211_hdr_3addr) + ie_offset; ie_len = 0; for (;;) { - p = rtw_get_ie23a(p, _VENDOR_SPECIFIC_IE_, &ie_len, pkt_len - sizeof(struct ieee80211_hdr_3addr) - ie_offset); + p = rtw_get_ie23a(p, WLAN_EID_VENDOR_SPECIFIC, &ie_len, + pkt_len - + sizeof(struct ieee80211_hdr_3addr) - + ie_offset); if (p != NULL) { if (!memcmp(p+2, WMM_IE, 6)) { @@ -1826,7 +1829,7 @@ unsigned int OnAssocRsp23a(struct rtw_adapter *padapter, struct recv_frame *prec switch (pIE->ElementID) { - case _VENDOR_SPECIFIC_IE_: + case WLAN_EID_VENDOR_SPECIFIC: if (!memcmp(pIE->data, WMM_PARA_OUI23A, 6))/* WMM */ WMM_param_handler23a(padapter, pIE); #if defined(CONFIG_8723AU_P2P) @@ -2245,7 +2248,8 @@ void issue_p2p_GO_request23a(struct rtw_adapter *padapter, u8* raddr) wpsielen += 2; - pframe = rtw_set_ie23a(pframe, _VENDOR_SPECIFIC_IE_, wpsielen, (unsigned char *) wpsie, &pattrib->pktlen); + pframe = rtw_set_ie23a(pframe, WLAN_EID_VENDOR_SPECIFIC, wpsielen, + (unsigned char *) wpsie, &pattrib->pktlen); /* P2P IE Section. */ @@ -2497,7 +2501,8 @@ void issue_p2p_GO_request23a(struct rtw_adapter *padapter, u8* raddr) /* Channel Number */ p2pie[p2pielen++] = pwdinfo->operating_channel; /* operating channel number */ - pframe = rtw_set_ie23a(pframe, _VENDOR_SPECIFIC_IE_, p2pielen, (unsigned char *) p2pie, &pattrib->pktlen); + pframe = rtw_set_ie23a(pframe, WLAN_EID_VENDOR_SPECIFIC, p2pielen, + (unsigned char *) p2pie, &pattrib->pktlen); #ifdef CONFIG_8723AU_P2P wfdielen = build_nego_req_wfd_ie(pwdinfo, pframe); @@ -2641,7 +2646,7 @@ static void issue_p2p_GO_response(struct rtw_adapter *padapter, u8* raddr, u8* f } } - pframe = rtw_set_ie23a(pframe, _VENDOR_SPECIFIC_IE_, wpsielen, + pframe = rtw_set_ie23a(pframe, WLAN_EID_VENDOR_SPECIFIC, wpsielen, (unsigned char *) wpsie, &pattrib->pktlen); /* P2P IE Section. */ @@ -2910,7 +2915,7 @@ static void issue_p2p_GO_response(struct rtw_adapter *padapter, u8* raddr, u8* f } - pframe = rtw_set_ie23a(pframe, _VENDOR_SPECIFIC_IE_, p2pielen, + pframe = rtw_set_ie23a(pframe, WLAN_EID_VENDOR_SPECIFIC, p2pielen, (unsigned char *) p2pie, &pattrib->pktlen); #ifdef CONFIG_8723AU_P2P @@ -3115,7 +3120,7 @@ static void issue_p2p_GO_confirm(struct rtw_adapter *padapter, u8* raddr, p2pielen += pwdinfo->nego_ssidlen; } - pframe = rtw_set_ie23a(pframe, _VENDOR_SPECIFIC_IE_, p2pielen, + pframe = rtw_set_ie23a(pframe, WLAN_EID_VENDOR_SPECIFIC, p2pielen, (unsigned char *)p2pie, &pattrib->pktlen); #ifdef CONFIG_8723AU_P2P @@ -3393,7 +3398,7 @@ void issue_p2p_invitation_request23a(struct rtw_adapter *padapter, u8* raddr) pwdinfo->device_name_len); p2pielen += pwdinfo->device_name_len; - pframe = rtw_set_ie23a(pframe, _VENDOR_SPECIFIC_IE_, p2pielen, + pframe = rtw_set_ie23a(pframe, WLAN_EID_VENDOR_SPECIFIC, p2pielen, (unsigned char *) p2pie, &pattrib->pktlen); #ifdef CONFIG_8723AU_P2P @@ -3612,7 +3617,7 @@ void issue_p2p_invitation_response23a(struct rtw_adapter *padapter, u8 *raddr, } } - pframe = rtw_set_ie23a(pframe, _VENDOR_SPECIFIC_IE_, p2pielen, + pframe = rtw_set_ie23a(pframe, WLAN_EID_VENDOR_SPECIFIC, p2pielen, (unsigned char *)p2pie, &pattrib->pktlen); #ifdef CONFIG_8723AU_P2P @@ -3721,7 +3726,7 @@ void issue_p2p_provision_request23a(struct rtw_adapter *padapter, u8 *pssid, *(u16*) (wpsie + wpsielen) = cpu_to_be16(pwdinfo->tx_prov_disc_info.wps_config_method_request); wpsielen += 2; - pframe = rtw_set_ie23a(pframe, _VENDOR_SPECIFIC_IE_, wpsielen, + pframe = rtw_set_ie23a(pframe, WLAN_EID_VENDOR_SPECIFIC, wpsielen, (unsigned char *) wpsie, &pattrib->pktlen); #ifdef CONFIG_8723AU_P2P @@ -4047,8 +4052,8 @@ void issue_probersp23a_p2p23a(struct rtw_adapter *padapter, unsigned char *da) cpu_to_be16(pwdinfo->supported_wps_cm); wpsielen += 2; - pframe = rtw_set_ie23a(pframe, _VENDOR_SPECIFIC_IE_, wpsielen, - (unsigned char *)wpsie, + pframe = rtw_set_ie23a(pframe, WLAN_EID_VENDOR_SPECIFIC, + wpsielen, (unsigned char *)wpsie, &pattrib->pktlen); p2pielen = build_probe_resp_p2p_ie23a(pwdinfo, pframe); @@ -4283,8 +4288,8 @@ static int _issue23a_probereq_p2p(struct rtw_adapter *padapter, u8 *da, cpu_to_be16(WPS_DPID_REGISTRAR_SPEC); wpsielen += 2; - pframe = rtw_set_ie23a(pframe, _VENDOR_SPECIFIC_IE_, wpsielen, - (unsigned char *)wpsie, + pframe = rtw_set_ie23a(pframe, WLAN_EID_VENDOR_SPECIFIC, + wpsielen, (unsigned char *)wpsie, &pattrib->pktlen); /* P2P OUI */ @@ -4393,8 +4398,8 @@ static int _issue23a_probereq_p2p(struct rtw_adapter *padapter, u8 *da, p2pie[p2pielen++] = pwdinfo->operating_channel; } - pframe = rtw_set_ie23a(pframe, _VENDOR_SPECIFIC_IE_, p2pielen, - (unsigned char *)p2pie, + pframe = rtw_set_ie23a(pframe, WLAN_EID_VENDOR_SPECIFIC, + p2pielen, (unsigned char *)p2pie, &pattrib->pktlen); if (pmlmepriv->wps_probe_req_ie) { @@ -6239,7 +6244,7 @@ void issue_asocrsp23a(struct rtw_adapter *padapter, unsigned short status, 0x01, 0x01}; for (pbuf = ie + _BEACON_IE_OFFSET_; ; pbuf += (ie_len + 2)) { - pbuf = rtw_get_ie23a(pbuf, _VENDOR_SPECIFIC_IE_, + pbuf = rtw_get_ie23a(pbuf, WLAN_EID_VENDOR_SPECIFIC, &ie_len, (pnetwork->IELength - _BEACON_IE_OFFSET_ - (ie_len + 2))); @@ -6257,7 +6262,7 @@ void issue_asocrsp23a(struct rtw_adapter *padapter, unsigned short status, } if (pmlmeinfo->assoc_AP_vendor == HT_IOT_PEER_REALTEK) { - pframe = rtw_set_ie23a(pframe, _VENDOR_SPECIFIC_IE_, 6, + pframe = rtw_set_ie23a(pframe, WLAN_EID_VENDOR_SPECIFIC, 6, REALTEK_96B_IE23A, &pattrib->pktlen); } @@ -6513,7 +6518,7 @@ void issue_assocreq23a(struct rtw_adapter *padapter) switch (pIE->ElementID) { - case _VENDOR_SPECIFIC_IE_: + case WLAN_EID_VENDOR_SPECIFIC: if (!memcmp(pIE->data, RTW_WPA_OUI23A, 4) || !memcmp(pIE->data, WMM_OUI23A, 4) || !memcmp(pIE->data, WPS_OUI23A, 4)) { @@ -6526,7 +6531,7 @@ void issue_assocreq23a(struct rtw_adapter *padapter) pIE->Length = 14; } pframe = rtw_set_ie23a(pframe, - _VENDOR_SPECIFIC_IE_, + WLAN_EID_VENDOR_SPECIFIC, pIE->Length, pIE->data, &pattrib->pktlen); } @@ -6540,7 +6545,7 @@ void issue_assocreq23a(struct rtw_adapter *padapter) } if (pmlmeinfo->assoc_AP_vendor == HT_IOT_PEER_REALTEK) - pframe = rtw_set_ie23a(pframe, _VENDOR_SPECIFIC_IE_, 6, + pframe = rtw_set_ie23a(pframe, WLAN_EID_VENDOR_SPECIFIC, 6, REALTEK_96B_IE23A, &pattrib->pktlen); #ifdef CONFIG_8723AU_P2P @@ -6704,7 +6709,7 @@ void issue_assocreq23a(struct rtw_adapter *padapter) ETH_ALEN); /* P2P Interface Address List */ p2pielen += ETH_ALEN; - pframe = rtw_set_ie23a(pframe, _VENDOR_SPECIFIC_IE_, + pframe = rtw_set_ie23a(pframe, WLAN_EID_VENDOR_SPECIFIC, p2pielen, (unsigned char *)p2pie, &pattrib->pktlen); @@ -9300,7 +9305,7 @@ u8 join_cmd_hdl23a(struct rtw_adapter *padapter, u8 *pbuf) switch (pIE->ElementID) { - case _VENDOR_SPECIFIC_IE_:/* Get WMM IE. */ + case WLAN_EID_VENDOR_SPECIFIC:/* Get WMM IE. */ if (!memcmp(pIE->data, WMM_OUI23A, 4)) pmlmeinfo->WMM_enable = 1; break; diff --git a/drivers/staging/rtl8723au/core/rtw_p2p.c b/drivers/staging/rtl8723au/core/rtw_p2p.c index a3bf031ee738..22753e34848e 100644 --- a/drivers/staging/rtl8723au/core/rtw_p2p.c +++ b/drivers/staging/rtl8723au/core/rtw_p2p.c @@ -256,7 +256,8 @@ static void issue_p2p_devdisc_resp(struct wifidirect_info *pwdinfo, u8 *da, u8 s /* P2P_ATTR_STATUS */ p2pielen += rtw_set_p2p_attr_content23a(&p2pie[p2pielen], P2P_ATTR_STATUS, 1, &status); - pframe = rtw_set_ie23a(pframe, _VENDOR_SPECIFIC_IE_, p2pielen, p2pie, &pattrib->pktlen); + pframe = rtw_set_ie23a(pframe, WLAN_EID_VENDOR_SPECIFIC, p2pielen, + p2pie, &pattrib->pktlen); pattrib->last_txcmdsz = pattrib->pktlen; @@ -340,7 +341,8 @@ static void issue_p2p_provision_resp(struct wifidirect_info *pwdinfo, u8* raddr, put_unaligned_be16(config_method, wpsie + wpsielen); wpsielen += 2; - pframe = rtw_set_ie23a(pframe, _VENDOR_SPECIFIC_IE_, wpsielen, (unsigned char *) wpsie, &pattrib->pktlen); + pframe = rtw_set_ie23a(pframe, WLAN_EID_VENDOR_SPECIFIC, wpsielen, + (unsigned char *) wpsie, &pattrib->pktlen); #ifdef CONFIG_8723AU_P2P wfdielen = build_provdisc_resp_wfd_ie(pwdinfo, pframe); @@ -428,8 +430,8 @@ static void issue_p2p_presence_resp(struct wifidirect_info *pwdinfo, u8 *da, u8 p2pielen += rtw_set_p2p_attr_content23a(&p2pie[p2pielen], P2P_ATTR_NOA, 2, noa_attr_content); - pframe = rtw_set_ie23a(pframe, _VENDOR_SPECIFIC_IE_, p2pielen, p2pie, - &pattrib->pktlen); + pframe = rtw_set_ie23a(pframe, WLAN_EID_VENDOR_SPECIFIC, p2pielen, + p2pie, &pattrib->pktlen); pattrib->last_txcmdsz = pattrib->pktlen; @@ -481,7 +483,8 @@ u32 build_beacon_p2p_ie23a(struct wifidirect_info *pwdinfo, u8 *pbuf) /* go_add_noa_attr(pwdinfo); */ - pbuf = rtw_set_ie23a(pbuf, _VENDOR_SPECIFIC_IE_, p2pielen, (unsigned char *) p2pie, &len); + pbuf = rtw_set_ie23a(pbuf, WLAN_EID_VENDOR_SPECIFIC, p2pielen, + (unsigned char *) p2pie, &len); return len; } @@ -602,7 +605,8 @@ u32 build_beacon_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf) wfdie[ wfdielen++ ] = 0; wfdie[ wfdielen++ ] = 0; - pbuf = rtw_set_ie23a(pbuf, _VENDOR_SPECIFIC_IE_, wfdielen, (unsigned char *) wfdie, &len); + pbuf = rtw_set_ie23a(pbuf, WLAN_EID_VENDOR_SPECIFIC, wfdielen, + (unsigned char *) wfdie, &len); return len; } @@ -713,7 +717,8 @@ u32 build_probe_req_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf) wfdie[ wfdielen++ ] = 0; wfdie[ wfdielen++ ] = 0; - pbuf = rtw_set_ie23a(pbuf, _VENDOR_SPECIFIC_IE_, wfdielen, (unsigned char *) wfdie, &len); + pbuf = rtw_set_ie23a(pbuf, WLAN_EID_VENDOR_SPECIFIC, wfdielen, + (unsigned char *) wfdie, &len); return len; } @@ -900,7 +905,8 @@ u32 build_probe_resp_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf, u8 tunnel } - pbuf = rtw_set_ie23a(pbuf, _VENDOR_SPECIFIC_IE_, wfdielen, (unsigned char *) wfdie, &len); + pbuf = rtw_set_ie23a(pbuf, WLAN_EID_VENDOR_SPECIFIC, wfdielen, + (unsigned char *) wfdie, &len); return len; } @@ -1007,7 +1013,8 @@ u32 build_assoc_req_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf) wfdie[ wfdielen++ ] = 0; wfdie[ wfdielen++ ] = 0; - pbuf = rtw_set_ie23a(pbuf, _VENDOR_SPECIFIC_IE_, wfdielen, (unsigned char *) wfdie, &len); + pbuf = rtw_set_ie23a(pbuf, WLAN_EID_VENDOR_SPECIFIC, wfdielen, + (unsigned char *) wfdie, &len); return len; } @@ -1105,7 +1112,8 @@ u32 build_assoc_resp_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf) wfdie[ wfdielen++ ] = 0; wfdie[ wfdielen++ ] = 0; - pbuf = rtw_set_ie23a(pbuf, _VENDOR_SPECIFIC_IE_, wfdielen, (unsigned char *) wfdie, &len); + pbuf = rtw_set_ie23a(pbuf, WLAN_EID_VENDOR_SPECIFIC, wfdielen, + (unsigned char *) wfdie, &len); return len; } @@ -1203,7 +1211,8 @@ u32 build_nego_req_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf) wfdie[ wfdielen++ ] = 0; wfdie[ wfdielen++ ] = 0; - pbuf = rtw_set_ie23a(pbuf, _VENDOR_SPECIFIC_IE_, wfdielen, (unsigned char *) wfdie, &len); + pbuf = rtw_set_ie23a(pbuf, WLAN_EID_VENDOR_SPECIFIC, wfdielen, + (unsigned char *) wfdie, &len); return len; } @@ -1301,7 +1310,8 @@ u32 build_nego_resp_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf) wfdie[ wfdielen++ ] = 0; wfdie[ wfdielen++ ] = 0; - pbuf = rtw_set_ie23a(pbuf, _VENDOR_SPECIFIC_IE_, wfdielen, (unsigned char *) wfdie, &len); + pbuf = rtw_set_ie23a(pbuf, WLAN_EID_VENDOR_SPECIFIC, wfdielen, + (unsigned char *) wfdie, &len); return len; } @@ -1398,7 +1408,8 @@ u32 build_nego_confirm_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf) wfdie[ wfdielen++ ] = 0; wfdie[ wfdielen++ ] = 0; - pbuf = rtw_set_ie23a(pbuf, _VENDOR_SPECIFIC_IE_, wfdielen, (unsigned char *) wfdie, &len); + pbuf = rtw_set_ie23a(pbuf, WLAN_EID_VENDOR_SPECIFIC, wfdielen, + (unsigned char *) wfdie, &len); return len; } @@ -1511,7 +1522,8 @@ u32 build_invitation_req_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf) } - pbuf = rtw_set_ie23a(pbuf, _VENDOR_SPECIFIC_IE_, wfdielen, (unsigned char *) wfdie, &len); + pbuf = rtw_set_ie23a(pbuf, WLAN_EID_VENDOR_SPECIFIC, wfdielen, + (unsigned char *) wfdie, &len); return len; } @@ -1624,7 +1636,8 @@ u32 build_invitation_resp_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf) } - pbuf = rtw_set_ie23a(pbuf, _VENDOR_SPECIFIC_IE_, wfdielen, (unsigned char *) wfdie, &len); + pbuf = rtw_set_ie23a(pbuf, WLAN_EID_VENDOR_SPECIFIC, wfdielen, + (unsigned char *) wfdie, &len); return len; } @@ -1722,7 +1735,8 @@ u32 build_provdisc_req_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf) wfdie[ wfdielen++ ] = 0; wfdie[ wfdielen++ ] = 0; - pbuf = rtw_set_ie23a(pbuf, _VENDOR_SPECIFIC_IE_, wfdielen, (unsigned char *) wfdie, &len); + pbuf = rtw_set_ie23a(pbuf, WLAN_EID_VENDOR_SPECIFIC, wfdielen, + (unsigned char *) wfdie, &len); return len; } @@ -1820,7 +1834,8 @@ u32 build_provdisc_resp_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf) wfdie[ wfdielen++ ] = 0; wfdie[ wfdielen++ ] = 0; - pbuf = rtw_set_ie23a(pbuf, _VENDOR_SPECIFIC_IE_, wfdielen, (unsigned char *) wfdie, &len); + pbuf = rtw_set_ie23a(pbuf, WLAN_EID_VENDOR_SPECIFIC, wfdielen, + (unsigned char *) wfdie, &len); return len; } @@ -1973,7 +1988,8 @@ u32 build_probe_resp_p2p_ie23a(struct wifidirect_info *pwdinfo, u8 *pbuf) p2pielen += go_add_group_info_attr(pwdinfo, p2pie + p2pielen); } - pbuf = rtw_set_ie23a(pbuf, _VENDOR_SPECIFIC_IE_, p2pielen, (unsigned char *) p2pie, &len); + pbuf = rtw_set_ie23a(pbuf, WLAN_EID_VENDOR_SPECIFIC, p2pielen, + (unsigned char *) p2pie, &len); return len; } @@ -2103,7 +2119,8 @@ u32 build_prov_disc_request_p2p_ie23a(struct wifidirect_info *pwdinfo, u8 *pbuf, } - pbuf = rtw_set_ie23a(pbuf, _VENDOR_SPECIFIC_IE_, p2pielen, (unsigned char *) p2pie, &len); + pbuf = rtw_set_ie23a(pbuf, WLAN_EID_VENDOR_SPECIFIC, p2pielen, + (unsigned char *) p2pie, &len); return len; } @@ -2132,7 +2149,8 @@ u32 build_assoc_resp_p2p_ie23a(struct wifidirect_info *pwdinfo, u8 *pbuf, u8 sta /* Length: */ /* Value: */ - pbuf = rtw_set_ie23a(pbuf, _VENDOR_SPECIFIC_IE_, p2pielen, (unsigned char *) p2pie, &len); + pbuf = rtw_set_ie23a(pbuf, WLAN_EID_VENDOR_SPECIFIC, p2pielen, + (unsigned char *) p2pie, &len); return len; } diff --git a/drivers/staging/rtl8723au/core/rtw_wlan_util.c b/drivers/staging/rtl8723au/core/rtw_wlan_util.c index f54021ceba5c..8f0e79e9664f 100644 --- a/drivers/staging/rtl8723au/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8723au/core/rtw_wlan_util.c @@ -1130,7 +1130,7 @@ unsigned int is_ap_in_tkip23a(struct rtw_adapter *padapter) pIE = (struct ndis_802_11_var_ies *)(pmlmeinfo->network.IEs + i); switch (pIE->ElementID) { - case _VENDOR_SPECIFIC_IE_: + case WLAN_EID_VENDOR_SPECIFIC: if ((!memcmp(pIE->data, RTW_WPA_OUI23A, 4)) && (!memcmp((pIE->data + 12), WPA_TKIP_CIPHER23A, 4))) return true; break; @@ -1161,7 +1161,7 @@ unsigned int should_forbid_n_rate23a(struct rtw_adapter * padapter) pIE = (struct ndis_802_11_var_ies *)(cur_network->IEs + i); switch (pIE->ElementID) { - case _VENDOR_SPECIFIC_IE_: + case WLAN_EID_VENDOR_SPECIFIC: if (!memcmp(pIE->data, RTW_WPA_OUI23A, 4) && ((!memcmp((pIE->data + 12), WPA_CIPHER_SUITE_CCMP23A, 4)) || (!memcmp((pIE->data + 16), WPA_CIPHER_SUITE_CCMP23A, 4)))) @@ -1196,7 +1196,7 @@ unsigned int is_ap_in_wep23a(struct rtw_adapter *padapter) pIE = (struct ndis_802_11_var_ies *)(pmlmeinfo->network.IEs + i); switch (pIE->ElementID) { - case _VENDOR_SPECIFIC_IE_: + case WLAN_EID_VENDOR_SPECIFIC: if (!memcmp(pIE->data, RTW_WPA_OUI23A, 4)) return false; break; @@ -1404,7 +1404,7 @@ unsigned char check_assoc_AP23a(u8 *pframe, uint len) pIE = (struct ndis_802_11_var_ies *)(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_8723A("link to Artheros AP\n"); diff --git a/drivers/staging/rtl8723au/include/rtw_security.h b/drivers/staging/rtl8723au/include/rtw_security.h index 75bbb934a53c..fcb43bd15b89 100644 --- a/drivers/staging/rtl8723au/include/rtw_security.h +++ b/drivers/staging/rtl8723au/include/rtw_security.h @@ -30,7 +30,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 diff --git a/drivers/staging/rtl8723au/include/wifi.h b/drivers/staging/rtl8723au/include/wifi.h index b5034c6ef1dc..a8695f435968 100644 --- a/drivers/staging/rtl8723au/include/wifi.h +++ b/drivers/staging/rtl8723au/include/wifi.h @@ -229,7 +229,6 @@ static inline unsigned char *get_hdr_bssid(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 @@ -249,7 +248,6 @@ static inline unsigned char *get_hdr_bssid(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/rtl8723au/os_dep/ioctl_cfg80211.c b/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c index 86721dc7c1b9..a0d59c7963d1 100644 --- a/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c +++ b/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c @@ -2986,10 +2986,10 @@ static int rtw_add_beacon(struct rtw_adapter *adapter, const u8 *head, #endif /* pbss_network->IEs will not include p2p_ie, wfd ie */ - rtw_ies_remove_ie23a(pbuf, &len, _BEACON_IE_OFFSET_, _VENDOR_SPECIFIC_IE_, - P2P_OUI23A, 4); - rtw_ies_remove_ie23a(pbuf, &len, _BEACON_IE_OFFSET_, _VENDOR_SPECIFIC_IE_, - WFD_OUI23A, 4); + rtw_ies_remove_ie23a(pbuf, &len, _BEACON_IE_OFFSET_, + WLAN_EID_VENDOR_SPECIFIC, P2P_OUI23A, 4); + rtw_ies_remove_ie23a(pbuf, &len, _BEACON_IE_OFFSET_, + WLAN_EID_VENDOR_SPECIFIC, WFD_OUI23A, 4); if (rtw_check_beacon_data23a(adapter, pbuf, len) == _SUCCESS) { #ifdef CONFIG_8723AU_P2P @@ -3489,7 +3489,7 @@ void rtw_cfg80211_issue_p2p_provision_request23a(struct rtw_adapter *padapter, memcpy(p2p_ie + p2pielen, devinfo_content, devinfo_contentlen); p2pielen += devinfo_contentlen; - pframe = rtw_set_ie23a(pframe, _VENDOR_SPECIFIC_IE_, p2pielen, + pframe = rtw_set_ie23a(pframe, WLAN_EID_VENDOR_SPECIFIC, p2pielen, (unsigned char *)p2p_ie, &p2p_ielen); pattrib->pktlen += p2p_ielen; @@ -3524,7 +3524,7 @@ void rtw_cfg80211_issue_p2p_provision_request23a(struct rtw_adapter *padapter, cpu_to_be16(pwdinfo->tx_prov_disc_info.wps_config_method_request); wpsielen += 2; - pframe = rtw_set_ie23a(pframe, _VENDOR_SPECIFIC_IE_, wpsielen, + pframe = rtw_set_ie23a(pframe, WLAN_EID_VENDOR_SPECIFIC, wpsielen, (unsigned char *)wpsie, &pattrib->pktlen); #ifdef CONFIG_8723AU_P2P @@ -3897,8 +3897,8 @@ static int rtw_cfg80211_set_beacon_wpsp2pie(struct net_device *ndev, char *buf, pmlmepriv->wps_beacon_ie_len = wps_ielen; #ifdef CONFIG_8723AU_AP_MODE - update_beacon23a(padapter, _VENDOR_SPECIFIC_IE_, wps_oui, - true); + update_beacon23a(padapter, WLAN_EID_VENDOR_SPECIFIC, + wps_oui, true); #endif } #ifdef CONFIG_8723AU_P2P -- cgit v1.2.3 From 1a2818fb28813eacde2cc6454dc628e0622c5874 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:43:22 +0200 Subject: staging: rtl8723au: rtw_security.h - remove some unused macros Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/include/rtw_security.h | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/drivers/staging/rtl8723au/include/rtw_security.h b/drivers/staging/rtl8723au/include/rtw_security.h index fcb43bd15b89..702dd845a3ff 100644 --- a/drivers/staging/rtl8723au/include/rtw_security.h +++ b/drivers/staging/rtl8723au/include/rtw_security.h @@ -315,22 +315,6 @@ static const unsigned long K[64] = { 0x90befffaUL, 0xa4506cebUL, 0xbef9a3f7UL, 0xc67178f2UL }; -/* Various logical functions */ -#define RORc(x, y) \ -(((((unsigned long)(x) & 0xFFFFFFFFUL) >> (unsigned long) ((y) & 31)) | \ -((unsigned long)(x) << (unsigned long) (32 - ((y) & 31)))) & 0xFFFFFFFFUL) -#define Ch(x, y, z) (z ^ (x & (y ^ z))) -#define Maj(x, y, z) (((x | y) & z) | (x & y)) -#define S(x, n) RORc((x), (n)) -#define R(x, n) (((x)&0xFFFFFFFFUL)>>(n)) -#define Sigma0(x) (S(x, 2) ^ S(x, 13) ^ S(x, 22)) -#define Sigma1(x) (S(x, 6) ^ S(x, 11) ^ S(x, 25)) -#define Gamma0(x) (S(x, 7) ^ S(x, 18) ^ R(x, 3)) -#define Gamma1(x) (S(x, 17) ^ S(x, 19) ^ R(x, 10)) -#ifndef MIN -#define MIN(x, y) (((x) < (y)) ? (x) : (y)) -#endif - void rtw_secmicsetkey23a(struct mic_data *pmicdata, u8 *key); void rtw_secmicappend23abyte23a(struct mic_data *pmicdata, u8 b); void rtw_secmicappend23a(struct mic_data *pmicdata, u8 *src, u32 nbBytes); -- cgit v1.2.3 From 7a65382f49f139f26425803d492538340897f982 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:43:23 +0200 Subject: staging: rtl8723au: make source * argument const Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_ieee80211.c | 2 +- drivers/staging/rtl8723au/include/ieee80211.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_ieee80211.c b/drivers/staging/rtl8723au/core/rtw_ieee80211.c index b01dd008e913..626a9df2645d 100644 --- a/drivers/staging/rtl8723au/core/rtw_ieee80211.c +++ b/drivers/staging/rtl8723au/core/rtw_ieee80211.c @@ -131,7 +131,7 @@ u8 *rtw_set_fixed_ie23a(unsigned char *pbuf, unsigned int len, } /* rtw_set_ie23a will update frame length */ -u8 *rtw_set_ie23a(u8 *pbuf, int index, uint len, u8 *source, uint *frlen) +u8 *rtw_set_ie23a(u8 *pbuf, int index, uint len, const u8 *source, uint *frlen) { *pbuf = (u8)index; diff --git a/drivers/staging/rtl8723au/include/ieee80211.h b/drivers/staging/rtl8723au/include/ieee80211.h index 28e4ab239fb9..61326e5e089c 100644 --- a/drivers/staging/rtl8723au/include/ieee80211.h +++ b/drivers/staging/rtl8723au/include/ieee80211.h @@ -518,7 +518,7 @@ enum parse_res rtw_ieee802_11_parse_elems23a(u8 *start, uint len, int show_errors); u8 *rtw_set_fixed_ie23a(unsigned char *pbuf, unsigned int len, unsigned char *source, unsigned int *frlen); -u8 *rtw_set_ie23a(u8 *pbuf, int index, uint len, u8 *source, uint *frlen); +u8 *rtw_set_ie23a(u8 *pbuf, int index, uint len, const u8 *source, uint *frlen); enum secondary_ch_offset { SCN = 0, /* no secondary channel */ -- cgit v1.2.3 From 5afd391a572b48b559a91b97cf0645580cf46da2 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:43:24 +0200 Subject: staging: rtl8723au: rtw_mlme_ext.c: Use the kernel's WLAN_EID_* definitions Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 149 ++++++++++++++------------ 1 file changed, 83 insertions(+), 66 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index 423f3956d063..9b9124c531ec 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -727,7 +727,7 @@ _continue: } p = rtw_get_ie23a(pframe + sizeof(struct ieee80211_hdr_3addr) + - _PROBEREQ_IE_OFFSET_, _SSID_IE_, (int *)&ielen, + _PROBEREQ_IE_OFFSET_, WLAN_EID_SSID, (int *)&ielen, len - sizeof(struct ieee80211_hdr_3addr) - _PROBEREQ_IE_OFFSET_); @@ -839,7 +839,7 @@ unsigned int OnBeacon23a(struct rtw_adapter *padapter, u32 ielen = 0; p = rtw_get_ie23a(pframe + sizeof(struct ieee80211_hdr_3addr) + - _BEACON_IE_OFFSET_, _EXT_SUPPORTEDRATES_IE_, &ielen, + _BEACON_IE_OFFSET_, WLAN_EID_EXT_SUPP_RATES, &ielen, len - sizeof(struct ieee80211_hdr_3addr) - _BEACON_IE_OFFSET_); if ((p != NULL) && (ielen > 0)) { @@ -1089,7 +1089,8 @@ unsigned int OnAuth23a(struct rtw_adapter *padapter, p = rtw_get_ie23a(pframe + sizeof(struct ieee80211_hdr_3addr) + - 4 + _AUTH_IE_OFFSET_, _CHLGETXT_IE_, + 4 + _AUTH_IE_OFFSET_, + WLAN_EID_CHALLENGE, (int *)&ie_len, len - sizeof(struct ieee80211_hdr_3addr) - _AUTH_IE_OFFSET_ - 4); @@ -1197,7 +1198,7 @@ unsigned int OnAuth23aClient23a(struct rtw_adapter *padapter, if (pmlmeinfo->auth_algo == dot11AuthAlgrthm_Shared) { /* legendary shared system */ - p = rtw_get_ie23a(pframe + sizeof(struct ieee80211_hdr_3addr) + _AUTH_IE_OFFSET_, _CHLGETXT_IE_, (int *)&len, + p = rtw_get_ie23a(pframe + sizeof(struct ieee80211_hdr_3addr) + _AUTH_IE_OFFSET_, WLAN_EID_CHALLENGE, (int *)&len, pkt_len - sizeof(struct ieee80211_hdr_3addr) - _AUTH_IE_OFFSET_); if (p == NULL) @@ -1351,8 +1352,9 @@ unsigned int OnAssocReq23a(struct rtw_adapter *padapter, struct recv_frame *prec /* now we should check all the fields... */ /* checking SSID */ - p = rtw_get_ie23a(pframe + sizeof(struct ieee80211_hdr_3addr) + ie_offset, _SSID_IE_, &ie_len, - pkt_len - sizeof(struct ieee80211_hdr_3addr) - ie_offset); + p = rtw_get_ie23a(pframe + sizeof(struct ieee80211_hdr_3addr) + + ie_offset, WLAN_EID_SSID, &ie_len, pkt_len - + sizeof(struct ieee80211_hdr_3addr) - ie_offset); if (p == NULL) { status = WLAN_STATUS_UNSPECIFIED_FAILURE; @@ -1373,7 +1375,7 @@ unsigned int OnAssocReq23a(struct rtw_adapter *padapter, struct recv_frame *prec goto OnAssocReq23aFail; /* check if the supported rate is ok */ - p = rtw_get_ie23a(pframe + sizeof(struct ieee80211_hdr_3addr) + ie_offset, _SUPPORTEDRATES_IE_, &ie_len, pkt_len - sizeof(struct ieee80211_hdr_3addr) - ie_offset); + p = rtw_get_ie23a(pframe + sizeof(struct ieee80211_hdr_3addr) + ie_offset, WLAN_EID_SUPP_RATES, &ie_len, pkt_len - sizeof(struct ieee80211_hdr_3addr) - ie_offset); if (p == NULL) { DBG_8723A("Rx a sta assoc-req which supported rate is empty!\n"); /* use our own rate set as statoin used */ @@ -1386,7 +1388,7 @@ unsigned int OnAssocReq23a(struct rtw_adapter *padapter, struct recv_frame *prec memcpy(supportRate, p+2, ie_len); supportRateNum = ie_len; - p = rtw_get_ie23a(pframe + sizeof(struct ieee80211_hdr_3addr) + ie_offset, _EXT_SUPPORTEDRATES_IE_, &ie_len, + p = rtw_get_ie23a(pframe + sizeof(struct ieee80211_hdr_3addr) + ie_offset, WLAN_EID_EXT_SUPP_RATES, &ie_len, pkt_len - sizeof(struct ieee80211_hdr_3addr) - ie_offset); if (p != NULL) { @@ -1840,15 +1842,15 @@ unsigned int OnAssocRsp23a(struct rtw_adapter *padapter, struct recv_frame *prec #endif break; - case _HT_CAPABILITY_IE_: /* HT caps */ + case WLAN_EID_HT_CAPABILITY: /* HT caps */ HT_caps_handler23a(padapter, pIE); break; - case _HT_EXTRA_INFO_IE_: /* HT info */ + case WLAN_EID_HT_OPERATION: /* HT info */ HT_info_handler23a(padapter, pIE); break; - case _ERPINFO_IE_: + case WLAN_EID_ERP_INFO: ERP_IE_handler23a(padapter, pIE); default: @@ -3847,22 +3849,24 @@ void issue_probersp23a_p2p23a(struct rtw_adapter *padapter, unsigned char *da) pattrib->pktlen += 2; /* SSID */ - pframe = rtw_set_ie23a(pframe, _SSID_IE_, 7, pwdinfo->p2p_wildcard_ssid, - &pattrib->pktlen); + pframe = rtw_set_ie23a(pframe, WLAN_EID_SSID, 7, + pwdinfo->p2p_wildcard_ssid, &pattrib->pktlen); /* supported rates... */ /* Use the OFDM rate in the P2P probe response frame. (6(B), 9(B), 12, 18, 24, 36, 48, 54) */ - pframe = rtw_set_ie23a(pframe, _SUPPORTEDRATES_IE_, 8, + pframe = rtw_set_ie23a(pframe, WLAN_EID_SUPP_RATES, 8, pwdinfo->support_rate, &pattrib->pktlen); /* DS parameter set */ if (wdev_to_priv(padapter->rtw_wdev)->p2p_enabled && listen_channel != 0) { - pframe = rtw_set_ie23a(pframe, _DSSET_IE_, 1, (unsigned char *) - &listen_channel, &pattrib->pktlen); + pframe = rtw_set_ie23a(pframe, WLAN_EID_DS_PARAMS, 1, + (unsigned char *) &listen_channel, + &pattrib->pktlen); } else { - pframe = rtw_set_ie23a(pframe, _DSSET_IE_, 1, (unsigned char *) + pframe = rtw_set_ie23a(pframe, WLAN_EID_DS_PARAMS, 1, + (unsigned char *) &pwdinfo->listen_channel, &pattrib->pktlen); } @@ -4149,19 +4153,19 @@ static int _issue23a_probereq_p2p(struct rtw_adapter *padapter, u8 *da, pattrib->pktlen = sizeof (struct ieee80211_hdr_3addr); if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_TX_PROVISION_DIS_REQ)) { - pframe = rtw_set_ie23a(pframe, _SSID_IE_, + pframe = rtw_set_ie23a(pframe, WLAN_EID_SSID, pwdinfo->tx_prov_disc_info.ssid.ssid_len, pwdinfo->tx_prov_disc_info.ssid.ssid, &pattrib->pktlen); } else { - pframe = rtw_set_ie23a(pframe, _SSID_IE_, + pframe = rtw_set_ie23a(pframe, WLAN_EID_SSID, P2P_WILDCARD_SSID_LEN, pwdinfo->p2p_wildcard_ssid, &pattrib->pktlen); } /* Use the OFDM rate in the P2P probe request frame. (6(B), 9(B), 12(B), 24(B), 36, 48, 54) */ - pframe = rtw_set_ie23a(pframe, _SUPPORTEDRATES_IE_, 8, + pframe = rtw_set_ie23a(pframe, WLAN_EID_SUPP_RATES, 8, pwdinfo->support_rate, &pattrib->pktlen); if (wdev_to_priv(padapter->rtw_wdev)->p2p_enabled) { @@ -5507,17 +5511,18 @@ void issue_beacon23a(struct rtw_adapter *padapter, int timeout_ms) pattrib->pktlen += 2; /* SSID */ - pframe = rtw_set_ie23a(pframe, _SSID_IE_, cur_network->Ssid.ssid_len, + pframe = rtw_set_ie23a(pframe, WLAN_EID_SSID, + cur_network->Ssid.ssid_len, cur_network->Ssid.ssid, &pattrib->pktlen); /* supported rates... */ rate_len = rtw_get_rateset_len23a(cur_network->SupportedRates); - pframe = rtw_set_ie23a(pframe, _SUPPORTEDRATES_IE_, + pframe = rtw_set_ie23a(pframe, WLAN_EID_SUPP_RATES, ((rate_len > 8)? 8: rate_len), cur_network->SupportedRates, &pattrib->pktlen); /* DS parameter set */ - pframe = rtw_set_ie23a(pframe, _DSSET_IE_, 1, (unsigned char *) + pframe = rtw_set_ie23a(pframe, WLAN_EID_DS_PARAMS, 1, (unsigned char *) &cur_network->Configuration.DSConfig, &pattrib->pktlen); @@ -5528,18 +5533,18 @@ void issue_beacon23a(struct rtw_adapter *padapter, int timeout_ms) /* IBSS Parameter Set... */ /* ATIMWindow = cur->Configuration.ATIMWindow; */ ATIMWindow = 0; - pframe = rtw_set_ie23a(pframe, _IBSS_PARA_IE_, 2, + pframe = rtw_set_ie23a(pframe, WLAN_EID_IBSS_PARAMS, 2, (unsigned char *)&ATIMWindow, &pattrib->pktlen); /* ERP IE */ - pframe = rtw_set_ie23a(pframe, _ERPINFO_IE_, 1, + pframe = rtw_set_ie23a(pframe, WLAN_EID_ERP_INFO, 1, &erpinfo, &pattrib->pktlen); } /* EXTERNDED SUPPORTED RATE */ if (rate_len > 8) - pframe = rtw_set_ie23a(pframe, _EXT_SUPPORTEDRATES_IE_, + pframe = rtw_set_ie23a(pframe, WLAN_EID_EXT_SUPP_RATES, rate_len - 8, cur_network->SupportedRates + 8, &pattrib->pktlen); @@ -5685,7 +5690,7 @@ void issue_probersp23a(struct rtw_adapter *padapter, unsigned char *da, ies = pmgntframe->buf_addr + TXDESC_OFFSET + sizeof(struct ieee80211_hdr_3addr); - ssid_ie = rtw_get_ie23a(ies+_FIXED_IE_LENGTH_, _SSID_IE_, + ssid_ie = rtw_get_ie23a(ies+_FIXED_IE_LENGTH_, WLAN_EID_SSID, &ssid_ielen, (pframe-ies)-_FIXED_IE_LENGTH_); @@ -5741,19 +5746,20 @@ void issue_probersp23a(struct rtw_adapter *padapter, unsigned char *da, /* below for ad-hoc mode */ /* SSID */ - pframe = rtw_set_ie23a(pframe, _SSID_IE_, + pframe = rtw_set_ie23a(pframe, WLAN_EID_SSID, cur_network->Ssid.ssid_len, cur_network->Ssid.ssid, &pattrib->pktlen); /* supported rates... */ rate_len = rtw_get_rateset_len23a(cur_network->SupportedRates); - pframe = rtw_set_ie23a(pframe, _SUPPORTEDRATES_IE_, + pframe = rtw_set_ie23a(pframe, WLAN_EID_SUPP_RATES, ((rate_len > 8)? 8: rate_len), cur_network->SupportedRates, &pattrib->pktlen); /* DS parameter set */ - pframe = rtw_set_ie23a(pframe, _DSSET_IE_, 1, (unsigned char *) + pframe = rtw_set_ie23a(pframe, WLAN_EID_DS_PARAMS, 1, + (unsigned char *) &cur_network->Configuration.DSConfig, &pattrib->pktlen); @@ -5763,18 +5769,18 @@ void issue_probersp23a(struct rtw_adapter *padapter, unsigned char *da, /* IBSS Parameter Set... */ /* ATIMWindow = cur->Configuration.ATIMWindow; */ ATIMWindow = 0; - pframe = rtw_set_ie23a(pframe, _IBSS_PARA_IE_, 2, + pframe = rtw_set_ie23a(pframe, WLAN_EID_IBSS_PARAMS, 2, (unsigned char *)&ATIMWindow, &pattrib->pktlen); /* ERP IE */ - pframe = rtw_set_ie23a(pframe, _ERPINFO_IE_, 1, + pframe = rtw_set_ie23a(pframe, WLAN_EID_ERP_INFO, 1, &erpinfo, &pattrib->pktlen); } /* EXTERNDED SUPPORTED RATE */ if (rate_len > 8) - pframe = rtw_set_ie23a(pframe, _EXT_SUPPORTEDRATES_IE_, + pframe = rtw_set_ie23a(pframe, WLAN_EID_EXT_SUPP_RATES, rate_len - 8, cur_network->SupportedRates + 8, &pattrib->pktlen); @@ -5878,22 +5884,22 @@ static int _issue_probereq23a(struct rtw_adapter *padapter, pattrib->pktlen = sizeof (struct ieee80211_hdr_3addr); if (pssid) - pframe = rtw_set_ie23a(pframe, _SSID_IE_, pssid->ssid_len, + pframe = rtw_set_ie23a(pframe, WLAN_EID_SSID, pssid->ssid_len, pssid->ssid, &pattrib->pktlen); else - pframe = rtw_set_ie23a(pframe, _SSID_IE_, 0, NULL, + pframe = rtw_set_ie23a(pframe, WLAN_EID_SSID, 0, NULL, &pattrib->pktlen); get_rate_set23a(padapter, bssrate, &bssrate_len); if (bssrate_len > 8) { - pframe = rtw_set_ie23a(pframe, _SUPPORTEDRATES_IE_, 8, + pframe = rtw_set_ie23a(pframe, WLAN_EID_SUPP_RATES, 8, bssrate, &pattrib->pktlen); - pframe = rtw_set_ie23a(pframe, _EXT_SUPPORTEDRATES_IE_, + pframe = rtw_set_ie23a(pframe, WLAN_EID_EXT_SUPP_RATES, (bssrate_len - 8), (bssrate + 8), &pattrib->pktlen); } else { - pframe = rtw_set_ie23a(pframe, _SUPPORTEDRATES_IE_, + pframe = rtw_set_ie23a(pframe, WLAN_EID_SUPP_RATES, bssrate_len, bssrate, &pattrib->pktlen); } @@ -6049,7 +6055,7 @@ void issue_auth23a(struct rtw_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_ie23a(pframe, _CHLGETXT_IE_, 128, + pframe = rtw_set_ie23a(pframe, WLAN_EID_CHALLENGE, 128, psta->chg_txt, &pattrib->pktlen); #endif } else { @@ -6108,7 +6114,7 @@ void issue_auth23a(struct rtw_adapter *padapter, struct sta_info *psta, if ((pmlmeinfo->auth_seq == 3) && (pmlmeinfo->state & WIFI_FW_AUTH_STATE) && (use_shared_key == 1)) { - pframe = rtw_set_ie23a(pframe, _CHLGETXT_IE_, 128, + pframe = rtw_set_ie23a(pframe, WLAN_EID_CHALLENGE, 128, pmlmeinfo->chg_txt, &pattrib->pktlen); @@ -6200,13 +6206,13 @@ void issue_asocrsp23a(struct rtw_adapter *padapter, unsigned short status, &pattrib->pktlen); if (pstat->bssratelen <= 8) { - pframe = rtw_set_ie23a(pframe, _SUPPORTEDRATES_IE_, + pframe = rtw_set_ie23a(pframe, WLAN_EID_SUPP_RATES, pstat->bssratelen, pstat->bssrateset, &pattrib->pktlen); } else { - pframe = rtw_set_ie23a(pframe, _SUPPORTEDRATES_IE_, 8, + pframe = rtw_set_ie23a(pframe, WLAN_EID_SUPP_RATES, 8, pstat->bssrateset, &pattrib->pktlen); - pframe = rtw_set_ie23a(pframe, _EXT_SUPPORTEDRATES_IE_, + pframe = rtw_set_ie23a(pframe, WLAN_EID_EXT_SUPP_RATES, pstat->bssratelen - 8, pstat->bssrateset + 8, &pattrib->pktlen); } @@ -6217,7 +6223,7 @@ void issue_asocrsp23a(struct rtw_adapter *padapter, unsigned short status, /* FILL HT CAP INFO IE */ /* p = hostapd_eid_ht_capabilities_info(hapd, p); */ pbuf = rtw_get_ie23a(ie + _BEACON_IE_OFFSET_, - _HT_CAPABILITY_IE_, &ie_len, + WLAN_EID_HT_CAPABILITY, &ie_len, pnetwork->IELength - _BEACON_IE_OFFSET_); if (pbuf && ie_len>0) { memcpy(pframe, pbuf, ie_len + 2); @@ -6227,8 +6233,8 @@ void issue_asocrsp23a(struct rtw_adapter *padapter, unsigned short status, /* FILL HT ADD INFO IE */ /* p = hostapd_eid_ht_operation(hapd, p); */ - pbuf = rtw_get_ie23a(ie + _BEACON_IE_OFFSET_, _HT_ADD_INFO_IE_, - &ie_len, + pbuf = rtw_get_ie23a(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); @@ -6356,7 +6362,7 @@ void issue_assocreq23a(struct rtw_adapter *padapter) pattrib->pktlen += 2; /* SSID */ - pframe = rtw_set_ie23a(pframe, _SSID_IE_, + pframe = rtw_set_ie23a(pframe, WLAN_EID_SSID, pmlmeinfo->network.Ssid.ssid_len, pmlmeinfo->network.Ssid.ssid, &pattrib->pktlen); @@ -6418,29 +6424,29 @@ void issue_assocreq23a(struct rtw_adapter *padapter) } if (bssrate_len > 8) { - pframe = rtw_set_ie23a(pframe, _SUPPORTEDRATES_IE_, 8, + pframe = rtw_set_ie23a(pframe, WLAN_EID_SUPP_RATES, 8, bssrate, &pattrib->pktlen); - pframe = rtw_set_ie23a(pframe, _EXT_SUPPORTEDRATES_IE_, + pframe = rtw_set_ie23a(pframe, WLAN_EID_EXT_SUPP_RATES, (bssrate_len - 8), (bssrate + 8), &pattrib->pktlen); } else - pframe = rtw_set_ie23a(pframe, _SUPPORTEDRATES_IE_, + pframe = rtw_set_ie23a(pframe, WLAN_EID_SUPP_RATES, bssrate_len, bssrate, &pattrib->pktlen); /* RSN */ p = rtw_get_ie23a((pmlmeinfo->network.IEs + - sizeof(struct ndis_802_11_fixed_ies)), _RSN_IE_2_, + sizeof(struct ndis_802_11_fixed_ies)), WLAN_EID_RSN, &ie_len, (pmlmeinfo->network.IELength - sizeof(struct ndis_802_11_fixed_ies))); if (p) - pframe = rtw_set_ie23a(pframe, _RSN_IE_2_, ie_len, (p + 2), + pframe = rtw_set_ie23a(pframe, WLAN_EID_RSN, ie_len, (p + 2), &pattrib->pktlen); /* HT caps */ if (padapter->mlmepriv.htpriv.ht_option == true) { p = rtw_get_ie23a((pmlmeinfo->network.IEs + sizeof(struct ndis_802_11_fixed_ies)), - _HT_CAPABILITY_IE_, &ie_len, + WLAN_EID_HT_CAPABILITY, &ie_len, (pmlmeinfo->network.IELength - sizeof(struct ndis_802_11_fixed_ies))); if ((p != NULL) && (!(is_ap_in_tkip23a(padapter)))) { @@ -6503,7 +6509,7 @@ void issue_assocreq23a(struct rtw_adapter *padapter) } #endif - pframe = rtw_set_ie23a(pframe, _HT_CAPABILITY_IE_, + pframe = rtw_set_ie23a(pframe, WLAN_EID_HT_CAPABILITY, ie_len, (u8 *)&pmlmeinfo->HT_caps, &pattrib->pktlen); @@ -7439,8 +7445,8 @@ static void issue_action_BSSCoexistPacket(struct rtw_adapter *padapter) iedata |= BIT(2);/* 20 MHz BSS Width Request */ - pframe = rtw_set_ie23a(pframe, EID_BSSCoexistence, 1, &iedata, &pattrib->pktlen); - + pframe = rtw_set_ie23a(pframe, WLAN_EID_BSS_COEX_2040, 1, + &iedata, &pattrib->pktlen); } /* */ @@ -7464,7 +7470,10 @@ static void issue_action_BSSCoexistPacket(struct rtw_adapter *padapter) pbss_network = &pnetwork->network; - p = rtw_get_ie23a(pbss_network->IEs + _FIXED_IE_LENGTH_, _HT_CAPABILITY_IE_, &len, pbss_network->IELength - _FIXED_IE_LENGTH_); + p = rtw_get_ie23a(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)) @@ -7829,7 +7838,8 @@ u8 collect_bss_info23a(struct rtw_adapter *padapter, struct recv_frame *precv_fr bssid->PhyInfo.SignalStrength = precv_frame->attrib.phy_info.SignalStrength;/* in percentage */ /* checking SSID */ - if ((p = rtw_get_ie23a(bssid->IEs + ie_offset, _SSID_IE_, &len, bssid->IELength - ie_offset)) == NULL) + if ((p = rtw_get_ie23a(bssid->IEs + ie_offset, WLAN_EID_SSID, &len, + bssid->IELength - ie_offset)) == NULL) { DBG_8723A("marc: cannot find SSID for survey event\n"); return _FAIL; @@ -7851,7 +7861,8 @@ u8 collect_bss_info23a(struct rtw_adapter *padapter, struct recv_frame *precv_fr /* checking rate info... */ i = 0; - p = rtw_get_ie23a(bssid->IEs + ie_offset, _SUPPORTEDRATES_IE_, &len, bssid->IELength - ie_offset); + p = rtw_get_ie23a(bssid->IEs + ie_offset, WLAN_EID_SUPP_RATES, &len, + bssid->IELength - ie_offset); if (p != NULL) { if (len > NDIS_802_11_LENGTH_RATES_EX) @@ -7863,7 +7874,8 @@ u8 collect_bss_info23a(struct rtw_adapter *padapter, struct recv_frame *precv_fr i = len; } - p = rtw_get_ie23a(bssid->IEs + ie_offset, _EXT_SUPPORTEDRATES_IE_, &len, bssid->IELength - ie_offset); + p = rtw_get_ie23a(bssid->IEs + ie_offset, WLAN_EID_EXT_SUPP_RATES, + &len, bssid->IELength - ie_offset); if (p != NULL) { if (len > (NDIS_802_11_LENGTH_RATES_EX-i)) @@ -7883,7 +7895,8 @@ u8 collect_bss_info23a(struct rtw_adapter *padapter, struct recv_frame *precv_fr return _FAIL; /* Checking for DSConfig */ - p = rtw_get_ie23a(bssid->IEs + ie_offset, _DSSET_IE_, &len, bssid->IELength - ie_offset); + p = rtw_get_ie23a(bssid->IEs + ie_offset, WLAN_EID_DS_PARAMS, &len, + bssid->IELength - ie_offset); bssid->Configuration.DSConfig = 0; bssid->Configuration.Length = 0; @@ -7895,7 +7908,9 @@ u8 collect_bss_info23a(struct rtw_adapter *padapter, struct recv_frame *precv_fr else {/* In 5G, some ap do not have DSSET IE */ /* checking HT info for channel */ - p = rtw_get_ie23a(bssid->IEs + ie_offset, _HT_ADD_INFO_IE_, &len, bssid->IELength - ie_offset); + p = rtw_get_ie23a(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); @@ -7940,7 +7955,7 @@ u8 collect_bss_info23a(struct rtw_adapter *padapter, struct recv_frame *precv_fr { struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - p = rtw_get_ie23a(bssid->IEs + ie_offset, _HT_CAPABILITY_IE_, &len, bssid->IELength - ie_offset); + p = rtw_get_ie23a(bssid->IEs + ie_offset, WLAN_EID_HT_CAPABILITY, &len, bssid->IELength - ie_offset); if (p && len > 0) { struct HT_caps_element *pHT_caps; pHT_caps = (struct HT_caps_element *)(p + 2); @@ -8171,7 +8186,9 @@ static void process_80211d(struct rtw_adapter *padapter, struct wlan_bssid_ex *b u8 noc; /* number of channel */ u8 j, k; - ie = rtw_get_ie23a(bssid->IEs + _FIXED_IE_LENGTH_, _COUNTRY_IE_, &len, bssid->IELength - _FIXED_IE_LENGTH_); + ie = rtw_get_ie23a(bssid->IEs + _FIXED_IE_LENGTH_, + WLAN_EID_COUNTRY, &len, + bssid->IELength - _FIXED_IE_LENGTH_); if (!ie) return; if (len < 6) return; @@ -9310,11 +9327,11 @@ u8 join_cmd_hdl23a(struct rtw_adapter *padapter, u8 *pbuf) 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 -- cgit v1.2.3 From a7eab38fe7d114597ebe6d6f6d5830804d9614f0 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:43:25 +0200 Subject: staging: rtl8723au: rtw_mlme.c: Use the kernel's WLAN_EID_* definitions Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme.c b/drivers/staging/rtl8723au/core/rtw_mlme.c index d94cff681ad4..59b2c6cedcf7 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme.c @@ -2236,7 +2236,8 @@ unsigned int rtw_restructure_ht_ie23a(struct rtw_adapter *padapter, u8 *in_ie, phtpriv->ht_option = false; - p = rtw_get_ie23a(in_ie + 12, _HT_CAPABILITY_IE_, &ielen, in_len - 12); + p = rtw_get_ie23a(in_ie + 12, WLAN_EID_HT_CAPABILITY, &ielen, + in_len - 12); if (p && ielen > 0) { u32 rx_packet_offset, max_recvbuf_sz; @@ -2273,17 +2274,19 @@ unsigned int rtw_restructure_ht_ie23a(struct rtw_adapter *padapter, u8 *in_ie, ht_capie.ampdu_params_info |= (IEEE80211_HT_AMPDU_PARM_DENSITY & 0x00); - pframe = rtw_set_ie23a(out_ie + out_len, _HT_CAPABILITY_IE_, + pframe = rtw_set_ie23a(out_ie + out_len, WLAN_EID_HT_CAPABILITY, sizeof(struct ieee80211_ht_cap), (unsigned char*)&ht_capie, pout_len); phtpriv->ht_option = true; - p = rtw_get_ie23a(in_ie + 12, _HT_ADD_INFO_IE_, &ielen, in_len-12); + p = rtw_get_ie23a(in_ie + 12, WLAN_EID_HT_OPERATION, &ielen, + in_len-12); if (p && (ielen == sizeof(struct ieee80211_ht_addt_info))) { out_len = *pout_len; - pframe = rtw_set_ie23a(out_ie + out_len, _HT_ADD_INFO_IE_, - ielen, p + 2 , pout_len); + pframe = rtw_set_ie23a(out_ie + out_len, + WLAN_EID_HT_OPERATION, + ielen, p + 2 , pout_len); } } @@ -2327,7 +2330,9 @@ void rtw_update_ht_cap23a(struct rtw_adapter *padapter, u8 *pie, uint ie_len) /* check Max Rx A-MPDU Size */ len = 0; - p = rtw_get_ie23a(pie+sizeof (struct ndis_802_11_fixed_ies), _HT_CAPABILITY_IE_, &len, ie_len-sizeof (struct ndis_802_11_fixed_ies)); + p = rtw_get_ie23a(pie+sizeof (struct ndis_802_11_fixed_ies), + WLAN_EID_HT_CAPABILITY, &len, + ie_len-sizeof (struct ndis_802_11_fixed_ies)); if (p && len > 0) { pht_capie = (struct ieee80211_ht_cap *)(p+2); max_ampdu_sz = (pht_capie->ampdu_params_info & IEEE80211_HT_AMPDU_PARM_FACTOR); @@ -2339,7 +2344,9 @@ void rtw_update_ht_cap23a(struct rtw_adapter *padapter, u8 *pie, uint ie_len) } len = 0; - p = rtw_get_ie23a(pie+sizeof (struct ndis_802_11_fixed_ies), _HT_ADD_INFO_IE_, &len, ie_len-sizeof (struct ndis_802_11_fixed_ies)); + p = rtw_get_ie23a(pie+sizeof (struct ndis_802_11_fixed_ies), + WLAN_EID_HT_OPERATION, &len, + ie_len-sizeof (struct ndis_802_11_fixed_ies)); if (p && len>0) { pht_addtinfo = (struct ieee80211_ht_addt_info *)(p+2); -- cgit v1.2.3 From af2cb2c2772293e94d30e13c9914dbeb6477a9d6 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:43:26 +0200 Subject: staging: rtl8723au: rtw_ap.c: Use the kernel's WLAN_EID_* definitions Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_ap.c | 62 ++++++++++++++++++--------------- 1 file changed, 34 insertions(+), 28 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_ap.c b/drivers/staging/rtl8723au/core/rtw_ap.c index fc8b7b2c4443..b9bf353e6b4e 100644 --- a/drivers/staging/rtl8723au/core/rtw_ap.c +++ b/drivers/staging/rtl8723au/core/rtw_ap.c @@ -79,7 +79,8 @@ static void update_BCNTIM(struct rtw_adapter *padapter) tim_bitmap_le = cpu_to_le16(pstapriv->tim_bitmap); - p = rtw_get_ie23a(pie + _FIXED_IE_LENGTH_, _TIM_IE_, &tim_ielen, pnetwork_mlmeext->IELength - _FIXED_IE_LENGTH_); + p = rtw_get_ie23a(pie + _FIXED_IE_LENGTH_, WLAN_EID_TIM, &tim_ielen, + pnetwork_mlmeext->IELength - _FIXED_IE_LENGTH_); if (p != NULL && tim_ielen>0) { tim_ielen += 2; @@ -98,12 +99,16 @@ static void update_BCNTIM(struct rtw_adapter *padapter) offset = _FIXED_IE_LENGTH_; /* get ssid_ie len */ - p = rtw_get_ie23a(pie + _BEACON_IE_OFFSET_, _SSID_IE_, &tmp_len, (pnetwork_mlmeext->IELength - _BEACON_IE_OFFSET_)); + p = rtw_get_ie23a(pie + _BEACON_IE_OFFSET_, WLAN_EID_SSID, + &tmp_len, (pnetwork_mlmeext->IELength - + _BEACON_IE_OFFSET_)); if (p != NULL) offset += tmp_len+2; /* get supported rates len */ - p = rtw_get_ie23a(pie + _BEACON_IE_OFFSET_, _SUPPORTEDRATES_IE_, &tmp_len, (pnetwork_mlmeext->IELength - _BEACON_IE_OFFSET_)); + p = rtw_get_ie23a(pie + _BEACON_IE_OFFSET_, WLAN_EID_SUPP_RATES, + &tmp_len, (pnetwork_mlmeext->IELength - + _BEACON_IE_OFFSET_)); if (p != NULL) offset += tmp_len+2; @@ -124,7 +129,7 @@ static void update_BCNTIM(struct rtw_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; @@ -248,7 +253,7 @@ void expire_timeout_chk23a(struct rtw_adapter *padapter) /* to update bcn with tim_bitmap for this station */ pstapriv->tim_bitmap |= CHKBIT(psta->aid); - update_beacon23a(padapter, _TIM_IE_, NULL, false); + update_beacon23a(padapter, WLAN_EID_TIM, NULL, false); if (!pmlmeext->active_keep_alive_check) continue; @@ -726,7 +731,7 @@ static void start_bss_network(struct rtw_adapter *padapter, u8 *pbuf) } /* set channel, bwmode */ p = rtw_get_ie23a((pnetwork->IEs + sizeof(struct ndis_802_11_fixed_ies)), - _HT_ADD_INFO_IE_, &ie_len, (pnetwork->IELength - + WLAN_EID_HT_OPERATION, &ie_len, (pnetwork->IELength - sizeof(struct ndis_802_11_fixed_ies))); if (p && ie_len) { pht_info = (struct HT_info_element *)(p+2); @@ -775,7 +780,7 @@ static void start_bss_network(struct rtw_adapter *padapter, u8 *pbuf) #endif /* CONFIG_8723AU_P2P */ if (pmlmeext->bstart_bss) { - update_beacon23a(padapter, _TIM_IE_, NULL, false); + update_beacon23a(padapter, WLAN_EID_TIM, NULL, false); /* issue beacon frame */ if (send_beacon23a(padapter) == _FAIL) @@ -847,7 +852,7 @@ int rtw_check_beacon_data23a(struct rtw_adapter *padapter, u8 *pbuf, int len) cap = get_unaligned_le16(ie); /* SSID */ - p = rtw_get_ie23a(ie + _BEACON_IE_OFFSET_, _SSID_IE_, &ie_len, + p = rtw_get_ie23a(ie + _BEACON_IE_OFFSET_, WLAN_EID_SSID, &ie_len, (pbss_network->IELength -_BEACON_IE_OFFSET_)); if (p && ie_len > 0) { memset(&pbss_network->Ssid, 0, sizeof(struct cfg80211_ssid)); @@ -858,7 +863,7 @@ int rtw_check_beacon_data23a(struct rtw_adapter *padapter, u8 *pbuf, int len) /* chnnel */ channel = 0; pbss_network->Configuration.Length = 0; - p = rtw_get_ie23a(ie + _BEACON_IE_OFFSET_, _DSSET_IE_, &ie_len, + p = rtw_get_ie23a(ie + _BEACON_IE_OFFSET_, WLAN_EID_DS_PARAMS, &ie_len, (pbss_network->IELength - _BEACON_IE_OFFSET_)); if (p && ie_len > 0) channel = *(p + 2); @@ -867,7 +872,7 @@ int rtw_check_beacon_data23a(struct rtw_adapter *padapter, u8 *pbuf, int len) memset(supportRate, 0, NDIS_802_11_LENGTH_RATES_EX); /* get supported rates */ - p = rtw_get_ie23a(ie + _BEACON_IE_OFFSET_, _SUPPORTEDRATES_IE_, &ie_len, + p = rtw_get_ie23a(ie + _BEACON_IE_OFFSET_, WLAN_EID_SUPP_RATES, &ie_len, (pbss_network->IELength - _BEACON_IE_OFFSET_)); if (p) { memcpy(supportRate, p+2, ie_len); @@ -875,7 +880,7 @@ int rtw_check_beacon_data23a(struct rtw_adapter *padapter, u8 *pbuf, int len) } /* get ext_supported rates */ - p = rtw_get_ie23a(ie + _BEACON_IE_OFFSET_, _EXT_SUPPORTEDRATES_IE_, + p = rtw_get_ie23a(ie + _BEACON_IE_OFFSET_, WLAN_EID_EXT_SUPP_RATES, &ie_len, pbss_network->IELength - _BEACON_IE_OFFSET_); if (p) { memcpy(supportRate+supportRateNum, p+2, ie_len); @@ -888,7 +893,7 @@ int rtw_check_beacon_data23a(struct rtw_adapter *padapter, u8 *pbuf, int len) rtw_set_supported_rate23a(pbss_network->SupportedRates, network_type); /* parsing ERP_IE */ - p = rtw_get_ie23a(ie + _BEACON_IE_OFFSET_, _ERPINFO_IE_, &ie_len, + p = rtw_get_ie23a(ie + _BEACON_IE_OFFSET_, WLAN_EID_ERP_INFO, &ie_len, (pbss_network->IELength - _BEACON_IE_OFFSET_)); if (p && ie_len > 0) ERP_IE_handler23a(padapter, (struct ndis_802_11_var_ies *)p); @@ -905,7 +910,7 @@ int rtw_check_beacon_data23a(struct rtw_adapter *padapter, u8 *pbuf, int len) group_cipher = 0; pairwise_cipher = 0; psecuritypriv->wpa2_group_cipher = _NO_PRIVACY_; psecuritypriv->wpa2_pairwise_cipher = _NO_PRIVACY_; - p = rtw_get_ie23a(ie + _BEACON_IE_OFFSET_, _RSN_IE_2_, &ie_len, + p = rtw_get_ie23a(ie + _BEACON_IE_OFFSET_, WLAN_EID_RSN, &ie_len, (pbss_network->IELength - _BEACON_IE_OFFSET_)); if (p && ie_len > 0) { if (rtw_parse_wpa2_ie23a(p, ie_len+2, &group_cipher, @@ -977,7 +982,7 @@ int rtw_check_beacon_data23a(struct rtw_adapter *padapter, u8 *pbuf, int len) } } /* parsing HT_CAP_IE */ - p = rtw_get_ie23a(ie + _BEACON_IE_OFFSET_, _HT_CAPABILITY_IE_, &ie_len, + p = rtw_get_ie23a(ie + _BEACON_IE_OFFSET_, WLAN_EID_HT_CAPABILITY, &ie_len, (pbss_network->IELength - _BEACON_IE_OFFSET_)); if (p && ie_len > 0) { u8 rf_type; @@ -1009,7 +1014,7 @@ int rtw_check_beacon_data23a(struct rtw_adapter *padapter, u8 *pbuf, int len) } /* parsing HT_INFO_IE */ - p = rtw_get_ie23a(ie + _BEACON_IE_OFFSET_, _HT_ADD_INFO_IE_, &ie_len, + p = rtw_get_ie23a(ie + _BEACON_IE_OFFSET_, WLAN_EID_HT_OPERATION, &ie_len, (pbss_network->IELength - _BEACON_IE_OFFSET_)); if (p && ie_len > 0) pHT_info_ie = p; @@ -1199,7 +1204,7 @@ static void update_bcn_erpinfo_ie(struct rtw_adapter *padapter) return; /* parsing ERP_IE */ - p = rtw_get_ie23a(ie + _BEACON_IE_OFFSET_, _ERPINFO_IE_, &len, (pnetwork->IELength - _BEACON_IE_OFFSET_)); + p = rtw_get_ie23a(ie + _BEACON_IE_OFFSET_, WLAN_EID_ERP_INFO, &len, (pnetwork->IELength - _BEACON_IE_OFFSET_)); if (p && len>0) { struct ndis_802_11_var_ies * pIE = (struct ndis_802_11_var_ies *)p; @@ -1354,23 +1359,23 @@ void update_beacon23a(struct rtw_adapter *padapter, u8 ie_id, u8 *oui, u8 tx) update_bcn_fixed_ie(padapter); break; - 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 _HT_CAPABILITY_IE_: + case WLAN_EID_HT_CAPABILITY: update_bcn_htcap_ie(padapter); break; - case _RSN_IE_2_: + case WLAN_EID_RSN: update_bcn_rsn_ie(padapter); break; - case _HT_ADD_INFO_IE_: + case WLAN_EID_HT_OPERATION: update_bcn_htinfo_ie(padapter); break; @@ -1548,7 +1553,7 @@ void bss_cap_update_on_sta_join23a(struct rtw_adapter *padapter, struct sta_info if (pmlmepriv->num_sta_non_erp == 1) { beacon_updated = true; - update_beacon23a(padapter, _ERPINFO_IE_, NULL, true); + update_beacon23a(padapter, WLAN_EID_ERP_INFO, NULL, true); } } @@ -1564,7 +1569,7 @@ void bss_cap_update_on_sta_join23a(struct rtw_adapter *padapter, struct sta_info if (pmlmepriv->num_sta_non_erp == 0) { beacon_updated = true; - update_beacon23a(padapter, _ERPINFO_IE_, NULL, true); + update_beacon23a(padapter, WLAN_EID_ERP_INFO, NULL, true); } } @@ -1655,8 +1660,8 @@ void bss_cap_update_on_sta_join23a(struct rtw_adapter *padapter, struct sta_info if (rtw_ht_operation_update(padapter) > 0) { - update_beacon23a(padapter, _HT_CAPABILITY_IE_, NULL, false); - update_beacon23a(padapter, _HT_ADD_INFO_IE_, NULL, true); + update_beacon23a(padapter, WLAN_EID_HT_CAPABILITY, NULL, false); + update_beacon23a(padapter, WLAN_EID_HT_OPERATION, NULL, true); } /* update associcated stations cap. */ @@ -1691,7 +1696,8 @@ u8 bss_cap_update_on_sta_leave23a(struct rtw_adapter *padapter, struct sta_info if (pmlmepriv->num_sta_non_erp == 0) { beacon_updated = true; - update_beacon23a(padapter, _ERPINFO_IE_, NULL, true); + update_beacon23a(padapter, WLAN_EID_ERP_INFO, + NULL, true); } } @@ -1723,8 +1729,8 @@ u8 bss_cap_update_on_sta_leave23a(struct rtw_adapter *padapter, struct sta_info if (rtw_ht_operation_update(padapter) > 0) { - update_beacon23a(padapter, _HT_CAPABILITY_IE_, NULL, false); - update_beacon23a(padapter, _HT_ADD_INFO_IE_, NULL, true); + update_beacon23a(padapter, WLAN_EID_HT_CAPABILITY, NULL, false); + update_beacon23a(padapter, WLAN_EID_HT_OPERATION, NULL, true); } /* update associcated stations cap. */ -- cgit v1.2.3 From 9676c3b9f5076c0572d4b6a6969a6319978e5118 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:43:27 +0200 Subject: staging: rtl8723au: rtw_p2p.c: Use the kernel's WLAN_EID_* definitions Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_p2p.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_p2p.c b/drivers/staging/rtl8723au/core/rtw_p2p.c index 22753e34848e..49c09089fd24 100644 --- a/drivers/staging/rtl8723au/core/rtw_p2p.c +++ b/drivers/staging/rtl8723au/core/rtw_p2p.c @@ -2170,8 +2170,11 @@ u32 process_probe_req_p2p_ie23a(struct wifidirect_info *pwdinfo, u8 *pframe, uin u32 p2pielen = 0; int ssid_len = 0, rate_cnt = 0; - p = rtw_get_ie23a(pframe + sizeof(struct ieee80211_hdr_3addr) + _PROBEREQ_IE_OFFSET_, _SUPPORTEDRATES_IE_, (int *)&rate_cnt, - len - sizeof(struct ieee80211_hdr_3addr) - _PROBEREQ_IE_OFFSET_); + p = rtw_get_ie23a(pframe + sizeof(struct ieee80211_hdr_3addr) + + _PROBEREQ_IE_OFFSET_, WLAN_EID_SUPP_RATES, + (int *)&rate_cnt, + len - sizeof(struct ieee80211_hdr_3addr) - + _PROBEREQ_IE_OFFSET_); if (rate_cnt <= 4) { @@ -2210,8 +2213,10 @@ u32 process_probe_req_p2p_ie23a(struct wifidirect_info *pwdinfo, u8 *pframe, uin /* 5. Requested Device Type in WSC IE. (Todo) */ /* 6. Device ID attribute in P2P IE. (Todo) */ - p = rtw_get_ie23a(pframe + sizeof(struct ieee80211_hdr_3addr) + _PROBEREQ_IE_OFFSET_, _SSID_IE_, (int *)&ssid_len, - len - sizeof(struct ieee80211_hdr_3addr) - _PROBEREQ_IE_OFFSET_); + p = rtw_get_ie23a(pframe + sizeof(struct ieee80211_hdr_3addr) + + _PROBEREQ_IE_OFFSET_, WLAN_EID_SSID, (int *)&ssid_len, + len - sizeof(struct ieee80211_hdr_3addr) - + _PROBEREQ_IE_OFFSET_); ssid_len &= 0xff; /* Just last 1 byte is valid for ssid len of the probe request */ if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_DEVICE) || rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO)) -- cgit v1.2.3 From 4323b043e41db47187888ac6b8da0a5ff1483afc Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:43:28 +0200 Subject: staging: rtl8723au: rtw_ieee80211.c: Use the kernel's WLAN_EID_* definitions Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_ieee80211.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_ieee80211.c b/drivers/staging/rtl8723au/core/rtw_ieee80211.c index 626a9df2645d..966b7be80923 100644 --- a/drivers/staging/rtl8723au/core/rtw_ieee80211.c +++ b/drivers/staging/rtl8723au/core/rtw_ieee80211.c @@ -413,7 +413,7 @@ int rtw_generate_ie23a(struct registry_priv *pregistrypriv) ie += 2; /* SSID */ - ie = rtw_set_ie23a(ie, _SSID_IE_, pdev_network->Ssid.ssid_len, + ie = rtw_set_ie23a(ie, WLAN_EID_SSID, pdev_network->Ssid.ssid_len, pdev_network->Ssid.ssid, &sz); /* supported rates */ @@ -431,25 +431,25 @@ int rtw_generate_ie23a(struct registry_priv *pregistrypriv) rateLen = rtw_get_rateset_len23a(pdev_network->SupportedRates); if (rateLen > 8) { - ie = rtw_set_ie23a(ie, _SUPPORTEDRATES_IE_, 8, + ie = rtw_set_ie23a(ie, WLAN_EID_SUPP_RATES, 8, pdev_network->SupportedRates, &sz); /* ie = rtw_set_ie23a(ie, _EXT_SUPPORTEDRATES_IE_, (rateLen - 8), (pdev_network->SupportedRates + 8), &sz); */ } else { - ie = rtw_set_ie23a(ie, _SUPPORTEDRATES_IE_, rateLen, + ie = rtw_set_ie23a(ie, WLAN_EID_SUPP_RATES, rateLen, pdev_network->SupportedRates, &sz); } /* DS parameter set */ - ie = rtw_set_ie23a(ie, _DSSET_IE_, 1, + ie = rtw_set_ie23a(ie, WLAN_EID_DS_PARAMS, 1, (u8 *)&pdev_network->Configuration.DSConfig, &sz); /* IBSS Parameter Set */ - ie = rtw_set_ie23a(ie, _IBSS_PARA_IE_, 2, + ie = rtw_set_ie23a(ie, WLAN_EID_IBSS_PARAMS, 2, (u8 *)&pdev_network->Configuration.ATIMWindow, &sz); if (rateLen > 8) { - ie = rtw_set_ie23a(ie, _EXT_SUPPORTEDRATES_IE_, (rateLen - 8), + ie = rtw_set_ie23a(ie, WLAN_EID_EXT_SUPP_RATES, (rateLen - 8), (pdev_network->SupportedRates + 8), &sz); } @@ -1694,8 +1694,8 @@ void rtw_get_bcn_info23a(struct wlan_network *pnetwork) /* get bwmode and ch_offset */ /* parsing HT_CAP_IE */ p = rtw_get_ie23a(pnetwork->network.IEs + _FIXED_IE_LENGTH_, - _HT_CAPABILITY_IE_, &len, - pnetwork->network.IELength - _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 = pht_cap->cap_info; @@ -1704,7 +1704,7 @@ void rtw_get_bcn_info23a(struct wlan_network *pnetwork) } /* parsing HT_INFO_IE */ p = rtw_get_ie23a(pnetwork->network.IEs + _FIXED_IE_LENGTH_, - _HT_ADD_INFO_IE_, &len, + WLAN_EID_HT_OPERATION, &len, pnetwork->network.IELength - _FIXED_IE_LENGTH_); if (p && len > 0) { pht_info = (struct HT_info_element *)(p + 2); -- cgit v1.2.3 From 25c934fa38326d51286b90f08fe03e3870bcb77d Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:43:29 +0200 Subject: staging: rtl8723au: rtw_wlan_util.c: Use the kernel's WLAN_EID_* definitions Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_wlan_util.c | 34 +++++++++++++++++--------- 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_wlan_util.c b/drivers/staging/rtl8723au/core/rtw_wlan_util.c index 8f0e79e9664f..f774b03f23d9 100644 --- a/drivers/staging/rtl8723au/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8723au/core/rtw_wlan_util.c @@ -933,7 +933,9 @@ int rtw_check_bcn_info23a(struct rtw_adapter *Adapter, u8 *pframe, u32 packet_le /* check bw and channel offset */ /* parsing HT_CAP_IE */ - p = rtw_get_ie23a(bssid->IEs + _FIXED_IE_LENGTH_, _HT_CAPABILITY_IE_, &len, bssid->IELength - _FIXED_IE_LENGTH_); + p = rtw_get_ie23a(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 = pht_cap->cap_info; @@ -941,7 +943,8 @@ int rtw_check_bcn_info23a(struct rtw_adapter *Adapter, u8 *pframe, u32 packet_le ht_cap_info = 0; } /* parsing HT_INFO_IE */ - p = rtw_get_ie23a(bssid->IEs + _FIXED_IE_LENGTH_, _HT_ADD_INFO_IE_, &len, bssid->IELength - _FIXED_IE_LENGTH_); + p = rtw_get_ie23a(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]; @@ -962,11 +965,14 @@ int rtw_check_bcn_info23a(struct rtw_adapter *Adapter, u8 *pframe, u32 packet_le } /* Checking for channel */ - p = rtw_get_ie23a(bssid->IEs + _FIXED_IE_LENGTH_, _DSSET_IE_, &len, bssid->IELength - _FIXED_IE_LENGTH_); + p = rtw_get_ie23a(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 */ - p = rtw_get_ie23a(bssid->IEs + _FIXED_IE_LENGTH_, _HT_ADD_INFO_IE_, &len, bssid->IELength - _FIXED_IE_LENGTH_); + p = rtw_get_ie23a(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 */ @@ -981,7 +987,9 @@ int rtw_check_bcn_info23a(struct rtw_adapter *Adapter, u8 *pframe, u32 packet_le } /* checking SSID */ - if ((p = rtw_get_ie23a(bssid->IEs + _FIXED_IE_LENGTH_, _SSID_IE_, &len, bssid->IELength - _FIXED_IE_LENGTH_)) == NULL) { + if ((p = rtw_get_ie23a(bssid->IEs + _FIXED_IE_LENGTH_, WLAN_EID_SSID, + &len, bssid->IELength - _FIXED_IE_LENGTH_)) == + NULL) { DBG_8723A("%s marc: cannot find SSID for survey event\n", __func__); hidden_ssid = true; } else { @@ -1102,11 +1110,11 @@ void update_beacon23a_info(struct rtw_adapter *padapter, u8 *pframe, uint pkt_le pIE = (struct ndis_802_11_var_ies *)(pframe + (_BEACON_IE_OFFSET_ + sizeof(struct ieee80211_hdr_3addr)) + i); switch (pIE->ElementID) { - case _HT_EXTRA_INFO_IE_: /* HT info */ + case WLAN_EID_HT_OPERATION: /* HT info */ /* HT_info_handler23a(padapter, pIE); */ bwmode_update_check(padapter, pIE); break; - case _ERPINFO_IE_: + case WLAN_EID_ERP_INFO: ERP_IE_handler23a(padapter, pIE); VCS_update23a(padapter, psta); break; @@ -1134,7 +1142,7 @@ unsigned int is_ap_in_tkip23a(struct rtw_adapter *padapter) if ((!memcmp(pIE->data, RTW_WPA_OUI23A, 4)) && (!memcmp((pIE->data + 12), WPA_TKIP_CIPHER23A, 4))) return true; break; - case _RSN_IE_2_: + case WLAN_EID_RSN: if (!memcmp((pIE->data + 8), RSN_TKIP_CIPHER23A, 4)) return true; break; @@ -1167,7 +1175,7 @@ unsigned int should_forbid_n_rate23a(struct rtw_adapter * padapter) (!memcmp((pIE->data + 16), WPA_CIPHER_SUITE_CCMP23A, 4)))) return false; break; - case _RSN_IE_2_: + case WLAN_EID_RSN: if ((!memcmp((pIE->data + 8), RSN_CIPHER_SUITE_CCMP23A, 4)) || (!memcmp((pIE->data + 12), RSN_CIPHER_SUITE_CCMP23A, 4))) return false; @@ -1200,7 +1208,7 @@ unsigned int is_ap_in_wep23a(struct rtw_adapter *padapter) if (!memcmp(pIE->data, RTW_WPA_OUI23A, 4)) return false; break; - case _RSN_IE_2_: + case WLAN_EID_RSN: return false; default: @@ -1598,14 +1606,16 @@ int update_sta_support_rate23a(struct rtw_adapter *padapter, u8 *pvar_ie, uint v struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; - pIE = (struct ndis_802_11_var_ies *)rtw_get_ie23a(pvar_ie, _SUPPORTEDRATES_IE_, &ie_len, var_ie_len); + pIE = (struct ndis_802_11_var_ies *)rtw_get_ie23a(pvar_ie, + WLAN_EID_SUPP_RATES, + &ie_len, var_ie_len); if (pIE == NULL) return _FAIL; memcpy(pmlmeinfo->FW_sta_info[cam_idx].SupportedRates, pIE->data, ie_len); supportRateNum = ie_len; - pIE = (struct ndis_802_11_var_ies *)rtw_get_ie23a(pvar_ie, _EXT_SUPPORTEDRATES_IE_, &ie_len, var_ie_len); + pIE = (struct ndis_802_11_var_ies *)rtw_get_ie23a(pvar_ie, WLAN_EID_EXT_SUPP_RATES, &ie_len, var_ie_len); if (pIE) memcpy((pmlmeinfo->FW_sta_info[cam_idx].SupportedRates + supportRateNum), pIE->data, ie_len); return _SUCCESS; -- cgit v1.2.3 From 4288e5fd1bd5f7880447a426dbb5fd3405a8d422 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:43:30 +0200 Subject: staging: rtl8723au: rtl8723a_cmd.c: Use the kernel's WLAN_EID_* definitions Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/hal/rtl8723a_cmd.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_cmd.c b/drivers/staging/rtl8723au/hal/rtl8723a_cmd.c index 0b205e1204fc..7a2284d96f4a 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_cmd.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_cmd.c @@ -255,30 +255,36 @@ static void ConstructBeacon(struct rtw_adapter *padapter, u8 *pframe, u32 *pLeng /* below for ad-hoc mode */ /* SSID */ - pframe = rtw_set_ie23a(pframe, _SSID_IE_, cur_network->Ssid.ssid_len, - cur_network->Ssid.ssid, &pktlen); + pframe = rtw_set_ie23a(pframe, WLAN_EID_SSID, + cur_network->Ssid.ssid_len, + cur_network->Ssid.ssid, &pktlen); /* supported rates... */ rate_len = rtw_get_rateset_len23a(cur_network->SupportedRates); - pframe = rtw_set_ie23a(pframe, _SUPPORTEDRATES_IE_, ((rate_len > 8) ? + pframe = rtw_set_ie23a(pframe, WLAN_EID_SUPP_RATES, ((rate_len > 8) ? 8 : rate_len), cur_network->SupportedRates, &pktlen); /* DS parameter set */ - pframe = rtw_set_ie23a(pframe, _DSSET_IE_, 1, (unsigned char *)&cur_network->Configuration.DSConfig, &pktlen); + pframe = rtw_set_ie23a(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 = cur->Configuration.ATIMWindow; */ ATIMWindow = 0; - pframe = rtw_set_ie23a(pframe, _IBSS_PARA_IE_, 2, (unsigned char *)(&ATIMWindow), &pktlen); + pframe = rtw_set_ie23a(pframe, WLAN_EID_IBSS_PARAMS, 2, + (unsigned char *)(&ATIMWindow), &pktlen); } /* todo: ERP IE */ /* EXTERNDED SUPPORTED RATE */ if (rate_len > 8) - pframe = rtw_set_ie23a(pframe, _EXT_SUPPORTEDRATES_IE_, (rate_len - 8), (cur_network->SupportedRates + 8), &pktlen); + pframe = rtw_set_ie23a(pframe, WLAN_EID_EXT_SUPP_RATES, + (rate_len - 8), + (cur_network->SupportedRates + 8), + &pktlen); /* todo:HT for adhoc */ -- cgit v1.2.3 From 3455f1f062641c13858c77c5a2c07c9a45a1a820 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:43:31 +0200 Subject: staging: rtl8723au: rtw_xmit.c: Use the kernel's WLAN_EID_* definitions Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_xmit.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_xmit.c b/drivers/staging/rtl8723au/core/rtw_xmit.c index c0e2d7607b72..c0eaf5e21057 100644 --- a/drivers/staging/rtl8723au/core/rtw_xmit.c +++ b/drivers/staging/rtl8723au/core/rtw_xmit.c @@ -1333,7 +1333,7 @@ void rtw_update_protection23a(struct rtw_adapter *padapter, u8 *ie, uint ie_len) break; case AUTO_VCS: default: - perp = rtw_get_ie23a(ie, _ERPINFO_IE_, &erp_len, ie_len); + perp = rtw_get_ie23a(ie, WLAN_EID_ERP_INFO, &erp_len, ie_len); if (perp == NULL) { pxmitpriv->vcs = NONE_VCS; } else { @@ -2042,7 +2042,8 @@ int xmitframe_enqueue_for_sleeping_sta23a(struct rtw_adapter *padapter, struct x /* DBG_8723A("enqueue, sq_len =%d, tim =%x\n", psta->sleepq_len, pstapriv->tim_bitmap); */ - update_beacon23a(padapter, _TIM_IE_, NULL, false);/* tx bc/mc packets after upate bcn */ + /* tx bc/mc packets after upate bcn */ + update_beacon23a(padapter, WLAN_EID_TIM, NULL, false); /* spin_unlock_bh(&psta->sleep_q.lock); */ @@ -2099,7 +2100,8 @@ int xmitframe_enqueue_for_sleeping_sta23a(struct rtw_adapter *padapter, struct x if (psta->sleepq_len == 1) { /* upate BCN for TIM IE */ - update_beacon23a(padapter, _TIM_IE_, NULL, false); + update_beacon23a(padapter, WLAN_EID_TIM, + NULL, false); } } @@ -2313,7 +2315,7 @@ void wakeup_sta_to_xmit23a(struct rtw_adapter *padapter, struct sta_info *psta) } if (update_mask) - update_beacon23a(padapter, _TIM_IE_, NULL, false); + update_beacon23a(padapter, WLAN_EID_TIM, NULL, false); } void xmit_delivery_enabled_frames23a(struct rtw_adapter *padapter, @@ -2378,7 +2380,7 @@ void xmit_delivery_enabled_frames23a(struct rtw_adapter *padapter, pstapriv->tim_bitmap &= ~CHKBIT(psta->aid); /* upate BCN for TIM IE */ - update_beacon23a(padapter, _TIM_IE_, NULL, false); + update_beacon23a(padapter, WLAN_EID_TIM, NULL, false); } } spin_unlock_bh(&pxmitpriv->lock); -- cgit v1.2.3 From df220942dfc5e64b0f84b4f381b9a08eb1bdd16b Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:43:32 +0200 Subject: staging: rtl8723au: rtw_recv.c: Use the kernel's WLAN_EID_* definitions Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_recv.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_recv.c b/drivers/staging/rtl8723au/core/rtw_recv.c index 713a377ce28f..5d81a8c18218 100644 --- a/drivers/staging/rtl8723au/core/rtw_recv.c +++ b/drivers/staging/rtl8723au/core/rtw_recv.c @@ -1216,8 +1216,8 @@ int validate_recv_ctrl_frame(struct rtw_adapter *padapter, /* upate BCN for TIM IE */ /* update_BCNTIM(padapter); */ - update_beacon23a(padapter, _TIM_IE_, - NULL, false); + update_beacon23a(padapter, WLAN_EID_TIM, + NULL, false); } /* spin_unlock_bh(&psta->sleep_q.lock); */ @@ -1248,8 +1248,8 @@ int validate_recv_ctrl_frame(struct rtw_adapter *padapter, /* upate BCN for TIM IE */ /* update_BCNTIM(padapter); */ - update_beacon23a(padapter, _TIM_IE_, - NULL, false); + update_beacon23a(padapter, WLAN_EID_TIM, + NULL, false); } } } -- cgit v1.2.3 From 3021bc42072ba073536a82458192bc98c8e0698e Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:43:33 +0200 Subject: staging: rtl8723au: Fixup last users to use the kernel's WLAN_EID_* definitions Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_cmd.c | 2 +- drivers/staging/rtl8723au/core/rtw_ioctl_set.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_cmd.c b/drivers/staging/rtl8723au/core/rtw_cmd.c index 592f0ee274e4..f8306efa979d 100644 --- a/drivers/staging/rtl8723au/core/rtw_cmd.c +++ b/drivers/staging/rtl8723au/core/rtw_cmd.c @@ -1461,7 +1461,7 @@ static void rtw_chk_hi_queue_hdl(struct rtw_adapter *padapter) pstapriv->tim_bitmap &= ~BIT(0); pstapriv->sta_dz_bitmap &= ~BIT(0); - update_beacon23a(padapter, _TIM_IE_, NULL, false); + update_beacon23a(padapter, WLAN_EID_TIM, NULL, false); } else /* re check again */ rtw_chk_hi_queue_cmd23a(padapter); } diff --git a/drivers/staging/rtl8723au/core/rtw_ioctl_set.c b/drivers/staging/rtl8723au/core/rtw_ioctl_set.c index 1f9d3a3d4920..6468c1ca2528 100644 --- a/drivers/staging/rtl8723au/core/rtw_ioctl_set.c +++ b/drivers/staging/rtl8723au/core/rtw_ioctl_set.c @@ -557,7 +557,7 @@ u16 rtw_get_cur_max_rate23a(struct rtw_adapter *adapter) return 0; if (pmlmeext->cur_wireless_mode & (WIRELESS_11_24N|WIRELESS_11_5N)) { - p = rtw_get_ie23a(&pcur_bss->IEs[12], _HT_CAPABILITY_IE_, + p = rtw_get_ie23a(&pcur_bss->IEs[12], WLAN_EID_HT_CAPABILITY, &ht_ielen, pcur_bss->IELength - 12); if (p && ht_ielen > 0) { pht_capie = (struct ieee80211_ht_cap *)(p + 2); -- cgit v1.2.3 From 91624933fd2868693c4f55ba503e9d1b6932de7b Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:43:34 +0200 Subject: staging: rtl8723au: Remove obsolete local defines matching WLAN_EID_* Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/include/wifi.h | 31 +------------------------------ 1 file changed, 1 insertion(+), 30 deletions(-) diff --git a/drivers/staging/rtl8723au/include/wifi.h b/drivers/staging/rtl8723au/include/wifi.h index a8695f435968..57e394543ec1 100644 --- a/drivers/staging/rtl8723au/include/wifi.h +++ b/drivers/staging/rtl8723au/include/wifi.h @@ -219,37 +219,8 @@ static inline unsigned char *get_hdr_bssid(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 _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 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 _RESERVED47_ 47 +#define EID_BSSIntolerantChlReport 73 /* --------------------------------------------------------------------------- Below is the fixed elements... -- cgit v1.2.3 From 98fb81291d30f83838379bf1522fead6673b5fdf Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:43:35 +0200 Subject: staging: rtl8723au: Remove P2P/WiFiDirect/WiFiDisplay code Discussing with Johannes Berg and Larry Finger, we have concluded that this code really should be handled through wpa_supplicant, and not in the kernel. Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/Kconfig | 8 - drivers/staging/rtl8723au/Makefile | 1 - drivers/staging/rtl8723au/core/rtw_ap.c | 9 - drivers/staging/rtl8723au/core/rtw_cmd.c | 58 - drivers/staging/rtl8723au/core/rtw_ieee80211.c | 311 -- drivers/staging/rtl8723au/core/rtw_mlme.c | 22 +- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 3564 +----------------- drivers/staging/rtl8723au/core/rtw_p2p.c | 4016 --------------------- drivers/staging/rtl8723au/core/rtw_pwrctrl.c | 57 +- drivers/staging/rtl8723au/core/rtw_wlan_util.c | 35 - drivers/staging/rtl8723au/hal/rtl8723a_cmd.c | 73 - drivers/staging/rtl8723au/hal/rtl8723a_dm.c | 7 - drivers/staging/rtl8723au/include/drv_types.h | 11 - drivers/staging/rtl8723au/include/ieee80211.h | 14 - drivers/staging/rtl8723au/include/rtl8723a_cmd.h | 4 - drivers/staging/rtl8723au/include/rtl8723a_hal.h | 5 - drivers/staging/rtl8723au/include/rtw_cmd.h | 3 - drivers/staging/rtl8723au/include/rtw_mlme.h | 123 - drivers/staging/rtl8723au/include/rtw_mlme_ext.h | 16 - drivers/staging/rtl8723au/include/rtw_p2p.h | 158 - drivers/staging/rtl8723au/include/wifi.h | 17 - drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c | 851 +---- drivers/staging/rtl8723au/os_dep/os_intfs.c | 42 - drivers/staging/rtl8723au/os_dep/usb_intf.c | 4 - 24 files changed, 85 insertions(+), 9324 deletions(-) delete mode 100644 drivers/staging/rtl8723au/core/rtw_p2p.c delete mode 100644 drivers/staging/rtl8723au/include/rtw_p2p.h diff --git a/drivers/staging/rtl8723au/Kconfig b/drivers/staging/rtl8723au/Kconfig index 07fb5e4e50fa..435f3594dabe 100644 --- a/drivers/staging/rtl8723au/Kconfig +++ b/drivers/staging/rtl8723au/Kconfig @@ -19,14 +19,6 @@ config 8723AU_AP_MODE will never be used as an AP, or the target system has limited memory, "Y" should be selected. -config 8723AU_P2P - bool "Realtek RTL8723AU Peer-to-peer mode" - default y - ---help--- - This option enables peer-to-peer mode for the r8723au driver. Unless you - know that peer-to-peer (P2P) mode will never be used, or the target system has - limited memory, "Y" should be selected. - config 8723AU_BT_COEXIST bool "Realtek RTL8723AU BlueTooth Coexistence" default y diff --git a/drivers/staging/rtl8723au/Makefile b/drivers/staging/rtl8723au/Makefile index 11c6dd486462..bbf503dd437a 100644 --- a/drivers/staging/rtl8723au/Makefile +++ b/drivers/staging/rtl8723au/Makefile @@ -8,7 +8,6 @@ r8723au-y := \ core/rtw_led.o \ core/rtw_mlme.o \ core/rtw_mlme_ext.o \ - core/rtw_p2p.o \ core/rtw_pwrctrl.o \ core/rtw_recv.o \ core/rtw_security.o \ diff --git a/drivers/staging/rtl8723au/core/rtw_ap.c b/drivers/staging/rtl8723au/core/rtw_ap.c index b9bf353e6b4e..f04d9dfb4446 100644 --- a/drivers/staging/rtl8723au/core/rtw_ap.c +++ b/drivers/staging/rtl8723au/core/rtw_ap.c @@ -659,9 +659,6 @@ static void start_bss_network(struct rtw_adapter *padapter, u8 *pbuf) struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; struct wlan_bssid_ex *pnetwork_mlmeext = &pmlmeinfo->network; struct HT_info_element *pht_info = NULL; -#ifdef CONFIG_8723AU_P2P - struct wifidirect_info *pwdinfo = &padapter->wdinfo; -#endif /* CONFIG_8723AU_P2P */ bcn_interval = (u16)pnetwork->Configuration.BeaconPeriod; cur_channel = pnetwork->Configuration.DSConfig; @@ -773,12 +770,6 @@ static void start_bss_network(struct rtw_adapter *padapter, u8 *pbuf) /* let pnetwork_mlmeext == pnetwork_mlme. */ memcpy(pnetwork_mlmeext, pnetwork, pnetwork->Length); -#ifdef CONFIG_8723AU_P2P - memcpy(pwdinfo->p2p_group_ssid, pnetwork->Ssid.ssid, - pnetwork->Ssid.ssid_len); - pwdinfo->p2p_group_ssid_len = pnetwork->Ssid.ssid_len; -#endif /* CONFIG_8723AU_P2P */ - if (pmlmeext->bstart_bss) { update_beacon23a(padapter, WLAN_EID_TIM, NULL, false); diff --git a/drivers/staging/rtl8723au/core/rtw_cmd.c b/drivers/staging/rtl8723au/core/rtw_cmd.c index f8306efa979d..cb15ddaae12e 100644 --- a/drivers/staging/rtl8723au/core/rtw_cmd.c +++ b/drivers/staging/rtl8723au/core/rtw_cmd.c @@ -527,12 +527,6 @@ u8 rtw_sitesurvey_cmd23a(struct rtw_adapter *padapter, if (check_fwstate(pmlmepriv, _FW_LINKED) == true) rtw_lps_ctrl_wk_cmd23a(padapter, LPS_CTRL_SCAN, 1); -#ifdef CONFIG_8723AU_P2P - if (check_fwstate(pmlmepriv, _FW_LINKED) == true) { - p2p_ps_wk_cmd23a(padapter, P2P_PS_SCAN, 1); - } -#endif /* CONFIG_8723AU_P2P */ - ph2c = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC); if (!ph2c) return _FAIL; @@ -1354,48 +1348,6 @@ static void power_saving_wk_hdl(struct rtw_adapter *padapter, u8 *pbuf, int sz) rtw_ps_processor23a(padapter); } -#ifdef CONFIG_8723AU_P2P -u8 p2p_protocol_wk_cmd23a(struct rtw_adapter*padapter, int intCmdType) -{ - struct cmd_obj *ph2c; - struct drvextra_cmd_parm *pdrvextra_cmd_parm; - struct wifidirect_info *pwdinfo = &padapter->wdinfo; - struct cmd_priv *pcmdpriv = &padapter->cmdpriv; - u8 res = _SUCCESS; - - if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)) - { - return res; - } - - ph2c = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC); - if (!ph2c) { - res = _FAIL; - goto exit; - } - - pdrvextra_cmd_parm = kzalloc(sizeof(struct drvextra_cmd_parm), - GFP_ATOMIC); - if (!pdrvextra_cmd_parm) { - kfree(ph2c); - res = _FAIL; - goto exit; - } - - pdrvextra_cmd_parm->ec_id = P2P_PROTO_WK_CID; - pdrvextra_cmd_parm->type_size = intCmdType; /* As the command tppe. */ - pdrvextra_cmd_parm->pbuf = NULL; /* Must be NULL here */ - - init_h2fwcmd_w_parm_no_rsp(ph2c, pdrvextra_cmd_parm, - GEN_CMD_CODE(_Set_Drv_Extra)); - - res = rtw_enqueue_cmd23a(pcmdpriv, ph2c); -exit: - - return res; -} -#endif /* CONFIG_8723AU_P2P */ - u8 rtw_ps_cmd23a(struct rtw_adapter*padapter) { struct cmd_obj *ppscmd; @@ -1634,16 +1586,6 @@ u8 rtw_drvextra_cmd_hdl23a(struct rtw_adapter *padapter, unsigned char *pbuf) case LPS_CTRL_WK_CID: lps_ctrl_wk_hdl(padapter, (u8)pdrvextra_cmd->type_size); break; -#ifdef CONFIG_8723AU_P2P - case P2P_PS_WK_CID: - p2p_ps_wk_hdl23a(padapter, pdrvextra_cmd->type_size); - break; - case P2P_PROTO_WK_CID: - /* Commented by Albert 2011/07/01 */ - /* I used the type_size as the type command */ - p2p_protocol_wk_hdl23a(padapter, pdrvextra_cmd->type_size); - break; -#endif /* CONFIG_8723AU_P2P */ #ifdef CONFIG_8723AU_AP_MODE case CHECK_HIQ_WK_CID: rtw_chk_hi_queue_hdl(padapter); diff --git a/drivers/staging/rtl8723au/core/rtw_ieee80211.c b/drivers/staging/rtl8723au/core/rtw_ieee80211.c index 966b7be80923..d7a6b47b49b3 100644 --- a/drivers/staging/rtl8723au/core/rtw_ieee80211.c +++ b/drivers/staging/rtl8723au/core/rtw_ieee80211.c @@ -1227,9 +1227,6 @@ void dump_ies23a(u8 *buf, u32 buf_len) { len = *(pos + 1); DBG_8723A("%s ID:%u, LEN:%u\n", __func__, id, len); -#ifdef CONFIG_8723AU_P2P - dump_p2p_ie23a(pos, len); -#endif dump_wps_ie23a(pos, len); pos += (2 + len); @@ -1259,314 +1256,6 @@ void dump_wps_ie23a(u8 *ie, u32 ie_len) { } } -#ifdef CONFIG_8723AU_P2P -void dump_p2p_ie23a(u8 *ie, u32 ie_len) { - u8* pos = (u8*)ie; - u8 id; - u16 len; - - u8 *p2p_ie; - uint p2p_ielen; - - p2p_ie = rtw_get_p2p_ie23a(ie, ie_len, NULL, &p2p_ielen); - if (p2p_ie != ie || p2p_ielen == 0) - return; - - pos += 6; - while (pos-ie < ie_len) { - id = *pos; - len = get_unaligned_le16(pos+1); - - DBG_8723A("%s ID:%u, LEN:%u\n", __func__, id, len); - - pos+= (3+len); - } -} - -/** - * rtw_get_p2p_ie23a - Search P2P IE from a series of IEs - * @in_ie: Address of IEs to search - * @in_len: Length limit from in_ie - * @p2p_ie: If not NULL and P2P IE is found, P2P IE will be copied to the - * buf starting from p2p_ie - * @p2p_ielen: If not NULL and P2P IE is found, will set to the length of - * the entire P2P IE - * - * Returns: The address of the P2P IE found, or NULL - */ -u8 *rtw_get_p2p_ie23a(u8 *in_ie, int in_len, u8 *p2p_ie, uint *p2p_ielen) -{ - uint cnt = 0; - u8 *p2p_ie_ptr; - u8 eid, p2p_oui[4]={0x50, 0x6F, 0x9A, 0x09}; - - if (p2p_ielen) - *p2p_ielen = 0; - - while (cnt MAX_IE_SZ)) { - dump_stack(); - return NULL; - } - if ((eid == WLAN_EID_VENDOR_SPECIFIC) && - !memcmp(&in_ie[cnt + 2], p2p_oui, 4)) { - p2p_ie_ptr = in_ie + cnt; - - if (p2p_ie != NULL) { - memcpy(p2p_ie, &in_ie[cnt], - in_ie[cnt + 1] + 2); - } - - if (p2p_ielen != NULL) { - *p2p_ielen = in_ie[cnt + 1] + 2; - } - - return p2p_ie_ptr; - - break; - } else { - cnt += in_ie[cnt + 1] + 2; /* goto next */ - } - } - - return NULL; -} - -/** - * rtw_get_p2p_attr23a - Search a specific P2P attribute from a given P2P IE - * @p2p_ie: Address of P2P IE to search - * @p2p_ielen: Length limit from p2p_ie - * @target_attr_id: The attribute ID of P2P attribute to search - * @buf_attr: If not NULL and the P2P attribute is found, P2P attribute will - * be copied to the buf starting from buf_attr - * @len_attr: If not NULL and the P2P attribute is found, will set to the - * length of the entire P2P attribute - * - * Returns: the address of the specific WPS attribute found, or NULL - */ -u8 *rtw_get_p2p_attr23a(u8 *p2p_ie, uint p2p_ielen, u8 target_attr_id, - u8 *buf_attr, u32 *len_attr) -{ - u8 *attr_ptr = NULL; - u8 *target_attr_ptr = NULL; - u8 p2p_oui[4]={0x50, 0x6F, 0x9A, 0x09}; - - if (len_attr) - *len_attr = 0; - - if (!p2p_ie || (p2p_ie[0] != WLAN_EID_VENDOR_SPECIFIC) || - memcmp(p2p_ie + 2, p2p_oui, 4)) { - return attr_ptr; - } - - /* 6 = 1(Element ID) + 1(Length) + 3 (OUI) + 1(OUI Type) */ - attr_ptr = p2p_ie + 6; /* goto first attr */ - - while (attr_ptr - p2p_ie < p2p_ielen) { - /* 3 = 1(Attribute ID) + 2(Length) */ - u8 attr_id = *attr_ptr; - u16 attr_data_len = get_unaligned_le16(attr_ptr + 1); - u16 attr_len = attr_data_len + 3; - - /* DBG_8723A("%s attr_ptr:%p, id:%u, length:%u\n", __func__, attr_ptr, attr_id, attr_data_len); */ - if (attr_id == target_attr_id) { - target_attr_ptr = attr_ptr; - - if (buf_attr) - memcpy(buf_attr, attr_ptr, attr_len); - - if (len_attr) - *len_attr = attr_len; - - break; - } else { - attr_ptr += attr_len; /* goto next */ - } - } - - return target_attr_ptr; -} - -/** - * rtw_get_p2p_attr23a_content - Search a specific P2P attribute content from - * a given P2P IE - * @p2p_ie: Address of P2P IE to search - * @p2p_ielen: Length limit from p2p_ie - * @target_attr_id: The attribute ID of P2P attribute to search - * @buf_content: If not NULL and the P2P attribute is found, P2P attribute - * content will be copied to the buf starting from buf_content - * @len_content: If not NULL and the P2P attribute is found, will set to the - * length of the P2P attribute content - * - * Returns: the address of the specific P2P attribute content found, or NULL - */ -u8 *rtw_get_p2p_attr23a_content(u8 *p2p_ie, uint p2p_ielen, u8 target_attr_id, - u8 *buf_content, uint *len_content) -{ - u8 *attr_ptr; - u32 attr_len; - - if (len_content) - *len_content = 0; - - attr_ptr = rtw_get_p2p_attr23a(p2p_ie, p2p_ielen, target_attr_id, - NULL, &attr_len); - - if (attr_ptr && attr_len) { - if (buf_content) - memcpy(buf_content, attr_ptr + 3, attr_len - 3); - - if (len_content) - *len_content = attr_len - 3; - - return attr_ptr+3; - } - - return NULL; -} - -u32 rtw_set_p2p_attr_content23a(u8 *pbuf, u8 attr_id, u16 attr_len, u8 *pdata_attr) -{ - u32 a_len; - - *pbuf = attr_id; - - /* u16*)(pbuf + 1) = cpu_to_le16(attr_len); */ - put_unaligned_le16(attr_len, pbuf + 1); - - if (pdata_attr) - memcpy(pbuf + 3, pdata_attr, attr_len); - - a_len = attr_len + 3; - - return a_len; -} - -static uint rtw_p2p_attr_remove(u8 *ie, uint ielen_ori, u8 attr_id) -{ - u8 *target_attr; - u32 target_attr_len; - uint ielen = ielen_ori; - - while(1) { - target_attr = rtw_get_p2p_attr23a(ie, ielen, attr_id, NULL, - &target_attr_len); - if (target_attr && target_attr_len) { - u8 *next_attr = target_attr+target_attr_len; - uint remain_len = ielen-(next_attr-ie); - /* dump_ies23a(ie, ielen); */ - - memset(target_attr, 0, target_attr_len); - memcpy(target_attr, next_attr, remain_len); - memset(target_attr+remain_len, 0, target_attr_len); - *(ie + 1) -= target_attr_len; - ielen -= target_attr_len; - } else { - /* if (index>0) */ - /* dump_ies23a(ie, ielen); */ - break; - } - } - - return ielen; -} - -void rtw_wlan_bssid_ex_remove_p2p_attr23a(struct wlan_bssid_ex *bss_ex, u8 attr_id) -{ - u8 *p2p_ie; - uint p2p_ielen, p2p_ielen_ori; - - if ((p2p_ie = rtw_get_p2p_ie23a(bss_ex->IEs + _FIXED_IE_LENGTH_, - bss_ex->IELength - _FIXED_IE_LENGTH_, - NULL, &p2p_ielen_ori))) { - p2p_ielen = rtw_p2p_attr_remove(p2p_ie, p2p_ielen_ori, attr_id); - if (p2p_ielen != p2p_ielen_ori) { - u8 *next_ie_ori = p2p_ie+p2p_ielen_ori; - u8 *next_ie = p2p_ie+p2p_ielen; - uint remain_len; - remain_len = bss_ex->IELength-(next_ie_ori-bss_ex->IEs); - - memcpy(next_ie, next_ie_ori, remain_len); - memset(next_ie+remain_len, 0, p2p_ielen_ori-p2p_ielen); - bss_ex->IELength -= p2p_ielen_ori-p2p_ielen; - } - } -} - -#endif /* CONFIG_8723AU_P2P */ - -#ifdef CONFIG_8723AU_P2P -int rtw_get_wfd_ie(u8 *in_ie, int in_len, u8 *wfd_ie, uint *wfd_ielen) -{ - int match; - const u8 *ie; - - match = 0; - - if (in_len < 0) - return match; - - ie = cfg80211_find_vendor_ie(0x506F9A, 0x0A, in_ie, in_len); - if (ie && (ie[1] <= (MAX_WFD_IE_LEN - 2))) { - if (wfd_ie) { - *wfd_ielen = ie[1] + 2; - memcpy(wfd_ie, ie, ie[1] + 2); - } else - if (wfd_ielen) - *wfd_ielen = 0; - - match = 1; - } - - return match; -} - -/* attr_content: The output buffer, contains the "body field" of - WFD attribute. */ -/* attr_contentlen: The data length of the "body field" of WFD - attribute. */ -int rtw_get_wfd_attr_content(u8 *wfd_ie, uint wfd_ielen, u8 target_attr_id, - u8 *attr_content, uint *attr_contentlen) -{ - int match; - uint cnt = 0; - u8 attr_id, wfd_oui[4] = {0x50, 0x6F, 0x9A, 0x0A}; - - match = false; - - if ((wfd_ie[0] != WLAN_EID_VENDOR_SPECIFIC) || - memcmp(wfd_ie + 2, wfd_oui, 4)) { - return match; - } - - /* 1 (WFD IE) + 1 (Length) + 3 (OUI) + 1 (OUI Type) */ - cnt = 6; - while (cnt < wfd_ielen) { - u16 attrlen = get_unaligned_be16(wfd_ie + cnt + 1); - - attr_id = wfd_ie[cnt]; - if (attr_id == target_attr_id) { - /* 3 -> 1 byte for attribute ID field, 2 - bytes for length field */ - if (attr_content) - memcpy(attr_content, &wfd_ie[cnt + 3], attrlen); - - if (attr_contentlen) - *attr_contentlen = attrlen; - - cnt += attrlen + 3; - - match = true; - break; - } else { - cnt += attrlen + 3; /* goto next */ - } - } - - return match; -} -#endif /* CONFIG_8723AU_P2P */ /* Baron adds to avoid FreeBSD warning */ int ieee80211_is_empty_essid23a(const char *essid, int essid_len) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme.c b/drivers/staging/rtl8723au/core/rtw_mlme.c index 59b2c6cedcf7..67df0d7bd116 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme.c @@ -787,11 +787,6 @@ void rtw_surveydone_event_callback23a(struct rtw_adapter *adapter, u8 *pbuf) spin_unlock_bh(&pmlmepriv->lock); -#ifdef CONFIG_8723AU_P2P - if (check_fwstate(pmlmepriv, _FW_LINKED) == true) - p2p_ps_wk_cmd23a(adapter, P2P_PS_SCAN_DONE, 0); -#endif /* CONFIG_8723AU_P2P */ - rtw_os_xmit_schedule23a(adapter); if(pmlmeext->sitesurvey_res.bss_cnt == 0) @@ -956,10 +951,6 @@ void rtw_indicate_disconnect23a(struct rtw_adapter *padapter) } -#ifdef CONFIG_8723AU_P2P - p2p_ps_wk_cmd23a(padapter, P2P_PS_DISABLE, 1); -#endif /* CONFIG_8723AU_P2P */ - rtw_lps_ctrl_wk_cmd23a(padapter, LPS_CTRL_DISCONNECT, 1); } @@ -1581,16 +1572,9 @@ void rtw_dynamic_check_timer_handler(unsigned long data) rtw_dynamic_chk_wk_cmd23a(adapter); - if (pregistrypriv->wifi_spec == 1) - { -#ifdef CONFIG_8723AU_P2P - struct wifidirect_info *pwdinfo = &adapter->wdinfo; - if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)) -#endif - { - /* auto site survey */ - rtw_auto_scan_handler(adapter); - } + if (pregistrypriv->wifi_spec == 1) { + /* auto site survey */ + rtw_auto_scan_handler(adapter); } out: mod_timer(&adapter->mlmepriv.dynamic_chk_timer, diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index 9b9124c531ec..084003943396 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -631,30 +631,6 @@ void mgt_dispatcher23a(struct rtw_adapter *padapter, #endif } -#ifdef CONFIG_8723AU_P2P -static u32 p2p_listen_state_process(struct rtw_adapter *padapter, - unsigned char *da) -{ - bool response = true; - - if (wdev_to_priv(padapter->rtw_wdev)->p2p_enabled == false || - padapter->mlmepriv.wps_probe_resp_ie == NULL || - padapter->mlmepriv.p2p_probe_resp_ie == NULL) { - DBG_8723A("DON'T issue_probersp23a_p2p23a: p2p_enabled:%d, " - "wps_probe_resp_ie:%p, p2p_probe_resp_ie:%p\n", - wdev_to_priv(padapter->rtw_wdev)->p2p_enabled, - padapter->mlmepriv.wps_probe_resp_ie, - padapter->mlmepriv.p2p_probe_resp_ie); - response = false; - } - - if (response == true) - issue_probersp23a_p2p23a(padapter, da); - - return _SUCCESS; -} -#endif /* CONFIG_8723AU_P2P */ - /**************************************************************************** Following are the callback functions for each subtype of the management frames @@ -676,46 +652,6 @@ unsigned int OnProbeReq23a(struct rtw_adapter *padapter, uint len = skb->len; u8 is_valid_p2p_probereq = false; -#ifdef CONFIG_8723AU_P2P - struct wifidirect_info *pwdinfo = &padapter->wdinfo; - u8 wifi_test_chk_rate = 1; - - if (!rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE) && - !rtw_p2p_chk_state(pwdinfo, P2P_STATE_IDLE) && - !rtw_p2p_chk_role(pwdinfo, P2P_ROLE_CLIENT) && - !rtw_p2p_chk_state(pwdinfo, P2P_STATE_FIND_PHASE_SEARCH) && - !rtw_p2p_chk_state(pwdinfo, P2P_STATE_SCAN)) { - /* mcs_rate = 0 -> CCK 1M rate */ - /* mcs_rate = 1 -> CCK 2M rate */ - /* mcs_rate = 2 -> CCK 5.5M rate */ - /* mcs_rate = 3 -> CCK 11M rate */ - /* In the P2P mode, the driver should not support - the CCK rate */ - - /* IOT issue: Google Nexus7 use 1M rate to send - p2p_probe_req after GO nego completed and Nexus7 - is client */ - if (wifi_test_chk_rate == 1) { - if ((is_valid_p2p_probereq = - process_probe_req_p2p_ie23a(pwdinfo, pframe, - len)) == true) { - if (rtw_p2p_chk_role(pwdinfo, - P2P_ROLE_DEVICE)) { - u8 *sa = ieee80211_get_SA(hdr); - p2p_listen_state_process(padapter, sa); - return _SUCCESS; - } - - if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO)) { - goto _continue; - } - } - } - } - -_continue: -#endif /* CONFIG_8723AU_P2P */ - if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)) { return _SUCCESS; } @@ -761,56 +697,6 @@ unsigned int OnProbeRsp23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) { struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; -#ifdef CONFIG_8723AU_P2P - struct sk_buff *skb = precv_frame->pkt; - struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; - struct wifidirect_info *pwdinfo = &padapter->wdinfo; -#endif - -#ifdef CONFIG_8723AU_P2P - if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_TX_PROVISION_DIS_REQ)) { - if (pwdinfo->tx_prov_disc_info.benable == true) { - if (ether_addr_equal(pwdinfo->tx_prov_disc_info.peerIFAddr, - hdr->addr2)) { - if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_CLIENT)) { - pwdinfo->tx_prov_disc_info.benable = false; - issue_p2p_provision_request23a(padapter, - pwdinfo->tx_prov_disc_info.ssid.ssid, - pwdinfo->tx_prov_disc_info.ssid.ssid_len, - pwdinfo->tx_prov_disc_info.peerDevAddr); - } - else if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_DEVICE) || rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO)) - { - pwdinfo->tx_prov_disc_info.benable = false; - issue_p2p_provision_request23a(padapter, - NULL, - 0, - pwdinfo->tx_prov_disc_info.peerDevAddr); - } - } - } - return _SUCCESS; - } else if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_GONEGO_ING)) { - if (pwdinfo->nego_req_info.benable == true) { - DBG_8723A("[%s] P2P State is GONEGO ING!\n", __func__); - if (ether_addr_equal(pwdinfo->nego_req_info.peerDevAddr, - hdr->addr2)) { - pwdinfo->nego_req_info.benable = false; - issue_p2p_GO_request23a(padapter, pwdinfo->nego_req_info.peerDevAddr); - } - } - } else if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_TX_INVITE_REQ)) { - if (pwdinfo->invitereq_info.benable == true) { - DBG_8723A("[%s] P2P_STATE_TX_INVITE_REQ!\n", __func__); - if (ether_addr_equal( - pwdinfo->invitereq_info.peer_macaddr, - hdr->addr2)) { - pwdinfo->invitereq_info.benable = false; - issue_p2p_invitation_request23a(padapter, pwdinfo->invitereq_info.peer_macaddr); - } - } - } -#endif if (pmlmeext->sitesurvey_res.state == SCAN_PROCESS) { report_survey_event23a(padapter, precv_frame); @@ -910,10 +796,6 @@ unsigned int OnBeacon23a(struct rtw_adapter *padapter, update_beacon23a_info(padapter, pframe, len, psta); } - -#ifdef CONFIG_8723AU_P2P - process_p2p_ps_ie23a(padapter, (pframe + sizeof(struct ieee80211_hdr_3addr)), (len - sizeof(struct ieee80211_hdr_3addr))); -#endif /* CONFIG_8723AU_P2P */ } } else if ((pmlmeinfo->state&0x03) == WIFI_FW_ADHOC_STATE) { psta = rtw_get_stainfo23a(pstapriv, hdr->addr2); @@ -1276,14 +1158,6 @@ unsigned int OnAssocReq23a(struct rtw_adapter *padapter, struct recv_frame *prec uint pkt_len = skb->len; struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; u16 frame_control; -#ifdef CONFIG_8723AU_P2P - struct wifidirect_info *pwdinfo = &padapter->wdinfo; - u8 p2p_status_code = P2P_STATUS_SUCCESS; - u8 *p2pie; - u32 p2pielen = 0; - u8 wfd_ie[MAX_WFD_IE_LEN] = { 0x00 }; - u32 wfd_ielen = 0; -#endif /* CONFIG_8723AU_P2P */ if ((pmlmeinfo->state&0x03) != WIFI_FW_AP_STATE) return _FAIL; @@ -1645,39 +1519,6 @@ unsigned int OnAssocReq23a(struct rtw_adapter *padapter, struct recv_frame *prec if (status != WLAN_STATUS_SUCCESS) goto OnAssocReq23aFail; -#ifdef CONFIG_8723AU_P2P - pstat->is_p2p_device = false; - if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO)) - { - if ((p2pie = rtw_get_p2p_ie23a(pframe + sizeof(struct ieee80211_hdr_3addr) + ie_offset, pkt_len - sizeof(struct ieee80211_hdr_3addr) - ie_offset, NULL, &p2pielen))) - { - pstat->is_p2p_device = true; - if ((p2p_status_code = (u8)process_assoc_req_p2p_ie23a(pwdinfo, pframe, pkt_len, pstat))>0) - { - pstat->p2p_status_code = p2p_status_code; - status = WLAN_STATUS_CAPS_UNSUPPORTED; - goto OnAssocReq23aFail; - } - } -#ifdef CONFIG_8723AU_P2P - if (rtw_get_wfd_ie(pframe + sizeof(struct ieee80211_hdr_3addr) + ie_offset, pkt_len - sizeof(struct ieee80211_hdr_3addr) - ie_offset, wfd_ie, &wfd_ielen)) - { - u8 attr_content[ 10 ] = { 0x00 }; - u32 attr_contentlen = 0; - - DBG_8723A("[%s] WFD IE Found!!\n", __func__); - rtw_get_wfd_attr_content(wfd_ie, wfd_ielen, WFD_ATTR_DEVICE_INFO, attr_content, &attr_contentlen); - if (attr_contentlen) - { - pwdinfo->wfd_info->peer_rtsp_ctrlport = get_unaligned_be16(attr_content + 2); - DBG_8723A("[%s] Peer PORT NUM = %d\n", __func__, pwdinfo->wfd_info->peer_rtsp_ctrlport); - } - } -#endif - } - pstat->p2p_status_code = p2p_status_code; -#endif /* CONFIG_8723AU_P2P */ - /* TODO: identify_proprietary_vendor_ie(); */ /* Realtek proprietary IE */ /* identify if this is Broadcom sta */ @@ -1833,13 +1674,7 @@ unsigned int OnAssocRsp23a(struct rtw_adapter *padapter, struct recv_frame *prec { case WLAN_EID_VENDOR_SPECIFIC: if (!memcmp(pIE->data, WMM_PARA_OUI23A, 6))/* WMM */ - WMM_param_handler23a(padapter, pIE); -#if defined(CONFIG_8723AU_P2P) - else if (!memcmp(pIE->data, WFD_OUI23A, 4)) { /* WFD */ - DBG_8723A("[%s] Found WFD IE\n", __func__); - WFD_info_handler(padapter, pIE); - } -#endif + WMM_param_handler23a(padapter, pIE); break; case WLAN_EID_HT_CAPABILITY: /* HT caps */ @@ -1893,21 +1728,11 @@ unsigned int OnDeAuth23a(struct rtw_adapter *padapter, struct sk_buff *skb = precv_frame->pkt; struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; u8 *pframe = skb->data; -#ifdef CONFIG_8723AU_P2P - struct wifidirect_info *pwdinfo = &padapter->wdinfo; -#endif /* CONFIG_8723AU_P2P */ /* check A3 */ if (!ether_addr_equal(hdr->addr3, get_my_bssid23a(&pmlmeinfo->network))) return _SUCCESS; -#ifdef CONFIG_8723AU_P2P - if (pwdinfo->rx_invitereq_info.scan_op_ch_only) { - mod_timer(&pwdinfo->reset_ch_sitesurvey, - jiffies + msecs_to_jiffies(10)); - } -#endif /* CONFIG_8723AU_P2P */ - reason = le16_to_cpu(*(unsigned short *)(pframe + sizeof(struct ieee80211_hdr_3addr))); DBG_8723A("%s Reason code(%d)\n", __func__, reason); @@ -1959,22 +1784,11 @@ unsigned int OnDisassoc23a(struct rtw_adapter *padapter, struct recv_frame *prec struct sk_buff *skb = precv_frame->pkt; struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; u8 *pframe = skb->data; -#ifdef CONFIG_8723AU_P2P - struct wifidirect_info *pwdinfo = &padapter->wdinfo; -#endif /* CONFIG_8723AU_P2P */ /* check A3 */ if (!ether_addr_equal(hdr->addr3, get_my_bssid23a(&pmlmeinfo->network))) return _SUCCESS; -#ifdef CONFIG_8723AU_P2P - if (pwdinfo->rx_invitereq_info.scan_op_ch_only) - { - mod_timer(&pwdinfo->reset_ch_sitesurvey, - jiffies + msecs_to_jiffies(10)); - } -#endif /* CONFIG_8723AU_P2P */ - reason = le16_to_cpu(*(unsigned short *) (pframe + sizeof(struct ieee80211_hdr_3addr))); @@ -2115,2388 +1929,26 @@ unsigned int OnAction23a_back23a(struct rtw_adapter *padapter, struct recv_frame /* reason_code = frame_body[4] | (frame_body[5] << 8); */ reason_code = get_unaligned_le16(&frame_body[4]); - } else if ((frame_body[3] & BIT(3)) == BIT(3)) { - tid = (frame_body[3] >> 4) & 0x0F; - - preorder_ctrl = &psta->recvreorder_ctrl[tid]; - preorder_ctrl->enable = false; - preorder_ctrl->indicate_seq = 0xffff; - } - - DBG_8723A("%s(): DELBA: %x(%x)\n", __func__, - pmlmeinfo->agg_enable_bitmap, reason_code); - /* todo: how to notify the host while receiving - DELETE BA */ - break; - default: - break; - } - } - return _SUCCESS; -} - -#ifdef CONFIG_8723AU_P2P - -static int get_reg_classes_full_count(struct p2p_channels channel_list) { - int cnt = 0; - int i; - - for (i = 0; i < channel_list.reg_classes; i++) - cnt += channel_list.reg_class[i].channels; - - return cnt; -} - -void issue_p2p_GO_request23a(struct rtw_adapter *padapter, u8* raddr) -{ - unsigned char category = WLAN_CATEGORY_PUBLIC; - u8 action = P2P_PUB_ACTION_ACTION; - u32 p2poui = cpu_to_be32(P2POUI); - u8 oui_subtype = P2P_GO_NEGO_REQ; - u8 wpsie[ 255 ] = { 0x00 }, p2pie[ 255 ] = { 0x00 }; - u8 wpsielen = 0, p2pielen = 0; - u16 len_channellist_attr = 0; -#ifdef CONFIG_8723AU_P2P - u32 wfdielen = 0; -#endif /* CONFIG_8723AU_P2P */ - - struct xmit_frame *pmgntframe; - struct pkt_attrib *pattrib; - unsigned char *pframe; - struct ieee80211_hdr *pwlanhdr; - unsigned short *fctrl; - struct xmit_priv *pxmitpriv = &padapter->xmitpriv; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct wifidirect_info *pwdinfo = &padapter->wdinfo; - - if ((pmgntframe = alloc_mgtxmitframe23a(pxmitpriv)) == NULL) - return; - - DBG_8723A("[%s] In\n", __func__); - /* update attribute */ - pattrib = &pmgntframe->attrib; - update_mgntframe_attrib23a(padapter, pattrib); - - memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET); - - pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET; - pwlanhdr = (struct ieee80211_hdr *)pframe; - - fctrl = &pwlanhdr->frame_control; - *fctrl = 0; - - ether_addr_copy(pwlanhdr->addr1, raddr); - ether_addr_copy(pwlanhdr->addr2, myid(&padapter->eeprompriv)); - ether_addr_copy(pwlanhdr->addr3, myid(&padapter->eeprompriv)); - - SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq); - pmlmeext->mgnt_seq++; - SetFrameSubType(pframe, WIFI_ACTION); - - pframe += sizeof(struct ieee80211_hdr_3addr); - pattrib->pktlen = sizeof(struct ieee80211_hdr_3addr); - - pframe = rtw_set_fixed_ie23a(pframe, 1, &category, &pattrib->pktlen); - pframe = rtw_set_fixed_ie23a(pframe, 1, &action, &pattrib->pktlen); - pframe = rtw_set_fixed_ie23a(pframe, 4, (unsigned char *)&p2poui, - &pattrib->pktlen); - pframe = rtw_set_fixed_ie23a(pframe, 1, &oui_subtype, &pattrib->pktlen); - pwdinfo->negotiation_dialog_token = 1; /*Initialize the dialog value*/ - pframe = rtw_set_fixed_ie23a(pframe, 1, - &pwdinfo->negotiation_dialog_token, - &pattrib->pktlen); - - /* WPS Section */ - wpsielen = 0; - /* WPS OUI */ - *(u32*) (wpsie) = cpu_to_be32(WPSOUI); - wpsielen += 4; - - /* WPS version */ - /* Type: */ - *(u16*) (wpsie + wpsielen) = cpu_to_be16(WPS_ATTR_VER1); - wpsielen += 2; - - /* Length: */ - *(u16*) (wpsie + wpsielen) = cpu_to_be16(0x0001); - wpsielen += 2; - - /* Value: */ - wpsie[wpsielen++] = WPS_VERSION_1; /* Version 1.0 */ - - /* Device Password ID */ - /* Type: */ - *(u16*) (wpsie + wpsielen) = cpu_to_be16(WPS_ATTR_DEVICE_PWID); - wpsielen += 2; - - /* Length: */ - *(u16*) (wpsie + wpsielen) = cpu_to_be16(0x0002); - wpsielen += 2; - - /* Value: */ - - if (pwdinfo->ui_got_wps_info == P2P_GOT_WPSINFO_PEER_DISPLAY_PIN) - { - *(u16*) (wpsie + wpsielen) = cpu_to_be16(WPS_DPID_USER_SPEC); - } - else if (pwdinfo->ui_got_wps_info == P2P_GOT_WPSINFO_SELF_DISPLAY_PIN) - { - *(u16*) (wpsie + wpsielen) = cpu_to_be16(WPS_DPID_REGISTRAR_SPEC); - } - else if (pwdinfo->ui_got_wps_info == P2P_GOT_WPSINFO_PBC) - { - *(u16*) (wpsie + wpsielen) = cpu_to_be16(WPS_DPID_PBC); - } - - wpsielen += 2; - - pframe = rtw_set_ie23a(pframe, WLAN_EID_VENDOR_SPECIFIC, wpsielen, - (unsigned char *) wpsie, &pattrib->pktlen); - - /* P2P IE Section. */ - - /* P2P OUI */ - p2pielen = 0; - p2pie[p2pielen++] = 0x50; - p2pie[p2pielen++] = 0x6F; - p2pie[p2pielen++] = 0x9A; - p2pie[p2pielen++] = 0x09; /* WFA P2P v1.0 */ - - /* Commented by Albert 20110306 */ - /* According to the P2P Specification, the group negoitation request frame should contain 9 P2P attributes */ - /* 1. P2P Capability */ - /* 2. Group Owner Intent */ - /* 3. Configuration Timeout */ - /* 4. Listen Channel */ - /* 5. Extended Listen Timing */ - /* 6. Intended P2P Interface Address */ - /* 7. Channel List */ - /* 8. P2P Device Info */ - /* 9. Operating Channel */ - - /* P2P Capability */ - /* Type: */ - p2pie[p2pielen++] = P2P_ATTR_CAPABILITY; - - /* Length: */ - *(u16*) (p2pie + p2pielen) = cpu_to_le16(0x0002); - p2pielen += 2; - - /* Value: */ - /* Device Capability Bitmap, 1 byte */ - p2pie[p2pielen++] = DMP_P2P_DEVCAP_SUPPORT; - - /* Group Capability Bitmap, 1 byte */ - if (pwdinfo->persistent_supported) - { - p2pie[p2pielen++] = P2P_GRPCAP_CROSS_CONN | P2P_GRPCAP_PERSISTENT_GROUP; - } - else - { - p2pie[p2pielen++] = P2P_GRPCAP_CROSS_CONN; - } - - /* Group Owner Intent */ - /* Type: */ - p2pie[p2pielen++] = P2P_ATTR_GO_INTENT; - - /* Length: */ - *(u16*) (p2pie + p2pielen) = cpu_to_le16(0x0001); - p2pielen += 2; - - /* Value: */ - /* Todo the tie breaker bit. */ - p2pie[p2pielen++] = ((pwdinfo->intent << 1) | BIT(0)); - - /* Configuration Timeout */ - /* Type: */ - p2pie[p2pielen++] = P2P_ATTR_CONF_TIMEOUT; - - /* Length: */ - *(u16*) (p2pie + p2pielen) = cpu_to_le16(0x0002); - p2pielen += 2; - - /* Value: */ - p2pie[p2pielen++] = 200; /* 2 seconds needed to be the P2P GO */ - p2pie[p2pielen++] = 200; /* 2 seconds needed to be the P2P Client */ - - /* Listen Channel */ - /* Type: */ - p2pie[p2pielen++] = P2P_ATTR_LISTEN_CH; - - /* Length: */ - *(u16*) (p2pie + p2pielen) = cpu_to_le16(0x0005); - p2pielen += 2; - - /* Value: */ - /* Country String */ - p2pie[p2pielen++] = 'X'; - p2pie[p2pielen++] = 'X'; - - /* The third byte should be set to 0x04. */ - /* Described in the "Operating Channel Attribute" section. */ - p2pie[p2pielen++] = 0x04; - - /* Operating Class */ - p2pie[p2pielen++] = 0x51; /* Copy from SD7 */ - - /* Channel Number */ - p2pie[p2pielen++] = pwdinfo->listen_channel; /* listening channel number */ - - /* Extended Listen Timing ATTR */ - /* Type: */ - p2pie[p2pielen++] = P2P_ATTR_EX_LISTEN_TIMING; - - /* Length: */ - *(u16*) (p2pie + p2pielen) = cpu_to_le16(0x0004); - p2pielen += 2; - - /* Value: */ - /* Availability Period */ - *(u16*) (p2pie + p2pielen) = cpu_to_le16(0xFFFF); - p2pielen += 2; - - /* Availability Interval */ - *(u16*) (p2pie + p2pielen) = cpu_to_le16(0xFFFF); - p2pielen += 2; - - /* Intended P2P Interface Address */ - /* Type: */ - p2pie[p2pielen++] = P2P_ATTR_INTENTED_IF_ADDR; - - /* Length: */ - *(u16*) (p2pie + p2pielen) = cpu_to_le16(ETH_ALEN); - p2pielen += 2; - - /* Value: */ - memcpy(p2pie + p2pielen, myid(&padapter->eeprompriv), ETH_ALEN); - p2pielen += ETH_ALEN; - - /* Channel List */ - /* Type: */ - p2pie[p2pielen++] = P2P_ATTR_CH_LIST; - - /* Length: */ - /* Country String(3) */ - /* + (Operating Class (1) + Number of Channels(1)) * Operation Classes (?) */ - /* + number of channels in all classes */ - len_channellist_attr = 3 - + (1 + 1) * (u16)(pmlmeext->channel_list.reg_classes) - + get_reg_classes_full_count(pmlmeext->channel_list); - - *(u16*) (p2pie + p2pielen) = cpu_to_le16(len_channellist_attr); - p2pielen += 2; - - /* Value: */ - /* Country String */ - p2pie[p2pielen++] = 'X'; - p2pie[p2pielen++] = 'X'; - - /* The third byte should be set to 0x04. */ - /* Described in the "Operating Channel Attribute" section. */ - p2pie[p2pielen++] = 0x04; - - /* Channel Entry List */ - - { - int i, j; - for (j = 0; j < pmlmeext->channel_list.reg_classes; j++) { - /* Operating Class */ - p2pie[p2pielen++] = pmlmeext->channel_list.reg_class[j].reg_class; - - /* Number of Channels */ - p2pie[p2pielen++] = pmlmeext->channel_list.reg_class[j].channels; - - /* Channel List */ - for (i = 0; i < pmlmeext->channel_list.reg_class[j].channels; i++) { - p2pie[p2pielen++] = pmlmeext->channel_list.reg_class[j].channel[i]; - } - } - } - - /* Device Info */ - /* Type: */ - p2pie[p2pielen++] = P2P_ATTR_DEVICE_INFO; - - /* Length: */ - /* 21 -> P2P Device Address (6bytes) + Config Methods (2bytes) + Primary Device Type (8bytes) */ - /* + NumofSecondDevType (1byte) + WPS Device Name ID field (2bytes) + WPS Device Name Len field (2bytes) */ - *(u16*) (p2pie + p2pielen) = cpu_to_le16(21 + pwdinfo->device_name_len); - p2pielen += 2; - - /* Value: */ - /* P2P Device Address */ - memcpy(p2pie + p2pielen, myid(&padapter->eeprompriv), ETH_ALEN); - p2pielen += ETH_ALEN; - - /* Config Method */ - /* This field should be big endian. Noted by P2P specification. */ - - *(u16*) (p2pie + p2pielen) = cpu_to_be16(pwdinfo->supported_wps_cm); - - p2pielen += 2; - - /* Primary Device Type */ - /* Category ID */ - *(u16*) (p2pie + p2pielen) = cpu_to_be16(WPS_PDT_CID_MULIT_MEDIA); - p2pielen += 2; - - /* OUI */ - *(u32*) (p2pie + p2pielen) = cpu_to_be32(WPSOUI); - p2pielen += 4; - - /* Sub Category ID */ - *(u16*) (p2pie + p2pielen) = cpu_to_be16(WPS_PDT_SCID_MEDIA_SERVER); - p2pielen += 2; - - /* Number of Secondary Device Types */ - p2pie[p2pielen++] = 0x00; /* No Secondary Device Type List */ - - /* Device Name */ - /* Type: */ - *(u16*) (p2pie + p2pielen) = cpu_to_be16(WPS_ATTR_DEVICE_NAME); - p2pielen += 2; - - /* Length: */ - *(u16*) (p2pie + p2pielen) = cpu_to_be16(pwdinfo->device_name_len); - p2pielen += 2; - - /* Value: */ - memcpy(p2pie + p2pielen, pwdinfo->device_name, - pwdinfo->device_name_len); - p2pielen += pwdinfo->device_name_len; - - /* Operating Channel */ - /* Type: */ - p2pie[p2pielen++] = P2P_ATTR_OPERATING_CH; - - /* Length: */ - *(u16*) (p2pie + p2pielen) = cpu_to_le16(0x0005); - p2pielen += 2; - - /* Value: */ - /* Country String */ - p2pie[p2pielen++] = 'X'; - p2pie[p2pielen++] = 'X'; - - /* The third byte should be set to 0x04. */ - /* Described in the "Operating Channel Attribute" section. */ - p2pie[p2pielen++] = 0x04; - - /* Operating Class */ - if (pwdinfo->operating_channel <= 14) - { - /* Operating Class */ - p2pie[p2pielen++] = 0x51; - } - else if ((pwdinfo->operating_channel >= 36) && (pwdinfo->operating_channel <= 48)) - { - /* Operating Class */ - p2pie[p2pielen++] = 0x73; - } - else - { - /* Operating Class */ - p2pie[p2pielen++] = 0x7c; - } - - /* Channel Number */ - p2pie[p2pielen++] = pwdinfo->operating_channel; /* operating channel number */ - - pframe = rtw_set_ie23a(pframe, WLAN_EID_VENDOR_SPECIFIC, p2pielen, - (unsigned char *) p2pie, &pattrib->pktlen); - -#ifdef CONFIG_8723AU_P2P - wfdielen = build_nego_req_wfd_ie(pwdinfo, pframe); - pframe += wfdielen; - pattrib->pktlen += wfdielen; -#endif /* CONFIG_8723AU_P2P */ - - pattrib->last_txcmdsz = pattrib->pktlen; - - dump_mgntframe23a(padapter, pmgntframe); - - return; -} - -static void issue_p2p_GO_response(struct rtw_adapter *padapter, u8* raddr, u8* frame_body, uint len, u8 result) -{ - - unsigned char category = WLAN_CATEGORY_PUBLIC; - u8 action = P2P_PUB_ACTION_ACTION; - u32 p2poui = cpu_to_be32(P2POUI); - u8 oui_subtype = P2P_GO_NEGO_RESP; - u8 wpsie[255] = { 0x00 }, p2pie[255] = { 0x00 }; - u8 p2pielen = 0; - uint wpsielen = 0; - u16 wps_devicepassword_id = 0x0000; - uint wps_devicepassword_id_len = 0; - u16 len_channellist_attr = 0; - int i, j; - struct xmit_frame *pmgntframe; - struct pkt_attrib *pattrib; - unsigned char *pframe; - struct ieee80211_hdr *pwlanhdr; - unsigned short *fctrl; - struct xmit_priv *pxmitpriv = &padapter->xmitpriv; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct wifidirect_info *pwdinfo = &padapter->wdinfo; -#ifdef CONFIG_8723AU_P2P - u32 wfdielen = 0; -#endif /* CONFIG_8723AU_P2P */ - - if ((pmgntframe = alloc_mgtxmitframe23a(pxmitpriv)) == NULL) - return; - - DBG_8723A("[%s] In, result = %d\n", __func__, result); - /* update attribute */ - pattrib = &pmgntframe->attrib; - update_mgntframe_attrib23a(padapter, pattrib); - - memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET); - - pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET; - pwlanhdr = (struct ieee80211_hdr *)pframe; - - fctrl = &pwlanhdr->frame_control; - *fctrl = 0; - - ether_addr_copy(pwlanhdr->addr1, raddr); - ether_addr_copy(pwlanhdr->addr2, myid(&padapter->eeprompriv)); - ether_addr_copy(pwlanhdr->addr3, myid(&padapter->eeprompriv)); - - SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq); - pmlmeext->mgnt_seq++; - SetFrameSubType(pframe, WIFI_ACTION); - - pframe += sizeof(struct ieee80211_hdr_3addr); - pattrib->pktlen = sizeof(struct ieee80211_hdr_3addr); - - pframe = rtw_set_fixed_ie23a(pframe, 1, &category, &pattrib->pktlen); - pframe = rtw_set_fixed_ie23a(pframe, 1, &action, &pattrib->pktlen); - pframe = rtw_set_fixed_ie23a(pframe, 4, (unsigned char *) &p2poui, - &pattrib->pktlen); - pframe = rtw_set_fixed_ie23a(pframe, 1, &oui_subtype, &pattrib->pktlen); - /* The Dialog Token of provisioning discovery request frame. */ - pwdinfo->negotiation_dialog_token = frame_body[7]; - pframe = rtw_set_fixed_ie23a(pframe, 1, - &pwdinfo->negotiation_dialog_token, - &pattrib->pktlen); - - /* Commented by Albert 20110328 */ - /* Try to get the device password ID from the WPS IE of group - negotiation request frame */ - /* WiFi Direct test plan 5.1.15 */ - rtw_get_wps_ie23a(frame_body + _PUBLIC_ACTION_IE_OFFSET_, - len - _PUBLIC_ACTION_IE_OFFSET_, wpsie, &wpsielen); - rtw_get_wps_attr_content23a(wpsie, wpsielen, WPS_ATTR_DEVICE_PWID, - (u8 *)&wps_devicepassword_id, - &wps_devicepassword_id_len); - wps_devicepassword_id = be16_to_cpu(wps_devicepassword_id); - - memset(wpsie, 0x00, 255); - wpsielen = 0; - - /* WPS Section */ - wpsielen = 0; - /* WPS OUI */ - *(u32*) (wpsie) = cpu_to_be32(WPSOUI); - wpsielen += 4; - - /* WPS version */ - /* Type: */ - *(u16*) (wpsie + wpsielen) = cpu_to_be16(WPS_ATTR_VER1); - wpsielen += 2; - - /* Length: */ - *(u16*) (wpsie + wpsielen) = cpu_to_be16(0x0001); - wpsielen += 2; - - /* Value: */ - wpsie[wpsielen++] = WPS_VERSION_1; /* Version 1.0 */ - - /* Device Password ID */ - /* Type: */ - *(u16*) (wpsie + wpsielen) = cpu_to_be16(WPS_ATTR_DEVICE_PWID); - wpsielen += 2; - - /* Length: */ - *(u16*) (wpsie + wpsielen) = cpu_to_be16(0x0002); - wpsielen += 2; - - /* Value: */ - if (wps_devicepassword_id == WPS_DPID_USER_SPEC) { - *(u16*) (wpsie + wpsielen) = - cpu_to_be16(WPS_DPID_REGISTRAR_SPEC); - } else if (wps_devicepassword_id == WPS_DPID_REGISTRAR_SPEC) { - *(u16*) (wpsie + wpsielen) = cpu_to_be16(WPS_DPID_USER_SPEC); - } else { - *(u16*) (wpsie + wpsielen) = cpu_to_be16(WPS_DPID_PBC); - } - wpsielen += 2; - - /* Commented by Kurt 20120113 */ - /* If some device wants to do p2p handshake without sending prov_disc_req */ - /* We have to get peer_req_cm from here. */ - if (!memcmp(pwdinfo->rx_prov_disc_info.strconfig_method_desc_of_prov_disc_req, "000", 3)) { - if (wps_devicepassword_id == WPS_DPID_USER_SPEC) { - memcpy(pwdinfo->rx_prov_disc_info.strconfig_method_desc_of_prov_disc_req, "dis", 3); - } else if (wps_devicepassword_id == WPS_DPID_REGISTRAR_SPEC) { - memcpy(pwdinfo->rx_prov_disc_info.strconfig_method_desc_of_prov_disc_req, "pad", 3); - } else { - memcpy(pwdinfo->rx_prov_disc_info.strconfig_method_desc_of_prov_disc_req, "pbc", 3); - } - } - - pframe = rtw_set_ie23a(pframe, WLAN_EID_VENDOR_SPECIFIC, wpsielen, - (unsigned char *) wpsie, &pattrib->pktlen); - - /* P2P IE Section. */ - - /* P2P OUI */ - p2pielen = 0; - p2pie[p2pielen++] = 0x50; - p2pie[p2pielen++] = 0x6F; - p2pie[p2pielen++] = 0x9A; - p2pie[p2pielen++] = 0x09; /* WFA P2P v1.0 */ - - /* Commented by Albert 20100908 */ - /* According to the P2P Specification, the group negoitation - response frame should contain 9 P2P attributes */ - /* 1. Status */ - /* 2. P2P Capability */ - /* 3. Group Owner Intent */ - /* 4. Configuration Timeout */ - /* 5. Operating Channel */ - /* 6. Intended P2P Interface Address */ - /* 7. Channel List */ - /* 8. Device Info */ - /* 9. Group ID (Only GO) */ - - /* ToDo: */ - - /* P2P Status */ - /* Type: */ - p2pie[p2pielen++] = P2P_ATTR_STATUS; - - /* Length: */ - *(u16*) (p2pie + p2pielen) = cpu_to_le16(0x0001); - p2pielen += 2; - - /* Value: */ - p2pie[p2pielen++] = result; - - /* P2P Capability */ - /* Type: */ - p2pie[p2pielen++] = P2P_ATTR_CAPABILITY; - - /* Length: */ - *(u16*) (p2pie + p2pielen) = cpu_to_le16(0x0002); - p2pielen += 2; - - /* Value: */ - /* Device Capability Bitmap, 1 byte */ - - if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_CLIENT)) { - /* Commented by Albert 2011/03/08 */ - /* According to the P2P specification */ - /* if the sending device will be client, the P2P - Capability should be reserved of group negotation - response frame */ - p2pie[p2pielen++] = 0; - } else { - /* Be group owner or meet the error case */ - p2pie[p2pielen++] = DMP_P2P_DEVCAP_SUPPORT; - } - - /* Group Capability Bitmap, 1 byte */ - if (pwdinfo->persistent_supported) { - p2pie[p2pielen++] = P2P_GRPCAP_CROSS_CONN | - P2P_GRPCAP_PERSISTENT_GROUP; - } else { - p2pie[p2pielen++] = P2P_GRPCAP_CROSS_CONN; - } - - /* Group Owner Intent */ - /* Type: */ - p2pie[p2pielen++] = P2P_ATTR_GO_INTENT; - - /* Length: */ - *(u16*) (p2pie + p2pielen) = cpu_to_le16(0x0001); - p2pielen += 2; - - /* Value: */ - if (pwdinfo->peer_intent & 0x01) { - /* Peer's tie breaker bit is 1, our tie breaker - bit should be 0 */ - p2pie[p2pielen++] = (pwdinfo->intent << 1); - } else { - /* Peer's tie breaker bit is 0, our tie breaker bit - should be 1 */ - p2pie[p2pielen++] = ((pwdinfo->intent << 1) | BIT(0)); - } - - /* Configuration Timeout */ - /* Type: */ - p2pie[p2pielen++] = P2P_ATTR_CONF_TIMEOUT; - - /* Length: */ - *(u16*) (p2pie + p2pielen) = cpu_to_le16(0x0002); - p2pielen += 2; - - /* Value: */ - /* 2 seconds needed to be the P2P GO */ - p2pie[p2pielen++] = 200; - /* 2 seconds needed to be the P2P Client */ - p2pie[p2pielen++] = 200; - - /* Operating Channel */ - /* Type: */ - p2pie[p2pielen++] = P2P_ATTR_OPERATING_CH; - - /* Length: */ - *(u16*) (p2pie + p2pielen) = cpu_to_le16(0x0005); - p2pielen += 2; - - /* Value: */ - /* Country String */ - p2pie[p2pielen++] = 'X'; - p2pie[p2pielen++] = 'X'; - - /* The third byte should be set to 0x04. */ - /* Described in the "Operating Channel Attribute" section. */ - p2pie[p2pielen++] = 0x04; - - /* Operating Class */ - if (pwdinfo->operating_channel <= 14) { - /* Operating Class */ - p2pie[p2pielen++] = 0x51; - } else if ((pwdinfo->operating_channel >= 36) && - (pwdinfo->operating_channel <= 48)) { - /* Operating Class */ - p2pie[p2pielen++] = 0x73; - } else { - /* Operating Class */ - p2pie[p2pielen++] = 0x7c; - } - - /* Channel Number */ - /* operating channel number */ - p2pie[p2pielen++] = pwdinfo->operating_channel; - - /* Intended P2P Interface Address */ - /* Type: */ - p2pie[p2pielen++] = P2P_ATTR_INTENTED_IF_ADDR; - - /* Length: */ - *(u16*) (p2pie + p2pielen) = cpu_to_le16(ETH_ALEN); - p2pielen += 2; - - /* Value: */ - memcpy(p2pie + p2pielen, myid(&padapter->eeprompriv), ETH_ALEN); - p2pielen += ETH_ALEN; - - /* Channel List */ - /* Type: */ - p2pie[p2pielen++] = P2P_ATTR_CH_LIST; - - /* Country String(3) */ - /* + (Operating Class (1) + Number of Channels(1)) * - Operation Classes (?) */ - /* + number of channels in all classes */ - len_channellist_attr = 3 + - (1 + 1) * (u16)pmlmeext->channel_list.reg_classes + - get_reg_classes_full_count(pmlmeext->channel_list); - - *(u16*) (p2pie + p2pielen) = cpu_to_le16(len_channellist_attr); - - p2pielen += 2; - - /* Value: */ - /* Country String */ - p2pie[p2pielen++] = 'X'; - p2pie[p2pielen++] = 'X'; - - /* The third byte should be set to 0x04. */ - /* Described in the "Operating Channel Attribute" section. */ - p2pie[p2pielen++] = 0x04; - - /* Channel Entry List */ - - for (j = 0; j < pmlmeext->channel_list.reg_classes; j++) { - /* Operating Class */ - p2pie[p2pielen++] = - pmlmeext->channel_list.reg_class[j].reg_class; - - /* Number of Channels */ - p2pie[p2pielen++] = - pmlmeext->channel_list.reg_class[j].channels; - - /* Channel List */ - for (i = 0; - i < pmlmeext->channel_list.reg_class[j].channels; i++) { - p2pie[p2pielen++] = - pmlmeext->channel_list.reg_class[j].channel[i]; - } - } - - /* Device Info */ - /* Type: */ - p2pie[p2pielen++] = P2P_ATTR_DEVICE_INFO; - - /* Length: */ - /* 21 -> P2P Device Address (6bytes) + Config Methods (2bytes) + - Primary Device Type (8bytes) */ - /* + NumofSecondDevType (1byte) + WPS Device Name ID field - (2bytes) + WPS Device Name Len field (2bytes) */ - *(u16*) (p2pie + p2pielen) = cpu_to_le16(21 + pwdinfo->device_name_len); - p2pielen += 2; - - /* Value: */ - /* P2P Device Address */ - memcpy(p2pie + p2pielen, myid(&padapter->eeprompriv), ETH_ALEN); - p2pielen += ETH_ALEN; - - /* Config Method */ - /* This field should be big endian. Noted by P2P specification. */ - - *(u16*) (p2pie + p2pielen) = cpu_to_be16(pwdinfo->supported_wps_cm); - - p2pielen += 2; - - /* Primary Device Type */ - /* Category ID */ - *(u16*) (p2pie + p2pielen) = cpu_to_be16(WPS_PDT_CID_MULIT_MEDIA); - p2pielen += 2; - - /* OUI */ - *(u32*) (p2pie + p2pielen) = cpu_to_be32(WPSOUI); - p2pielen += 4; - - /* Sub Category ID */ - *(u16*) (p2pie + p2pielen) = cpu_to_be16(WPS_PDT_SCID_MEDIA_SERVER); - p2pielen += 2; - - /* Number of Secondary Device Types */ - p2pie[p2pielen++] = 0x00; /* No Secondary Device Type List */ - - /* Device Name */ - /* Type: */ - *(u16*) (p2pie + p2pielen) = cpu_to_be16(WPS_ATTR_DEVICE_NAME); - p2pielen += 2; - - /* Length: */ - *(u16*) (p2pie + p2pielen) = cpu_to_be16(pwdinfo->device_name_len); - p2pielen += 2; - - /* Value: */ - memcpy(p2pie + p2pielen, pwdinfo->device_name, - pwdinfo->device_name_len); - p2pielen += pwdinfo->device_name_len; - - if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO)) - { - /* Group ID Attribute */ - /* Type: */ - p2pie[p2pielen++] = P2P_ATTR_GROUP_ID; - - /* Length: */ - *(u16*) (p2pie + p2pielen) = - cpu_to_le16(ETH_ALEN + pwdinfo->nego_ssidlen); - p2pielen += 2; - - /* Value: */ - /* p2P Device Address */ - memcpy(p2pie + p2pielen, pwdinfo->device_addr, ETH_ALEN); - p2pielen += ETH_ALEN; - - /* SSID */ - memcpy(p2pie + p2pielen, pwdinfo->nego_ssid, - pwdinfo->nego_ssidlen); - p2pielen += pwdinfo->nego_ssidlen; - - } - - pframe = rtw_set_ie23a(pframe, WLAN_EID_VENDOR_SPECIFIC, p2pielen, - (unsigned char *) p2pie, &pattrib->pktlen); - -#ifdef CONFIG_8723AU_P2P - wfdielen = build_nego_resp_wfd_ie(pwdinfo, pframe); - pframe += wfdielen; - pattrib->pktlen += wfdielen; -#endif /* CONFIG_8723AU_P2P */ - - pattrib->last_txcmdsz = pattrib->pktlen; - - dump_mgntframe23a(padapter, pmgntframe); - - return; -} - -static void issue_p2p_GO_confirm(struct rtw_adapter *padapter, u8* raddr, - u8 result) -{ - - unsigned char category = WLAN_CATEGORY_PUBLIC; - u8 action = P2P_PUB_ACTION_ACTION; - u32 p2poui = cpu_to_be32(P2POUI); - u8 oui_subtype = P2P_GO_NEGO_CONF; - u8 p2pie[ 255 ] = { 0x00 }; - u8 p2pielen = 0; - struct xmit_frame *pmgntframe; - struct pkt_attrib *pattrib; - unsigned char *pframe; - struct ieee80211_hdr *pwlanhdr; - unsigned short *fctrl; - struct xmit_priv *pxmitpriv = &padapter->xmitpriv; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct wifidirect_info *pwdinfo = &padapter->wdinfo; -#ifdef CONFIG_8723AU_P2P - u32 wfdielen = 0; -#endif /* CONFIG_8723AU_P2P */ - - if ((pmgntframe = alloc_mgtxmitframe23a(pxmitpriv)) == NULL) - return; - - DBG_8723A("[%s] In\n", __func__); - /* update attribute */ - pattrib = &pmgntframe->attrib; - update_mgntframe_attrib23a(padapter, pattrib); - - memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET); - - pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET; - pwlanhdr = (struct ieee80211_hdr *)pframe; - - fctrl = &pwlanhdr->frame_control; - *fctrl = 0; - - ether_addr_copy(pwlanhdr->addr1, raddr); - ether_addr_copy(pwlanhdr->addr2, myid(&padapter->eeprompriv)); - ether_addr_copy(pwlanhdr->addr3, myid(&padapter->eeprompriv)); - - SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq); - pmlmeext->mgnt_seq++; - SetFrameSubType(pframe, WIFI_ACTION); - - pframe += sizeof(struct ieee80211_hdr_3addr); - pattrib->pktlen = sizeof(struct ieee80211_hdr_3addr); - - pframe = rtw_set_fixed_ie23a(pframe, 1, &category, &pattrib->pktlen); - pframe = rtw_set_fixed_ie23a(pframe, 1, &action, &pattrib->pktlen); - pframe = rtw_set_fixed_ie23a(pframe, 4, (unsigned char *)&p2poui, - &pattrib->pktlen); - pframe = rtw_set_fixed_ie23a(pframe, 1, &oui_subtype, &pattrib->pktlen); - pframe = rtw_set_fixed_ie23a(pframe, 1, - &pwdinfo->negotiation_dialog_token, - &pattrib->pktlen); - /* P2P OUI */ - p2pielen = 0; - p2pie[p2pielen++] = 0x50; - p2pie[p2pielen++] = 0x6F; - p2pie[p2pielen++] = 0x9A; - p2pie[p2pielen++] = 0x09; /* WFA P2P v1.0 */ - - /* Commented by Albert 20110306 */ - /* According to the P2P Specification, the group negoitation - request frame should contain 5 P2P attributes */ - /* 1. Status */ - /* 2. P2P Capability */ - /* 3. Operating Channel */ - /* 4. Channel List */ - /* 5. Group ID (if this WiFi is GO) */ - - /* P2P Status */ - /* Type: */ - p2pie[p2pielen++] = P2P_ATTR_STATUS; - - /* Length: */ - *(u16*) (p2pie + p2pielen) = cpu_to_le16(0x0001); - p2pielen += 2; - - /* Value: */ - p2pie[p2pielen++] = result; - - /* P2P Capability */ - /* Type: */ - p2pie[p2pielen++] = P2P_ATTR_CAPABILITY; - - /* Length: */ - *(u16*) (p2pie + p2pielen) = cpu_to_le16(0x0002); - p2pielen += 2; - - /* Value: */ - /* Device Capability Bitmap, 1 byte */ - p2pie[p2pielen++] = DMP_P2P_DEVCAP_SUPPORT; - - /* Group Capability Bitmap, 1 byte */ - if (pwdinfo->persistent_supported) { - p2pie[p2pielen++] = P2P_GRPCAP_CROSS_CONN | - P2P_GRPCAP_PERSISTENT_GROUP; - } else { - p2pie[p2pielen++] = P2P_GRPCAP_CROSS_CONN; - } - - /* Operating Channel */ - /* Type: */ - p2pie[p2pielen++] = P2P_ATTR_OPERATING_CH; - - /* Length: */ - *(u16*) (p2pie + p2pielen) = cpu_to_le16(0x0005); - p2pielen += 2; - - /* Value: */ - /* Country String */ - p2pie[p2pielen++] = 'X'; - p2pie[p2pielen++] = 'X'; - - /* The third byte should be set to 0x04. */ - /* Described in the "Operating Channel Attribute" section. */ - p2pie[p2pielen++] = 0x04; - - if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_CLIENT)) { - if (pwdinfo->peer_operating_ch <= 14) { - /* Operating Class */ - p2pie[p2pielen++] = 0x51; - } else if ((pwdinfo->peer_operating_ch >= 36) && - (pwdinfo->peer_operating_ch <= 48)) { - /* Operating Class */ - p2pie[p2pielen++] = 0x73; - } else { - /* Operating Class */ - p2pie[p2pielen++] = 0x7c; - } - - p2pie[p2pielen++] = pwdinfo->peer_operating_ch; - } else { - if (pwdinfo->operating_channel <= 14) { - /* Operating Class */ - p2pie[p2pielen++] = 0x51; - } - else if ((pwdinfo->operating_channel >= 36) && - (pwdinfo->operating_channel <= 48)) { - /* Operating Class */ - p2pie[p2pielen++] = 0x73; - } else { - /* Operating Class */ - p2pie[p2pielen++] = 0x7c; - } - - /* Channel Number */ - /* Use the listen channel as the operating channel */ - p2pie[p2pielen++] = pwdinfo->operating_channel; - } - - /* Channel List */ - /* Type: */ - p2pie[p2pielen++] = P2P_ATTR_CH_LIST; - - /* Length: */ - *(u16*) (p2pie + p2pielen) = - cpu_to_le16(pwdinfo->channel_list_attr_len); - p2pielen += 2; - - /* Value: */ - memcpy(p2pie + p2pielen, pwdinfo->channel_list_attr, - pwdinfo->channel_list_attr_len); - p2pielen += pwdinfo->channel_list_attr_len; - - if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO)) { - /* Group ID Attribute */ - /* Type: */ - p2pie[p2pielen++] = P2P_ATTR_GROUP_ID; - - /* Length: */ - *(u16*) (p2pie + p2pielen) = - cpu_to_le16(ETH_ALEN + pwdinfo->nego_ssidlen); - p2pielen += 2; - - /* Value: */ - /* p2P Device Address */ - memcpy(p2pie + p2pielen, pwdinfo->device_addr, ETH_ALEN); - p2pielen += ETH_ALEN; - - /* SSID */ - memcpy(p2pie + p2pielen, pwdinfo->nego_ssid, - pwdinfo->nego_ssidlen); - p2pielen += pwdinfo->nego_ssidlen; - } - - pframe = rtw_set_ie23a(pframe, WLAN_EID_VENDOR_SPECIFIC, p2pielen, - (unsigned char *)p2pie, &pattrib->pktlen); - -#ifdef CONFIG_8723AU_P2P - wfdielen = build_nego_confirm_wfd_ie(pwdinfo, pframe); - pframe += wfdielen; - pattrib->pktlen += wfdielen; -#endif /* CONFIG_8723AU_P2P */ - - pattrib->last_txcmdsz = pattrib->pktlen; - - dump_mgntframe23a(padapter, pmgntframe); - - return; -} - -void issue_p2p_invitation_request23a(struct rtw_adapter *padapter, u8* raddr) -{ - unsigned char category = WLAN_CATEGORY_PUBLIC; - u8 action = P2P_PUB_ACTION_ACTION; - u32 p2poui = cpu_to_be32(P2POUI); - u8 oui_subtype = P2P_INVIT_REQ; - u8 p2pie[ 255 ] = { 0x00 }; - u8 p2pielen = 0; - u8 dialogToken = 3; - u16 len_channellist_attr = 0; -#ifdef CONFIG_8723AU_P2P - u32 wfdielen = 0; -#endif /* CONFIG_8723AU_P2P */ - int i, j; - struct xmit_frame *pmgntframe; - struct pkt_attrib *pattrib; - unsigned char *pframe; - struct ieee80211_hdr *pwlanhdr; - unsigned short *fctrl; - struct xmit_priv *pxmitpriv = &padapter->xmitpriv; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct wifidirect_info *pwdinfo = &padapter->wdinfo; - - if ((pmgntframe = alloc_mgtxmitframe23a(pxmitpriv)) == NULL) - return; - - /* update attribute */ - pattrib = &pmgntframe->attrib; - update_mgntframe_attrib23a(padapter, pattrib); - - memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET); - - pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET; - pwlanhdr = (struct ieee80211_hdr *)pframe; - - fctrl = &pwlanhdr->frame_control; - *fctrl = 0; - - ether_addr_copy(pwlanhdr->addr1, raddr); - ether_addr_copy(pwlanhdr->addr2, myid(&padapter->eeprompriv)); - ether_addr_copy(pwlanhdr->addr3, raddr); - - SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq); - pmlmeext->mgnt_seq++; - SetFrameSubType(pframe, WIFI_ACTION); - - pframe += sizeof(struct ieee80211_hdr_3addr); - pattrib->pktlen = sizeof(struct ieee80211_hdr_3addr); - - pframe = rtw_set_fixed_ie23a(pframe, 1, &category, &pattrib->pktlen); - pframe = rtw_set_fixed_ie23a(pframe, 1, &action, &pattrib->pktlen); - pframe = rtw_set_fixed_ie23a(pframe, 4, (unsigned char *) &p2poui, - &pattrib->pktlen); - pframe = rtw_set_fixed_ie23a(pframe, 1, &oui_subtype, &pattrib->pktlen); - pframe = rtw_set_fixed_ie23a(pframe, 1, &dialogToken, &pattrib->pktlen); - - /* P2P IE Section. */ - - /* P2P OUI */ - p2pielen = 0; - p2pie[p2pielen++] = 0x50; - p2pie[p2pielen++] = 0x6F; - p2pie[p2pielen++] = 0x9A; - p2pie[p2pielen++] = 0x09; /* WFA P2P v1.0 */ - - /* Commented by Albert 20101011 */ - /* According to the P2P Specification, the P2P Invitation - request frame should contain 7 P2P attributes */ - /* 1. Configuration Timeout */ - /* 2. Invitation Flags */ - /* 3. Operating Channel (Only GO) */ - /* 4. P2P Group BSSID (Should be included if I am the GO) */ - /* 5. Channel List */ - /* 6. P2P Group ID */ - /* 7. P2P Device Info */ - - /* Configuration Timeout */ - /* Type: */ - p2pie[p2pielen++] = P2P_ATTR_CONF_TIMEOUT; - - /* Length: */ - *(u16*) (p2pie + p2pielen) = cpu_to_le16(0x0002); - p2pielen += 2; - - /* Value: */ - /* 2 seconds needed to be the P2P GO */ - p2pie[p2pielen++] = 200; - /* 2 seconds needed to be the P2P Client */ - p2pie[p2pielen++] = 200; - - /* Invitation Flags */ - /* Type: */ - p2pie[p2pielen++] = P2P_ATTR_INVITATION_FLAGS; - - /* Length: */ - *(u16*) (p2pie + p2pielen) = cpu_to_le16(0x0001); - p2pielen += 2; - - /* Value: */ - p2pie[p2pielen++] = P2P_INVITATION_FLAGS_PERSISTENT; - - /* Operating Channel */ - /* Type: */ - p2pie[p2pielen++] = P2P_ATTR_OPERATING_CH; - - /* Length: */ - *(u16*) (p2pie + p2pielen) = cpu_to_le16(0x0005); - p2pielen += 2; - - /* Value: */ - /* Country String */ - p2pie[p2pielen++] = 'X'; - p2pie[p2pielen++] = 'X'; - - /* The third byte should be set to 0x04. */ - /* Described in the "Operating Channel Attribute" section. */ - p2pie[p2pielen++] = 0x04; - - /* Operating Class */ - if (pwdinfo->invitereq_info.operating_ch <= 14) - p2pie[p2pielen++] = 0x51; - else if ((pwdinfo->invitereq_info.operating_ch >= 36) && - (pwdinfo->invitereq_info.operating_ch <= 48)) - p2pie[p2pielen++] = 0x73; - else - p2pie[p2pielen++] = 0x7c; - - /* Channel Number */ - /* operating channel number */ - p2pie[p2pielen++] = pwdinfo->invitereq_info.operating_ch; - - if (ether_addr_equal(myid(&padapter->eeprompriv), - pwdinfo->invitereq_info.go_bssid)) { - /* P2P Group BSSID */ - /* Type: */ - p2pie[p2pielen++] = P2P_ATTR_GROUP_BSSID; - - /* Length: */ - *(u16*) (p2pie + p2pielen) = cpu_to_le16(ETH_ALEN); - p2pielen += 2; - - /* Value: */ - /* P2P Device Address for GO */ - memcpy(p2pie + p2pielen, pwdinfo->invitereq_info.go_bssid, - ETH_ALEN); - p2pielen += ETH_ALEN; - } - - /* Channel List */ - /* Type: */ - p2pie[p2pielen++] = P2P_ATTR_CH_LIST; - - /* Length: */ - /* Country String(3) */ - /* + (Operating Class (1) + Number of Channels(1)) * - Operation Classes (?) */ - /* + number of channels in all classes */ - len_channellist_attr = 3 + - (1 + 1) * (u16)pmlmeext->channel_list.reg_classes + - get_reg_classes_full_count(pmlmeext->channel_list); - - *(u16*) (p2pie + p2pielen) = cpu_to_le16(len_channellist_attr); - p2pielen += 2; - - /* Value: */ - /* Country String */ - p2pie[p2pielen++] = 'X'; - p2pie[p2pielen++] = 'X'; - - /* The third byte should be set to 0x04. */ - /* Described in the "Operating Channel Attribute" section. */ - p2pie[p2pielen++] = 0x04; - - /* Channel Entry List */ - for (j = 0; j < pmlmeext->channel_list.reg_classes; j++) { - /* Operating Class */ - p2pie[p2pielen++] = - pmlmeext->channel_list.reg_class[j].reg_class; - - /* Number of Channels */ - p2pie[p2pielen++] = - pmlmeext->channel_list.reg_class[j].channels; - - /* Channel List */ - for (i = 0; - i < pmlmeext->channel_list.reg_class[j].channels; i++) { - p2pie[p2pielen++] = - pmlmeext->channel_list.reg_class[j].channel[i]; - } - } - - /* P2P Group ID */ - /* Type: */ - p2pie[p2pielen++] = P2P_ATTR_GROUP_ID; - - /* Length: */ - *(u16*) (p2pie + p2pielen) = - cpu_to_le16(6 + pwdinfo->invitereq_info.ssidlen); - p2pielen += 2; - - /* Value: */ - /* P2P Device Address for GO */ - memcpy(p2pie + p2pielen, pwdinfo->invitereq_info.go_bssid, ETH_ALEN); - p2pielen += ETH_ALEN; - - /* SSID */ - memcpy(p2pie + p2pielen, pwdinfo->invitereq_info.go_ssid, - pwdinfo->invitereq_info.ssidlen); - p2pielen += pwdinfo->invitereq_info.ssidlen; - - /* Device Info */ - /* Type: */ - p2pie[p2pielen++] = P2P_ATTR_DEVICE_INFO; - - /* Length: */ - /* 21 -> P2P Device Address (6bytes) + Config Methods (2bytes) + - Primary Device Type (8bytes) */ - /* + NumofSecondDevType (1byte) + WPS Device Name ID field - (2bytes) + WPS Device Name Len field (2bytes) */ - *(u16*) (p2pie + p2pielen) = cpu_to_le16(21 + pwdinfo->device_name_len); - p2pielen += 2; - - /* Value: */ - /* P2P Device Address */ - memcpy(p2pie + p2pielen, myid(&padapter->eeprompriv), ETH_ALEN); - p2pielen += ETH_ALEN; - - /* Config Method */ - /* This field should be big endian. Noted by P2P specification. */ - *(u16*) (p2pie + p2pielen) = cpu_to_be16(WPS_CONFIG_METHOD_DISPLAY); - p2pielen += 2; - - /* Primary Device Type */ - /* Category ID */ - *(u16*) (p2pie + p2pielen) = cpu_to_be16(WPS_PDT_CID_MULIT_MEDIA); - p2pielen += 2; - - /* OUI */ - *(u32*) (p2pie + p2pielen) = cpu_to_be32(WPSOUI); - p2pielen += 4; - - /* Sub Category ID */ - *(u16*) (p2pie + p2pielen) = cpu_to_be16(WPS_PDT_SCID_MEDIA_SERVER); - p2pielen += 2; - - /* Number of Secondary Device Types */ - p2pie[p2pielen++] = 0x00; /* No Secondary Device Type List */ - - /* Device Name */ - /* Type: */ - *(u16*) (p2pie + p2pielen) = cpu_to_be16(WPS_ATTR_DEVICE_NAME); - p2pielen += 2; - - /* Length: */ - *(u16*) (p2pie + p2pielen) = cpu_to_be16(pwdinfo->device_name_len); - p2pielen += 2; - - /* Value: */ - memcpy(p2pie + p2pielen, pwdinfo->device_name, - pwdinfo->device_name_len); - p2pielen += pwdinfo->device_name_len; - - pframe = rtw_set_ie23a(pframe, WLAN_EID_VENDOR_SPECIFIC, p2pielen, - (unsigned char *) p2pie, &pattrib->pktlen); - -#ifdef CONFIG_8723AU_P2P - wfdielen = build_invitation_req_wfd_ie(pwdinfo, pframe); - pframe += wfdielen; - pattrib->pktlen += wfdielen; -#endif /* CONFIG_8723AU_P2P */ - - pattrib->last_txcmdsz = pattrib->pktlen; - - dump_mgntframe23a(padapter, pmgntframe); - - return; -} - -void issue_p2p_invitation_response23a(struct rtw_adapter *padapter, u8 *raddr, - u8 dialogToken, u8 status_code) -{ - unsigned char category = WLAN_CATEGORY_PUBLIC; - u8 action = P2P_PUB_ACTION_ACTION; - u32 p2poui = cpu_to_be32(P2POUI); - u8 oui_subtype = P2P_INVIT_RESP; - u8 p2pie[ 255 ] = { 0x00 }; - u8 p2pielen = 0; - u16 len_channellist_attr = 0; -#ifdef CONFIG_8723AU_P2P - u32 wfdielen = 0; -#endif /* CONFIG_8723AU_P2P */ - int i, j; - - struct xmit_frame *pmgntframe; - struct pkt_attrib *pattrib; - unsigned char *pframe; - struct ieee80211_hdr *pwlanhdr; - unsigned short *fctrl; - struct xmit_priv *pxmitpriv = &padapter->xmitpriv; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct wifidirect_info *pwdinfo = &padapter->wdinfo; - - if ((pmgntframe = alloc_mgtxmitframe23a(pxmitpriv)) == NULL) - return; - - /* update attribute */ - pattrib = &pmgntframe->attrib; - update_mgntframe_attrib23a(padapter, pattrib); - - memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET); - - pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET; - pwlanhdr = (struct ieee80211_hdr *)pframe; - - fctrl = &pwlanhdr->frame_control; - *fctrl = 0; - - ether_addr_copy(pwlanhdr->addr1, raddr); - ether_addr_copy(pwlanhdr->addr2, myid(&padapter->eeprompriv)); - ether_addr_copy(pwlanhdr->addr3, raddr); - - SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq); - pmlmeext->mgnt_seq++; - SetFrameSubType(pframe, WIFI_ACTION); - - pframe += sizeof(struct ieee80211_hdr_3addr); - pattrib->pktlen = sizeof(struct ieee80211_hdr_3addr); - - pframe = rtw_set_fixed_ie23a(pframe, 1, &category, &pattrib->pktlen); - pframe = rtw_set_fixed_ie23a(pframe, 1, &action, &pattrib->pktlen); - pframe = rtw_set_fixed_ie23a(pframe, 4, (unsigned char *)&p2poui, - &pattrib->pktlen); - pframe = rtw_set_fixed_ie23a(pframe, 1, &oui_subtype, &pattrib->pktlen); - pframe = rtw_set_fixed_ie23a(pframe, 1, &dialogToken, &pattrib->pktlen); - - /* P2P IE Section. */ - - /* P2P OUI */ - p2pielen = 0; - p2pie[p2pielen++] = 0x50; - p2pie[p2pielen++] = 0x6F; - p2pie[p2pielen++] = 0x9A; - p2pie[p2pielen++] = 0x09; /* WFA P2P v1.0 */ - - /* Commented by Albert 20101005 */ - /* According to the P2P Specification, the P2P Invitation - response frame should contain 5 P2P attributes */ - /* 1. Status */ - /* 2. Configuration Timeout */ - /* 3. Operating Channel (Only GO) */ - /* 4. P2P Group BSSID (Only GO) */ - /* 5. Channel List */ - - /* P2P Status */ - /* Type: */ - p2pie[p2pielen++] = P2P_ATTR_STATUS; - - /* Length: */ - *(u16*) (p2pie + p2pielen) = cpu_to_le16(0x0001); - p2pielen += 2; - - /* Value: */ - /* When status code is P2P_STATUS_FAIL_INFO_UNAVAILABLE. */ - /* Sent the event receiving the P2P Invitation Req frame - to DMP UI. */ - /* DMP had to compare the MAC address to find out the profile. */ - /* So, the WiFi driver will send the - P2P_STATUS_FAIL_INFO_UNAVAILABLE to NB. */ - /* If the UI found the corresponding profile, the WiFi driver - sends the P2P Invitation Req */ - /* to NB to rebuild the persistent group. */ - p2pie[p2pielen++] = status_code; - - /* Configuration Timeout */ - /* Type: */ - p2pie[p2pielen++] = P2P_ATTR_CONF_TIMEOUT; - - /* Length: */ - *(u16*) (p2pie + p2pielen) = cpu_to_le16(0x0002); - p2pielen += 2; - - /* Value: */ - /* 2 seconds needed to be the P2P GO */ - p2pie[p2pielen++] = 200; - /* 2 seconds needed to be the P2P Client */ - p2pie[p2pielen++] = 200; - - if (status_code == P2P_STATUS_SUCCESS) { - if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO)) { - /* The P2P Invitation request frame asks this - Wi-Fi device to be the P2P GO */ - /* In this case, the P2P Invitation response - frame should carry the two more P2P attributes. */ - /* First one is operating channel attribute. */ - /* Second one is P2P Group BSSID attribute. */ - - /* Operating Channel */ - /* Type: */ - p2pie[p2pielen++] = P2P_ATTR_OPERATING_CH; - - /* Length: */ - *(u16*) (p2pie + p2pielen) = cpu_to_le16(0x0005); - p2pielen += 2; - - /* Value: */ - /* Country String */ - p2pie[p2pielen++] = 'X'; - p2pie[p2pielen++] = 'X'; - - /* The third byte should be set to 0x04. */ - /* Described in the "Operating Channel Attribute" - section. */ - p2pie[p2pielen++] = 0x04; - - /* Operating Class */ - /* Copy from SD7 */ - p2pie[p2pielen++] = 0x51; - - /* Channel Number */ - /* operating channel number */ - p2pie[p2pielen++] = pwdinfo->operating_channel; - - /* P2P Group BSSID */ - /* Type: */ - p2pie[p2pielen++] = P2P_ATTR_GROUP_BSSID; - - /* Length: */ - *(u16*) (p2pie + p2pielen) = cpu_to_le16(ETH_ALEN); - p2pielen += 2; - - /* Value: */ - /* P2P Device Address for GO */ - memcpy(p2pie + p2pielen, myid(&padapter->eeprompriv), - ETH_ALEN); - p2pielen += ETH_ALEN; - } - - /* Channel List */ - /* Type: */ - p2pie[p2pielen++] = P2P_ATTR_CH_LIST; - - /* Length: */ - /* Country String(3) */ - /* + (Operating Class (1) + Number of Channels(1)) * - Operation Classes (?) */ - /* + number of channels in all classes */ - len_channellist_attr = 3 + - (1 + 1) * (u16)pmlmeext->channel_list.reg_classes + - get_reg_classes_full_count(pmlmeext->channel_list); - - *(u16*) (p2pie + p2pielen) = cpu_to_le16(len_channellist_attr); - p2pielen += 2; - - /* Value: */ - /* Country String */ - p2pie[p2pielen++] = 'X'; - p2pie[p2pielen++] = 'X'; - - /* The third byte should be set to 0x04. */ - /* Described in the "Operating Channel Attribute" section. */ - p2pie[p2pielen++] = 0x04; - - /* Channel Entry List */ - for (j = 0; j < pmlmeext->channel_list.reg_classes; j++) { - /* Operating Class */ - p2pie[p2pielen++] = - pmlmeext->channel_list.reg_class[j].reg_class; - - /* Number of Channels */ - p2pie[p2pielen++] = - pmlmeext->channel_list.reg_class[j].channels; - - /* Channel List */ - for (i = 0; - i < pmlmeext->channel_list.reg_class[j].channels; - i++) { - p2pie[p2pielen++] = pmlmeext->channel_list.reg_class[j].channel[i]; - } - } - } - - pframe = rtw_set_ie23a(pframe, WLAN_EID_VENDOR_SPECIFIC, p2pielen, - (unsigned char *)p2pie, &pattrib->pktlen); - -#ifdef CONFIG_8723AU_P2P - wfdielen = build_invitation_resp_wfd_ie(pwdinfo, pframe); - pframe += wfdielen; - pattrib->pktlen += wfdielen; -#endif /* CONFIG_8723AU_P2P */ - - pattrib->last_txcmdsz = pattrib->pktlen; - - dump_mgntframe23a(padapter, pmgntframe); - - return; -} - -void issue_p2p_provision_request23a(struct rtw_adapter *padapter, u8 *pssid, - u8 ussidlen, u8 *pdev_raddr) -{ - unsigned char category = WLAN_CATEGORY_PUBLIC; - u8 action = P2P_PUB_ACTION_ACTION; - u8 dialogToken = 1; - u32 p2poui = cpu_to_be32(P2POUI); - u8 oui_subtype = P2P_PROVISION_DISC_REQ; - u8 wpsie[100] = { 0x00 }; - u8 wpsielen = 0; - u32 p2pielen = 0; -#ifdef CONFIG_8723AU_P2P - u32 wfdielen = 0; -#endif /* CONFIG_8723AU_P2P */ - struct xmit_frame *pmgntframe; - struct pkt_attrib *pattrib; - unsigned char *pframe; - struct ieee80211_hdr *pwlanhdr; - unsigned short *fctrl; - struct xmit_priv *pxmitpriv = &padapter->xmitpriv; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct wifidirect_info *pwdinfo = &padapter->wdinfo; - - if ((pmgntframe = alloc_mgtxmitframe23a(pxmitpriv)) == NULL) - return; - - DBG_8723A("[%s] In\n", __func__); - /* update attribute */ - pattrib = &pmgntframe->attrib; - update_mgntframe_attrib23a(padapter, pattrib); - - memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET); - - pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET; - pwlanhdr = (struct ieee80211_hdr *)pframe; - - fctrl = &pwlanhdr->frame_control; - *fctrl = 0; - - ether_addr_copy(pwlanhdr->addr1, pdev_raddr); - ether_addr_copy(pwlanhdr->addr2, myid(&padapter->eeprompriv)); - ether_addr_copy(pwlanhdr->addr3, pdev_raddr); - - SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq); - pmlmeext->mgnt_seq++; - SetFrameSubType(pframe, WIFI_ACTION); - - pframe += sizeof(struct ieee80211_hdr_3addr); - pattrib->pktlen = sizeof(struct ieee80211_hdr_3addr); - - pframe = rtw_set_fixed_ie23a(pframe, 1, &category, &pattrib->pktlen); - pframe = rtw_set_fixed_ie23a(pframe, 1, &action, &pattrib->pktlen); - pframe = rtw_set_fixed_ie23a(pframe, 4, (unsigned char *)&p2poui, - &pattrib->pktlen); - pframe = rtw_set_fixed_ie23a(pframe, 1, &oui_subtype, &pattrib->pktlen); - pframe = rtw_set_fixed_ie23a(pframe, 1, &dialogToken, &pattrib->pktlen); - - p2pielen = build_prov_disc_request_p2p_ie23a(pwdinfo, pframe, pssid, - ussidlen, pdev_raddr); - - pframe += p2pielen; - pattrib->pktlen += p2pielen; - - wpsielen = 0; - /* WPS OUI */ - *(u32*) (wpsie) = cpu_to_be32(WPSOUI); - wpsielen += 4; - - /* WPS version */ - /* Type: */ - *(u16*) (wpsie + wpsielen) = cpu_to_be16(WPS_ATTR_VER1); - wpsielen += 2; - - /* Length: */ - *(u16*) (wpsie + wpsielen) = cpu_to_be16(0x0001); - wpsielen += 2; - - /* Value: */ - wpsie[wpsielen++] = WPS_VERSION_1; /* Version 1.0 */ - - /* Config Method */ - /* Type: */ - *(u16*) (wpsie + wpsielen) = cpu_to_be16(WPS_ATTR_CONF_METHOD); - wpsielen += 2; - - /* Length: */ - *(u16*) (wpsie + wpsielen) = cpu_to_be16(0x0002); - wpsielen += 2; - - /* Value: */ - *(u16*) (wpsie + wpsielen) = cpu_to_be16(pwdinfo->tx_prov_disc_info.wps_config_method_request); - wpsielen += 2; - - pframe = rtw_set_ie23a(pframe, WLAN_EID_VENDOR_SPECIFIC, wpsielen, - (unsigned char *) wpsie, &pattrib->pktlen); - -#ifdef CONFIG_8723AU_P2P - wfdielen = build_provdisc_req_wfd_ie(pwdinfo, pframe); - pframe += wfdielen; - pattrib->pktlen += wfdielen; -#endif /* CONFIG_8723AU_P2P */ - - pattrib->last_txcmdsz = pattrib->pktlen; - - dump_mgntframe23a(padapter, pmgntframe); - - return; -} - -static u8 is_matched_in_profilelist(u8 *peermacaddr, - struct profile_info *profileinfo) -{ - u8 i, match_result = 0; - - DBG_8723A("[%s] peermac = %.2X %.2X %.2X %.2X %.2X %.2X\n", __func__, - peermacaddr[0], peermacaddr[1], peermacaddr[2], - peermacaddr[3], peermacaddr[4], peermacaddr[5]); - - for (i = 0; i < P2P_MAX_PERSISTENT_GROUP_NUM; i++, profileinfo++) { - DBG_8723A("[%s] profileinfo_mac = %.2X %.2X %.2X %.2X %.2X " - "%.2X\n", __func__, profileinfo->peermac[0], - profileinfo->peermac[1], profileinfo->peermac[2], - profileinfo->peermac[3], profileinfo->peermac[4], - profileinfo->peermac[5]); - if (ether_addr_equal(peermacaddr, profileinfo->peermac)) { - match_result = 1; - DBG_8723A("[%s] Match!\n", __func__); - break; - } - } - - return match_result; -} - -void issue_probersp23a_p2p23a(struct rtw_adapter *padapter, unsigned char *da) -{ - struct xmit_frame *pmgntframe; - struct pkt_attrib *pattrib; - unsigned char *pframe; - struct ieee80211_hdr *pwlanhdr; - unsigned short *fctrl; - unsigned char *mac; - struct xmit_priv *pxmitpriv = &padapter->xmitpriv; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - u16 beacon_interval = 100; - u16 capInfo = 0; - struct wifidirect_info *pwdinfo = &padapter->wdinfo; - u8 wpsie[255] = { 0x00 }; - u32 wpsielen = 0, p2pielen = 0; -#ifdef CONFIG_8723AU_P2P - u32 wfdielen = 0; -#endif /* CONFIG_8723AU_P2P */ - struct cfg80211_wifidirect_info *pcfg80211_wdinfo = - &padapter->cfg80211_wdinfo; - struct ieee80211_channel *ieee_ch = - &pcfg80211_wdinfo->remain_on_ch_channel; - u8 listen_channel = - (u8)ieee80211_frequency_to_channel(ieee_ch->center_freq); - - /* DBG_8723A("%s\n", __func__); */ - - if ((pmgntframe = alloc_mgtxmitframe23a(pxmitpriv)) == NULL) - { - return; - } - - /* update attribute */ - pattrib = &pmgntframe->attrib; - update_mgntframe_attrib23a(padapter, pattrib); - - memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET); - - pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET; - pwlanhdr = (struct ieee80211_hdr *)pframe; - - mac = myid(&padapter->eeprompriv); - - fctrl = &pwlanhdr->frame_control; - *fctrl = 0; - ether_addr_copy(pwlanhdr->addr1, da); - ether_addr_copy(pwlanhdr->addr2, mac); - - /* Use the device address for BSSID field. */ - ether_addr_copy(pwlanhdr->addr3, mac); - - SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq); - pmlmeext->mgnt_seq++; - SetFrameSubType(fctrl, WIFI_PROBERSP); - - pattrib->hdrlen = sizeof(struct ieee80211_hdr_3addr); - pattrib->pktlen = pattrib->hdrlen; - pframe += pattrib->hdrlen; - - /* timestamp will be inserted by hardware */ - pframe += 8; - pattrib->pktlen += 8; - - /* beacon interval: 2 bytes */ - memcpy(pframe, (unsigned char *) &beacon_interval, 2); - pframe += 2; - pattrib->pktlen += 2; - - /* capability info: 2 bytes */ - /* ESS and IBSS bits must be 0 (defined in the 3.1.2.1.1 of - WiFi Direct Spec) */ - capInfo |= cap_ShortPremble; - capInfo |= cap_ShortSlot; - - memcpy(pframe, (unsigned char *) &capInfo, 2); - pframe += 2; - pattrib->pktlen += 2; - - /* SSID */ - pframe = rtw_set_ie23a(pframe, WLAN_EID_SSID, 7, - pwdinfo->p2p_wildcard_ssid, &pattrib->pktlen); - - /* supported rates... */ - /* Use the OFDM rate in the P2P probe response frame. - (6(B), 9(B), 12, 18, 24, 36, 48, 54) */ - pframe = rtw_set_ie23a(pframe, WLAN_EID_SUPP_RATES, 8, - pwdinfo->support_rate, &pattrib->pktlen); - - /* DS parameter set */ - if (wdev_to_priv(padapter->rtw_wdev)->p2p_enabled && - listen_channel != 0) { - pframe = rtw_set_ie23a(pframe, WLAN_EID_DS_PARAMS, 1, - (unsigned char *) &listen_channel, - &pattrib->pktlen); - } else { - pframe = rtw_set_ie23a(pframe, WLAN_EID_DS_PARAMS, 1, - (unsigned char *) - &pwdinfo->listen_channel, - &pattrib->pktlen); - } - - if (wdev_to_priv(padapter->rtw_wdev)->p2p_enabled) { - if (pmlmepriv->wps_probe_resp_ie && - pmlmepriv->p2p_probe_resp_ie) { - /* WPS IE */ - memcpy(pframe, pmlmepriv->wps_probe_resp_ie, - pmlmepriv->wps_probe_resp_ie_len); - pattrib->pktlen += pmlmepriv->wps_probe_resp_ie_len; - pframe += pmlmepriv->wps_probe_resp_ie_len; - - /* P2P IE */ - memcpy(pframe, pmlmepriv->p2p_probe_resp_ie, - pmlmepriv->p2p_probe_resp_ie_len); - pattrib->pktlen += pmlmepriv->p2p_probe_resp_ie_len; - pframe += pmlmepriv->p2p_probe_resp_ie_len; - } - } else { - - /* Todo: WPS IE */ - /* Noted by Albert 20100907 */ - /* According to the WPS specification, all the WPS - attribute is presented by Big Endian. */ - - wpsielen = 0; - /* WPS OUI */ - *(u32*) (wpsie) = cpu_to_be32(WPSOUI); - wpsielen += 4; - - /* WPS version */ - /* Type: */ - *(u16*) (wpsie + wpsielen) = cpu_to_be16(WPS_ATTR_VER1); - wpsielen += 2; - - /* Length: */ - *(u16*) (wpsie + wpsielen) = cpu_to_be16(0x0001); - wpsielen += 2; - - /* Value: */ - wpsie[wpsielen++] = WPS_VERSION_1; /* Version 1.0 */ - - /* WiFi Simple Config State */ - /* Type: */ - *(u16*) (wpsie + wpsielen) = - cpu_to_be16(WPS_ATTR_SIMPLE_CONF_STATE); - wpsielen += 2; - - /* Length: */ - *(u16*) (wpsie + wpsielen) = cpu_to_be16(0x0001); - wpsielen += 2; - - /* Value: */ - wpsie[wpsielen++] = WPS_WSC_STATE_NOT_CONFIG; - - /* Response Type */ - /* Type: */ - *(u16*) (wpsie + wpsielen) = cpu_to_be16(WPS_ATTR_RESP_TYPE); - wpsielen += 2; - - /* Length: */ - *(u16*) (wpsie + wpsielen) = cpu_to_be16(0x0001); - wpsielen += 2; - - /* Value: */ - wpsie[wpsielen++] = WPS_RESPONSE_TYPE_8021X; - - /* UUID-E */ - /* Type: */ - *(u16*) (wpsie + wpsielen) = cpu_to_be16(WPS_ATTR_UUID_E); - wpsielen += 2; - - /* Length: */ - *(u16*) (wpsie + wpsielen) = cpu_to_be16(0x0010); - wpsielen += 2; - - /* Value: */ - memcpy(wpsie + wpsielen, myid(&padapter->eeprompriv), ETH_ALEN); - wpsielen += 0x10; - - /* Manufacturer */ - /* Type: */ - *(u16*) (wpsie + wpsielen) = cpu_to_be16(WPS_ATTR_MANUFACTURER); - wpsielen += 2; - - /* Length: */ - *(u16*) (wpsie + wpsielen) = cpu_to_be16(0x0007); - wpsielen += 2; - - /* Value: */ - memcpy(wpsie + wpsielen, "Realtek", 7); - wpsielen += 7; - - /* Model Name */ - /* Type: */ - *(u16*) (wpsie + wpsielen) = cpu_to_be16(WPS_ATTR_MODEL_NAME); - wpsielen += 2; - - /* Length: */ - *(u16*) (wpsie + wpsielen) = cpu_to_be16(0x0006); - wpsielen += 2; - - /* Value: */ - memcpy(wpsie + wpsielen, "8192CU", 6); - wpsielen += 6; - - /* Model Number */ - /* Type: */ - *(u16*) (wpsie + wpsielen) = cpu_to_be16(WPS_ATTR_MODEL_NUMBER); - wpsielen += 2; - - /* Length: */ - *(u16*) (wpsie + wpsielen) = cpu_to_be16(0x0001); - wpsielen += 2; - - /* Value: */ - wpsie[ wpsielen++ ] = 0x31; /* character 1 */ - - /* Serial Number */ - /* Type: */ - *(u16*) (wpsie + wpsielen) = - cpu_to_be16(WPS_ATTR_SERIAL_NUMBER); - wpsielen += 2; - - /* Length: */ - *(u16*) (wpsie + wpsielen) = cpu_to_be16(ETH_ALEN); - wpsielen += 2; - - /* Value: */ - memcpy(wpsie + wpsielen, "123456", ETH_ALEN); - wpsielen += ETH_ALEN; - - /* Primary Device Type */ - /* Type: */ - *(u16*) (wpsie + wpsielen) = - cpu_to_be16(WPS_ATTR_PRIMARY_DEV_TYPE); - wpsielen += 2; - - /* Length: */ - *(u16*) (wpsie + wpsielen) = cpu_to_be16(0x0008); - wpsielen += 2; - - /* Value: */ - /* Category ID */ - *(u16*) (wpsie + wpsielen) = - cpu_to_be16(WPS_PDT_CID_MULIT_MEDIA); - wpsielen += 2; - - /* OUI */ - *(u32*) (wpsie + wpsielen) = cpu_to_be32(WPSOUI); - wpsielen += 4; - - /* Sub Category ID */ - *(u16*) (wpsie + wpsielen) = - cpu_to_be16(WPS_PDT_SCID_MEDIA_SERVER); - wpsielen += 2; - - /* Device Name */ - /* Type: */ - *(u16*) (wpsie + wpsielen) = cpu_to_be16(WPS_ATTR_DEVICE_NAME); - wpsielen += 2; - - /* Length: */ - *(u16*) (wpsie + wpsielen) = - cpu_to_be16(pwdinfo->device_name_len); - wpsielen += 2; - - /* Value: */ - if (pwdinfo->device_name_len) { - memcpy(wpsie + wpsielen, pwdinfo->device_name, - pwdinfo->device_name_len); - wpsielen += pwdinfo->device_name_len; - } - - /* Config Method */ - /* Type: */ - *(u16*) (wpsie + wpsielen) = cpu_to_be16(WPS_ATTR_CONF_METHOD); - wpsielen += 2; - - /* Length: */ - *(u16*) (wpsie + wpsielen) = cpu_to_be16(0x0002); - wpsielen += 2; - - /* Value: */ - *(u16*) (wpsie + wpsielen) = - cpu_to_be16(pwdinfo->supported_wps_cm); - wpsielen += 2; - - pframe = rtw_set_ie23a(pframe, WLAN_EID_VENDOR_SPECIFIC, - wpsielen, (unsigned char *)wpsie, - &pattrib->pktlen); - - p2pielen = build_probe_resp_p2p_ie23a(pwdinfo, pframe); - pframe += p2pielen; - pattrib->pktlen += p2pielen; - } - -#ifdef CONFIG_8723AU_P2P - if (pwdinfo->wfd_info->wfd_enable) { - wfdielen = build_probe_resp_wfd_ie(pwdinfo, pframe, 0); - pframe += wfdielen; - pattrib->pktlen += wfdielen; - } else if (pmlmepriv->wfd_probe_resp_ie && - pmlmepriv->wfd_probe_resp_ie_len > 0) { - /* WFD IE */ - memcpy(pframe, pmlmepriv->wfd_probe_resp_ie, - pmlmepriv->wfd_probe_resp_ie_len); - pattrib->pktlen += pmlmepriv->wfd_probe_resp_ie_len; - pframe += pmlmepriv->wfd_probe_resp_ie_len; - } -#endif /* CONFIG_8723AU_P2P */ - - pattrib->last_txcmdsz = pattrib->pktlen; - - dump_mgntframe23a(padapter, pmgntframe); - - return; -} - -static int _issue23a_probereq_p2p(struct rtw_adapter *padapter, u8 *da, - int wait_ack) -{ - int ret = _FAIL; - struct xmit_frame *pmgntframe; - struct pkt_attrib *pattrib; - unsigned char *pframe; - struct ieee80211_hdr *pwlanhdr; - unsigned short *fctrl; - unsigned char *mac; - struct xmit_priv *pxmitpriv = &padapter->xmitpriv; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - u8 bc_addr[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; - struct wifidirect_info *pwdinfo = &padapter->wdinfo; - u8 wpsie[255] = {0x00}, p2pie[255] = {0x00}; - u16 wpsielen = 0, p2pielen = 0; -#ifdef CONFIG_8723AU_P2P - u32 wfdielen = 0; -#endif /* CONFIG_8723AU_P2P */ - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - - if ((pmgntframe = alloc_mgtxmitframe23a(pxmitpriv)) == NULL) - goto exit; - - /* update attribute */ - pattrib = &pmgntframe->attrib; - update_mgntframe_attrib23a(padapter, pattrib); - - memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET); - - pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET; - pwlanhdr = (struct ieee80211_hdr *)pframe; - - mac = myid(&padapter->eeprompriv); - - fctrl = &pwlanhdr->frame_control; - *fctrl = 0; - - if (da) { - ether_addr_copy(pwlanhdr->addr1, da); - ether_addr_copy(pwlanhdr->addr3, da); - } else { - if ((pwdinfo->p2p_info.scan_op_ch_only) || - (pwdinfo->rx_invitereq_info.scan_op_ch_only)) { - /* This two flags will be set when this is - only the P2P client mode. */ - ether_addr_copy(pwlanhdr->addr1, - pwdinfo->p2p_peer_interface_addr); - ether_addr_copy(pwlanhdr->addr3, - pwdinfo->p2p_peer_interface_addr); - } else { - /* broadcast probe request frame */ - ether_addr_copy(pwlanhdr->addr1, bc_addr); - ether_addr_copy(pwlanhdr->addr3, bc_addr); - } - } - ether_addr_copy(pwlanhdr->addr2, mac); - - SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq); - pmlmeext->mgnt_seq++; - SetFrameSubType(pframe, WIFI_PROBEREQ); - - pframe += sizeof (struct ieee80211_hdr_3addr); - pattrib->pktlen = sizeof (struct ieee80211_hdr_3addr); - - if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_TX_PROVISION_DIS_REQ)) { - pframe = rtw_set_ie23a(pframe, WLAN_EID_SSID, - pwdinfo->tx_prov_disc_info.ssid.ssid_len, - pwdinfo->tx_prov_disc_info.ssid.ssid, - &pattrib->pktlen); - } else { - pframe = rtw_set_ie23a(pframe, WLAN_EID_SSID, - P2P_WILDCARD_SSID_LEN, - pwdinfo->p2p_wildcard_ssid, - &pattrib->pktlen); - } - /* Use the OFDM rate in the P2P probe request frame. - (6(B), 9(B), 12(B), 24(B), 36, 48, 54) */ - pframe = rtw_set_ie23a(pframe, WLAN_EID_SUPP_RATES, 8, - pwdinfo->support_rate, &pattrib->pktlen); - - if (wdev_to_priv(padapter->rtw_wdev)->p2p_enabled) { - if (pmlmepriv->wps_probe_req_ie && - pmlmepriv->p2p_probe_req_ie) { - /* WPS IE */ - memcpy(pframe, pmlmepriv->wps_probe_req_ie, - pmlmepriv->wps_probe_req_ie_len); - pattrib->pktlen += pmlmepriv->wps_probe_req_ie_len; - pframe += pmlmepriv->wps_probe_req_ie_len; - - /* P2P IE */ - memcpy(pframe, pmlmepriv->p2p_probe_req_ie, - pmlmepriv->p2p_probe_req_ie_len); - pattrib->pktlen += pmlmepriv->p2p_probe_req_ie_len; - pframe += pmlmepriv->p2p_probe_req_ie_len; - } - } else { - - /* WPS IE */ - /* Noted by Albert 20110221 */ - /* According to the WPS specification, all the WPS - attribute is presented by Big Endian. */ - - wpsielen = 0; - /* WPS OUI */ - *(u32*) (wpsie) = cpu_to_be32(WPSOUI); - wpsielen += 4; - - /* WPS version */ - /* Type: */ - *(u16*) (wpsie + wpsielen) = cpu_to_be16(WPS_ATTR_VER1); - wpsielen += 2; - - /* Length: */ - *(u16*) (wpsie + wpsielen) = cpu_to_be16(0x0001); - wpsielen += 2; - - /* Value: */ - wpsie[wpsielen++] = WPS_VERSION_1; /* Version 1.0 */ - - if (pmlmepriv->wps_probe_req_ie == NULL) { - /* UUID-E */ - /* Type: */ - *(u16*) (wpsie + wpsielen) = - cpu_to_be16(WPS_ATTR_UUID_E); - wpsielen += 2; - - /* Length: */ - *(u16*) (wpsie + wpsielen) = cpu_to_be16(0x0010); - wpsielen += 2; - - /* Value: */ - memcpy(wpsie + wpsielen, myid(&padapter->eeprompriv), - ETH_ALEN); - wpsielen += 0x10; - - /* Config Method */ - /* Type: */ - *(u16*) (wpsie + wpsielen) = - cpu_to_be16(WPS_ATTR_CONF_METHOD); - wpsielen += 2; - - /* Length: */ - *(u16*) (wpsie + wpsielen) = cpu_to_be16(0x0002); - wpsielen += 2; - - /* Value: */ - *(u16*) (wpsie + wpsielen) = - cpu_to_be16(pwdinfo->supported_wps_cm); - wpsielen += 2; - } - - /* Device Name */ - /* Type: */ - *(u16*) (wpsie + wpsielen) = cpu_to_be16(WPS_ATTR_DEVICE_NAME); - wpsielen += 2; - - /* Length: */ - *(u16*) (wpsie + wpsielen) = - cpu_to_be16(pwdinfo->device_name_len); - wpsielen += 2; - - /* Value: */ - memcpy(wpsie + wpsielen, pwdinfo->device_name, - pwdinfo->device_name_len); - wpsielen += pwdinfo->device_name_len; - - /* Primary Device Type */ - /* Type: */ - *(u16*) (wpsie + wpsielen) = - cpu_to_be16(WPS_ATTR_PRIMARY_DEV_TYPE); - wpsielen += 2; - - /* Length: */ - *(u16*) (wpsie + wpsielen) = cpu_to_be16(0x0008); - wpsielen += 2; - - /* Value: */ - /* Category ID */ - *(u16*) (wpsie + wpsielen) = cpu_to_be16(WPS_PDT_CID_RTK_WIDI); - wpsielen += 2; - - /* OUI */ - *(u32*) (wpsie + wpsielen) = cpu_to_be32(WPSOUI); - wpsielen += 4; - - /* Sub Category ID */ - *(u16*) (wpsie + wpsielen) = cpu_to_be16(WPS_PDT_SCID_RTK_DMP); - wpsielen += 2; - - /* Device Password ID */ - /* Type: */ - *(u16*) (wpsie + wpsielen) = cpu_to_be16(WPS_ATTR_DEVICE_PWID); - wpsielen += 2; - - /* Length: */ - *(u16*) (wpsie + wpsielen) = cpu_to_be16(0x0002); - wpsielen += 2; - - /* Value: */ - /* Registrar-specified */ - *(u16*) (wpsie + wpsielen) = - cpu_to_be16(WPS_DPID_REGISTRAR_SPEC); - wpsielen += 2; - - pframe = rtw_set_ie23a(pframe, WLAN_EID_VENDOR_SPECIFIC, - wpsielen, (unsigned char *)wpsie, - &pattrib->pktlen); - - /* P2P OUI */ - p2pielen = 0; - p2pie[p2pielen++] = 0x50; - p2pie[p2pielen++] = 0x6F; - p2pie[p2pielen++] = 0x9A; - p2pie[p2pielen++] = 0x09; /* WFA P2P v1.0 */ - - /* Commented by Albert 20110221 */ - /* According to the P2P Specification, the probe request - frame should contain 5 P2P attributes */ - /* 1. P2P Capability */ - /* 2. P2P Device ID if this probe request wants to - find the specific P2P device */ - /* 3. Listen Channel */ - /* 4. Extended Listen Timing */ - /* 5. Operating Channel if this WiFi is working as - the group owner now */ - - /* P2P Capability */ - /* Type: */ - p2pie[p2pielen++] = P2P_ATTR_CAPABILITY; - - /* Length: */ - *(u16*) (p2pie + p2pielen) = cpu_to_le16(0x0002); - p2pielen += 2; - - /* Value: */ - /* Device Capability Bitmap, 1 byte */ - p2pie[p2pielen++] = DMP_P2P_DEVCAP_SUPPORT; - - /* Group Capability Bitmap, 1 byte */ - if (pwdinfo->persistent_supported) - p2pie[p2pielen++] = P2P_GRPCAP_PERSISTENT_GROUP | - DMP_P2P_GRPCAP_SUPPORT; - else - p2pie[p2pielen++] = DMP_P2P_GRPCAP_SUPPORT; - - /* Listen Channel */ - /* Type: */ - p2pie[p2pielen++] = P2P_ATTR_LISTEN_CH; - - /* Length: */ - *(u16*) (p2pie + p2pielen) = cpu_to_le16(0x0005); - p2pielen += 2; - - /* Value: */ - /* Country String */ - p2pie[p2pielen++] = 'X'; - p2pie[p2pielen++] = 'X'; - - /* The third byte should be set to 0x04. */ - /* Described in the "Operating Channel Attribute" section. */ - p2pie[p2pielen++] = 0x04; - - /* Operating Class */ - p2pie[p2pielen++] = 0x51; /* Copy from SD7 */ - - /* Channel Number */ - /* listen channel */ - p2pie[p2pielen++] = pwdinfo->listen_channel; - - /* Extended Listen Timing */ - /* Type: */ - p2pie[p2pielen++] = P2P_ATTR_EX_LISTEN_TIMING; - - /* Length: */ - *(u16*) (p2pie + p2pielen) = cpu_to_le16(0x0004); - p2pielen += 2; - - /* Value: */ - /* Availability Period */ - *(u16*) (p2pie + p2pielen) = cpu_to_le16(0xFFFF); - p2pielen += 2; - - /* Availability Interval */ - *(u16*) (p2pie + p2pielen) = cpu_to_le16(0xFFFF); - p2pielen += 2; - - if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO)) { - /* Operating Channel (if this WiFi is working as - the group owner now) */ - /* Type: */ - p2pie[p2pielen++] = P2P_ATTR_OPERATING_CH; - - /* Length: */ - *(u16*) (p2pie + p2pielen) = cpu_to_le16(0x0005); - p2pielen += 2; - - /* Value: */ - /* Country String */ - p2pie[p2pielen++] = 'X'; - p2pie[p2pielen++] = 'X'; - - /* The third byte should be set to 0x04. */ - /* Described in the "Operating Channel Attribute" - section. */ - p2pie[p2pielen++] = 0x04; - - /* Operating Class */ - p2pie[p2pielen++] = 0x51; /* Copy from SD7 */ - - /* Channel Number */ - /* operating channel number */ - p2pie[p2pielen++] = pwdinfo->operating_channel; - } - - pframe = rtw_set_ie23a(pframe, WLAN_EID_VENDOR_SPECIFIC, - p2pielen, (unsigned char *)p2pie, - &pattrib->pktlen); - - if (pmlmepriv->wps_probe_req_ie) { - /* WPS IE */ - memcpy(pframe, pmlmepriv->wps_probe_req_ie, - pmlmepriv->wps_probe_req_ie_len); - pattrib->pktlen += pmlmepriv->wps_probe_req_ie_len; - pframe += pmlmepriv->wps_probe_req_ie_len; - } - } - -#ifdef CONFIG_8723AU_P2P - if (pwdinfo->wfd_info->wfd_enable) { - wfdielen = build_probe_req_wfd_ie(pwdinfo, pframe); - pframe += wfdielen; - pattrib->pktlen += wfdielen; - } else if (pmlmepriv->wfd_probe_req_ie && - pmlmepriv->wfd_probe_req_ie_len>0) { - /* WFD IE */ - memcpy(pframe, pmlmepriv->wfd_probe_req_ie, - pmlmepriv->wfd_probe_req_ie_len); - pattrib->pktlen += pmlmepriv->wfd_probe_req_ie_len; - pframe += pmlmepriv->wfd_probe_req_ie_len; - } -#endif /* CONFIG_8723AU_P2P */ - - pattrib->last_txcmdsz = pattrib->pktlen; - - RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, - ("issuing probe_req, tx_len =%d\n", pattrib->last_txcmdsz)); - - if (wait_ack) { - ret = dump_mgntframe23a_and_wait_ack23a(padapter, pmgntframe); - } else { - dump_mgntframe23a(padapter, pmgntframe); - ret = _SUCCESS; - } - -exit: - return ret; -} - -inline void issue23a_probereq_p2p(struct rtw_adapter *adapter, u8 *da) -{ - _issue23a_probereq_p2p(adapter, da, false); -} - -int issue23a_probereq_p2p_ex(struct rtw_adapter *adapter, u8 *da, - int try_cnt, int wait_ms) -{ - int ret; - int i = 0; - unsigned long start = jiffies; - - do { - ret = _issue23a_probereq_p2p(adapter, da, - wait_ms > 0 ? true : false); - - i++; - - if (adapter->bDriverStopped || adapter->bSurpriseRemoved) - break; - - if (i < try_cnt && wait_ms > 0 && ret == _FAIL) - msleep(wait_ms); - - } while ((i < try_cnt) && ((ret == _FAIL) || (wait_ms == 0))); + } else if ((frame_body[3] & BIT(3)) == BIT(3)) { + tid = (frame_body[3] >> 4) & 0x0F; - if (ret != _FAIL) { - ret = _SUCCESS; - goto exit; - } + preorder_ctrl = &psta->recvreorder_ctrl[tid]; + preorder_ctrl->enable = false; + preorder_ctrl->indicate_seq = 0xffff; + } - if (try_cnt && wait_ms) { - if (da) - DBG_8723A(FUNC_ADPT_FMT" to "MAC_FMT", ch:%u%s, %d/%d " - "in %u ms\n", FUNC_ADPT_ARG(adapter), - MAC_ARG(da), rtw_get_oper_ch23a(adapter), - ret == _SUCCESS?", acked":"", i, try_cnt, - jiffies_to_msecs(jiffies - start)); - else - DBG_8723A(FUNC_ADPT_FMT", ch:%u%s, %d/%d in %u ms\n", - FUNC_ADPT_ARG(adapter), - rtw_get_oper_ch23a(adapter), - ret == _SUCCESS?", acked":"", i, try_cnt, - jiffies_to_msecs(jiffies - start)); + DBG_8723A("%s(): DELBA: %x(%x)\n", __func__, + pmlmeinfo->agg_enable_bitmap, reason_code); + /* todo: how to notify the host while receiving + DELETE BA */ + break; + default: + break; + } } -exit: - return ret; + return _SUCCESS; } -#endif /* CONFIG_8723AU_P2P */ - static s32 rtw_action_public_decache(struct recv_frame *recv_frame, s32 token) { struct rtw_adapter *adapter = recv_frame->adapter; @@ -4543,15 +1995,6 @@ static unsigned int on_action_public23a_p2p(struct recv_frame *precv_frame) u8 *pframe = skb->data; u8 *frame_body; u8 dialogToken = 0; -#ifdef CONFIG_8723AU_P2P - struct rtw_adapter *padapter = precv_frame->adapter; - struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; - uint len = skb->len; - u8 *p2p_ie; - u32 p2p_ielen; - struct wifidirect_info *pwdinfo = &padapter->wdinfo; - u8 result = P2P_STATUS_SUCCESS; -#endif /* CONFIG_8723AU_P2P */ frame_body = (unsigned char *) (pframe + sizeof(struct ieee80211_hdr_3addr)); @@ -4561,345 +2004,6 @@ static unsigned int on_action_public23a_p2p(struct recv_frame *precv_frame) if (rtw_action_public_decache(precv_frame, dialogToken) == _FAIL) return _FAIL; -#ifdef CONFIG_8723AU_P2P - del_timer_sync(&pwdinfo->reset_ch_sitesurvey); - if (wdev_to_priv(padapter->rtw_wdev)->p2p_enabled) { - rtw_cfg80211_rx_p2p_action_public(padapter, pframe, len); - } else { - /* Do nothing if the driver doesn't enable the P2P function. */ - if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE) || rtw_p2p_chk_state(pwdinfo, P2P_STATE_IDLE)) - return _SUCCESS; - - len -= sizeof(struct ieee80211_hdr_3addr); - - switch (frame_body[ 6 ])/* OUI Subtype */ - { - case P2P_GO_NEGO_REQ: - DBG_8723A("[%s] Got GO Nego Req Frame\n", __func__); - memset(&pwdinfo->groupid_info, 0x00, sizeof(struct group_id_info)); - - if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_RX_PROVISION_DIS_REQ)) - { - rtw_p2p_set_state(pwdinfo, rtw_p2p_pre_state(pwdinfo)); - } - - if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_GONEGO_FAIL)) - { - /* Commented by Albert 20110526 */ - /* In this case, this means the previous nego fail doesn't be reset yet. */ - del_timer_sync(&pwdinfo->restore_p2p_state_timer); - /* Restore the previous p2p state */ - rtw_p2p_set_state(pwdinfo, rtw_p2p_pre_state(pwdinfo)); - DBG_8723A("[%s] Restore the previous p2p state to %d\n", __func__, rtw_p2p_state(pwdinfo)); - } - - /* Commented by Kurt 20110902 */ - /* Add if statement to avoid receiving duplicate prov disc req. such that pre_p2p_state would be covered. */ - if (!rtw_p2p_chk_state(pwdinfo, P2P_STATE_GONEGO_ING)) - rtw_p2p_set_pre_state(pwdinfo, rtw_p2p_state(pwdinfo)); - - /* Commented by Kurt 20120113 */ - /* Get peer_dev_addr here if peer doesn't issue prov_disc frame. */ - if (is_zero_ether_addr(pwdinfo->rx_prov_disc_info.peerDevAddr)) - ether_addr_copy(pwdinfo->rx_prov_disc_info.peerDevAddr, hdr->addr2); - - result = process_p2p_group_negotation_req23a(pwdinfo, frame_body, len); - issue_p2p_GO_response(padapter, hdr->addr2, - frame_body, len, result); - - /* Commented by Albert 20110718 */ - /* No matter negotiating or negotiation failure, the driver should set up the restore P2P state timer. */ - mod_timer(&pwdinfo->restore_p2p_state_timer, - jiffies + msecs_to_jiffies(5000)); - break; - - case P2P_GO_NEGO_RESP: - DBG_8723A("[%s] Got GO Nego Resp Frame\n", __func__); - - if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_GONEGO_ING)) - { - /* Commented by Albert 20110425 */ - /* The restore timer is enabled when issuing the nego request frame of rtw_p2p_connect function. */ - del_timer_sync(&pwdinfo->restore_p2p_state_timer); - pwdinfo->nego_req_info.benable = false; - result = process_p2p_group_negotation_resp23a(pwdinfo, frame_body, len); - issue_p2p_GO_confirm(pwdinfo->padapter, - hdr->addr2, - result); - if (result == P2P_STATUS_SUCCESS) { - if (rtw_p2p_role(pwdinfo) == - P2P_ROLE_CLIENT) { - pwdinfo->p2p_info.operation_ch[ 0 ] = pwdinfo->peer_operating_ch; - pwdinfo->p2p_info.scan_op_ch_only = 1; - mod_timer(&pwdinfo->reset_ch_sitesurvey2, jiffies + msecs_to_jiffies(P2P_RESET_SCAN_CH)); - } - } - - /* Reset the dialog token for group negotiation frames. */ - pwdinfo->negotiation_dialog_token = 1; - - if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_GONEGO_FAIL)) - { - mod_timer(&pwdinfo->restore_p2p_state_timer, jiffies + msecs_to_jiffies(5000)); - } - } else { - DBG_8723A("[%s] Skipped GO Nego Resp Frame (p2p_state != P2P_STATE_GONEGO_ING)\n", __func__); - } - - break; - - case P2P_GO_NEGO_CONF: - - DBG_8723A("[%s] Got GO Nego Confirm Frame\n", __func__); - result = process_p2p_group_negotation_confirm23a(pwdinfo, frame_body, len); - if (P2P_STATUS_SUCCESS == result) - { - if (rtw_p2p_role(pwdinfo) == P2P_ROLE_CLIENT) - { - pwdinfo->p2p_info.operation_ch[ 0 ] = pwdinfo->peer_operating_ch; - pwdinfo->p2p_info.scan_op_ch_only = 1; - mod_timer(&pwdinfo->reset_ch_sitesurvey2, jiffies + msecs_to_jiffies(P2P_RESET_SCAN_CH)); - } - } - break; - - case P2P_INVIT_REQ: - /* Added by Albert 2010/10/05 */ - /* Received the P2P Invite Request frame. */ - - DBG_8723A("[%s] Got invite request frame!\n", __func__); - if ((p2p_ie = rtw_get_p2p_ie23a(frame_body + _PUBLIC_ACTION_IE_OFFSET_, len - _PUBLIC_ACTION_IE_OFFSET_, NULL, &p2p_ielen))) - { - /* Parse the necessary information from the P2P Invitation Request frame. */ - /* For example: The MAC address of sending this P2P Invitation Request frame. */ - u32 attr_contentlen = 0; - u8 status_code = P2P_STATUS_FAIL_INFO_UNAVAILABLE; - struct group_id_info group_id; - u8 invitation_flag = 0; - - rtw_get_p2p_attr23a_content(p2p_ie, p2p_ielen, P2P_ATTR_INVITATION_FLAGS, &invitation_flag, &attr_contentlen); - if (attr_contentlen) - { - - rtw_get_p2p_attr23a_content(p2p_ie, p2p_ielen, P2P_ATTR_GROUP_BSSID, pwdinfo->p2p_peer_interface_addr, &attr_contentlen); - /* Commented by Albert 20120510 */ - /* Copy to the pwdinfo->p2p_peer_interface_addr. */ - /* So that the WFD UI (or Sigma) can get the peer interface address by using the following command. */ - /* #> iwpriv wlan0 p2p_get peer_ifa */ - /* After having the peer interface address, the sigma can find the correct conf file for wpa_supplicant. */ - - if (attr_contentlen) - { - DBG_8723A("[%s] GO's BSSID = %.2X %.2X %.2X %.2X %.2X %.2X\n", __func__, - pwdinfo->p2p_peer_interface_addr[0], pwdinfo->p2p_peer_interface_addr[1], - pwdinfo->p2p_peer_interface_addr[2], pwdinfo->p2p_peer_interface_addr[3], - pwdinfo->p2p_peer_interface_addr[4], pwdinfo->p2p_peer_interface_addr[5]); - } - - if (invitation_flag & P2P_INVITATION_FLAGS_PERSISTENT) - { - /* Re-invoke the persistent group. */ - - memset(&group_id, 0x00, sizeof(struct group_id_info)); - rtw_get_p2p_attr23a_content(p2p_ie, p2p_ielen, P2P_ATTR_GROUP_ID, (u8*) &group_id, &attr_contentlen); - if (attr_contentlen) { - if (ether_addr_equal(group_id.go_device_addr, myid(&padapter->eeprompriv))) { - /* The p2p device sending this p2p invitation request wants this Wi-Fi device to be the persistent GO. */ - rtw_p2p_set_state(pwdinfo, P2P_STATE_RECV_INVITE_REQ_GO); - rtw_p2p_set_role(pwdinfo, P2P_ROLE_GO); - status_code = P2P_STATUS_SUCCESS; - } - else - { - /* The p2p device sending this p2p invitation request wants to be the persistent GO. */ - if (is_matched_in_profilelist(pwdinfo->p2p_peer_interface_addr, &pwdinfo->profileinfo[ 0 ])) - { - u8 operatingch_info[5] = { 0x00 }; - if (rtw_get_p2p_attr23a_content(p2p_ie, p2p_ielen, P2P_ATTR_OPERATING_CH, operatingch_info, &attr_contentlen)) - { - if (rtw_ch_set_search_ch23a(padapter->mlmeextpriv.channel_set, (u32)operatingch_info[4])) - { - /* The operating channel is acceptable for this device. */ - pwdinfo->rx_invitereq_info.operation_ch[0]= operatingch_info[4]; - pwdinfo->rx_invitereq_info.scan_op_ch_only = 1; - mod_timer(&pwdinfo->reset_ch_sitesurvey, jiffies + msecs_to_jiffies(P2P_RESET_SCAN_CH)); - rtw_p2p_set_state(pwdinfo, P2P_STATE_RECV_INVITE_REQ_MATCH); - rtw_p2p_set_role(pwdinfo, P2P_ROLE_CLIENT); - status_code = P2P_STATUS_SUCCESS; - } - else - { - /* The operating channel isn't supported by this device. */ - rtw_p2p_set_state(pwdinfo, P2P_STATE_RECV_INVITE_REQ_DISMATCH); - rtw_p2p_set_role(pwdinfo, P2P_ROLE_DEVICE); - status_code = P2P_STATUS_FAIL_NO_COMMON_CH; - mod_timer(&pwdinfo->restore_p2p_state_timer, jiffies + msecs_to_jiffies(3000)); - } - } - else { - /* Commented by Albert 20121130 */ - /* Intel will use the different P2P IE to store the operating channel information */ - /* Workaround for Intel WiDi 3.5 */ - rtw_p2p_set_state(pwdinfo, P2P_STATE_RECV_INVITE_REQ_MATCH); - rtw_p2p_set_role(pwdinfo, P2P_ROLE_CLIENT); - status_code = P2P_STATUS_SUCCESS; - } - } - else - { - rtw_p2p_set_state(pwdinfo, P2P_STATE_RECV_INVITE_REQ_DISMATCH); - - status_code = P2P_STATUS_FAIL_UNKNOWN_P2PGROUP; - } - } - } - else - { - DBG_8723A("[%s] P2P Group ID Attribute NOT FOUND!\n", __func__); - status_code = P2P_STATUS_FAIL_INFO_UNAVAILABLE; - } - } - else - { - /* Received the invitation to join a P2P group. */ - - memset(&group_id, 0x00, sizeof(struct group_id_info)); - rtw_get_p2p_attr23a_content(p2p_ie, p2p_ielen, P2P_ATTR_GROUP_ID, (u8*) &group_id, &attr_contentlen); - if (attr_contentlen) - { - if (ether_addr_equal(group_id.go_device_addr, myid(&padapter->eeprompriv))) { - /* In this case, the GO can't be myself. */ - rtw_p2p_set_state(pwdinfo, P2P_STATE_RECV_INVITE_REQ_DISMATCH); - status_code = P2P_STATUS_FAIL_INFO_UNAVAILABLE; - } - else - { - /* The p2p device sending this p2p invitation request wants to join an existing P2P group */ - /* Commented by Albert 2012/06/28 */ - /* In this case, this Wi-Fi device should use the iwpriv command to get the peer device address. */ - /* The peer device address should be the destination address for the provisioning discovery request. */ - /* Then, this Wi-Fi device should use the iwpriv command to get the peer interface address. */ - /* The peer interface address should be the address for WPS mac address */ - ether_addr_copy(pwdinfo->p2p_peer_device_addr, group_id.go_device_addr); - rtw_p2p_set_role(pwdinfo, P2P_ROLE_CLIENT); - rtw_p2p_set_state(pwdinfo, P2P_STATE_RECV_INVITE_REQ_JOIN); - status_code = P2P_STATUS_SUCCESS; - } - } - else - { - DBG_8723A("[%s] P2P Group ID Attribute NOT FOUND!\n", __func__); - status_code = P2P_STATUS_FAIL_INFO_UNAVAILABLE; - } - } - } - else - { - DBG_8723A("[%s] P2P Invitation Flags Attribute NOT FOUND!\n", __func__); - status_code = P2P_STATUS_FAIL_INFO_UNAVAILABLE; - } - - DBG_8723A("[%s] status_code = %d\n", __func__, status_code); - - pwdinfo->inviteresp_info.token = frame_body[ 7 ]; - issue_p2p_invitation_response23a(padapter, hdr->addr2, pwdinfo->inviteresp_info.token, status_code); - } - break; - - case P2P_INVIT_RESP: - { - u8 attr_content = 0x00; - u32 attr_contentlen = 0; - - DBG_8723A("[%s] Got invite response frame!\n", __func__); - del_timer_sync(&pwdinfo->restore_p2p_state_timer); - if ((p2p_ie = rtw_get_p2p_ie23a(frame_body + _PUBLIC_ACTION_IE_OFFSET_, len - _PUBLIC_ACTION_IE_OFFSET_, NULL, &p2p_ielen))) - { - rtw_get_p2p_attr23a_content(p2p_ie, p2p_ielen, P2P_ATTR_STATUS, &attr_content, &attr_contentlen); - - if (attr_contentlen == 1) - { - DBG_8723A("[%s] Status = %d\n", __func__, attr_content); - pwdinfo->invitereq_info.benable = false; - - if (attr_content == P2P_STATUS_SUCCESS) - { - if (ether_addr_equal(pwdinfo->invitereq_info.go_bssid, myid(&padapter->eeprompriv))) { - rtw_p2p_set_role(pwdinfo, P2P_ROLE_GO); - } - else - { - rtw_p2p_set_role(pwdinfo, P2P_ROLE_CLIENT); - } - rtw_p2p_set_state(pwdinfo, P2P_STATE_RX_INVITE_RESP_OK); - } - else - { - rtw_p2p_set_role(pwdinfo, P2P_ROLE_DEVICE); - rtw_p2p_set_state(pwdinfo, P2P_STATE_RX_INVITE_RESP_FAIL); - } - } - else - { - rtw_p2p_set_role(pwdinfo, P2P_ROLE_DEVICE); - rtw_p2p_set_state(pwdinfo, P2P_STATE_RX_INVITE_RESP_FAIL); - } - } - else - { - rtw_p2p_set_role(pwdinfo, P2P_ROLE_DEVICE); - rtw_p2p_set_state(pwdinfo, P2P_STATE_RX_INVITE_RESP_FAIL); - } - - if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_RX_INVITE_RESP_FAIL)) { - mod_timer(&pwdinfo->restore_p2p_state_timer, jiffies + msecs_to_jiffies(5000)); - } - break; - } - case P2P_DEVDISC_REQ: - - process_p2p_devdisc_req23a(pwdinfo, pframe, len); - - break; - - case P2P_DEVDISC_RESP: - - process_p2p_devdisc_resp23a(pwdinfo, pframe, len); - - break; - - case P2P_PROVISION_DISC_REQ: - DBG_8723A("[%s] Got Provisioning Discovery Request Frame\n", __func__); - process_p2p_provdisc_req23a(pwdinfo, pframe, len); - ether_addr_copy(pwdinfo->rx_prov_disc_info.peerDevAddr, hdr->addr2); - - /* 20110902 Kurt */ - /* Add the following statement to avoid receiving duplicate prov disc req. such that pre_p2p_state would be covered. */ - if (!rtw_p2p_chk_state(pwdinfo, P2P_STATE_RX_PROVISION_DIS_REQ)) - rtw_p2p_set_pre_state(pwdinfo, rtw_p2p_state(pwdinfo)); - - rtw_p2p_set_state(pwdinfo, P2P_STATE_RX_PROVISION_DIS_REQ); - mod_timer(&pwdinfo->restore_p2p_state_timer, - jiffies + msecs_to_jiffies(P2P_PROVISION_TIMEOUT)); - break; - - case P2P_PROVISION_DISC_RESP: - /* Commented by Albert 20110707 */ - /* Should we check the pwdinfo->tx_prov_disc_info.bsent flag here?? */ - DBG_8723A("[%s] Got Provisioning Discovery Response Frame\n", __func__); - /* Commented by Albert 20110426 */ - /* The restore timer is enabled when issuing the provisioing request frame in rtw_p2p_prov_disc function. */ - del_timer_sync(&pwdinfo->restore_p2p_state_timer); - rtw_p2p_set_state(pwdinfo, P2P_STATE_RX_PROVISION_DIS_RSP); - process_p2p_provdisc_resp23a(pwdinfo, pframe); - mod_timer(&pwdinfo->restore_p2p_state_timer, - jiffies + msecs_to_jiffies(P2P_PROVISION_TIMEOUT)); - break; - - } - } -#endif /* CONFIG_8723AU_P2P */ - return _SUCCESS; } @@ -4992,60 +2096,6 @@ unsigned int OnAction23a_wmm(struct rtw_adapter *padapter, unsigned int OnAction23a_p2p(struct rtw_adapter *padapter, struct recv_frame *precv_frame) { -#ifdef CONFIG_8723AU_P2P - u8 *frame_body; - u8 category, OUI_Subtype, dialogToken = 0; - struct sk_buff *skb = precv_frame->pkt; - struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; - u8 *pframe = skb->data; - uint len = skb->len; - struct wifidirect_info *pwdinfo = &padapter->wdinfo; - - DBG_8723A("%s\n", __func__); - - /* check RA matches or not */ - if (!ether_addr_equal(myid(&padapter->eeprompriv), hdr->addr1)) - return _SUCCESS; - - frame_body = (unsigned char *) - (pframe + sizeof(struct ieee80211_hdr_3addr)); - - category = frame_body[0]; - if (category != WLAN_CATEGORY_VENDOR_SPECIFIC) - return _SUCCESS; - - if (cpu_to_be32(*((u32*) (frame_body + 1))) != P2POUI) - return _SUCCESS; - - if (wdev_to_priv(padapter->rtw_wdev)->p2p_enabled) { - rtw_cfg80211_rx_action_p2p(padapter, pframe, len); - return _SUCCESS; - } else { - len -= sizeof(struct ieee80211_hdr_3addr); - OUI_Subtype = frame_body[5]; - dialogToken = frame_body[6]; - - switch (OUI_Subtype) - { - case P2P_NOTICE_OF_ABSENCE: - break; - - case P2P_PRESENCE_REQUEST: - process_p2p_presence_req23a(pwdinfo, pframe, len); - break; - - case P2P_PRESENCE_RESPONSE: - break; - - case P2P_GO_DISC_REQUEST: - break; - - default: - break; - } - } -#endif /* CONFIG_8723AU_P2P */ - return _SUCCESS; } @@ -5275,9 +2325,6 @@ void issue_beacon23a(struct rtw_adapter *padapter, int timeout_ms) struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; struct wlan_bssid_ex *cur_network = &pmlmeinfo->network; u8 bc_addr[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; -#ifdef CONFIG_8723AU_P2P - struct wifidirect_info *pwdinfo = &padapter->wdinfo; -#endif /* CONFIG_8723AU_P2P */ u8 *wps_ie; u32 wps_ielen; u8 sr = 0; @@ -5319,119 +2366,7 @@ void issue_beacon23a(struct rtw_adapter *padapter, int timeout_ms) if ((pmlmeinfo->state&0x03) == WIFI_FW_AP_STATE) { /* DBG_8723A("ie len =%d\n", cur_network->IELength); */ -#ifdef CONFIG_8723AU_P2P - /* for P2P : Primary Device Type & Device Name */ - u32 insert_len = 0; - wps_ie = rtw_get_wps_ie23a(cur_network->IEs + _FIXED_IE_LENGTH_, - cur_network->IELength - - _FIXED_IE_LENGTH_, NULL, &wps_ielen); - - if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO) && wps_ie && - wps_ielen > 0) { - uint wps_offset, remainder_ielen; - u8 *premainder_ie, *pframe_wscie; - - wps_offset = (uint)(wps_ie - cur_network->IEs); - - premainder_ie = wps_ie + wps_ielen; - - remainder_ielen = cur_network->IELength - wps_offset - - wps_ielen; - - if (wdev_to_priv(padapter->rtw_wdev)->p2p_enabled) { - if (pmlmepriv->wps_beacon_ie && - pmlmepriv->wps_beacon_ie_len>0) { - memcpy(pframe, cur_network->IEs, - wps_offset); - pframe += wps_offset; - pattrib->pktlen += wps_offset; - - memcpy(pframe, pmlmepriv->wps_beacon_ie, - pmlmepriv->wps_beacon_ie_len); - pframe += pmlmepriv->wps_beacon_ie_len; - pattrib->pktlen += - pmlmepriv->wps_beacon_ie_len; - - /* copy remainder_ie to pframe */ - memcpy(pframe, premainder_ie, - remainder_ielen); - pframe += remainder_ielen; - pattrib->pktlen += remainder_ielen; - } else { - memcpy(pframe, cur_network->IEs, - cur_network->IELength); - pframe += cur_network->IELength; - pattrib->pktlen += - cur_network->IELength; - } - } else { - pframe_wscie = pframe + wps_offset; - memcpy(pframe, cur_network->IEs, - wps_offset + wps_ielen); - pframe += (wps_offset + wps_ielen); - pattrib->pktlen += (wps_offset + wps_ielen); - - /* now pframe is end of wsc ie, insert Primary - Device Type & Device Name */ - /* Primary Device Type */ - /* Type: */ - *(u16*) (pframe + insert_len) = - cpu_to_be16(WPS_ATTR_PRIMARY_DEV_TYPE); - insert_len += 2; - - /* Length: */ - *(u16*) (pframe + insert_len) = - cpu_to_be16(0x0008); - insert_len += 2; - - /* Value: */ - /* Category ID */ - *(u16*) (pframe + insert_len) = - cpu_to_be16(WPS_PDT_CID_MULIT_MEDIA); - insert_len += 2; - - /* OUI */ - *(u32*) (pframe + insert_len) = - cpu_to_be32(WPSOUI); - insert_len += 4; - - /* Sub Category ID */ - *(u16*) (pframe + insert_len) = - cpu_to_be16(WPS_PDT_SCID_MEDIA_SERVER); - insert_len += 2; - - /* Device Name */ - /* Type: */ - *(u16*) (pframe + insert_len) = - cpu_to_be16(WPS_ATTR_DEVICE_NAME); - insert_len += 2; - - /* Length: */ - *(u16*) (pframe + insert_len) = - cpu_to_be16(pwdinfo->device_name_len); - insert_len += 2; - - /* Value: */ - memcpy(pframe + insert_len, - pwdinfo->device_name, - pwdinfo->device_name_len); - insert_len += pwdinfo->device_name_len; - - /* update wsc ie length */ - *(pframe_wscie+1) = (wps_ielen -2) + insert_len; - - /* pframe move to end */ - pframe+= insert_len; - pattrib->pktlen += insert_len; - - /* copy remainder_ie to pframe */ - memcpy(pframe, premainder_ie, remainder_ielen); - pframe += remainder_ielen; - pattrib->pktlen += remainder_ielen; - } - } else -#endif /* CONFIG_8723AU_P2P */ - memcpy(pframe, cur_network->IEs, cur_network->IELength); + memcpy(pframe, cur_network->IEs, cur_network->IELength); len_diff = update_hidden_ssid(pframe + _BEACON_IE_OFFSET_, cur_network->IELength - _BEACON_IE_OFFSET_, @@ -5455,36 +2390,6 @@ void issue_beacon23a(struct rtw_adapter *padapter, int timeout_ms) else _clr_fwstate_(pmlmepriv, WIFI_UNDER_WPS); -#ifdef CONFIG_8723AU_P2P - if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO)) { - u32 len; - if (wdev_to_priv(padapter->rtw_wdev)->p2p_enabled) { - len = pmlmepriv->p2p_beacon_ie_len; - if (pmlmepriv->p2p_beacon_ie && len > 0) - memcpy(pframe, - pmlmepriv->p2p_beacon_ie, len); - } else - len = build_beacon_p2p_ie23a(pwdinfo, pframe); - - pframe += len; - pattrib->pktlen += len; - - if (true == pwdinfo->wfd_info->wfd_enable) { - len = build_beacon_wfd_ie(pwdinfo, pframe); - } else { - len = 0; - if (pmlmepriv->wfd_beacon_ie && - pmlmepriv->wfd_beacon_ie_len>0) { - len = pmlmepriv->wfd_beacon_ie_len; - memcpy(pframe, - pmlmepriv->wfd_beacon_ie, len); - } - } - pframe += len; - pattrib->pktlen += len; - } -#endif /* CONFIG_8723AU_P2P */ - goto _issue_bcn; } @@ -5591,17 +2496,12 @@ void issue_probersp23a(struct rtw_adapter *padapter, unsigned char *da, int ssid_ielen_diff; u8 buf[MAX_IE_SZ]; u8 *ies; -#endif -#if defined(CONFIG_8723AU_AP_MODE) || defined(CONFIG_8723AU_P2P) struct mlme_priv *pmlmepriv = &padapter->mlmepriv; #endif struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; struct wlan_bssid_ex *cur_network = &pmlmeinfo->network; unsigned int rate_len; -#ifdef CONFIG_8723AU_P2P - struct wifidirect_info *pwdinfo = &padapter->wdinfo; -#endif /* CONFIG_8723AU_P2P */ /* DBG_8723A("%s\n", __func__); */ @@ -5788,38 +2688,6 @@ void issue_probersp23a(struct rtw_adapter *padapter, unsigned char *da, /* todo:HT for adhoc */ } -#ifdef CONFIG_8723AU_P2P - if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO) && is_valid_p2p_probereq) { - u32 len; - if (wdev_to_priv(padapter->rtw_wdev)->p2p_enabled) { - /* if pwdinfo->role == P2P_ROLE_DEVICE will call - issue_probersp23a_p2p23a() */ - len = pmlmepriv->p2p_go_probe_resp_ie_len; - if (pmlmepriv->p2p_go_probe_resp_ie && len>0) - memcpy(pframe, pmlmepriv->p2p_go_probe_resp_ie, - len); - } else - len = build_probe_resp_p2p_ie23a(pwdinfo, pframe); - - pframe += len; - pattrib->pktlen += len; - - if (true == pwdinfo->wfd_info->wfd_enable) { - len = build_probe_resp_wfd_ie(pwdinfo, pframe, 0); - } else { - len = 0; - if (pmlmepriv->wfd_probe_resp_ie && - pmlmepriv->wfd_probe_resp_ie_len > 0) { - len = pmlmepriv->wfd_probe_resp_ie_len; - memcpy(pframe, pmlmepriv->wfd_probe_resp_ie, - len); - } - } - pframe += len; - pattrib->pktlen += len; - } -#endif /* CONFIG_8723AU_P2P */ - pattrib->last_txcmdsz = pattrib->pktlen; dump_mgntframe23a(padapter, pmgntframe); @@ -6154,10 +3022,6 @@ void issue_asocrsp23a(struct rtw_adapter *padapter, unsigned short status, struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; struct wlan_bssid_ex *pnetwork = &pmlmeinfo->network; u8 *ie = pnetwork->IEs; -#ifdef CONFIG_8723AU_P2P - struct wifidirect_info *pwdinfo = &padapter->wdinfo; - u32 wfdielen = 0; -#endif /* CONFIG_8723AU_P2P */ DBG_8723A("%s\n", __func__); @@ -6282,15 +3146,6 @@ void issue_asocrsp23a(struct rtw_adapter *padapter, unsigned short status, pattrib->pktlen += pmlmepriv->wps_assoc_resp_ie_len; } -#ifdef CONFIG_8723AU_P2P - if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO) && - pwdinfo->wfd_info->wfd_enable) { - wfdielen = build_assoc_resp_wfd_ie(pwdinfo, pframe); - pframe += wfdielen; - pattrib->pktlen += wfdielen; - } -#endif /* CONFIG_8723AU_P2P */ - pattrib->last_txcmdsz = pattrib->pktlen; dump_mgntframe23a(padapter, pmgntframe); @@ -6315,12 +3170,6 @@ void issue_assocreq23a(struct rtw_adapter *padapter) struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; int bssrate_len = 0, sta_bssrate_len = 0; -#ifdef CONFIG_8723AU_P2P - struct wifidirect_info *pwdinfo = &padapter->wdinfo; - u8 p2pie[255] = { 0x00 }; - u16 p2pielen = 0; - u32 wfdielen = 0; -#endif /* CONFIG_8723AU_P2P */ if ((pmgntframe = alloc_mgtxmitframe23a(pxmitpriv)) == NULL) goto exit; @@ -6554,191 +3403,6 @@ void issue_assocreq23a(struct rtw_adapter *padapter) pframe = rtw_set_ie23a(pframe, WLAN_EID_VENDOR_SPECIFIC, 6, REALTEK_96B_IE23A, &pattrib->pktlen); -#ifdef CONFIG_8723AU_P2P - - if (wdev_to_priv(padapter->rtw_wdev)->p2p_enabled) { - if (pmlmepriv->p2p_assoc_req_ie && - pmlmepriv->p2p_assoc_req_ie_len>0) { - memcpy(pframe, pmlmepriv->p2p_assoc_req_ie, - pmlmepriv->p2p_assoc_req_ie_len); - pframe += pmlmepriv->p2p_assoc_req_ie_len; - pattrib->pktlen += pmlmepriv->p2p_assoc_req_ie_len; - } - } else { - if (!rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE) && - !rtw_p2p_chk_state(pwdinfo, P2P_STATE_IDLE)) { - /* Should add the P2P IE in the association - request frame. */ - /* P2P OUI */ - - p2pielen = 0; - p2pie[p2pielen++] = 0x50; - p2pie[p2pielen++] = 0x6F; - p2pie[p2pielen++] = 0x9A; - p2pie[p2pielen++] = 0x09; /* WFA P2P v1.0 */ - - /* Commented by Albert 20101109 */ - /* According to the P2P Specification, the - association request frame should contain - 3 P2P attributes */ - /* 1. P2P Capability */ - /* 2. Extended Listen Timing */ - /* 3. Device Info */ - /* Commented by Albert 20110516 */ - /* 4. P2P Interface */ - - /* P2P Capability */ - /* Type: */ - p2pie[p2pielen++] = P2P_ATTR_CAPABILITY; - - /* Length: */ - *(u16*) (p2pie + p2pielen) = cpu_to_le16(0x0002); - p2pielen += 2; - - /* Value: */ - /* Device Capability Bitmap, 1 byte */ - p2pie[p2pielen++] = DMP_P2P_DEVCAP_SUPPORT; - - /* Group Capability Bitmap, 1 byte */ - if (pwdinfo->persistent_supported) - p2pie[p2pielen++] = - P2P_GRPCAP_PERSISTENT_GROUP | - DMP_P2P_GRPCAP_SUPPORT; - else - p2pie[p2pielen++] = DMP_P2P_GRPCAP_SUPPORT; - - /* Extended Listen Timing */ - /* Type: */ - p2pie[p2pielen++] = P2P_ATTR_EX_LISTEN_TIMING; - - /* Length: */ - *(u16*) (p2pie + p2pielen) = cpu_to_le16(0x0004); - p2pielen += 2; - - /* Value: */ - /* Availability Period */ - *(u16*) (p2pie + p2pielen) = cpu_to_le16(0xFFFF); - p2pielen += 2; - - /* Availability Interval */ - *(u16*) (p2pie + p2pielen) = cpu_to_le16(0xFFFF); - p2pielen += 2; - - /* Device Info */ - /* Type: */ - p2pie[p2pielen++] = P2P_ATTR_DEVICE_INFO; - - /* Length: */ - /* 21 -> P2P Device Address (6bytes) + Config - Methods (2bytes) + Primary Device - Type (8bytes) */ - /* + NumofSecondDevType (1byte) + WPS Device - Name ID field (2bytes) + WPS Device Name - Len field (2bytes) */ - *(u16*) (p2pie + p2pielen) = - cpu_to_le16(21 + pwdinfo->device_name_len); - p2pielen += 2; - - /* Value: */ - /* P2P Device Address */ - memcpy(p2pie + p2pielen, - myid(&padapter->eeprompriv), ETH_ALEN); - p2pielen += ETH_ALEN; - - /* Config Method */ - /* This field should be big endian. - Noted by P2P specification. */ - if ((pwdinfo->ui_got_wps_info == - P2P_GOT_WPSINFO_PEER_DISPLAY_PIN) || - (pwdinfo->ui_got_wps_info == - P2P_GOT_WPSINFO_SELF_DISPLAY_PIN)) - *(u16*) (p2pie + p2pielen) = - cpu_to_be16(WPS_CONFIG_METHOD_DISPLAY); - else - *(u16*) (p2pie + p2pielen) = - cpu_to_be16(WPS_CONFIG_METHOD_PBC); - - p2pielen += 2; - - /* Primary Device Type */ - /* Category ID */ - *(u16*) (p2pie + p2pielen) = - cpu_to_be16(WPS_PDT_CID_MULIT_MEDIA); - p2pielen += 2; - - /* OUI */ - *(u32*) (p2pie + p2pielen) = cpu_to_be32(WPSOUI); - p2pielen += 4; - - /* Sub Category ID */ - *(u16*) (p2pie + p2pielen) = - cpu_to_be16(WPS_PDT_SCID_MEDIA_SERVER); - p2pielen += 2; - - /* Number of Secondary Device Types */ - /* No Secondary Device Type List */ - p2pie[p2pielen++] = 0x00; - - /* Device Name */ - /* Type: */ - *(u16*) (p2pie + p2pielen) = - cpu_to_be16(WPS_ATTR_DEVICE_NAME); - p2pielen += 2; - - /* Length: */ - *(u16*) (p2pie + p2pielen) = - cpu_to_be16(pwdinfo->device_name_len); - p2pielen += 2; - - /* Value: */ - memcpy(p2pie + p2pielen, pwdinfo->device_name, - pwdinfo->device_name_len); - p2pielen += pwdinfo->device_name_len; - - /* P2P Interface */ - /* Type: */ - p2pie[p2pielen++] = P2P_ATTR_INTERFACE; - - /* Length: */ - *(u16*) (p2pie + p2pielen) = cpu_to_le16(0x000D); - p2pielen += 2; - - /* Value: */ - memcpy(p2pie + p2pielen, pwdinfo->device_addr, - ETH_ALEN); /* P2P Device Address */ - p2pielen += ETH_ALEN; - - /* P2P Interface Address Count */ - p2pie[p2pielen++] = 1; - - memcpy(p2pie + p2pielen, pwdinfo->device_addr, - ETH_ALEN); /* P2P Interface Address List */ - p2pielen += ETH_ALEN; - - pframe = rtw_set_ie23a(pframe, WLAN_EID_VENDOR_SPECIFIC, - p2pielen, (unsigned char *)p2pie, - &pattrib->pktlen); - - /* wfdielen = build_assoc_req_wfd_ie(pwdinfo, pframe);*/ - /* pframe += wfdielen; */ - /* pattrib->pktlen += wfdielen; */ - } - } - - if (true == pwdinfo->wfd_info->wfd_enable) { - wfdielen = build_assoc_req_wfd_ie(pwdinfo, pframe); - pframe += wfdielen; - pattrib->pktlen += wfdielen; - } else if (pmlmepriv->wfd_assoc_req_ie != NULL && - pmlmepriv->wfd_assoc_req_ie_len > 0) { - /* WFD IE */ - memcpy(pframe, pmlmepriv->wfd_assoc_req_ie, - pmlmepriv->wfd_assoc_req_ie_len); - pattrib->pktlen += pmlmepriv->wfd_assoc_req_ie_len; - pframe += pmlmepriv->wfd_assoc_req_ie_len; - } -#endif /* CONFIG_8723AU_P2P */ - pattrib->last_txcmdsz = pattrib->pktlen; dump_mgntframe23a(padapter, pmgntframe); @@ -7023,20 +3687,9 @@ static int _issue_deauth23a(struct rtw_adapter *padapter, unsigned char *da, struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; int ret = _FAIL; -#ifdef CONFIG_8723AU_P2P - struct wifidirect_info *pwdinfo = &padapter->wdinfo; -#endif /* CONFIG_8723AU_P2P */ /* DBG_8723A("%s to "MAC_FMT"\n", __func__, MAC_ARG(da)); */ -#ifdef CONFIG_8723AU_P2P - if (!(rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)) && - (pwdinfo->rx_invitereq_info.scan_op_ch_only)) { - mod_timer(&pwdinfo->reset_ch_sitesurvey, - jiffies + msecs_to_jiffies(10)); - } -#endif /* CONFIG_8723AU_P2P */ - if ((pmgntframe = alloc_mgtxmitframe23a(pxmitpriv)) == NULL) goto exit; @@ -7631,34 +4284,14 @@ void site_survey23a(struct rtw_adapter *padapter) enum rt_scan_type ScanType = SCAN_PASSIVE; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; -#ifdef CONFIG_8723AU_P2P - struct wifidirect_info *pwdinfo = &padapter->wdinfo; + struct rtw_ieee80211_channel *ch; - if ((pwdinfo->rx_invitereq_info.scan_op_ch_only) || - (pwdinfo->p2p_info.scan_op_ch_only)) { - if (pwdinfo->rx_invitereq_info.scan_op_ch_only) - survey_channel = pwdinfo->rx_invitereq_info.operation_ch[pmlmeext->sitesurvey_res.channel_idx]; - else - survey_channel = pwdinfo->p2p_info.operation_ch[pmlmeext->sitesurvey_res.channel_idx]; - ScanType = SCAN_ACTIVE; - } else if (rtw_p2p_findphase_ex_is_social(pwdinfo)) { - /* The driver is in the find phase, it should go through the social channel. */ - int ch_set_idx; - survey_channel = pwdinfo->social_chan[pmlmeext->sitesurvey_res.channel_idx]; - ch_set_idx = rtw_ch_set_search_ch23a(pmlmeext->channel_set, survey_channel); - if (ch_set_idx >= 0) - ScanType = pmlmeext->channel_set[ch_set_idx].ScanType; - else - ScanType = SCAN_ACTIVE; - } else -#endif /* CONFIG_8723AU_P2P */ - { - struct rtw_ieee80211_channel *ch; - if (pmlmeext->sitesurvey_res.channel_idx < pmlmeext->sitesurvey_res.ch_num) { - ch = &pmlmeext->sitesurvey_res.ch[pmlmeext->sitesurvey_res.channel_idx]; - survey_channel = ch->hw_value; - ScanType = (ch->flags & IEEE80211_CHAN_NO_IR) ? SCAN_PASSIVE : SCAN_ACTIVE; -} + if (pmlmeext->sitesurvey_res.channel_idx < + pmlmeext->sitesurvey_res.ch_num) { + ch = &pmlmeext->sitesurvey_res.ch[pmlmeext->sitesurvey_res.channel_idx]; + survey_channel = ch->hw_value; + ScanType = (ch->flags & IEEE80211_CHAN_NO_IR) ? + SCAN_PASSIVE : SCAN_ACTIVE; } if (survey_channel != 0) { @@ -7672,112 +4305,59 @@ void site_survey23a(struct rtw_adapter *padapter) if (ScanType == SCAN_ACTIVE) /* obey the channel plan setting... */ { -#ifdef CONFIG_8723AU_P2P - if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_SCAN) || - rtw_p2p_chk_state(pwdinfo, P2P_STATE_FIND_PHASE_SEARCH) - ) - { - issue23a_probereq_p2p(padapter, NULL); - issue23a_probereq_p2p(padapter, NULL); - issue23a_probereq_p2p(padapter, NULL); - } - else -#endif /* CONFIG_8723AU_P2P */ - { - int i; - for (i = 0;isitesurvey_res.ssid[i].ssid_len) { - /* todo: to issue two probe req??? */ - issue_probereq23a(padapter, &pmlmeext->sitesurvey_res.ssid[i], NULL); - /* msleep(SURVEY_TO>>1); */ - issue_probereq23a(padapter, &pmlmeext->sitesurvey_res.ssid[i], NULL); - } - } - - if (pmlmeext->sitesurvey_res.scan_mode == SCAN_ACTIVE) { + int i; + for (i = 0;isitesurvey_res.ssid[i].ssid_len) { /* todo: to issue two probe req??? */ - issue_probereq23a(padapter, NULL, NULL); + issue_probereq23a(padapter, &pmlmeext->sitesurvey_res.ssid[i], NULL); /* msleep(SURVEY_TO>>1); */ - issue_probereq23a(padapter, NULL, NULL); + issue_probereq23a(padapter, &pmlmeext->sitesurvey_res.ssid[i], NULL); } } + + if (pmlmeext->sitesurvey_res.scan_mode == SCAN_ACTIVE) { + /* todo: to issue two probe req??? */ + issue_probereq23a(padapter, NULL, NULL); + /* msleep(SURVEY_TO>>1); */ + issue_probereq23a(padapter, NULL, NULL); + } } set_survey_timer(pmlmeext, pmlmeext->chan_scan_time); } else { - /* channel number is 0 or this channel is not valid. */ + pmlmeext->sitesurvey_res.state = SCAN_COMPLETE; + /* switch back to the original channel */ -#ifdef CONFIG_8723AU_P2P - if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_SCAN) || rtw_p2p_chk_state(pwdinfo, P2P_STATE_FIND_PHASE_SEARCH)) - { - if ((pwdinfo->rx_invitereq_info.scan_op_ch_only) || (pwdinfo->p2p_info.scan_op_ch_only)) - { - /* Set the find_phase_state_exchange_cnt to P2P_FINDPHASE_EX_CNT. */ - /* This will let the following flow to run the scanning end. */ - rtw_p2p_findphase_ex_set(pwdinfo, P2P_FINDPHASE_EX_MAX); - } - } - - if (rtw_p2p_findphase_ex_is_needed(pwdinfo)) - { - /* Set the P2P State to the listen state of find phase and set the current channel to the listen channel */ - set_channel_bwmode23a(padapter, pwdinfo->listen_channel, HAL_PRIME_CHNL_OFFSET_DONT_CARE, HT_CHANNEL_WIDTH_20); - rtw_p2p_set_state(pwdinfo, P2P_STATE_FIND_PHASE_LISTEN); - pmlmeext->sitesurvey_res.state = SCAN_DISABLE; - - /* restore RX GAIN */ - rtl8723a_set_initial_gain(padapter, 0xff); - /* turn on dynamic functions */ - rtl8723a_odm_support_ability_restore(padapter); - - mod_timer(&pwdinfo->find_phase_timer, jiffies + - msecs_to_jiffies(pwdinfo->listen_dwell * 100)); - } else -#endif /* CONFIG_8723AU_P2P */ - { -#ifdef CONFIG_8723AU_P2P - if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_SCAN) || rtw_p2p_chk_state(pwdinfo, P2P_STATE_FIND_PHASE_SEARCH)) - rtw_p2p_set_state(pwdinfo, rtw_p2p_pre_state(pwdinfo)); - rtw_p2p_findphase_ex_set(pwdinfo, P2P_FINDPHASE_EX_NONE); -#endif /* CONFIG_8723AU_P2P */ - - pmlmeext->sitesurvey_res.state = SCAN_COMPLETE; - - /* switch back to the original channel */ - - set_channel_bwmode23a(padapter, pmlmeext->cur_channel, pmlmeext->cur_ch_offset, pmlmeext->cur_bwmode); - - /* flush 4-AC Queue after site_survey23a */ - /* val8 = 0; */ + set_channel_bwmode23a(padapter, pmlmeext->cur_channel, + pmlmeext->cur_ch_offset, + pmlmeext->cur_bwmode); - /* config MSR */ - Set_MSR23a(padapter, (pmlmeinfo->state & 0x3)); + /* flush 4-AC Queue after site_survey23a */ + /* val8 = 0; */ - /* restore RX GAIN */ - rtl8723a_set_initial_gain(padapter, 0xff); - /* turn on dynamic functions */ - rtl8723a_odm_support_ability_restore(padapter); - - if (is_client_associated_to_ap23a(padapter) == true) - { - issue_nulldata23a(padapter, NULL, 0, 3, 500); + /* config MSR */ + Set_MSR23a(padapter, (pmlmeinfo->state & 0x3)); - } + /* restore RX GAIN */ + rtl8723a_set_initial_gain(padapter, 0xff); + /* turn on dynamic functions */ + rtl8723a_odm_support_ability_restore(padapter); - rtl8723a_mlme_sitesurvey(padapter, 0); + if (is_client_associated_to_ap23a(padapter) == true) + issue_nulldata23a(padapter, NULL, 0, 3, 500); - report_surveydone_event23a(padapter); + rtl8723a_mlme_sitesurvey(padapter, 0); - pmlmeext->chan_scan_time = SURVEY_TO; - pmlmeext->sitesurvey_res.state = SCAN_DISABLE; + report_surveydone_event23a(padapter); - issue_action_BSSCoexistPacket(padapter); - issue_action_BSSCoexistPacket(padapter); - issue_action_BSSCoexistPacket(padapter); + pmlmeext->chan_scan_time = SURVEY_TO; + pmlmeext->sitesurvey_res.state = SCAN_DISABLE; - } + issue_action_BSSCoexistPacket(padapter); + issue_action_BSSCoexistPacket(padapter); + issue_action_BSSCoexistPacket(padapter); } return; @@ -8915,9 +5495,6 @@ void linked_status_chk23a(struct rtw_adapter *padapter) if ((psta = rtw_get_stainfo23a(pstapriv, pmlmeinfo->network.MacAddress)) != NULL) { bool is_p2p_enable = false; -#ifdef CONFIG_8723AU_P2P - is_p2p_enable = !rtw_p2p_chk_state(&padapter->wdinfo, P2P_STATE_NONE); -#endif if (chk_ap_is_alive(padapter, psta) == false) rx_chk = _FAIL; @@ -9031,32 +5608,17 @@ static void survey_timer_hdl(unsigned long data) struct sitesurvey_parm *psurveyPara; struct cmd_priv *pcmdpriv = &padapter->cmdpriv; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; -#ifdef CONFIG_8723AU_P2P - struct wifidirect_info *pwdinfo = &padapter->wdinfo; -#endif /* issue rtw_sitesurvey_cmd23a */ if (pmlmeext->sitesurvey_res.state > SCAN_START) { if (pmlmeext->sitesurvey_res.state == SCAN_PROCESS) pmlmeext->sitesurvey_res.channel_idx++; - if (pmlmeext->scan_abort == true) - { -#ifdef CONFIG_8723AU_P2P - if (!rtw_p2p_chk_state(&padapter->wdinfo, P2P_STATE_NONE)) - { - rtw_p2p_findphase_ex_set(pwdinfo, P2P_FINDPHASE_EX_MAX); - pmlmeext->sitesurvey_res.channel_idx = 3; - DBG_8723A("%s idx:%d, cnt:%u\n", __func__, - pmlmeext->sitesurvey_res.channel_idx, - pwdinfo->find_phase_state_exchange_cnt); - } else - #endif - { - pmlmeext->sitesurvey_res.channel_idx = pmlmeext->sitesurvey_res.ch_num; - DBG_8723A("%s idx:%d\n", __func__, - pmlmeext->sitesurvey_res.channel_idx); - } + if (pmlmeext->scan_abort == true) { + pmlmeext->sitesurvey_res.channel_idx = + pmlmeext->sitesurvey_res.ch_num; + DBG_8723A("%s idx:%d\n", __func__, + pmlmeext->sitesurvey_res.channel_idx); pmlmeext->scan_abort = false;/* reset */ } diff --git a/drivers/staging/rtl8723au/core/rtw_p2p.c b/drivers/staging/rtl8723au/core/rtw_p2p.c deleted file mode 100644 index 49c09089fd24..000000000000 --- a/drivers/staging/rtl8723au/core/rtw_p2p.c +++ /dev/null @@ -1,4016 +0,0 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - ******************************************************************************/ -#define _RTW_P2P_C_ - -#include -#include -#include -#include - -#ifdef CONFIG_8723AU_P2P - -static int rtw_p2p_is_channel_list_ok(u8 desired_ch, u8* ch_list, u8 ch_cnt) -{ - int found = 0, i = 0; - - for (i = 0; i < ch_cnt; i++) - { - if (ch_list[ i ] == desired_ch) - { - found = 1; - break; - } - } - return found; -} - -static int is_any_client_associated(struct rtw_adapter *padapter) -{ - return padapter->stapriv.asoc_list_cnt ? true : false; -} - -static u32 go_add_group_info_attr(struct wifidirect_info *pwdinfo, u8 *pbuf) -{ - struct list_head *phead, *plist; - u32 len = 0; - u16 attr_len = 0; - u8 tmplen, *pdata_attr, *pstart, *pcur; - struct sta_info *psta; - struct rtw_adapter *padapter = pwdinfo->padapter; - struct sta_priv *pstapriv = &padapter->stapriv; - - DBG_8723A("%s\n", __func__); - - pdata_attr = kzalloc(MAX_P2P_IE_LEN, GFP_ATOMIC); - - pstart = pdata_attr; - pcur = pdata_attr; - - spin_lock_bh(&pstapriv->asoc_list_lock); - phead = &pstapriv->asoc_list; - - list_for_each(plist, phead) { - psta = container_of(plist, struct sta_info, asoc_list); - - if (psta->is_p2p_device) - { - tmplen = 0; - - pcur++; - - /* P2P device address */ - memcpy(pcur, psta->dev_addr, ETH_ALEN); - pcur += ETH_ALEN; - - /* P2P interface address */ - memcpy(pcur, psta->hwaddr, ETH_ALEN); - pcur += ETH_ALEN; - - *pcur = psta->dev_cap; - pcur++; - - /* u16*)(pcur) = cpu_to_be16(psta->config_methods); */ - put_unaligned_be16(psta->config_methods, pcur); - pcur += 2; - - memcpy(pcur, psta->primary_dev_type, 8); - pcur += 8; - - *pcur = psta->num_of_secdev_type; - pcur++; - - memcpy(pcur, psta->secdev_types_list, psta->num_of_secdev_type*8); - pcur += psta->num_of_secdev_type*8; - - if (psta->dev_name_len>0) - { - /* u16*)(pcur) = cpu_to_be16(WPS_ATTR_DEVICE_NAME); */ - put_unaligned_be16(WPS_ATTR_DEVICE_NAME, pcur); - pcur += 2; - - /* u16*)(pcur) = cpu_to_be16(psta->dev_name_len); */ - put_unaligned_be16(psta->dev_name_len, pcur); - pcur += 2; - - memcpy(pcur, psta->dev_name, psta->dev_name_len); - pcur += psta->dev_name_len; - } - - tmplen = (u8)(pcur-pstart); - - *pstart = (tmplen-1); - - attr_len += tmplen; - - /* pstart += tmplen; */ - pstart = pcur; - - } - - } - spin_unlock_bh(&pstapriv->asoc_list_lock); - - if (attr_len>0) - { - len = rtw_set_p2p_attr_content23a(pbuf, P2P_ATTR_GROUP_INFO, attr_len, pdata_attr); - } - - kfree(pdata_attr); - - return len; -} - -static void issue_group_disc_req(struct wifidirect_info *pwdinfo, u8 *da) -{ - struct xmit_frame *pmgntframe; - struct pkt_attrib *pattrib; - unsigned char *pframe; - struct ieee80211_hdr *pwlanhdr; - unsigned short *fctrl; - struct rtw_adapter *padapter = pwdinfo->padapter; - struct xmit_priv *pxmitpriv = &padapter->xmitpriv; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - unsigned char category = WLAN_CATEGORY_VENDOR_SPECIFIC;/* P2P action frame */ - u32 p2poui = cpu_to_be32(P2POUI); - u8 oui_subtype = P2P_GO_DISC_REQUEST; - u8 dialogToken = 0; - - DBG_8723A("[%s]\n", __func__); - - if ((pmgntframe = alloc_mgtxmitframe23a(pxmitpriv)) == NULL) - { - return; - } - - /* update attribute */ - pattrib = &pmgntframe->attrib; - update_mgntframe_attrib23a(padapter, pattrib); - - memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET); - - pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET; - pwlanhdr = (struct ieee80211_hdr *)pframe; - - fctrl = &pwlanhdr->frame_control; - *fctrl = 0; - - memcpy(pwlanhdr->addr1, da, ETH_ALEN); - memcpy(pwlanhdr->addr2, pwdinfo->interface_addr, ETH_ALEN); - memcpy(pwlanhdr->addr3, pwdinfo->interface_addr, ETH_ALEN); - - SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq); - pmlmeext->mgnt_seq++; - SetFrameSubType(pframe, WIFI_ACTION); - - pframe += sizeof(struct ieee80211_hdr_3addr); - pattrib->pktlen = sizeof(struct ieee80211_hdr_3addr); - - /* Build P2P action frame header */ - pframe = rtw_set_fixed_ie23a(pframe, 1, &category, &pattrib->pktlen); - pframe = rtw_set_fixed_ie23a(pframe, 4, (unsigned char *)&p2poui, &pattrib->pktlen); - pframe = rtw_set_fixed_ie23a(pframe, 1, &oui_subtype, &pattrib->pktlen); - pframe = rtw_set_fixed_ie23a(pframe, 1, &dialogToken, &pattrib->pktlen); - - /* there is no IE in this P2P action frame */ - - pattrib->last_txcmdsz = pattrib->pktlen; - - dump_mgntframe23a(padapter, pmgntframe); -} - -static void issue_p2p_devdisc_resp(struct wifidirect_info *pwdinfo, u8 *da, u8 status, u8 dialogToken) -{ - struct xmit_frame *pmgntframe; - struct pkt_attrib *pattrib; - unsigned char *pframe; - struct ieee80211_hdr *pwlanhdr; - unsigned short *fctrl; - struct rtw_adapter *padapter = pwdinfo->padapter; - struct xmit_priv *pxmitpriv = &padapter->xmitpriv; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - unsigned char category = WLAN_CATEGORY_PUBLIC; - u8 action = P2P_PUB_ACTION_ACTION; - u32 p2poui = cpu_to_be32(P2POUI); - u8 oui_subtype = P2P_DEVDISC_RESP; - u8 p2pie[8] = { 0x00 }; - u32 p2pielen = 0; - - DBG_8723A("[%s]\n", __func__); - - if ((pmgntframe = alloc_mgtxmitframe23a(pxmitpriv)) == NULL) - { - return; - } - - /* update attribute */ - pattrib = &pmgntframe->attrib; - update_mgntframe_attrib23a(padapter, pattrib); - - memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET); - - pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET; - pwlanhdr = (struct ieee80211_hdr *)pframe; - - fctrl = &pwlanhdr->frame_control; - *fctrl = 0; - - memcpy(pwlanhdr->addr1, da, ETH_ALEN); - memcpy(pwlanhdr->addr2, pwdinfo->device_addr, ETH_ALEN); - memcpy(pwlanhdr->addr3, pwdinfo->device_addr, ETH_ALEN); - - SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq); - pmlmeext->mgnt_seq++; - SetFrameSubType(pframe, WIFI_ACTION); - - pframe += sizeof(struct ieee80211_hdr_3addr); - pattrib->pktlen = sizeof(struct ieee80211_hdr_3addr); - - /* Build P2P public action frame header */ - pframe = rtw_set_fixed_ie23a(pframe, 1, &category, &pattrib->pktlen); - pframe = rtw_set_fixed_ie23a(pframe, 1, &action, &pattrib->pktlen); - pframe = rtw_set_fixed_ie23a(pframe, 4, (unsigned char *) &p2poui, - &pattrib->pktlen); - pframe = rtw_set_fixed_ie23a(pframe, 1, &oui_subtype, &pattrib->pktlen); - pframe = rtw_set_fixed_ie23a(pframe, 1, &dialogToken, &pattrib->pktlen); - - /* Build P2P IE */ - /* P2P OUI */ - p2pielen = 0; - p2pie[ p2pielen++ ] = 0x50; - p2pie[ p2pielen++ ] = 0x6F; - p2pie[ p2pielen++ ] = 0x9A; - p2pie[ p2pielen++ ] = 0x09; /* WFA P2P v1.0 */ - - /* P2P_ATTR_STATUS */ - p2pielen += rtw_set_p2p_attr_content23a(&p2pie[p2pielen], P2P_ATTR_STATUS, 1, &status); - - pframe = rtw_set_ie23a(pframe, WLAN_EID_VENDOR_SPECIFIC, p2pielen, - p2pie, &pattrib->pktlen); - - pattrib->last_txcmdsz = pattrib->pktlen; - - dump_mgntframe23a(padapter, pmgntframe); -} - -static void issue_p2p_provision_resp(struct wifidirect_info *pwdinfo, u8* raddr, u8* frame_body, u16 config_method) -{ - struct rtw_adapter *padapter = pwdinfo->padapter; - unsigned char category = WLAN_CATEGORY_PUBLIC; - u8 action = P2P_PUB_ACTION_ACTION; - u8 dialogToken = frame_body[7]; /* The Dialog Token of provisioning discovery request frame. */ - u32 p2poui = cpu_to_be32(P2POUI); - u8 oui_subtype = P2P_PROVISION_DISC_RESP; - u8 wpsie[ 100 ] = { 0x00 }; - u8 wpsielen = 0; -#ifdef CONFIG_8723AU_P2P - u32 wfdielen = 0; -#endif /* CONFIG_8723AU_P2P */ - - struct xmit_frame *pmgntframe; - struct pkt_attrib *pattrib; - unsigned char *pframe; - struct ieee80211_hdr *pwlanhdr; - unsigned short *fctrl; - struct xmit_priv *pxmitpriv = &padapter->xmitpriv; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - - if ((pmgntframe = alloc_mgtxmitframe23a(pxmitpriv)) == NULL) - return; - - /* update attribute */ - pattrib = &pmgntframe->attrib; - update_mgntframe_attrib23a(padapter, pattrib); - - memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET); - - pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET; - pwlanhdr = (struct ieee80211_hdr *)pframe; - - fctrl = &pwlanhdr->frame_control; - *fctrl = 0; - - memcpy(pwlanhdr->addr1, raddr, ETH_ALEN); - memcpy(pwlanhdr->addr2, myid(&padapter->eeprompriv), ETH_ALEN); - memcpy(pwlanhdr->addr3, myid(&padapter->eeprompriv), ETH_ALEN); - - SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq); - pmlmeext->mgnt_seq++; - SetFrameSubType(pframe, WIFI_ACTION); - - pframe += sizeof(struct ieee80211_hdr_3addr); - pattrib->pktlen = sizeof(struct ieee80211_hdr_3addr); - - pframe = rtw_set_fixed_ie23a(pframe, 1, &category, &pattrib->pktlen); - pframe = rtw_set_fixed_ie23a(pframe, 1, &action, &pattrib->pktlen); - pframe = rtw_set_fixed_ie23a(pframe, 4, (unsigned char *) &p2poui, - &pattrib->pktlen); - pframe = rtw_set_fixed_ie23a(pframe, 1, &oui_subtype, &pattrib->pktlen); - pframe = rtw_set_fixed_ie23a(pframe, 1, &dialogToken, &pattrib->pktlen); - - wpsielen = 0; - /* WPS OUI */ - /* u32*) (wpsie) = cpu_to_be32(WPSOUI); */ - put_unaligned_be32(WPSOUI, wpsie); - wpsielen += 4; - - /* Config Method */ - /* Type: */ - /* u16*) (wpsie + wpsielen) = cpu_to_be16(WPS_ATTR_CONF_METHOD); */ - put_unaligned_be16(WPS_ATTR_CONF_METHOD, wpsie + wpsielen); - wpsielen += 2; - - /* Length: */ - /* u16*) (wpsie + wpsielen) = cpu_to_be16(0x0002); */ - put_unaligned_be16(0x0002, wpsie + wpsielen); - wpsielen += 2; - - /* Value: */ - /* u16*) (wpsie + wpsielen) = cpu_to_be16(config_method); */ - put_unaligned_be16(config_method, wpsie + wpsielen); - wpsielen += 2; - - pframe = rtw_set_ie23a(pframe, WLAN_EID_VENDOR_SPECIFIC, wpsielen, - (unsigned char *) wpsie, &pattrib->pktlen); - -#ifdef CONFIG_8723AU_P2P - wfdielen = build_provdisc_resp_wfd_ie(pwdinfo, pframe); - pframe += wfdielen; - pattrib->pktlen += wfdielen; -#endif /* CONFIG_8723AU_P2P */ - - pattrib->last_txcmdsz = pattrib->pktlen; - - dump_mgntframe23a(padapter, pmgntframe); - - return; -} - -static void issue_p2p_presence_resp(struct wifidirect_info *pwdinfo, u8 *da, u8 status, u8 dialogToken) -{ - struct xmit_frame *pmgntframe; - struct pkt_attrib *pattrib; - unsigned char *pframe; - struct ieee80211_hdr *pwlanhdr; - unsigned short *fctrl; - struct rtw_adapter *padapter = pwdinfo->padapter; - struct xmit_priv *pxmitpriv = &padapter->xmitpriv; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - unsigned char category = WLAN_CATEGORY_VENDOR_SPECIFIC;/* P2P action frame */ - u32 p2poui = cpu_to_be32(P2POUI); - u8 oui_subtype = P2P_PRESENCE_RESPONSE; - u8 p2pie[ MAX_P2P_IE_LEN] = { 0x00 }; - u8 noa_attr_content[32] = { 0x00 }; - u32 p2pielen = 0; - - DBG_8723A("[%s]\n", __func__); - - if ((pmgntframe = alloc_mgtxmitframe23a(pxmitpriv)) == NULL) - { - return; - } - - /* update attribute */ - pattrib = &pmgntframe->attrib; - update_mgntframe_attrib23a(padapter, pattrib); - - memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET); - - pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET; - pwlanhdr = (struct ieee80211_hdr *)pframe; - - fctrl = &pwlanhdr->frame_control; - *fctrl = 0; - - memcpy(pwlanhdr->addr1, da, ETH_ALEN); - memcpy(pwlanhdr->addr2, pwdinfo->interface_addr, ETH_ALEN); - memcpy(pwlanhdr->addr3, pwdinfo->interface_addr, ETH_ALEN); - - SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq); - pmlmeext->mgnt_seq++; - SetFrameSubType(pframe, WIFI_ACTION); - - pframe += sizeof(struct ieee80211_hdr_3addr); - pattrib->pktlen = sizeof(struct ieee80211_hdr_3addr); - - /* Build P2P action frame header */ - pframe = rtw_set_fixed_ie23a(pframe, 1, &category, &pattrib->pktlen); - pframe = rtw_set_fixed_ie23a(pframe, 4, (unsigned char *) &p2poui, - &pattrib->pktlen); - pframe = rtw_set_fixed_ie23a(pframe, 1, &oui_subtype, &pattrib->pktlen); - pframe = rtw_set_fixed_ie23a(pframe, 1, &dialogToken, &pattrib->pktlen); - - /* Add P2P IE header */ - /* P2P OUI */ - p2pielen = 0; - p2pie[ p2pielen++ ] = 0x50; - p2pie[ p2pielen++ ] = 0x6F; - p2pie[ p2pielen++ ] = 0x9A; - p2pie[ p2pielen++ ] = 0x09; /* WFA P2P v1.0 */ - - /* Add Status attribute in P2P IE */ - p2pielen += rtw_set_p2p_attr_content23a(&p2pie[p2pielen], P2P_ATTR_STATUS, 1, &status); - - /* Add NoA attribute in P2P IE */ - noa_attr_content[0] = 0x1;/* index */ - noa_attr_content[1] = 0x0;/* CTWindow and OppPS Parameters */ - - /* todo: Notice of Absence Descriptor(s) */ - - p2pielen += rtw_set_p2p_attr_content23a(&p2pie[p2pielen], P2P_ATTR_NOA, 2, noa_attr_content); - - pframe = rtw_set_ie23a(pframe, WLAN_EID_VENDOR_SPECIFIC, p2pielen, - p2pie, &pattrib->pktlen); - - pattrib->last_txcmdsz = pattrib->pktlen; - - dump_mgntframe23a(padapter, pmgntframe); -} - -u32 build_beacon_p2p_ie23a(struct wifidirect_info *pwdinfo, u8 *pbuf) -{ - u8 p2pie[ MAX_P2P_IE_LEN] = { 0x00 }; - u16 capability = 0; - u32 len = 0, p2pielen = 0; - - /* P2P OUI */ - p2pielen = 0; - p2pie[ p2pielen++ ] = 0x50; - p2pie[ p2pielen++ ] = 0x6F; - p2pie[ p2pielen++ ] = 0x9A; - p2pie[ p2pielen++ ] = 0x09; /* WFA P2P v1.0 */ - - /* According to the P2P Specification, the beacon frame should contain 3 P2P attributes */ - /* 1. P2P Capability */ - /* 2. P2P Device ID */ - /* 3. Notice of Absence (NOA) */ - - /* P2P Capability ATTR */ - /* Type: */ - /* Length: */ - /* Value: */ - /* Device Capability Bitmap, 1 byte */ - /* Be able to participate in additional P2P Groups and */ - /* support the P2P Invitation Procedure */ - /* Group Capability Bitmap, 1 byte */ - capability = P2P_DEVCAP_INVITATION_PROC|P2P_DEVCAP_CLIENT_DISCOVERABILITY; - capability |= ((P2P_GRPCAP_GO | P2P_GRPCAP_INTRABSS) << 8); - if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_PROVISIONING_ING)) - capability |= (P2P_GRPCAP_GROUP_FORMATION<<8); - - capability = cpu_to_le16(capability); - - p2pielen += rtw_set_p2p_attr_content23a(&p2pie[p2pielen], P2P_ATTR_CAPABILITY, 2, (u8*)&capability); - - /* P2P Device ID ATTR */ - p2pielen += rtw_set_p2p_attr_content23a(&p2pie[p2pielen], P2P_ATTR_DEVICE_ID, ETH_ALEN, pwdinfo->device_addr); - - /* Notice of Absence ATTR */ - /* Type: */ - /* Length: */ - /* Value: */ - - /* go_add_noa_attr(pwdinfo); */ - - pbuf = rtw_set_ie23a(pbuf, WLAN_EID_VENDOR_SPECIFIC, p2pielen, - (unsigned char *) p2pie, &len); - - return len; -} - -#ifdef CONFIG_8723AU_P2P -u32 build_beacon_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf) -{ - u8 wfdie[ MAX_WFD_IE_LEN] = { 0x00 }; - u32 len = 0, wfdielen = 0; - struct rtw_adapter *padapter = pwdinfo->padapter; - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct wifi_display_info* pwfd_info = padapter->wdinfo.wfd_info; - - /* WFD OUI */ - wfdielen = 0; - wfdie[ wfdielen++ ] = 0x50; - wfdie[ wfdielen++ ] = 0x6F; - wfdie[ wfdielen++ ] = 0x9A; - wfdie[ wfdielen++ ] = 0x0A; /* WFA WFD v1.0 */ - - /* Commented by Albert 20110812 */ - /* According to the WFD Specification, the beacon frame should contain 4 WFD attributes */ - /* 1. WFD Device Information */ - /* 2. Associated BSSID */ - /* 3. Coupled Sink Information */ - - /* WFD Device Information ATTR */ - /* Type: */ - wfdie[ wfdielen++ ] = WFD_ATTR_DEVICE_INFO; - - /* Length: */ - /* Note: In the WFD specification, the size of length field is 2. */ - put_unaligned_be16(0x0006, wfdie + wfdielen); - wfdielen += 2; - - /* Value1: */ - /* WFD device information */ - - if (P2P_ROLE_GO == pwdinfo->role) - { - if (is_any_client_associated(pwdinfo->padapter)) - { - /* WFD primary sink + WiFi Direct mode + WSD (WFD Service Discovery) */ - put_unaligned_be16(pwfd_info->wfd_device_type | - WFD_DEVINFO_WSD, wfdie + wfdielen); - } - else - { - /* WFD primary sink + available for WFD session + WiFi Direct mode + WSD (WFD Service Discovery) */ - put_unaligned_be16(pwfd_info->wfd_device_type | - WFD_DEVINFO_SESSION_AVAIL | - WFD_DEVINFO_WSD, wfdie + wfdielen); - } - - } - else - { - /* WFD primary sink + available for WFD session + WiFi Direct mode + WSD (WFD Service Discovery) */ - put_unaligned_be16(pwfd_info->wfd_device_type | - WFD_DEVINFO_SESSION_AVAIL | - WFD_DEVINFO_WSD, wfdie + wfdielen); - } - - wfdielen += 2; - - /* Value2: */ - /* Session Management Control Port */ - /* Default TCP port for RTSP messages is 554 */ - put_unaligned_be16(pwfd_info->rtsp_ctrlport, wfdie + wfdielen); - wfdielen += 2; - - /* Value3: */ - /* WFD Device Maximum Throughput */ - /* 300Mbps is the maximum throughput */ - put_unaligned_be16(300, wfdie + wfdielen); - wfdielen += 2; - - /* Associated BSSID ATTR */ - /* Type: */ - wfdie[ wfdielen++ ] = WFD_ATTR_ASSOC_BSSID; - - /* Length: */ - /* Note: In the WFD specification, the size of length field is 2. */ - put_unaligned_be16(0x0006, wfdie + wfdielen); - wfdielen += 2; - - /* Value: */ - /* Associated BSSID */ - if (check_fwstate(pmlmepriv, _FW_LINKED) == true) - { - memcpy(wfdie + wfdielen, &pmlmepriv->assoc_bssid[ 0 ], ETH_ALEN); - } - else - { - memset(wfdie + wfdielen, 0x00, ETH_ALEN); - } - - wfdielen += ETH_ALEN; - - /* Coupled Sink Information ATTR */ - /* Type: */ - wfdie[ wfdielen++ ] = WFD_ATTR_COUPLED_SINK_INFO; - - /* Length: */ - /* Note: In the WFD specification, the size of length field is 2. */ - put_unaligned_be16(0x0007, wfdie + wfdielen); - wfdielen += 2; - - /* Value: */ - /* Coupled Sink Status bitmap */ - /* Not coupled/available for Coupling */ - wfdie[ wfdielen++ ] = 0; - /* MAC Addr. */ - wfdie[ wfdielen++ ] = 0; - wfdie[ wfdielen++ ] = 0; - wfdie[ wfdielen++ ] = 0; - wfdie[ wfdielen++ ] = 0; - wfdie[ wfdielen++ ] = 0; - wfdie[ wfdielen++ ] = 0; - - pbuf = rtw_set_ie23a(pbuf, WLAN_EID_VENDOR_SPECIFIC, wfdielen, - (unsigned char *) wfdie, &len); - - return len; -} - -u32 build_probe_req_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf) -{ - u8 wfdie[ MAX_WFD_IE_LEN] = { 0x00 }; - u32 len = 0, wfdielen = 0; - struct rtw_adapter *padapter = pwdinfo->padapter; - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct wifi_display_info* pwfd_info = padapter->wdinfo.wfd_info; - - /* WFD OUI */ - wfdielen = 0; - wfdie[ wfdielen++ ] = 0x50; - wfdie[ wfdielen++ ] = 0x6F; - wfdie[ wfdielen++ ] = 0x9A; - wfdie[ wfdielen++ ] = 0x0A; /* WFA WFD v1.0 */ - - /* Commented by Albert 20110812 */ - /* According to the WFD Specification, the probe request frame should contain 4 WFD attributes */ - /* 1. WFD Device Information */ - /* 2. Associated BSSID */ - /* 3. Coupled Sink Information */ - - /* WFD Device Information ATTR */ - /* Type: */ - wfdie[ wfdielen++ ] = WFD_ATTR_DEVICE_INFO; - - /* Length: */ - /* Note: In the WFD specification, the size of length field is 2. */ - put_unaligned_be16(0x0006, wfdie + wfdielen); - wfdielen += 2; - - /* Value1: */ - /* WFD device information */ - - if (1 == pwdinfo->wfd_tdls_enable) - { - /* WFD primary sink + available for WFD session + WiFi TDLS mode + WSC (WFD Service Discovery) */ - put_unaligned_be16(pwfd_info->wfd_device_type | - WFD_DEVINFO_SESSION_AVAIL | - WFD_DEVINFO_WSD | - WFD_DEVINFO_PC_TDLS, wfdie + wfdielen); - } - else - { - /* WFD primary sink + available for WFD session + WiFi Direct mode + WSC (WFD Service Discovery) */ - put_unaligned_be16(pwfd_info->wfd_device_type | - WFD_DEVINFO_SESSION_AVAIL | - WFD_DEVINFO_WSD, wfdie + wfdielen); - } - - wfdielen += 2; - - /* Value2: */ - /* Session Management Control Port */ - /* Default TCP port for RTSP messages is 554 */ - put_unaligned_be16(pwfd_info->rtsp_ctrlport, wfdie + wfdielen); - wfdielen += 2; - - /* Value3: */ - /* WFD Device Maximum Throughput */ - /* 300Mbps is the maximum throughput */ - put_unaligned_be16(300, wfdie + wfdielen); - wfdielen += 2; - - /* Associated BSSID ATTR */ - /* Type: */ - wfdie[ wfdielen++ ] = WFD_ATTR_ASSOC_BSSID; - - /* Length: */ - /* Note: In the WFD specification, the size of length field is 2. */ - put_unaligned_be16(0x0006, wfdie + wfdielen); - wfdielen += 2; - - /* Value: */ - /* Associated BSSID */ - if (check_fwstate(pmlmepriv, _FW_LINKED) == true) - { - memcpy(wfdie + wfdielen, &pmlmepriv->assoc_bssid[ 0 ], ETH_ALEN); - } - else - { - memset(wfdie + wfdielen, 0x00, ETH_ALEN); - } - - wfdielen += ETH_ALEN; - - /* Coupled Sink Information ATTR */ - /* Type: */ - wfdie[ wfdielen++ ] = WFD_ATTR_COUPLED_SINK_INFO; - - /* Length: */ - /* Note: In the WFD specification, the size of length field is 2. */ - put_unaligned_be16(0x0007, wfdie + wfdielen); - wfdielen += 2; - - /* Value: */ - /* Coupled Sink Status bitmap */ - /* Not coupled/available for Coupling */ - wfdie[ wfdielen++ ] = 0; - /* MAC Addr. */ - wfdie[ wfdielen++ ] = 0; - wfdie[ wfdielen++ ] = 0; - wfdie[ wfdielen++ ] = 0; - wfdie[ wfdielen++ ] = 0; - wfdie[ wfdielen++ ] = 0; - wfdie[ wfdielen++ ] = 0; - - pbuf = rtw_set_ie23a(pbuf, WLAN_EID_VENDOR_SPECIFIC, wfdielen, - (unsigned char *) wfdie, &len); - - return len; -} - -u32 build_probe_resp_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf, u8 tunneled) -{ - u8 wfdie[ MAX_WFD_IE_LEN] = { 0x00 }; - u32 len = 0, wfdielen = 0; - struct rtw_adapter *padapter = pwdinfo->padapter; - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct wifi_display_info* pwfd_info = padapter->wdinfo.wfd_info; - - /* WFD OUI */ - wfdielen = 0; - wfdie[ wfdielen++ ] = 0x50; - wfdie[ wfdielen++ ] = 0x6F; - wfdie[ wfdielen++ ] = 0x9A; - wfdie[ wfdielen++ ] = 0x0A; /* WFA WFD v1.0 */ - - /* Commented by Albert 20110812 */ - /* According to the WFD Specification, the probe response frame should contain 4 WFD attributes */ - /* 1. WFD Device Information */ - /* 2. Associated BSSID */ - /* 3. Coupled Sink Information */ - /* 4. WFD Session Information */ - - /* WFD Device Information ATTR */ - /* Type: */ - wfdie[ wfdielen++ ] = WFD_ATTR_DEVICE_INFO; - - /* Length: */ - /* Note: In the WFD specification, the size of length field is 2. */ - put_unaligned_be16(0x0006, wfdie + wfdielen); - wfdielen += 2; - - /* Value1: */ - /* WFD device information */ - /* WFD primary sink + available for WFD session + WiFi Direct mode */ - - if (true == pwdinfo->session_available) - { - if (P2P_ROLE_GO == pwdinfo->role) - { - if (is_any_client_associated(pwdinfo->padapter)) - { - if (pwdinfo->wfd_tdls_enable) - { - /* TDLS mode + WSD (WFD Service Discovery) */ - put_unaligned_be16(pwfd_info->wfd_device_type | WFD_DEVINFO_WSD | WFD_DEVINFO_PC_TDLS | WFD_DEVINFO_HDCP_SUPPORT, wfdie + wfdielen); - } - else - { - /* WiFi Direct mode + WSD (WFD Service Discovery) */ - put_unaligned_be16(pwfd_info->wfd_device_type | WFD_DEVINFO_WSD | WFD_DEVINFO_HDCP_SUPPORT, wfdie + wfdielen); - } - } - else - { - if (pwdinfo->wfd_tdls_enable) - { - /* available for WFD session + TDLS mode + WSD (WFD Service Discovery) */ - put_unaligned_be16(pwfd_info->wfd_device_type | WFD_DEVINFO_SESSION_AVAIL | WFD_DEVINFO_WSD | WFD_DEVINFO_PC_TDLS | WFD_DEVINFO_HDCP_SUPPORT, wfdie + wfdielen); - } - else - { - /* available for WFD session + WiFi Direct mode + WSD (WFD Service Discovery) */ - put_unaligned_be16(pwfd_info->wfd_device_type | WFD_DEVINFO_SESSION_AVAIL | WFD_DEVINFO_WSD | WFD_DEVINFO_HDCP_SUPPORT, wfdie + wfdielen); - } - } - } - else - { - if (pwdinfo->wfd_tdls_enable) - { - /* available for WFD session + WiFi Direct mode + WSD (WFD Service Discovery) */ - put_unaligned_be16(pwfd_info->wfd_device_type | - WFD_DEVINFO_SESSION_AVAIL | - WFD_DEVINFO_WSD | - WFD_DEVINFO_PC_TDLS | - WFD_DEVINFO_HDCP_SUPPORT, - wfdie + wfdielen); - } - else - { - - /* available for WFD session + WiFi Direct mode + WSD (WFD Service Discovery) */ - put_unaligned_be16(pwfd_info->wfd_device_type | - WFD_DEVINFO_SESSION_AVAIL | - WFD_DEVINFO_WSD | - WFD_DEVINFO_HDCP_SUPPORT, - wfdie + wfdielen); - } - } - } - else - { - if (pwdinfo->wfd_tdls_enable) - { - put_unaligned_be16(pwfd_info->wfd_device_type | - WFD_DEVINFO_WSD | - WFD_DEVINFO_PC_TDLS | - WFD_DEVINFO_HDCP_SUPPORT, - wfdie + wfdielen); - } - else - { - put_unaligned_be16(pwfd_info->wfd_device_type | - WFD_DEVINFO_WSD | - WFD_DEVINFO_HDCP_SUPPORT, - wfdie + wfdielen); - } - - } - - wfdielen += 2; - - /* Value2: */ - /* Session Management Control Port */ - /* Default TCP port for RTSP messages is 554 */ - put_unaligned_be16(pwfd_info->rtsp_ctrlport, wfdie + wfdielen); - wfdielen += 2; - - /* Value3: */ - /* WFD Device Maximum Throughput */ - /* 300Mbps is the maximum throughput */ - put_unaligned_be16(300, wfdie + wfdielen); - wfdielen += 2; - - /* Associated BSSID ATTR */ - /* Type: */ - wfdie[ wfdielen++ ] = WFD_ATTR_ASSOC_BSSID; - - /* Length: */ - /* Note: In the WFD specification, the size of length field is 2. */ - put_unaligned_be16(0x0006, wfdie + wfdielen); - wfdielen += 2; - - /* Value: */ - /* Associated BSSID */ - if (check_fwstate(pmlmepriv, _FW_LINKED) == true) - { - memcpy(wfdie + wfdielen, &pmlmepriv->assoc_bssid[ 0 ], ETH_ALEN); - } - else - { - memset(wfdie + wfdielen, 0x00, ETH_ALEN); - } - - wfdielen += ETH_ALEN; - - /* Coupled Sink Information ATTR */ - /* Type: */ - wfdie[ wfdielen++ ] = WFD_ATTR_COUPLED_SINK_INFO; - - /* Length: */ - /* Note: In the WFD specification, the size of length field is 2. */ - put_unaligned_be16(0x0007, wfdie + wfdielen); - wfdielen += 2; - - /* Value: */ - /* Coupled Sink Status bitmap */ - /* Not coupled/available for Coupling */ - wfdie[ wfdielen++ ] = 0; - /* MAC Addr. */ - wfdie[ wfdielen++ ] = 0; - wfdie[ wfdielen++ ] = 0; - wfdie[ wfdielen++ ] = 0; - wfdie[ wfdielen++ ] = 0; - wfdie[ wfdielen++ ] = 0; - wfdie[ wfdielen++ ] = 0; - - if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO)) - { - /* WFD Session Information ATTR */ - /* Type: */ - wfdie[ wfdielen++ ] = WFD_ATTR_SESSION_INFO; - - /* Length: */ - /* Note: In the WFD specification, the size of length field is 2. */ - put_unaligned_be16(0x0000, wfdie + wfdielen); - wfdielen += 2; - - /* Todo: to add the list of WFD device info descriptor in WFD group. */ - - } - - pbuf = rtw_set_ie23a(pbuf, WLAN_EID_VENDOR_SPECIFIC, wfdielen, - (unsigned char *) wfdie, &len); - - return len; -} - -u32 build_assoc_req_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf) -{ - u8 wfdie[ MAX_WFD_IE_LEN] = { 0x00 }; - u32 len = 0, wfdielen = 0; - struct rtw_adapter *padapter = NULL; - struct mlme_priv *pmlmepriv = NULL; - struct wifi_display_info *pwfd_info = NULL; - - /* WFD OUI */ - if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE) || rtw_p2p_chk_state(pwdinfo, P2P_STATE_IDLE)) - { - return 0; - } - - padapter = pwdinfo->padapter; - pmlmepriv = &padapter->mlmepriv; - pwfd_info = padapter->wdinfo.wfd_info; - - wfdielen = 0; - wfdie[ wfdielen++ ] = 0x50; - wfdie[ wfdielen++ ] = 0x6F; - wfdie[ wfdielen++ ] = 0x9A; - wfdie[ wfdielen++ ] = 0x0A; /* WFA WFD v1.0 */ - - /* Commented by Albert 20110812 */ - /* According to the WFD Specification, the probe request frame should contain 4 WFD attributes */ - /* 1. WFD Device Information */ - /* 2. Associated BSSID */ - /* 3. Coupled Sink Information */ - - /* WFD Device Information ATTR */ - /* Type: */ - wfdie[ wfdielen++ ] = WFD_ATTR_DEVICE_INFO; - - /* Length: */ - /* Note: In the WFD specification, the size of length field is 2. */ - put_unaligned_be16(0x0006, wfdie + wfdielen); - wfdielen += 2; - - /* Value1: */ - /* WFD device information */ - /* WFD primary sink + available for WFD session + WiFi Direct mode + WSD (WFD Service Discovery) */ - put_unaligned_be16(pwfd_info->wfd_device_type | - WFD_DEVINFO_SESSION_AVAIL | - WFD_DEVINFO_WSD, wfdie + wfdielen); - wfdielen += 2; - - /* Value2: */ - /* Session Management Control Port */ - /* Default TCP port for RTSP messages is 554 */ - put_unaligned_be16(pwfd_info->rtsp_ctrlport, wfdie + wfdielen); - wfdielen += 2; - - /* Value3: */ - /* WFD Device Maximum Throughput */ - /* 300Mbps is the maximum throughput */ - put_unaligned_be16(300, wfdie + wfdielen); - wfdielen += 2; - - /* Associated BSSID ATTR */ - /* Type: */ - wfdie[ wfdielen++ ] = WFD_ATTR_ASSOC_BSSID; - - /* Length: */ - /* Note: In the WFD specification, the size of length field is 2. */ - put_unaligned_be16(0x0006, wfdie + wfdielen); - wfdielen += 2; - - /* Value: */ - /* Associated BSSID */ - if (check_fwstate(pmlmepriv, _FW_LINKED) == true) - { - memcpy(wfdie + wfdielen, &pmlmepriv->assoc_bssid[ 0 ], ETH_ALEN); - } - else - { - memset(wfdie + wfdielen, 0x00, ETH_ALEN); - } - - wfdielen += ETH_ALEN; - - /* Coupled Sink Information ATTR */ - /* Type: */ - wfdie[ wfdielen++ ] = WFD_ATTR_COUPLED_SINK_INFO; - - /* Length: */ - /* Note: In the WFD specification, the size of length field is 2. */ - put_unaligned_be16(0x0007, wfdie + wfdielen); - wfdielen += 2; - - /* Value: */ - /* Coupled Sink Status bitmap */ - /* Not coupled/available for Coupling */ - wfdie[ wfdielen++ ] = 0; - /* MAC Addr. */ - wfdie[ wfdielen++ ] = 0; - wfdie[ wfdielen++ ] = 0; - wfdie[ wfdielen++ ] = 0; - wfdie[ wfdielen++ ] = 0; - wfdie[ wfdielen++ ] = 0; - wfdie[ wfdielen++ ] = 0; - - pbuf = rtw_set_ie23a(pbuf, WLAN_EID_VENDOR_SPECIFIC, wfdielen, - (unsigned char *) wfdie, &len); - - return len; -} - -u32 build_assoc_resp_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf) -{ - u8 wfdie[ MAX_WFD_IE_LEN] = { 0x00 }; - u32 len = 0, wfdielen = 0; - struct rtw_adapter *padapter = pwdinfo->padapter; - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct wifi_display_info* pwfd_info = padapter->wdinfo.wfd_info; - - /* WFD OUI */ - wfdielen = 0; - wfdie[ wfdielen++ ] = 0x50; - wfdie[ wfdielen++ ] = 0x6F; - wfdie[ wfdielen++ ] = 0x9A; - wfdie[ wfdielen++ ] = 0x0A; /* WFA WFD v1.0 */ - - /* Commented by Albert 20110812 */ - /* According to the WFD Specification, the probe request frame should contain 4 WFD attributes */ - /* 1. WFD Device Information */ - /* 2. Associated BSSID */ - /* 3. Coupled Sink Information */ - - /* WFD Device Information ATTR */ - /* Type: */ - wfdie[ wfdielen++ ] = WFD_ATTR_DEVICE_INFO; - - /* Length: */ - /* Note: In the WFD specification, the size of length field is 2. */ - put_unaligned_be16(0x0006, wfdie + wfdielen); - wfdielen += 2; - - /* Value1: */ - /* WFD device information */ - /* WFD primary sink + available for WFD session + WiFi Direct mode + WSD (WFD Service Discovery) */ - put_unaligned_be16(pwfd_info->wfd_device_type | - WFD_DEVINFO_SESSION_AVAIL | - WFD_DEVINFO_WSD, wfdie + wfdielen); - wfdielen += 2; - - /* Value2: */ - /* Session Management Control Port */ - /* Default TCP port for RTSP messages is 554 */ - put_unaligned_be16(pwfd_info->rtsp_ctrlport, wfdie + wfdielen); - wfdielen += 2; - - /* Value3: */ - /* WFD Device Maximum Throughput */ - /* 300Mbps is the maximum throughput */ - put_unaligned_be16(300, wfdie + wfdielen); - wfdielen += 2; - - /* Associated BSSID ATTR */ - /* Type: */ - wfdie[ wfdielen++ ] = WFD_ATTR_ASSOC_BSSID; - - /* Length: */ - /* Note: In the WFD specification, the size of length field is 2. */ - put_unaligned_be16(0x0006, wfdie + wfdielen); - wfdielen += 2; - - /* Value: */ - /* Associated BSSID */ - if (check_fwstate(pmlmepriv, _FW_LINKED) == true) - { - memcpy(wfdie + wfdielen, &pmlmepriv->assoc_bssid[ 0 ], ETH_ALEN); - } - else - { - memset(wfdie + wfdielen, 0x00, ETH_ALEN); - } - - wfdielen += ETH_ALEN; - - /* Coupled Sink Information ATTR */ - /* Type: */ - wfdie[ wfdielen++ ] = WFD_ATTR_COUPLED_SINK_INFO; - - /* Length: */ - /* Note: In the WFD specification, the size of length field is 2. */ - put_unaligned_be16(0x0007, wfdie + wfdielen); - wfdielen += 2; - - /* Value: */ - /* Coupled Sink Status bitmap */ - /* Not coupled/available for Coupling */ - wfdie[ wfdielen++ ] = 0; - /* MAC Addr. */ - wfdie[ wfdielen++ ] = 0; - wfdie[ wfdielen++ ] = 0; - wfdie[ wfdielen++ ] = 0; - wfdie[ wfdielen++ ] = 0; - wfdie[ wfdielen++ ] = 0; - wfdie[ wfdielen++ ] = 0; - - pbuf = rtw_set_ie23a(pbuf, WLAN_EID_VENDOR_SPECIFIC, wfdielen, - (unsigned char *) wfdie, &len); - - return len; -} - -u32 build_nego_req_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf) -{ - u8 wfdie[ MAX_WFD_IE_LEN] = { 0x00 }; - u32 len = 0, wfdielen = 0; - struct rtw_adapter *padapter = pwdinfo->padapter; - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct wifi_display_info* pwfd_info = padapter->wdinfo.wfd_info; - - /* WFD OUI */ - wfdielen = 0; - wfdie[ wfdielen++ ] = 0x50; - wfdie[ wfdielen++ ] = 0x6F; - wfdie[ wfdielen++ ] = 0x9A; - wfdie[ wfdielen++ ] = 0x0A; /* WFA WFD v1.0 */ - - /* Commented by Albert 20110825 */ - /* According to the WFD Specification, the negotiation request frame should contain 3 WFD attributes */ - /* 1. WFD Device Information */ - /* 2. Associated BSSID (Optional) */ - /* 3. Local IP Adress (Optional) */ - - /* WFD Device Information ATTR */ - /* Type: */ - wfdie[ wfdielen++ ] = WFD_ATTR_DEVICE_INFO; - - /* Length: */ - /* Note: In the WFD specification, the size of length field is 2. */ - put_unaligned_be16(0x0006, wfdie + wfdielen); - wfdielen += 2; - - /* Value1: */ - /* WFD device information */ - /* WFD primary sink + WiFi Direct mode + WSD (WFD Service Discovery) + WFD Session Available */ - put_unaligned_be16(pwfd_info->wfd_device_type | - WFD_DEVINFO_WSD | WFD_DEVINFO_SESSION_AVAIL, - wfdie + wfdielen); - wfdielen += 2; - - /* Value2: */ - /* Session Management Control Port */ - /* Default TCP port for RTSP messages is 554 */ - put_unaligned_be16(pwfd_info->rtsp_ctrlport, wfdie + wfdielen); - wfdielen += 2; - - /* Value3: */ - /* WFD Device Maximum Throughput */ - /* 300Mbps is the maximum throughput */ - put_unaligned_be16(300, wfdie + wfdielen); - wfdielen += 2; - - /* Associated BSSID ATTR */ - /* Type: */ - wfdie[ wfdielen++ ] = WFD_ATTR_ASSOC_BSSID; - - /* Length: */ - /* Note: In the WFD specification, the size of length field is 2. */ - put_unaligned_be16(0x0006, wfdie + wfdielen); - wfdielen += 2; - - /* Value: */ - /* Associated BSSID */ - if (check_fwstate(pmlmepriv, _FW_LINKED) == true) - { - memcpy(wfdie + wfdielen, &pmlmepriv->assoc_bssid[ 0 ], ETH_ALEN); - } - else - { - memset(wfdie + wfdielen, 0x00, ETH_ALEN); - } - - wfdielen += ETH_ALEN; - - /* Coupled Sink Information ATTR */ - /* Type: */ - wfdie[ wfdielen++ ] = WFD_ATTR_COUPLED_SINK_INFO; - - /* Length: */ - /* Note: In the WFD specification, the size of length field is 2. */ - put_unaligned_be16(0x0007, wfdie + wfdielen); - wfdielen += 2; - - /* Value: */ - /* Coupled Sink Status bitmap */ - /* Not coupled/available for Coupling */ - wfdie[ wfdielen++ ] = 0; - /* MAC Addr. */ - wfdie[ wfdielen++ ] = 0; - wfdie[ wfdielen++ ] = 0; - wfdie[ wfdielen++ ] = 0; - wfdie[ wfdielen++ ] = 0; - wfdie[ wfdielen++ ] = 0; - wfdie[ wfdielen++ ] = 0; - - pbuf = rtw_set_ie23a(pbuf, WLAN_EID_VENDOR_SPECIFIC, wfdielen, - (unsigned char *) wfdie, &len); - - return len; -} - -u32 build_nego_resp_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf) -{ - u8 wfdie[ MAX_WFD_IE_LEN] = { 0x00 }; - u32 len = 0, wfdielen = 0; - struct rtw_adapter *padapter = pwdinfo->padapter; - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct wifi_display_info* pwfd_info = padapter->wdinfo.wfd_info; - - /* WFD OUI */ - wfdielen = 0; - wfdie[ wfdielen++ ] = 0x50; - wfdie[ wfdielen++ ] = 0x6F; - wfdie[ wfdielen++ ] = 0x9A; - wfdie[ wfdielen++ ] = 0x0A; /* WFA WFD v1.0 */ - - /* Commented by Albert 20110825 */ - /* According to the WFD Specification, the negotiation request frame should contain 3 WFD attributes */ - /* 1. WFD Device Information */ - /* 2. Associated BSSID (Optional) */ - /* 3. Local IP Adress (Optional) */ - - /* WFD Device Information ATTR */ - /* Type: */ - wfdie[ wfdielen++ ] = WFD_ATTR_DEVICE_INFO; - - /* Length: */ - /* Note: In the WFD specification, the size of length field is 2. */ - put_unaligned_be16(0x0006, wfdie + wfdielen); - wfdielen += 2; - - /* Value1: */ - /* WFD device information */ - /* WFD primary sink + WiFi Direct mode + WSD (WFD Service Discovery) + WFD Session Available */ - put_unaligned_be16(pwfd_info->wfd_device_type | - WFD_DEVINFO_WSD | WFD_DEVINFO_SESSION_AVAIL, - wfdie + wfdielen); - wfdielen += 2; - - /* Value2: */ - /* Session Management Control Port */ - /* Default TCP port for RTSP messages is 554 */ - put_unaligned_be16(pwfd_info->rtsp_ctrlport, wfdie + wfdielen); - wfdielen += 2; - - /* Value3: */ - /* WFD Device Maximum Throughput */ - /* 300Mbps is the maximum throughput */ - put_unaligned_be16(300, wfdie + wfdielen); - wfdielen += 2; - - /* Associated BSSID ATTR */ - /* Type: */ - wfdie[ wfdielen++ ] = WFD_ATTR_ASSOC_BSSID; - - /* Length: */ - /* Note: In the WFD specification, the size of length field is 2. */ - put_unaligned_be16(0x0006, wfdie + wfdielen); - wfdielen += 2; - - /* Value: */ - /* Associated BSSID */ - if (check_fwstate(pmlmepriv, _FW_LINKED) == true) - { - memcpy(wfdie + wfdielen, &pmlmepriv->assoc_bssid[ 0 ], ETH_ALEN); - } - else - { - memset(wfdie + wfdielen, 0x00, ETH_ALEN); - } - - wfdielen += ETH_ALEN; - - /* Coupled Sink Information ATTR */ - /* Type: */ - wfdie[ wfdielen++ ] = WFD_ATTR_COUPLED_SINK_INFO; - - /* Length: */ - /* Note: In the WFD specification, the size of length field is 2. */ - put_unaligned_be16(0x0007, wfdie + wfdielen); - wfdielen += 2; - - /* Value: */ - /* Coupled Sink Status bitmap */ - /* Not coupled/available for Coupling */ - wfdie[ wfdielen++ ] = 0; - /* MAC Addr. */ - wfdie[ wfdielen++ ] = 0; - wfdie[ wfdielen++ ] = 0; - wfdie[ wfdielen++ ] = 0; - wfdie[ wfdielen++ ] = 0; - wfdie[ wfdielen++ ] = 0; - wfdie[ wfdielen++ ] = 0; - - pbuf = rtw_set_ie23a(pbuf, WLAN_EID_VENDOR_SPECIFIC, wfdielen, - (unsigned char *) wfdie, &len); - - return len; -} - -u32 build_nego_confirm_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf) -{ - u8 wfdie[ MAX_WFD_IE_LEN] = { 0x00 }; - u32 len = 0, wfdielen = 0; - struct rtw_adapter *padapter = pwdinfo->padapter; - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct wifi_display_info* pwfd_info = padapter->wdinfo.wfd_info; - - /* WFD OUI */ - wfdielen = 0; - wfdie[ wfdielen++ ] = 0x50; - wfdie[ wfdielen++ ] = 0x6F; - wfdie[ wfdielen++ ] = 0x9A; - wfdie[ wfdielen++ ] = 0x0A; /* WFA WFD v1.0 */ - - /* Commented by Albert 20110825 */ - /* According to the WFD Specification, the negotiation request frame should contain 3 WFD attributes */ - /* 1. WFD Device Information */ - /* 2. Associated BSSID (Optional) */ - /* 3. Local IP Adress (Optional) */ - - /* WFD Device Information ATTR */ - /* Type: */ - wfdie[ wfdielen++ ] = WFD_ATTR_DEVICE_INFO; - - /* Length: */ - /* Note: In the WFD specification, the size of length field is 2. */ - put_unaligned_be16(0x0006, wfdie + wfdielen); - wfdielen += 2; - - /* Value1: */ - /* WFD device information */ - /* WFD primary sink + WiFi Direct mode + WSD (WFD Service Discovery) + WFD Session Available */ - put_unaligned_be16(pwfd_info->wfd_device_type | WFD_DEVINFO_WSD | - WFD_DEVINFO_SESSION_AVAIL, wfdie + wfdielen); - wfdielen += 2; - - /* Value2: */ - /* Session Management Control Port */ - /* Default TCP port for RTSP messages is 554 */ - put_unaligned_be16(pwfd_info->rtsp_ctrlport, wfdie + wfdielen); - wfdielen += 2; - - /* Value3: */ - /* WFD Device Maximum Throughput */ - /* 300Mbps is the maximum throughput */ - put_unaligned_be16(300, wfdie + wfdielen); - wfdielen += 2; - - /* Associated BSSID ATTR */ - /* Type: */ - wfdie[ wfdielen++ ] = WFD_ATTR_ASSOC_BSSID; - - /* Length: */ - /* Note: In the WFD specification, the size of length field is 2. */ - put_unaligned_be16(0x0006, wfdie + wfdielen); - wfdielen += 2; - - /* Value: */ - /* Associated BSSID */ - if (check_fwstate(pmlmepriv, _FW_LINKED) == true) - { - memcpy(wfdie + wfdielen, &pmlmepriv->assoc_bssid[ 0 ], ETH_ALEN); - } - else - { - memset(wfdie + wfdielen, 0x00, ETH_ALEN); - } - - wfdielen += ETH_ALEN; - - /* Coupled Sink Information ATTR */ - /* Type: */ - wfdie[ wfdielen++ ] = WFD_ATTR_COUPLED_SINK_INFO; - - /* Length: */ - /* Note: In the WFD specification, the size of length field is 2. */ - put_unaligned_be16(0x0007, wfdie + wfdielen); - wfdielen += 2; - - /* Value: */ - /* Coupled Sink Status bitmap */ - /* Not coupled/available for Coupling */ - wfdie[ wfdielen++ ] = 0; - /* MAC Addr. */ - wfdie[ wfdielen++ ] = 0; - wfdie[ wfdielen++ ] = 0; - wfdie[ wfdielen++ ] = 0; - wfdie[ wfdielen++ ] = 0; - wfdie[ wfdielen++ ] = 0; - wfdie[ wfdielen++ ] = 0; - - pbuf = rtw_set_ie23a(pbuf, WLAN_EID_VENDOR_SPECIFIC, wfdielen, - (unsigned char *) wfdie, &len); - - return len; -} - -u32 build_invitation_req_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf) -{ - u8 wfdie[ MAX_WFD_IE_LEN] = { 0x00 }; - u32 len = 0, wfdielen = 0; - struct rtw_adapter *padapter = pwdinfo->padapter; - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct wifi_display_info* pwfd_info = padapter->wdinfo.wfd_info; - - /* WFD OUI */ - wfdielen = 0; - wfdie[ wfdielen++ ] = 0x50; - wfdie[ wfdielen++ ] = 0x6F; - wfdie[ wfdielen++ ] = 0x9A; - wfdie[ wfdielen++ ] = 0x0A; /* WFA WFD v1.0 */ - - /* Commented by Albert 20110825 */ - /* According to the WFD Specification, the provision discovery request frame should contain 3 WFD attributes */ - /* 1. WFD Device Information */ - /* 2. Associated BSSID (Optional) */ - /* 3. Local IP Adress (Optional) */ - - /* WFD Device Information ATTR */ - /* Type: */ - wfdie[ wfdielen++ ] = WFD_ATTR_DEVICE_INFO; - - /* Length: */ - /* Note: In the WFD specification, the size of length field is 2. */ - put_unaligned_be16(0x0006, wfdie + wfdielen); - wfdielen += 2; - - /* Value1: */ - /* WFD device information */ - /* WFD primary sink + available for WFD session + WiFi Direct mode + WSD (WFD Service Discovery) */ - put_unaligned_be16(pwfd_info->wfd_device_type | - WFD_DEVINFO_SESSION_AVAIL | WFD_DEVINFO_WSD, - wfdie + wfdielen); - wfdielen += 2; - - /* Value2: */ - /* Session Management Control Port */ - /* Default TCP port for RTSP messages is 554 */ - put_unaligned_be16(pwfd_info->rtsp_ctrlport, wfdie + wfdielen); - wfdielen += 2; - - /* Value3: */ - /* WFD Device Maximum Throughput */ - /* 300Mbps is the maximum throughput */ - put_unaligned_be16(300, wfdie + wfdielen); - wfdielen += 2; - - /* Associated BSSID ATTR */ - /* Type: */ - wfdie[ wfdielen++ ] = WFD_ATTR_ASSOC_BSSID; - - /* Length: */ - /* Note: In the WFD specification, the size of length field is 2. */ - put_unaligned_be16(0x0006, wfdie + wfdielen); - wfdielen += 2; - - /* Value: */ - /* Associated BSSID */ - if (check_fwstate(pmlmepriv, _FW_LINKED) == true) - { - memcpy(wfdie + wfdielen, &pmlmepriv->assoc_bssid[ 0 ], ETH_ALEN); - } - else - { - memset(wfdie + wfdielen, 0x00, ETH_ALEN); - } - - wfdielen += ETH_ALEN; - - /* Coupled Sink Information ATTR */ - /* Type: */ - wfdie[ wfdielen++ ] = WFD_ATTR_COUPLED_SINK_INFO; - - /* Length: */ - /* Note: In the WFD specification, the size of length field is 2. */ - put_unaligned_be16(0x0007, wfdie + wfdielen); - wfdielen += 2; - - /* Value: */ - /* Coupled Sink Status bitmap */ - /* Not coupled/available for Coupling */ - wfdie[ wfdielen++ ] = 0; - /* MAC Addr. */ - wfdie[ wfdielen++ ] = 0; - wfdie[ wfdielen++ ] = 0; - wfdie[ wfdielen++ ] = 0; - wfdie[ wfdielen++ ] = 0; - wfdie[ wfdielen++ ] = 0; - wfdie[ wfdielen++ ] = 0; - - if (P2P_ROLE_GO == pwdinfo->role) - { - /* WFD Session Information ATTR */ - /* Type: */ - wfdie[ wfdielen++ ] = WFD_ATTR_SESSION_INFO; - - /* Length: */ - /* Note: In the WFD specification, the size of length field is 2. */ - put_unaligned_be16(0x0000, wfdie + wfdielen); - wfdielen += 2; - - /* Todo: to add the list of WFD device info descriptor in WFD group. */ - - } - - pbuf = rtw_set_ie23a(pbuf, WLAN_EID_VENDOR_SPECIFIC, wfdielen, - (unsigned char *) wfdie, &len); - - return len; -} - -u32 build_invitation_resp_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf) -{ - u8 wfdie[ MAX_WFD_IE_LEN] = { 0x00 }; - u32 len = 0, wfdielen = 0; - struct rtw_adapter *padapter = pwdinfo->padapter; - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct wifi_display_info* pwfd_info = padapter->wdinfo.wfd_info; - - /* WFD OUI */ - wfdielen = 0; - wfdie[ wfdielen++ ] = 0x50; - wfdie[ wfdielen++ ] = 0x6F; - wfdie[ wfdielen++ ] = 0x9A; - wfdie[ wfdielen++ ] = 0x0A; /* WFA WFD v1.0 */ - - /* Commented by Albert 20110825 */ - /* According to the WFD Specification, the provision discovery request frame should contain 3 WFD attributes */ - /* 1. WFD Device Information */ - /* 2. Associated BSSID (Optional) */ - /* 3. Local IP Adress (Optional) */ - - /* WFD Device Information ATTR */ - /* Type: */ - wfdie[ wfdielen++ ] = WFD_ATTR_DEVICE_INFO; - - /* Length: */ - /* Note: In the WFD specification, the size of length field is 2. */ - put_unaligned_be16(0x0006, wfdie + wfdielen); - wfdielen += 2; - - /* Value1: */ - /* WFD device information */ - /* WFD primary sink + available for WFD session + WiFi Direct mode + WSD (WFD Service Discovery) */ - put_unaligned_be16(pwfd_info->wfd_device_type | - WFD_DEVINFO_SESSION_AVAIL | WFD_DEVINFO_WSD, - wfdie + wfdielen); - wfdielen += 2; - - /* Value2: */ - /* Session Management Control Port */ - /* Default TCP port for RTSP messages is 554 */ - put_unaligned_be16(pwfd_info->rtsp_ctrlport, wfdie + wfdielen); - wfdielen += 2; - - /* Value3: */ - /* WFD Device Maximum Throughput */ - /* 300Mbps is the maximum throughput */ - put_unaligned_be16(300, wfdie + wfdielen); - wfdielen += 2; - - /* Associated BSSID ATTR */ - /* Type: */ - wfdie[ wfdielen++ ] = WFD_ATTR_ASSOC_BSSID; - - /* Length: */ - /* Note: In the WFD specification, the size of length field is 2. */ - put_unaligned_be16(0x0006, wfdie + wfdielen); - wfdielen += 2; - - /* Value: */ - /* Associated BSSID */ - if (check_fwstate(pmlmepriv, _FW_LINKED) == true) - { - memcpy(wfdie + wfdielen, &pmlmepriv->assoc_bssid[ 0 ], ETH_ALEN); - } - else - { - memset(wfdie + wfdielen, 0x00, ETH_ALEN); - } - - wfdielen += ETH_ALEN; - - /* Coupled Sink Information ATTR */ - /* Type: */ - wfdie[ wfdielen++ ] = WFD_ATTR_COUPLED_SINK_INFO; - - /* Length: */ - /* Note: In the WFD specification, the size of length field is 2. */ - put_unaligned_be16(0x0007, wfdie + wfdielen); - wfdielen += 2; - - /* Value: */ - /* Coupled Sink Status bitmap */ - /* Not coupled/available for Coupling */ - wfdie[ wfdielen++ ] = 0; - /* MAC Addr. */ - wfdie[ wfdielen++ ] = 0; - wfdie[ wfdielen++ ] = 0; - wfdie[ wfdielen++ ] = 0; - wfdie[ wfdielen++ ] = 0; - wfdie[ wfdielen++ ] = 0; - wfdie[ wfdielen++ ] = 0; - - if (P2P_ROLE_GO == pwdinfo->role) - { - /* WFD Session Information ATTR */ - /* Type: */ - wfdie[ wfdielen++ ] = WFD_ATTR_SESSION_INFO; - - /* Length: */ - /* Note: In the WFD specification, the size of length field is 2. */ - put_unaligned_be16(0x0000, wfdie + wfdielen); - wfdielen += 2; - - /* Todo: to add the list of WFD device info descriptor in WFD group. */ - - } - - pbuf = rtw_set_ie23a(pbuf, WLAN_EID_VENDOR_SPECIFIC, wfdielen, - (unsigned char *) wfdie, &len); - - return len; -} - -u32 build_provdisc_req_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf) -{ - u8 wfdie[ MAX_WFD_IE_LEN] = { 0x00 }; - u32 len = 0, wfdielen = 0; - struct rtw_adapter *padapter = pwdinfo->padapter; - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct wifi_display_info* pwfd_info = padapter->wdinfo.wfd_info; - - /* WFD OUI */ - wfdielen = 0; - wfdie[ wfdielen++ ] = 0x50; - wfdie[ wfdielen++ ] = 0x6F; - wfdie[ wfdielen++ ] = 0x9A; - wfdie[ wfdielen++ ] = 0x0A; /* WFA WFD v1.0 */ - - /* Commented by Albert 20110825 */ - /* According to the WFD Specification, the provision discovery request frame should contain 3 WFD attributes */ - /* 1. WFD Device Information */ - /* 2. Associated BSSID (Optional) */ - /* 3. Local IP Adress (Optional) */ - - /* WFD Device Information ATTR */ - /* Type: */ - wfdie[ wfdielen++ ] = WFD_ATTR_DEVICE_INFO; - - /* Length: */ - /* Note: In the WFD specification, the size of length field is 2. */ - put_unaligned_be16(0x0006, wfdie + wfdielen); - wfdielen += 2; - - /* Value1: */ - /* WFD device information */ - /* WFD primary sink + available for WFD session + WiFi Direct mode + WSD (WFD Service Discovery) */ - put_unaligned_be16(pwfd_info->wfd_device_type | - WFD_DEVINFO_SESSION_AVAIL | WFD_DEVINFO_WSD, - wfdie + wfdielen); - wfdielen += 2; - - /* Value2: */ - /* Session Management Control Port */ - /* Default TCP port for RTSP messages is 554 */ - put_unaligned_be16(pwfd_info->rtsp_ctrlport, wfdie + wfdielen); - wfdielen += 2; - - /* Value3: */ - /* WFD Device Maximum Throughput */ - /* 300Mbps is the maximum throughput */ - put_unaligned_be16(300, wfdie + wfdielen); - wfdielen += 2; - - /* Associated BSSID ATTR */ - /* Type: */ - wfdie[ wfdielen++ ] = WFD_ATTR_ASSOC_BSSID; - - /* Length: */ - /* Note: In the WFD specification, the size of length field is 2. */ - put_unaligned_be16(0x0006, wfdie + wfdielen); - wfdielen += 2; - - /* Value: */ - /* Associated BSSID */ - if (check_fwstate(pmlmepriv, _FW_LINKED) == true) - { - memcpy(wfdie + wfdielen, &pmlmepriv->assoc_bssid[ 0 ], ETH_ALEN); - } - else - { - memset(wfdie + wfdielen, 0x00, ETH_ALEN); - } - - wfdielen += ETH_ALEN; - - /* Coupled Sink Information ATTR */ - /* Type: */ - wfdie[ wfdielen++ ] = WFD_ATTR_COUPLED_SINK_INFO; - - /* Length: */ - /* Note: In the WFD specification, the size of length field is 2. */ - put_unaligned_be16(0x0007, wfdie + wfdielen); - wfdielen += 2; - - /* Value: */ - /* Coupled Sink Status bitmap */ - /* Not coupled/available for Coupling */ - wfdie[ wfdielen++ ] = 0; - /* MAC Addr. */ - wfdie[ wfdielen++ ] = 0; - wfdie[ wfdielen++ ] = 0; - wfdie[ wfdielen++ ] = 0; - wfdie[ wfdielen++ ] = 0; - wfdie[ wfdielen++ ] = 0; - wfdie[ wfdielen++ ] = 0; - - pbuf = rtw_set_ie23a(pbuf, WLAN_EID_VENDOR_SPECIFIC, wfdielen, - (unsigned char *) wfdie, &len); - - return len; -} - -u32 build_provdisc_resp_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf) -{ - u8 wfdie[ MAX_WFD_IE_LEN] = { 0x00 }; - u32 len = 0, wfdielen = 0; - struct rtw_adapter *padapter = pwdinfo->padapter; - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct wifi_display_info* pwfd_info = padapter->wdinfo.wfd_info; - - /* WFD OUI */ - wfdielen = 0; - wfdie[ wfdielen++ ] = 0x50; - wfdie[ wfdielen++ ] = 0x6F; - wfdie[ wfdielen++ ] = 0x9A; - wfdie[ wfdielen++ ] = 0x0A; /* WFA WFD v1.0 */ - - /* Commented by Albert 20110825 */ - /* According to the WFD Specification, the provision discovery response frame should contain 3 WFD attributes */ - /* 1. WFD Device Information */ - /* 2. Associated BSSID (Optional) */ - /* 3. Local IP Adress (Optional) */ - - /* WFD Device Information ATTR */ - /* Type: */ - wfdie[ wfdielen++ ] = WFD_ATTR_DEVICE_INFO; - - /* Length: */ - /* Note: In the WFD specification, the size of length field is 2. */ - put_unaligned_be16(0x0006, wfdie + wfdielen); - wfdielen += 2; - - /* Value1: */ - /* WFD device information */ - /* WFD primary sink + available for WFD session + WiFi Direct mode + WSD (WFD Service Discovery) */ - put_unaligned_be16(pwfd_info->wfd_device_type | - WFD_DEVINFO_SESSION_AVAIL | WFD_DEVINFO_WSD, - wfdie + wfdielen); - wfdielen += 2; - - /* Value2: */ - /* Session Management Control Port */ - /* Default TCP port for RTSP messages is 554 */ - put_unaligned_be16(pwfd_info->rtsp_ctrlport, wfdie + wfdielen); - wfdielen += 2; - - /* Value3: */ - /* WFD Device Maximum Throughput */ - /* 300Mbps is the maximum throughput */ - put_unaligned_be16(300, wfdie + wfdielen); - wfdielen += 2; - - /* Associated BSSID ATTR */ - /* Type: */ - wfdie[ wfdielen++ ] = WFD_ATTR_ASSOC_BSSID; - - /* Length: */ - /* Note: In the WFD specification, the size of length field is 2. */ - put_unaligned_be16(0x0006, wfdie + wfdielen); - wfdielen += 2; - - /* Value: */ - /* Associated BSSID */ - if (check_fwstate(pmlmepriv, _FW_LINKED) == true) - { - memcpy(wfdie + wfdielen, &pmlmepriv->assoc_bssid[ 0 ], ETH_ALEN); - } - else - { - memset(wfdie + wfdielen, 0x00, ETH_ALEN); - } - - wfdielen += ETH_ALEN; - - /* Coupled Sink Information ATTR */ - /* Type: */ - wfdie[ wfdielen++ ] = WFD_ATTR_COUPLED_SINK_INFO; - - /* Length: */ - /* Note: In the WFD specification, the size of length field is 2. */ - put_unaligned_be16(0x0007, wfdie + wfdielen); - wfdielen += 2; - - /* Value: */ - /* Coupled Sink Status bitmap */ - /* Not coupled/available for Coupling */ - wfdie[ wfdielen++ ] = 0; - /* MAC Addr. */ - wfdie[ wfdielen++ ] = 0; - wfdie[ wfdielen++ ] = 0; - wfdie[ wfdielen++ ] = 0; - wfdie[ wfdielen++ ] = 0; - wfdie[ wfdielen++ ] = 0; - wfdie[ wfdielen++ ] = 0; - - pbuf = rtw_set_ie23a(pbuf, WLAN_EID_VENDOR_SPECIFIC, wfdielen, - (unsigned char *) wfdie, &len); - - return len; -} - -#endif /* CONFIG_8723AU_P2P */ - -u32 build_probe_resp_p2p_ie23a(struct wifidirect_info *pwdinfo, u8 *pbuf) -{ - u8 p2pie[ MAX_P2P_IE_LEN] = { 0x00 }; - u32 len = 0, p2pielen = 0; - - /* P2P OUI */ - p2pielen = 0; - p2pie[ p2pielen++ ] = 0x50; - p2pie[ p2pielen++ ] = 0x6F; - p2pie[ p2pielen++ ] = 0x9A; - p2pie[ p2pielen++ ] = 0x09; /* WFA P2P v1.0 */ - - /* Commented by Albert 20100907 */ - /* According to the P2P Specification, the probe response frame should contain 5 P2P attributes */ - /* 1. P2P Capability */ - /* 2. Extended Listen Timing */ - /* 3. Notice of Absence (NOA) (Only GO needs this) */ - /* 4. Device Info */ - /* 5. Group Info (Only GO need this) */ - - /* P2P Capability ATTR */ - /* Type: */ - p2pie[ p2pielen++ ] = P2P_ATTR_CAPABILITY; - - /* Length: */ - /* u16*) (p2pie + p2pielen) = cpu_to_le16(0x0002); */ - put_unaligned_le16(0x0002, p2pie + p2pielen); - p2pielen += 2; - - /* Value: */ - /* Device Capability Bitmap, 1 byte */ - p2pie[ p2pielen++ ] = DMP_P2P_DEVCAP_SUPPORT; - - /* Group Capability Bitmap, 1 byte */ - if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO)) - { - p2pie[ p2pielen ] = (P2P_GRPCAP_GO | P2P_GRPCAP_INTRABSS); - - if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_PROVISIONING_ING)) - p2pie[ p2pielen ] |= P2P_GRPCAP_GROUP_FORMATION; - - p2pielen++; - } - else if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_DEVICE)) - { - /* Group Capability Bitmap, 1 byte */ - if (pwdinfo->persistent_supported) - p2pie[ p2pielen++ ] = P2P_GRPCAP_PERSISTENT_GROUP | DMP_P2P_GRPCAP_SUPPORT; - else - p2pie[ p2pielen++ ] = DMP_P2P_GRPCAP_SUPPORT; - } - - /* Extended Listen Timing ATTR */ - /* Type: */ - p2pie[ p2pielen++ ] = P2P_ATTR_EX_LISTEN_TIMING; - - /* Length: */ - /* u16*) (p2pie + p2pielen) = cpu_to_le16(0x0004); */ - put_unaligned_le16(0x0004, p2pie + p2pielen); - p2pielen += 2; - - /* Value: */ - /* Availability Period */ - /* u16*) (p2pie + p2pielen) = cpu_to_le16(0xFFFF); */ - put_unaligned_le16(0xFFFF, p2pie + p2pielen); - p2pielen += 2; - - /* Availability Interval */ - /* u16*) (p2pie + p2pielen) = cpu_to_le16(0xFFFF); */ - put_unaligned_le16(0xFFFF, p2pie + p2pielen); - p2pielen += 2; - - /* Notice of Absence ATTR */ - /* Type: */ - /* Length: */ - /* Value: */ - if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO)) - { - /* go_add_noa_attr(pwdinfo); */ - } - - /* Device Info ATTR */ - /* Type: */ - p2pie[ p2pielen++ ] = P2P_ATTR_DEVICE_INFO; - - /* Length: */ - /* 21 -> P2P Device Address (6bytes) + Config Methods (2bytes) + Primary Device Type (8bytes) */ - /* + NumofSecondDevType (1byte) + WPS Device Name ID field (2bytes) + WPS Device Name Len field (2bytes) */ - /* u16*) (p2pie + p2pielen) = cpu_to_le16(21 + pwdinfo->device_name_len); */ - put_unaligned_le16(21 + pwdinfo->device_name_len, p2pie + p2pielen); - p2pielen += 2; - - /* Value: */ - /* P2P Device Address */ - memcpy(p2pie + p2pielen, pwdinfo->device_addr, ETH_ALEN); - p2pielen += ETH_ALEN; - - /* Config Method */ - /* This field should be big endian. Noted by P2P specification. */ - /* u16*) (p2pie + p2pielen) = cpu_to_be16(pwdinfo->supported_wps_cm); */ - put_unaligned_be16(pwdinfo->supported_wps_cm, p2pie + p2pielen); - p2pielen += 2; - - /* Primary Device Type */ - /* Category ID */ - /* u16*) (p2pie + p2pielen) = cpu_to_be16(WPS_PDT_CID_MULIT_MEDIA); */ - put_unaligned_be16(WPS_PDT_CID_MULIT_MEDIA, p2pie + p2pielen); - p2pielen += 2; - - /* OUI */ - /* u32*) (p2pie + p2pielen) = cpu_to_be32(WPSOUI); */ - put_unaligned_be32(WPSOUI, p2pie + p2pielen); - p2pielen += 4; - - /* Sub Category ID */ - /* u16*) (p2pie + p2pielen) = cpu_to_be16(WPS_PDT_SCID_MEDIA_SERVER); */ - put_unaligned_be16(WPS_PDT_SCID_MEDIA_SERVER, p2pie + p2pielen); - p2pielen += 2; - - /* Number of Secondary Device Types */ - p2pie[ p2pielen++ ] = 0x00; /* No Secondary Device Type List */ - - /* Device Name */ - /* Type: */ - /* u16*) (p2pie + p2pielen) = cpu_to_be16(WPS_ATTR_DEVICE_NAME); */ - put_unaligned_be16(WPS_ATTR_DEVICE_NAME, p2pie + p2pielen); - p2pielen += 2; - - /* Length: */ - /* u16*) (p2pie + p2pielen) = cpu_to_be16(pwdinfo->device_name_len); */ - put_unaligned_be16(pwdinfo->device_name_len, p2pie + p2pielen); - p2pielen += 2; - - /* Value: */ - memcpy(p2pie + p2pielen, pwdinfo->device_name, pwdinfo->device_name_len); - p2pielen += pwdinfo->device_name_len; - - /* Group Info ATTR */ - /* Type: */ - /* Length: */ - /* Value: */ - if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO)) - { - p2pielen += go_add_group_info_attr(pwdinfo, p2pie + p2pielen); - } - - pbuf = rtw_set_ie23a(pbuf, WLAN_EID_VENDOR_SPECIFIC, p2pielen, - (unsigned char *) p2pie, &len); - - return len; -} - -u32 build_prov_disc_request_p2p_ie23a(struct wifidirect_info *pwdinfo, u8 *pbuf, u8* pssid, u8 ussidlen, u8* pdev_raddr) -{ - u8 p2pie[ MAX_P2P_IE_LEN] = { 0x00 }; - u32 len = 0, p2pielen = 0; - - /* P2P OUI */ - p2pielen = 0; - p2pie[ p2pielen++ ] = 0x50; - p2pie[ p2pielen++ ] = 0x6F; - p2pie[ p2pielen++ ] = 0x9A; - p2pie[ p2pielen++ ] = 0x09; /* WFA P2P v1.0 */ - - /* Commented by Albert 20110301 */ - /* According to the P2P Specification, the provision discovery request frame should contain 3 P2P attributes */ - /* 1. P2P Capability */ - /* 2. Device Info */ - /* 3. Group ID (When joining an operating P2P Group) */ - - /* P2P Capability ATTR */ - /* Type: */ - p2pie[ p2pielen++ ] = P2P_ATTR_CAPABILITY; - - /* Length: */ - /* u16*) (p2pie + p2pielen) = cpu_to_le16(0x0002); */ - put_unaligned_le16(0x0002, p2pie + p2pielen); - p2pielen += 2; - - /* Value: */ - /* Device Capability Bitmap, 1 byte */ - p2pie[ p2pielen++ ] = DMP_P2P_DEVCAP_SUPPORT; - - /* Group Capability Bitmap, 1 byte */ - if (pwdinfo->persistent_supported) - p2pie[ p2pielen++ ] = P2P_GRPCAP_PERSISTENT_GROUP | DMP_P2P_GRPCAP_SUPPORT; - else - p2pie[ p2pielen++ ] = DMP_P2P_GRPCAP_SUPPORT; - - /* Device Info ATTR */ - /* Type: */ - p2pie[ p2pielen++ ] = P2P_ATTR_DEVICE_INFO; - - /* Length: */ - /* 21 -> P2P Device Address (6bytes) + Config Methods (2bytes) + Primary Device Type (8bytes) */ - /* + NumofSecondDevType (1byte) + WPS Device Name ID field (2bytes) + WPS Device Name Len field (2bytes) */ - /* u16*) (p2pie + p2pielen) = cpu_to_le16(21 + pwdinfo->device_name_len); */ - put_unaligned_le16(21 + pwdinfo->device_name_len, p2pie + p2pielen); - p2pielen += 2; - - /* Value: */ - /* P2P Device Address */ - memcpy(p2pie + p2pielen, pwdinfo->device_addr, ETH_ALEN); - p2pielen += ETH_ALEN; - - /* Config Method */ - /* This field should be big endian. Noted by P2P specification. */ - if (pwdinfo->ui_got_wps_info == P2P_GOT_WPSINFO_PBC) - { - /* u16*) (p2pie + p2pielen) = cpu_to_be16(WPS_CONFIG_METHOD_PBC); */ - put_unaligned_be16(WPS_CONFIG_METHOD_PBC, p2pie + p2pielen); - } - else - { - /* u16*) (p2pie + p2pielen) = cpu_to_be16(WPS_CONFIG_METHOD_DISPLAY); */ - put_unaligned_be16(WPS_CONFIG_METHOD_DISPLAY, p2pie + p2pielen); - } - - p2pielen += 2; - - /* Primary Device Type */ - /* Category ID */ - /* u16*) (p2pie + p2pielen) = cpu_to_be16(WPS_PDT_CID_MULIT_MEDIA); */ - put_unaligned_be16(WPS_PDT_CID_MULIT_MEDIA, p2pie + p2pielen); - p2pielen += 2; - - /* OUI */ - /* u32*) (p2pie + p2pielen) = cpu_to_be32(WPSOUI); */ - put_unaligned_be32(WPSOUI, p2pie + p2pielen); - p2pielen += 4; - - /* Sub Category ID */ - /* u16*) (p2pie + p2pielen) = cpu_to_be16(WPS_PDT_SCID_MEDIA_SERVER); */ - put_unaligned_be16(WPS_PDT_SCID_MEDIA_SERVER, p2pie + p2pielen); - p2pielen += 2; - - /* Number of Secondary Device Types */ - p2pie[ p2pielen++ ] = 0x00; /* No Secondary Device Type List */ - - /* Device Name */ - /* Type: */ - /* u16*) (p2pie + p2pielen) = cpu_to_be16(WPS_ATTR_DEVICE_NAME); */ - put_unaligned_be16(WPS_ATTR_DEVICE_NAME, p2pie + p2pielen); - p2pielen += 2; - - /* Length: */ - /* u16*) (p2pie + p2pielen) = cpu_to_be16(pwdinfo->device_name_len); */ - put_unaligned_be16(pwdinfo->device_name_len, p2pie + p2pielen); - p2pielen += 2; - - /* Value: */ - memcpy(p2pie + p2pielen, pwdinfo->device_name, pwdinfo->device_name_len); - p2pielen += pwdinfo->device_name_len; - - if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_CLIENT)) - { - /* Added by Albert 2011/05/19 */ - /* In this case, the pdev_raddr is the device address of the group owner. */ - - /* P2P Group ID ATTR */ - /* Type: */ - p2pie[ p2pielen++ ] = P2P_ATTR_GROUP_ID; - - /* Length: */ - /* u16*) (p2pie + p2pielen) = cpu_to_le16(ETH_ALEN + ussidlen); */ - put_unaligned_le16(ETH_ALEN + ussidlen, p2pie + p2pielen); - p2pielen += 2; - - /* Value: */ - memcpy(p2pie + p2pielen, pdev_raddr, ETH_ALEN); - p2pielen += ETH_ALEN; - - memcpy(p2pie + p2pielen, pssid, ussidlen); - p2pielen += ussidlen; - - } - - pbuf = rtw_set_ie23a(pbuf, WLAN_EID_VENDOR_SPECIFIC, p2pielen, - (unsigned char *) p2pie, &len); - - return len; -} - -u32 build_assoc_resp_p2p_ie23a(struct wifidirect_info *pwdinfo, u8 *pbuf, u8 status_code) -{ - u8 p2pie[ MAX_P2P_IE_LEN] = { 0x00 }; - u32 len = 0, p2pielen = 0; - - /* P2P OUI */ - p2pielen = 0; - p2pie[ p2pielen++ ] = 0x50; - p2pie[ p2pielen++ ] = 0x6F; - p2pie[ p2pielen++ ] = 0x9A; - p2pie[ p2pielen++ ] = 0x09; /* WFA P2P v1.0 */ - - /* According to the P2P Specification, the Association response frame should contain 2 P2P attributes */ - /* 1. Status */ - /* 2. Extended Listen Timing (optional) */ - - /* Status ATTR */ - p2pielen += rtw_set_p2p_attr_content23a(&p2pie[p2pielen], P2P_ATTR_STATUS, 1, &status_code); - - /* Extended Listen Timing ATTR */ - /* Type: */ - /* Length: */ - /* Value: */ - - pbuf = rtw_set_ie23a(pbuf, WLAN_EID_VENDOR_SPECIFIC, p2pielen, - (unsigned char *) p2pie, &len); - - return len; -} - -u32 build_deauth_p2p_ie23a(struct wifidirect_info *pwdinfo, u8 *pbuf) -{ - u32 len = 0; - - return len; -} - -u32 process_probe_req_p2p_ie23a(struct wifidirect_info *pwdinfo, u8 *pframe, uint len) -{ - u8 *p; - u32 ret = false; - u8 *p2pie; - u32 p2pielen = 0; - int ssid_len = 0, rate_cnt = 0; - - p = rtw_get_ie23a(pframe + sizeof(struct ieee80211_hdr_3addr) + - _PROBEREQ_IE_OFFSET_, WLAN_EID_SUPP_RATES, - (int *)&rate_cnt, - len - sizeof(struct ieee80211_hdr_3addr) - - _PROBEREQ_IE_OFFSET_); - - if (rate_cnt <= 4) - { - int i, g_rate = 0; - - for (i = 0; i < rate_cnt; i++) - { - if (((*(p + 2 + i) & 0xff) != 0x02) && - ((*(p + 2 + i) & 0xff) != 0x04) && - ((*(p + 2 + i) & 0xff) != 0x0B) && - ((*(p + 2 + i) & 0xff) != 0x16)) - { - g_rate = 1; - } - } - - if (g_rate == 0) - { - /* There is no OFDM rate included in SupportedRates IE of this probe request frame */ - /* The driver should response this probe request. */ - return ret; - } - } - else - { - /* rate_cnt > 4 means the SupportRates IE contains the OFDM rate because the count of CCK rates are 4. */ - /* We should proceed the following check for this probe request. */ - } - - /* Added comments by Albert 20100906 */ - /* There are several items we should check here. */ - /* 1. This probe request frame must contain the P2P IE. (Done) */ - /* 2. This probe request frame must contain the wildcard SSID. (Done) */ - /* 3. Wildcard BSSID. (Todo) */ - /* 4. Destination Address. (Done in mgt_dispatcher23a function) */ - /* 5. Requested Device Type in WSC IE. (Todo) */ - /* 6. Device ID attribute in P2P IE. (Todo) */ - - p = rtw_get_ie23a(pframe + sizeof(struct ieee80211_hdr_3addr) + - _PROBEREQ_IE_OFFSET_, WLAN_EID_SSID, (int *)&ssid_len, - len - sizeof(struct ieee80211_hdr_3addr) - - _PROBEREQ_IE_OFFSET_); - - ssid_len &= 0xff; /* Just last 1 byte is valid for ssid len of the probe request */ - if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_DEVICE) || rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO)) - { - if ((p2pie = rtw_get_p2p_ie23a(pframe + sizeof(struct ieee80211_hdr_3addr) + _PROBEREQ_IE_OFFSET_, len - sizeof(struct ieee80211_hdr_3addr) - _PROBEREQ_IE_OFFSET_, NULL, &p2pielen))) - { - if ((p) && !memcmp((void *)(p+2), (void *)pwdinfo->p2p_wildcard_ssid, 7)) - { - /* todo: */ - /* Check Requested Device Type attributes in WSC IE. */ - /* Check Device ID attribute in P2P IE */ - - ret = true; - } - else if ((p != NULL) && (ssid_len == 0)) - { - ret = true; - } - } - else - { - /* non -p2p device */ - } - - } - - return ret; -} - -u32 process_assoc_req_p2p_ie23a(struct wifidirect_info *pwdinfo, u8 *pframe, uint len, struct sta_info *psta) -{ - u8 status_code = P2P_STATUS_SUCCESS; - u8 *pbuf, *pattr_content = NULL; - u32 attr_contentlen = 0; - u16 cap_attr = 0; - unsigned short ie_offset; - u8 * ies; - u32 ies_len; - u8 * p2p_ie; - u32 p2p_ielen = 0; - struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)pframe; - - if (!rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO)) - return P2P_STATUS_FAIL_REQUEST_UNABLE; - - if (ieee80211_is_assoc_req(hdr->frame_control)) - ie_offset = _ASOCREQ_IE_OFFSET_; - else /* WIFI_REASSOCREQ */ - ie_offset = _REASOCREQ_IE_OFFSET_; - - ies = pframe + sizeof(struct ieee80211_hdr_3addr) + ie_offset; - ies_len = len - sizeof(struct ieee80211_hdr_3addr) - ie_offset; - - p2p_ie = rtw_get_p2p_ie23a(ies, ies_len, NULL, &p2p_ielen); - - if (!p2p_ie) - { - DBG_8723A("[%s] P2P IE not Found!!\n", __func__); - status_code = P2P_STATUS_FAIL_INVALID_PARAM; - } - else - { - DBG_8723A("[%s] P2P IE Found!!\n", __func__); - } - - while (p2p_ie) - { - /* Check P2P Capability ATTR */ - if (rtw_get_p2p_attr23a_content(p2p_ie, p2p_ielen, P2P_ATTR_CAPABILITY, (u8*)&cap_attr, (uint*) &attr_contentlen)) - { - DBG_8723A("[%s] Got P2P Capability Attr!!\n", __func__); - cap_attr = le16_to_cpu(cap_attr); - psta->dev_cap = cap_attr&0xff; - } - - /* Check Extended Listen Timing ATTR */ - - /* Check P2P Device Info ATTR */ - if (rtw_get_p2p_attr23a_content(p2p_ie, p2p_ielen, P2P_ATTR_DEVICE_INFO, NULL, (uint*)&attr_contentlen)) - { - DBG_8723A("[%s] Got P2P DEVICE INFO Attr!!\n", __func__); - pattr_content = pbuf = kzalloc(attr_contentlen, - GFP_ATOMIC); - if (pattr_content) { - u8 num_of_secdev_type; - u16 dev_name_len; - - rtw_get_p2p_attr23a_content(p2p_ie, p2p_ielen, P2P_ATTR_DEVICE_INFO, pattr_content, (uint*)&attr_contentlen); - - memcpy(psta->dev_addr, pattr_content, ETH_ALEN);/* P2P Device Address */ - - pattr_content += ETH_ALEN; - - memcpy(&psta->config_methods, pattr_content, 2);/* Config Methods */ - psta->config_methods = be16_to_cpu(psta->config_methods); - - pattr_content += 2; - - memcpy(psta->primary_dev_type, pattr_content, 8); - - pattr_content += 8; - - num_of_secdev_type = *pattr_content; - pattr_content += 1; - - if (num_of_secdev_type == 0) - { - psta->num_of_secdev_type = 0; - } - else - { - u32 len; - - psta->num_of_secdev_type = num_of_secdev_type; - - len = (sizeof(psta->secdev_types_list)<(num_of_secdev_type*8)) ? (sizeof(psta->secdev_types_list)) : (num_of_secdev_type*8); - - memcpy(psta->secdev_types_list, pattr_content, len); - - pattr_content += (num_of_secdev_type*8); - } - - /* dev_name_len = attr_contentlen - ETH_ALEN - 2 - 8 - 1 - (num_of_secdev_type*8); */ - psta->dev_name_len = 0; - if (WPS_ATTR_DEVICE_NAME == be16_to_cpu(*(u16*)pattr_content)) - { - dev_name_len = be16_to_cpu(*(u16*)(pattr_content+2)); - - psta->dev_name_len = (sizeof(psta->dev_name)dev_name):dev_name_len; - - memcpy(psta->dev_name, pattr_content+4, psta->dev_name_len); - } - - kfree(pbuf); - - } - - } - - /* Get the next P2P IE */ - p2p_ie = rtw_get_p2p_ie23a(p2p_ie+p2p_ielen, ies_len -(p2p_ie -ies + p2p_ielen), NULL, &p2p_ielen); - - } - - return status_code; -} - -u32 process_p2p_devdisc_req23a(struct wifidirect_info *pwdinfo, u8 *pframe, - uint len) -{ - u8 *frame_body; - u8 status, dialogToken; - struct sta_info *psta = NULL; - struct rtw_adapter *padapter = pwdinfo->padapter; - struct sta_priv *pstapriv = &padapter->stapriv; - u8 *p2p_ie; - u32 p2p_ielen = 0; - struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) pframe; - - frame_body = (unsigned char *) - (pframe + sizeof(struct ieee80211_hdr_3addr)); - - dialogToken = frame_body[7]; - status = P2P_STATUS_FAIL_UNKNOWN_P2PGROUP; - - if ((p2p_ie = rtw_get_p2p_ie23a(frame_body + _PUBLIC_ACTION_IE_OFFSET_, - len - _PUBLIC_ACTION_IE_OFFSET_, NULL, - &p2p_ielen))) { - u8 groupid[38] = { 0x00 }; - u8 dev_addr[ETH_ALEN] = { 0x00 }; - u32 attr_contentlen = 0; - - if (rtw_get_p2p_attr23a_content(p2p_ie, p2p_ielen, - P2P_ATTR_GROUP_ID, groupid, - &attr_contentlen)) { - if (!memcmp(pwdinfo->device_addr, groupid, ETH_ALEN) && - !memcmp(pwdinfo->p2p_group_ssid, groupid + ETH_ALEN, - pwdinfo->p2p_group_ssid_len)) { - attr_contentlen = 0; - - if (rtw_get_p2p_attr23a_content(p2p_ie, p2p_ielen, - P2P_ATTR_DEVICE_ID, - dev_addr, - &attr_contentlen)) { - struct list_head *phead, *plist, *ptmp; - - spin_lock_bh(&pstapriv->asoc_list_lock); - phead = &pstapriv->asoc_list; - - list_for_each_safe(plist, ptmp, phead) { - psta = container_of(plist, struct sta_info, asoc_list); - - if (psta->is_p2p_device && (psta->dev_cap&P2P_DEVCAP_CLIENT_DISCOVERABILITY) && - !memcmp(psta->dev_addr, dev_addr, ETH_ALEN)) - { - /* spin_unlock_bh(&pstapriv->asoc_list_lock); */ - /* issue GO Discoverability Request */ - issue_group_disc_req(pwdinfo, psta->hwaddr); - /* spin_lock_bh(&pstapriv->asoc_list_lock); */ - status = P2P_STATUS_SUCCESS; - break; - } else { - status = P2P_STATUS_FAIL_INFO_UNAVAILABLE; - } - } - spin_unlock_bh(&pstapriv->asoc_list_lock); - } else { - status = P2P_STATUS_FAIL_INVALID_PARAM; - } - } else { - status = P2P_STATUS_FAIL_INVALID_PARAM; - } - } - } - - /* issue Device Discoverability Response */ - issue_p2p_devdisc_resp(pwdinfo, hdr->addr2, status, dialogToken); - - return (status == P2P_STATUS_SUCCESS) ? true:false; -} - -u32 process_p2p_devdisc_resp23a(struct wifidirect_info *pwdinfo, u8 *pframe, uint len) -{ - return true; -} - -u8 process_p2p_provdisc_req23a(struct wifidirect_info *pwdinfo, - u8 *pframe, uint len) -{ - u8 *frame_body; - u8 *wpsie; - u8 *ptr = NULL; - uint wps_ielen = 0, attr_contentlen = 0; - u16 uconfig_method = 0; - struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)pframe; - - frame_body = (pframe + sizeof(struct ieee80211_hdr_3addr)); - - wpsie = rtw_get_wps_ie23a(frame_body + _PUBLIC_ACTION_IE_OFFSET_, - len - _PUBLIC_ACTION_IE_OFFSET_, NULL, - &wps_ielen); - if (!wpsie) - goto out; - - if (!rtw_get_wps_attr_content23a(wpsie, wps_ielen, WPS_ATTR_CONF_METHOD, - (u8 *)&uconfig_method, &attr_contentlen)) - goto out; - - uconfig_method = be16_to_cpu(uconfig_method); - ptr = pwdinfo->rx_prov_disc_info.strconfig_method_desc_of_prov_disc_req; - - switch (uconfig_method) - { - case WPS_CM_DISPLYA: - memcpy(ptr, "dis", 3); - break; - - case WPS_CM_LABEL: - memcpy(ptr, "lab", 3); - break; - - case WPS_CM_PUSH_BUTTON: - memcpy(ptr, "pbc", 3); - break; - - case WPS_CM_KEYPAD: - memcpy(ptr, "pad", 3); - break; - } - issue_p2p_provision_resp(pwdinfo, hdr->addr2, frame_body, - uconfig_method); - -out: - DBG_8723A("[%s] config method = %s\n", __func__, ptr); - - return true; -} - -u8 process_p2p_provdisc_resp23a(struct wifidirect_info *pwdinfo, u8 *pframe) -{ - - return true; -} - -static u8 rtw_p2p_get_peer_ch_list(struct wifidirect_info *pwdinfo, u8 *ch_content, u8 ch_cnt, u8 *peer_ch_list) -{ - u8 i = 0, j = 0; - u8 temp = 0; - u8 ch_no = 0; - ch_content += 3; - ch_cnt -= 3; - - while(ch_cnt > 0) - { - ch_content += 1; - ch_cnt -= 1; - temp = *ch_content; - for (i = 0 ; i < temp ; i++, j++) - { - peer_ch_list[j] = *(ch_content + 1 + i); - } - ch_content += (temp + 1); - ch_cnt -= (temp + 1); - ch_no += temp ; - } - - return ch_no; -} - -static u8 rtw_p2p_ch_inclusion(struct mlme_ext_priv *pmlmeext, u8 *peer_ch_list, u8 peer_ch_num, u8 *ch_list_inclusioned) -{ - int i = 0, j = 0, temp = 0; - u8 ch_no = 0; - - for (i = 0; i < peer_ch_num; i++) - { - for (j = temp; j < pmlmeext->max_chan_nums; j++) - { - if (*(peer_ch_list + i) == pmlmeext->channel_set[ j ].ChannelNum) - { - ch_list_inclusioned[ ch_no++ ] = *(peer_ch_list + i); - temp = j; - break; - } - } - } - - return ch_no; -} - -u8 process_p2p_group_negotation_req23a(struct wifidirect_info *pwdinfo, u8 *pframe, uint len) -{ - struct rtw_adapter *padapter = pwdinfo->padapter; - u8 result = P2P_STATUS_SUCCESS; - u32 p2p_ielen = 0, wps_ielen = 0; - u8 * ies; - u32 ies_len; - u8 *p2p_ie; - u8 *wpsie; - u16 wps_devicepassword_id = 0x0000; - uint wps_devicepassword_id_len = 0; -#ifdef CONFIG_8723AU_P2P - u8 wfd_ie[MAX_WFD_IE_LEN] = { 0x00 }; - u32 wfd_ielen = 0; -#endif /* CONFIG_8723AU_P2P */ - - if ((wpsie = rtw_get_wps_ie23a(pframe + _PUBLIC_ACTION_IE_OFFSET_, len - _PUBLIC_ACTION_IE_OFFSET_, NULL, &wps_ielen))) - { - /* Commented by Kurt 20120113 */ - /* If some device wants to do p2p handshake without sending prov_disc_req */ - /* We have to get peer_req_cm from here. */ - if (!memcmp(pwdinfo->rx_prov_disc_info.strconfig_method_desc_of_prov_disc_req, "000", 3)) - { - rtw_get_wps_attr_content23a(wpsie, wps_ielen, WPS_ATTR_DEVICE_PWID, (u8*) &wps_devicepassword_id, &wps_devicepassword_id_len); - wps_devicepassword_id = be16_to_cpu(wps_devicepassword_id); - - if (wps_devicepassword_id == WPS_DPID_USER_SPEC) - { - memcpy(pwdinfo->rx_prov_disc_info.strconfig_method_desc_of_prov_disc_req, "dis", 3); - } - else if (wps_devicepassword_id == WPS_DPID_REGISTRAR_SPEC) - { - memcpy(pwdinfo->rx_prov_disc_info.strconfig_method_desc_of_prov_disc_req, "pad", 3); - } - else - { - memcpy(pwdinfo->rx_prov_disc_info.strconfig_method_desc_of_prov_disc_req, "pbc", 3); - } - } - } - else - { - DBG_8723A("[%s] WPS IE not Found!!\n", __func__); - result = P2P_STATUS_FAIL_INCOMPATIBLE_PARAM; - rtw_p2p_set_state(pwdinfo, P2P_STATE_GONEGO_FAIL); - return result; - } - - if (pwdinfo->ui_got_wps_info == P2P_NO_WPSINFO) - { - result = P2P_STATUS_FAIL_INFO_UNAVAILABLE; - rtw_p2p_set_state(pwdinfo, P2P_STATE_TX_INFOR_NOREADY); - return result; - } - - ies = pframe + _PUBLIC_ACTION_IE_OFFSET_; - ies_len = len - _PUBLIC_ACTION_IE_OFFSET_; - - p2p_ie = rtw_get_p2p_ie23a(ies, ies_len, NULL, &p2p_ielen); - - if (!p2p_ie) - { - DBG_8723A("[%s] P2P IE not Found!!\n", __func__); - result = P2P_STATUS_FAIL_INCOMPATIBLE_PARAM; - rtw_p2p_set_state(pwdinfo, P2P_STATE_GONEGO_FAIL); - } - - while (p2p_ie) - { - u8 attr_content = 0x00; - u32 attr_contentlen = 0; - u8 ch_content[50] = { 0x00 }; - uint ch_cnt = 0; - u8 peer_ch_list[50] = { 0x00 }; - u8 peer_ch_num = 0; - u8 ch_list_inclusioned[50] = { 0x00 }; - u8 ch_num_inclusioned = 0; - u16 cap_attr; - - rtw_p2p_set_state(pwdinfo, P2P_STATE_GONEGO_ING); - - /* Check P2P Capability ATTR */ - if (rtw_get_p2p_attr23a_content(p2p_ie, p2p_ielen, P2P_ATTR_CAPABILITY, (u8*)&cap_attr, (uint*)&attr_contentlen)) - cap_attr = le16_to_cpu(cap_attr); - - if (rtw_get_p2p_attr23a_content(p2p_ie, p2p_ielen, P2P_ATTR_GO_INTENT, &attr_content, &attr_contentlen)) - { - DBG_8723A("[%s] GO Intent = %d, tie = %d\n", __func__, attr_content >> 1, attr_content & 0x01); - pwdinfo->peer_intent = attr_content; /* include both intent and tie breaker values. */ - - if (pwdinfo->intent == (pwdinfo->peer_intent >> 1)) - { - /* Try to match the tie breaker value */ - if (pwdinfo->intent == P2P_MAX_INTENT) - { - rtw_p2p_set_role(pwdinfo, P2P_ROLE_DEVICE); - result = P2P_STATUS_FAIL_BOTH_GOINTENT_15; - } - else - { - if (attr_content & 0x01) - { - rtw_p2p_set_role(pwdinfo, P2P_ROLE_CLIENT); - } - else - { - rtw_p2p_set_role(pwdinfo, P2P_ROLE_GO); - } - } - } - else if (pwdinfo->intent > (pwdinfo->peer_intent >> 1)) - { - rtw_p2p_set_role(pwdinfo, P2P_ROLE_GO); - } - else - { - rtw_p2p_set_role(pwdinfo, P2P_ROLE_CLIENT); - } - - if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO)) - { - /* Store the group id information. */ - memcpy(pwdinfo->groupid_info.go_device_addr, pwdinfo->device_addr, ETH_ALEN); - memcpy(pwdinfo->groupid_info.ssid, pwdinfo->nego_ssid, pwdinfo->nego_ssidlen); - } - } - - attr_contentlen = 0; - if (rtw_get_p2p_attr23a_content(p2p_ie, p2p_ielen, P2P_ATTR_INTENTED_IF_ADDR, pwdinfo->p2p_peer_interface_addr, &attr_contentlen)) - { - if (attr_contentlen != ETH_ALEN) - { - memset(pwdinfo->p2p_peer_interface_addr, 0x00, ETH_ALEN); - } - } - - if (rtw_get_p2p_attr23a_content(p2p_ie, p2p_ielen, P2P_ATTR_CH_LIST, ch_content, &ch_cnt)) - { - peer_ch_num = rtw_p2p_get_peer_ch_list(pwdinfo, ch_content, ch_cnt, peer_ch_list); - ch_num_inclusioned = rtw_p2p_ch_inclusion(&padapter->mlmeextpriv, peer_ch_list, peer_ch_num, ch_list_inclusioned); - - if (ch_num_inclusioned == 0) - { - DBG_8723A("[%s] No common channel in channel list!\n", __func__); - result = P2P_STATUS_FAIL_NO_COMMON_CH; - rtw_p2p_set_state(pwdinfo, P2P_STATE_GONEGO_FAIL); - break; - } - - if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO)) - { - if (!rtw_p2p_is_channel_list_ok(pwdinfo->operating_channel, - ch_list_inclusioned, ch_num_inclusioned)) - { - { - u8 operatingch_info[5] = { 0x00 }, peer_operating_ch = 0; - attr_contentlen = 0; - - if (rtw_get_p2p_attr23a_content(p2p_ie, p2p_ielen, P2P_ATTR_OPERATING_CH, operatingch_info, &attr_contentlen)) - { - peer_operating_ch = operatingch_info[4]; - } - - if (rtw_p2p_is_channel_list_ok(peer_operating_ch, - ch_list_inclusioned, ch_num_inclusioned)) - { - /** - * Change our operating channel as peer's for compatibility. - */ - pwdinfo->operating_channel = peer_operating_ch; - DBG_8723A("[%s] Change op ch to %02x as peer's\n", __func__, pwdinfo->operating_channel); - } - else - { - /* Take first channel of ch_list_inclusioned as operating channel */ - pwdinfo->operating_channel = ch_list_inclusioned[0]; - DBG_8723A("[%s] Change op ch to %02x\n", __func__, pwdinfo->operating_channel); - } - } - - } - } - } - - /* Get the next P2P IE */ - p2p_ie = rtw_get_p2p_ie23a(p2p_ie+p2p_ielen, ies_len -(p2p_ie -ies + p2p_ielen), NULL, &p2p_ielen); - } - -#ifdef CONFIG_8723AU_P2P - /* Added by Albert 20110823 */ - /* Try to get the TCP port information when receiving the negotiation request. */ - if (rtw_get_wfd_ie(pframe + _PUBLIC_ACTION_IE_OFFSET_, len - _PUBLIC_ACTION_IE_OFFSET_, wfd_ie, &wfd_ielen)) - { - u8 attr_content[ 10 ] = { 0x00 }; - u32 attr_contentlen = 0; - - DBG_8723A("[%s] WFD IE Found!!\n", __func__); - rtw_get_wfd_attr_content(wfd_ie, wfd_ielen, WFD_ATTR_DEVICE_INFO, attr_content, &attr_contentlen); - if (attr_contentlen) - { - pwdinfo->wfd_info->peer_rtsp_ctrlport = get_unaligned_be16(attr_content + 2); - DBG_8723A("[%s] Peer PORT NUM = %d\n", __func__, pwdinfo->wfd_info->peer_rtsp_ctrlport); - } - } -#endif /* CONFIG_8723AU_P2P */ - - return result; -} - -u8 process_p2p_group_negotation_resp23a(struct wifidirect_info *pwdinfo, u8 *pframe, uint len) -{ - struct rtw_adapter *padapter = pwdinfo->padapter; - u8 result = P2P_STATUS_SUCCESS; - u32 p2p_ielen, wps_ielen; - u8 * ies; - u32 ies_len; - u8 * p2p_ie; -#ifdef CONFIG_8723AU_P2P - u8 wfd_ie[MAX_WFD_IE_LEN] = { 0x00 }; - u32 wfd_ielen = 0; -#endif /* CONFIG_8723AU_P2P */ - - ies = pframe + _PUBLIC_ACTION_IE_OFFSET_; - ies_len = len - _PUBLIC_ACTION_IE_OFFSET_; - - /* Be able to know which one is the P2P GO and which one is P2P client. */ - - if (rtw_get_wps_ie23a(ies, ies_len, NULL, &wps_ielen)) - { - - } - else - { - DBG_8723A("[%s] WPS IE not Found!!\n", __func__); - result = P2P_STATUS_FAIL_INCOMPATIBLE_PARAM; - rtw_p2p_set_state(pwdinfo, P2P_STATE_GONEGO_FAIL); - } - - p2p_ie = rtw_get_p2p_ie23a(ies, ies_len, NULL, &p2p_ielen); - if (!p2p_ie) - { - rtw_p2p_set_role(pwdinfo, P2P_ROLE_DEVICE); - rtw_p2p_set_state(pwdinfo, P2P_STATE_GONEGO_FAIL); - result = P2P_STATUS_FAIL_INCOMPATIBLE_PARAM; - } - else - { - - u8 attr_content = 0x00; - u32 attr_contentlen = 0; - u8 operatingch_info[5] = { 0x00 }; - u8 groupid[ 38 ]; - u16 cap_attr; - u8 peer_ch_list[50] = { 0x00 }; - u8 peer_ch_num = 0; - u8 ch_list_inclusioned[50] = { 0x00 }; - u8 ch_num_inclusioned = 0; - - while (p2p_ie) /* Found the P2P IE. */ - { - - /* Check P2P Capability ATTR */ - if (rtw_get_p2p_attr23a_content(p2p_ie, p2p_ielen, P2P_ATTR_CAPABILITY, (u8*)&cap_attr, (uint*)&attr_contentlen)) - cap_attr = le16_to_cpu(cap_attr); - - rtw_get_p2p_attr23a_content(p2p_ie, p2p_ielen, P2P_ATTR_STATUS, &attr_content, &attr_contentlen); - if (attr_contentlen == 1) - { - DBG_8723A("[%s] Status = %d\n", __func__, attr_content); - if (attr_content == P2P_STATUS_SUCCESS) - { - /* Do nothing. */ - } - else - { - if (P2P_STATUS_FAIL_INFO_UNAVAILABLE == attr_content) { - rtw_p2p_set_state(pwdinfo, P2P_STATE_RX_INFOR_NOREADY); - } else { - rtw_p2p_set_state(pwdinfo, P2P_STATE_GONEGO_FAIL); - } - rtw_p2p_set_role(pwdinfo, P2P_ROLE_DEVICE); - result = attr_content; - break; - } - } - - /* Try to get the peer's interface address */ - attr_contentlen = 0; - if (rtw_get_p2p_attr23a_content(p2p_ie, p2p_ielen, P2P_ATTR_INTENTED_IF_ADDR, pwdinfo->p2p_peer_interface_addr, &attr_contentlen)) - { - if (attr_contentlen != ETH_ALEN) - { - memset(pwdinfo->p2p_peer_interface_addr, 0x00, ETH_ALEN); - } - } - - /* Try to get the peer's intent and tie breaker value. */ - attr_content = 0x00; - attr_contentlen = 0; - if (rtw_get_p2p_attr23a_content(p2p_ie, p2p_ielen, P2P_ATTR_GO_INTENT, &attr_content, &attr_contentlen)) - { - DBG_8723A("[%s] GO Intent = %d, tie = %d\n", __func__, attr_content >> 1, attr_content & 0x01); - pwdinfo->peer_intent = attr_content; /* include both intent and tie breaker values. */ - - if (pwdinfo->intent == (pwdinfo->peer_intent >> 1)) - { - /* Try to match the tie breaker value */ - if (pwdinfo->intent == P2P_MAX_INTENT) - { - rtw_p2p_set_role(pwdinfo, P2P_ROLE_DEVICE); - result = P2P_STATUS_FAIL_BOTH_GOINTENT_15; - rtw_p2p_set_state(pwdinfo, P2P_STATE_GONEGO_FAIL); - } - else - { - rtw_p2p_set_state(pwdinfo, P2P_STATE_GONEGO_OK); - rtw_p2p_set_pre_state(pwdinfo, P2P_STATE_GONEGO_OK); - if (attr_content & 0x01) - { - rtw_p2p_set_role(pwdinfo, P2P_ROLE_CLIENT); - } - else - { - rtw_p2p_set_role(pwdinfo, P2P_ROLE_GO); - } - } - } - else if (pwdinfo->intent > (pwdinfo->peer_intent >> 1)) - { - rtw_p2p_set_state(pwdinfo, P2P_STATE_GONEGO_OK); - rtw_p2p_set_pre_state(pwdinfo, P2P_STATE_GONEGO_OK); - rtw_p2p_set_role(pwdinfo, P2P_ROLE_GO); - } - else - { - rtw_p2p_set_state(pwdinfo, P2P_STATE_GONEGO_OK); - rtw_p2p_set_pre_state(pwdinfo, P2P_STATE_GONEGO_OK); - rtw_p2p_set_role(pwdinfo, P2P_ROLE_CLIENT); - } - - if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO)) - { - /* Store the group id information. */ - memcpy(pwdinfo->groupid_info.go_device_addr, pwdinfo->device_addr, ETH_ALEN); - memcpy(pwdinfo->groupid_info.ssid, pwdinfo->nego_ssid, pwdinfo->nego_ssidlen); - - } - } - - /* Try to get the operation channel information */ - - attr_contentlen = 0; - if (rtw_get_p2p_attr23a_content(p2p_ie, p2p_ielen, P2P_ATTR_OPERATING_CH, operatingch_info, &attr_contentlen)) - { - DBG_8723A("[%s] Peer's operating channel = %d\n", __func__, operatingch_info[4]); - pwdinfo->peer_operating_ch = operatingch_info[4]; - } - - /* Try to get the channel list information */ - if (rtw_get_p2p_attr23a_content(p2p_ie, p2p_ielen, P2P_ATTR_CH_LIST, pwdinfo->channel_list_attr, &pwdinfo->channel_list_attr_len)) - { - DBG_8723A("[%s] channel list attribute found, len = %d\n", __func__, pwdinfo->channel_list_attr_len); - - peer_ch_num = rtw_p2p_get_peer_ch_list(pwdinfo, pwdinfo->channel_list_attr, pwdinfo->channel_list_attr_len, peer_ch_list); - ch_num_inclusioned = rtw_p2p_ch_inclusion(&padapter->mlmeextpriv, peer_ch_list, peer_ch_num, ch_list_inclusioned); - - if (ch_num_inclusioned == 0) - { - DBG_8723A("[%s] No common channel in channel list!\n", __func__); - result = P2P_STATUS_FAIL_NO_COMMON_CH; - rtw_p2p_set_state(pwdinfo, P2P_STATE_GONEGO_FAIL); - break; - } - - if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO)) - { - if (!rtw_p2p_is_channel_list_ok(pwdinfo->operating_channel, - ch_list_inclusioned, ch_num_inclusioned)) - { - { - u8 operatingch_info[5] = { 0x00 }, peer_operating_ch = 0; - attr_contentlen = 0; - - if (rtw_get_p2p_attr23a_content(p2p_ie, p2p_ielen, P2P_ATTR_OPERATING_CH, operatingch_info, &attr_contentlen)) - { - peer_operating_ch = operatingch_info[4]; - } - - if (rtw_p2p_is_channel_list_ok(peer_operating_ch, - ch_list_inclusioned, ch_num_inclusioned)) - { - /** - * Change our operating channel as peer's for compatibility. - */ - pwdinfo->operating_channel = peer_operating_ch; - DBG_8723A("[%s] Change op ch to %02x as peer's\n", __func__, pwdinfo->operating_channel); - } - else - { - /* Take first channel of ch_list_inclusioned as operating channel */ - pwdinfo->operating_channel = ch_list_inclusioned[0]; - DBG_8723A("[%s] Change op ch to %02x\n", __func__, pwdinfo->operating_channel); - } - } - - } - } - - } - else - { - DBG_8723A("[%s] channel list attribute not found!\n", __func__); - } - - /* Try to get the group id information if peer is GO */ - attr_contentlen = 0; - memset(groupid, 0x00, 38); - if (rtw_get_p2p_attr23a_content(p2p_ie, p2p_ielen, P2P_ATTR_GROUP_ID, groupid, &attr_contentlen)) - { - memcpy(pwdinfo->groupid_info.go_device_addr, &groupid[0], ETH_ALEN); - memcpy(pwdinfo->groupid_info.ssid, &groupid[6], attr_contentlen - ETH_ALEN); - } - - /* Get the next P2P IE */ - p2p_ie = rtw_get_p2p_ie23a(p2p_ie+p2p_ielen, ies_len -(p2p_ie -ies + p2p_ielen), NULL, &p2p_ielen); - } - - } - -#ifdef CONFIG_8723AU_P2P - /* Added by Albert 20111122 */ - /* Try to get the TCP port information when receiving the negotiation response. */ - if (rtw_get_wfd_ie(pframe + _PUBLIC_ACTION_IE_OFFSET_, len - _PUBLIC_ACTION_IE_OFFSET_, wfd_ie, &wfd_ielen)) - { - u8 attr_content[ 10 ] = { 0x00 }; - u32 attr_contentlen = 0; - - DBG_8723A("[%s] WFD IE Found!!\n", __func__); - rtw_get_wfd_attr_content(wfd_ie, wfd_ielen, WFD_ATTR_DEVICE_INFO, attr_content, &attr_contentlen); - if (attr_contentlen) - { - pwdinfo->wfd_info->peer_rtsp_ctrlport = get_unaligned_be16(attr_content + 2); - DBG_8723A("[%s] Peer PORT NUM = %d\n", __func__, pwdinfo->wfd_info->peer_rtsp_ctrlport); - } - } -#endif /* CONFIG_8723AU_P2P */ - - return result; -} - -u8 process_p2p_group_negotation_confirm23a(struct wifidirect_info *pwdinfo, u8 *pframe, uint len) -{ - u8 * ies; - u32 ies_len; - u8 * p2p_ie; - u32 p2p_ielen = 0; - u8 result = P2P_STATUS_SUCCESS; - ies = pframe + _PUBLIC_ACTION_IE_OFFSET_; - ies_len = len - _PUBLIC_ACTION_IE_OFFSET_; - - p2p_ie = rtw_get_p2p_ie23a(ies, ies_len, NULL, &p2p_ielen); - while (p2p_ie) /* Found the P2P IE. */ - { - u8 attr_content = 0x00, operatingch_info[5] = { 0x00 }; - u8 groupid[ 38 ] = { 0x00 }; - u32 attr_contentlen = 0; - - pwdinfo->negotiation_dialog_token = 1; - rtw_get_p2p_attr23a_content(p2p_ie, p2p_ielen, P2P_ATTR_STATUS, &attr_content, &attr_contentlen); - if (attr_contentlen == 1) - { - DBG_8723A("[%s] Status = %d\n", __func__, attr_content); - result = attr_content; - - if (attr_content == P2P_STATUS_SUCCESS) - { - del_timer_sync(&pwdinfo->restore_p2p_state_timer); - - /* Commented by Albert 20100911 */ - /* Todo: Need to handle the case which both Intents are the same. */ - rtw_p2p_set_state(pwdinfo, P2P_STATE_GONEGO_OK); - rtw_p2p_set_pre_state(pwdinfo, P2P_STATE_GONEGO_OK); - if ((pwdinfo->intent) > (pwdinfo->peer_intent >> 1)) - { - rtw_p2p_set_role(pwdinfo, P2P_ROLE_GO); - } - else if ((pwdinfo->intent) < (pwdinfo->peer_intent >> 1)) - { - rtw_p2p_set_role(pwdinfo, P2P_ROLE_CLIENT); - } - else - { - /* Have to compare the Tie Breaker */ - if (pwdinfo->peer_intent & 0x01) - { - rtw_p2p_set_role(pwdinfo, P2P_ROLE_CLIENT); - } - else - { - rtw_p2p_set_role(pwdinfo, P2P_ROLE_GO); - } - } - } - else - { - rtw_p2p_set_role(pwdinfo, P2P_ROLE_DEVICE); - rtw_p2p_set_state(pwdinfo, P2P_STATE_GONEGO_FAIL); - break; - } - } - - /* Try to get the group id information */ - attr_contentlen = 0; - memset(groupid, 0x00, 38); - if (rtw_get_p2p_attr23a_content(p2p_ie, p2p_ielen, P2P_ATTR_GROUP_ID, groupid, &attr_contentlen)) - { - DBG_8723A("[%s] Ssid = %s, ssidlen = %zu\n", __func__, &groupid[ETH_ALEN], strlen(&groupid[ETH_ALEN])); - memcpy(pwdinfo->groupid_info.go_device_addr, &groupid[0], ETH_ALEN); - memcpy(pwdinfo->groupid_info.ssid, &groupid[6], attr_contentlen - ETH_ALEN); - } - - attr_contentlen = 0; - if (rtw_get_p2p_attr23a_content(p2p_ie, p2p_ielen, P2P_ATTR_OPERATING_CH, operatingch_info, &attr_contentlen)) - { - DBG_8723A("[%s] Peer's operating channel = %d\n", __func__, operatingch_info[4]); - pwdinfo->peer_operating_ch = operatingch_info[4]; - } - - /* Get the next P2P IE */ - p2p_ie = rtw_get_p2p_ie23a(p2p_ie+p2p_ielen, ies_len -(p2p_ie -ies + p2p_ielen), NULL, &p2p_ielen); - - } - - return result; -} - -u8 process_p2p_presence_req23a(struct wifidirect_info *pwdinfo, u8 *pframe, uint len) -{ - u8 *frame_body; - u8 dialogToken = 0; - u8 status = P2P_STATUS_SUCCESS; - struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) pframe; - - frame_body = (unsigned char *)(pframe + sizeof(struct ieee80211_hdr_3addr)); - - dialogToken = frame_body[6]; - - /* todo: check NoA attribute */ - - issue_p2p_presence_resp(pwdinfo, hdr->addr2, status, dialogToken); - - return true; -} - -static void find_phase_handler(struct rtw_adapter *padapter) -{ - struct wifidirect_info *pwdinfo = &padapter->wdinfo; - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct cfg80211_ssid ssid; - u8 _status = 0; - - - - memset((unsigned char*)&ssid, 0, sizeof(struct cfg80211_ssid)); - memcpy(ssid.ssid, pwdinfo->p2p_wildcard_ssid, P2P_WILDCARD_SSID_LEN); - ssid.ssid_len = P2P_WILDCARD_SSID_LEN; - - rtw_p2p_set_state(pwdinfo, P2P_STATE_FIND_PHASE_SEARCH); - - spin_lock_bh(&pmlmepriv->lock); - _status = rtw_sitesurvey_cmd23a(padapter, &ssid, 1, NULL, 0); - spin_unlock_bh(&pmlmepriv->lock); - - -} - -void p2p_concurrent_handler(struct rtw_adapter* padapter); - -static void restore_p2p_state_handler(struct rtw_adapter *padapter) -{ - struct wifidirect_info *pwdinfo = &padapter->wdinfo; - - if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_GONEGO_ING) || rtw_p2p_chk_state(pwdinfo, P2P_STATE_GONEGO_FAIL)) - rtw_p2p_set_role(pwdinfo, P2P_ROLE_DEVICE); - - rtw_p2p_set_state(pwdinfo, rtw_p2p_pre_state(pwdinfo)); - - if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_DEVICE)) { - /* In the P2P client mode, the driver should not switch back to its listen channel */ - /* because this P2P client should stay at the operating channel of P2P GO. */ - set_channel_bwmode23a(padapter, pwdinfo->listen_channel, HAL_PRIME_CHNL_OFFSET_DONT_CARE, HT_CHANNEL_WIDTH_20); - } -} - -static void pre_tx_invitereq_handler(struct rtw_adapter *padapter) -{ - struct wifidirect_info *pwdinfo = &padapter->wdinfo; - - set_channel_bwmode23a(padapter, pwdinfo->invitereq_info.peer_ch, HAL_PRIME_CHNL_OFFSET_DONT_CARE, HT_CHANNEL_WIDTH_20); - rtl8723a_mlme_sitesurvey(padapter, 1); - issue23a_probereq_p2p(padapter, NULL); - mod_timer(&pwdinfo->pre_tx_scan_timer, - jiffies + msecs_to_jiffies(P2P_TX_PRESCAN_TIMEOUT)); -} - -static void pre_tx_provdisc_handler(struct rtw_adapter *padapter) -{ - struct wifidirect_info *pwdinfo = &padapter->wdinfo; - - set_channel_bwmode23a(padapter, - pwdinfo->tx_prov_disc_info.peer_channel_num[0], - HAL_PRIME_CHNL_OFFSET_DONT_CARE, - HT_CHANNEL_WIDTH_20); - rtl8723a_mlme_sitesurvey(padapter, 1); - issue23a_probereq_p2p(padapter, NULL); - mod_timer(&pwdinfo->pre_tx_scan_timer, - jiffies + msecs_to_jiffies(P2P_TX_PRESCAN_TIMEOUT)); -} - -static void pre_tx_negoreq_handler(struct rtw_adapter *padapter) -{ - struct wifidirect_info *pwdinfo = &padapter->wdinfo; - - set_channel_bwmode23a(padapter, - pwdinfo->nego_req_info.peer_channel_num[0], - HAL_PRIME_CHNL_OFFSET_DONT_CARE, - HT_CHANNEL_WIDTH_20); - rtl8723a_mlme_sitesurvey(padapter, 1); - issue23a_probereq_p2p(padapter, NULL); - mod_timer(&pwdinfo->pre_tx_scan_timer, - jiffies + msecs_to_jiffies(P2P_TX_PRESCAN_TIMEOUT)); -} - -static void ro_ch_handler(struct rtw_adapter *padapter) -{ - struct cfg80211_wifidirect_info *pcfg80211_wdinfo = &padapter->cfg80211_wdinfo; - struct wifidirect_info *pwdinfo = &padapter->wdinfo; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - - if (pcfg80211_wdinfo->restore_channel != pmlmeext->cur_channel) { - if (!check_fwstate(&padapter->mlmepriv, _FW_LINKED)) - pmlmeext->cur_channel = pcfg80211_wdinfo->restore_channel; - - set_channel_bwmode23a(padapter, pmlmeext->cur_channel, - HAL_PRIME_CHNL_OFFSET_DONT_CARE, - HT_CHANNEL_WIDTH_20); - } - - rtw_p2p_set_state(pwdinfo, rtw_p2p_pre_state(pwdinfo)); - - pcfg80211_wdinfo->is_ro_ch = false; - - DBG_8723A("cfg80211_remain_on_channel_expired\n"); - - rtw_cfg80211_remain_on_channel_expired(padapter, - pcfg80211_wdinfo->remain_on_ch_cookie, - &pcfg80211_wdinfo->remain_on_ch_channel, - pcfg80211_wdinfo->remain_on_ch_type, GFP_KERNEL); -} - -static void ro_ch_timer_process (unsigned long data) -{ - struct rtw_adapter *adapter = (struct rtw_adapter *)data; - - p2p_protocol_wk_cmd23a(adapter, P2P_RO_CH_WK); -} - -#ifdef CONFIG_8723AU_P2P -void rtw_append_wfd_ie(struct rtw_adapter *padapter, u8 *buf, u32* len) -{ - unsigned char *frame_body; - u8 category, action, OUI_Subtype, dialogToken = 0; - u32 wfdielen = 0; - - frame_body = (unsigned char *)(buf + sizeof(struct ieee80211_hdr_3addr)); - category = frame_body[0]; - - if (category == WLAN_CATEGORY_PUBLIC) { - action = frame_body[1]; - if (action == ACT_PUBLIC_VENDOR && - !memcmp(frame_body+2, P2P_OUI23A, 4)) { - OUI_Subtype = frame_body[6]; - dialogToken = frame_body[7]; - switch (OUI_Subtype)/* OUI Subtype */ { - case P2P_GO_NEGO_REQ: - wfdielen = build_nego_req_wfd_ie(&padapter->wdinfo, buf + (*len)); - (*len) += wfdielen; - break; - case P2P_GO_NEGO_RESP: - wfdielen = build_nego_resp_wfd_ie(&padapter->wdinfo, buf + (*len)); - (*len) += wfdielen; - break; - case P2P_GO_NEGO_CONF: - wfdielen = build_nego_confirm_wfd_ie(&padapter->wdinfo, buf + (*len)); - (*len) += wfdielen; - break; - case P2P_INVIT_REQ: - wfdielen = build_invitation_req_wfd_ie(&padapter->wdinfo, buf + (*len)); - (*len) += wfdielen; - break; - case P2P_INVIT_RESP: - wfdielen = build_invitation_resp_wfd_ie(&padapter->wdinfo, buf + (*len)); - (*len) += wfdielen; - break; - case P2P_DEVDISC_REQ: - break; - case P2P_DEVDISC_RESP: - break; - case P2P_PROVISION_DISC_REQ: - wfdielen = build_provdisc_req_wfd_ie(&padapter->wdinfo, buf + (*len)); - (*len) += wfdielen; - break; - case P2P_PROVISION_DISC_RESP: - wfdielen = build_provdisc_resp_wfd_ie(&padapter->wdinfo, buf + (*len)); - (*len) += wfdielen; - break; - default: - break; - } - } - } else if (category == WLAN_CATEGORY_VENDOR_SPECIFIC) { - OUI_Subtype = frame_body[5]; - dialogToken = frame_body[6]; - } else { - DBG_8723A("%s, action frame category =%d\n", __func__, category); - } -} -#endif - -int rtw_p2p_check_frames(struct rtw_adapter *padapter, const u8 *buf, u32 len, u8 tx) -{ - int is_p2p_frame = (-1); - unsigned char *frame_body; - u8 category, action, OUI_Subtype, dialogToken = 0; - u8 *p2p_ie = NULL; - uint p2p_ielen = 0; - struct rtw_wdev_priv *pwdev_priv = wdev_to_priv(padapter->rtw_wdev); - - frame_body = (unsigned char *)(buf + sizeof(struct ieee80211_hdr_3addr)); - category = frame_body[0]; - /* just for check */ - if (category == WLAN_CATEGORY_PUBLIC) - { - action = frame_body[1]; - if (action == ACT_PUBLIC_VENDOR && - !memcmp(frame_body+2, P2P_OUI23A, 4)) { - OUI_Subtype = frame_body[6]; - dialogToken = frame_body[7]; - is_p2p_frame = OUI_Subtype; - p2p_ie = rtw_get_p2p_ie23a( - (u8 *)buf+sizeof(struct ieee80211_hdr_3addr)+_PUBLIC_ACTION_IE_OFFSET_, - len-sizeof(struct ieee80211_hdr_3addr)-_PUBLIC_ACTION_IE_OFFSET_, - NULL, &p2p_ielen); - - switch (OUI_Subtype) {/* OUI Subtype */ - u8 *cont; - uint cont_len; - case P2P_GO_NEGO_REQ: - DBG_8723A("RTW_%s:P2P_GO_NEGO_REQ, dialogToken =%d\n", (tx == true)?"Tx":"Rx", dialogToken); - break; - case P2P_GO_NEGO_RESP: - cont = rtw_get_p2p_attr23a_content(p2p_ie, p2p_ielen, P2P_ATTR_STATUS, NULL, &cont_len); - DBG_8723A("RTW_%s:P2P_GO_NEGO_RESP, dialogToken =%d, status:%d\n", (tx == true)?"Tx":"Rx", dialogToken, cont?*cont:-1); - - if (!tx) - pwdev_priv->provdisc_req_issued = false; - break; - case P2P_GO_NEGO_CONF: - cont = rtw_get_p2p_attr23a_content(p2p_ie, p2p_ielen, P2P_ATTR_STATUS, NULL, &cont_len); - DBG_8723A("RTW_%s:P2P_GO_NEGO_CONF, dialogToken =%d, status:%d\n", - (tx == true)?"Tx":"Rx", dialogToken, cont?*cont:-1); - break; - case P2P_INVIT_REQ: - { - struct rtw_wdev_invit_info* invit_info = &pwdev_priv->invit_info; - int flags = -1; - int op_ch = 0; - - if ((cont = rtw_get_p2p_attr23a_content(p2p_ie, p2p_ielen, P2P_ATTR_INVITATION_FLAGS, NULL, &cont_len))) - flags = *cont; - if ((cont = rtw_get_p2p_attr23a_content(p2p_ie, p2p_ielen, P2P_ATTR_OPERATING_CH, NULL, &cont_len))) - op_ch = *(cont+4); - - if (invit_info->token != dialogToken) - rtw_wdev_invit_info_init(invit_info); - - invit_info->token = dialogToken; - invit_info->flags = (flags ==-1) ? 0x0 : flags; - invit_info->req_op_ch = op_ch; - - DBG_8723A("RTW_%s:P2P_INVIT_REQ, dialogToken =%d, flags:0x%02x, op_ch:%d\n", - (tx) ? "Tx" : "Rx", dialogToken, flags, op_ch); - break; - } - case P2P_INVIT_RESP: - { - struct rtw_wdev_invit_info* invit_info = &pwdev_priv->invit_info; - int status = -1; - int op_ch = 0; - - if ((cont = rtw_get_p2p_attr23a_content(p2p_ie, p2p_ielen, P2P_ATTR_STATUS, NULL, &cont_len))) - status = *cont; - if ((cont = rtw_get_p2p_attr23a_content(p2p_ie, p2p_ielen, P2P_ATTR_OPERATING_CH, NULL, &cont_len))) - op_ch = *(cont+4); - - if (invit_info->token != dialogToken) { - rtw_wdev_invit_info_init(invit_info); - } else { - invit_info->token = 0; - invit_info->status = (status ==-1) ? 0xff : status; - invit_info->rsp_op_ch = op_ch; - } - - DBG_8723A("RTW_%s:P2P_INVIT_RESP, dialogToken =%d, status:%d, op_ch:%d\n", - (tx == true)?"Tx":"Rx", dialogToken, status, op_ch); - break; - } - case P2P_DEVDISC_REQ: - DBG_8723A("RTW_%s:P2P_DEVDISC_REQ, dialogToken =%d\n", (tx == true)?"Tx":"Rx", dialogToken); - break; - case P2P_DEVDISC_RESP: - cont = rtw_get_p2p_attr23a_content(p2p_ie, p2p_ielen, P2P_ATTR_STATUS, NULL, &cont_len); - DBG_8723A("RTW_%s:P2P_DEVDISC_RESP, dialogToken =%d, status:%d\n", (tx == true)?"Tx":"Rx", dialogToken, cont?*cont:-1); - break; - case P2P_PROVISION_DISC_REQ: - { - size_t frame_body_len = len - sizeof(struct ieee80211_hdr_3addr); - u8 *p2p_ie; - uint p2p_ielen = 0; - uint contentlen = 0; - - DBG_8723A("RTW_%s:P2P_PROVISION_DISC_REQ, dialogToken =%d\n", (tx == true)?"Tx":"Rx", dialogToken); - - pwdev_priv->provdisc_req_issued = false; - - p2p_ie = rtw_get_p2p_ie23a(frame_body + _PUBLIC_ACTION_IE_OFFSET_, - frame_body_len - _PUBLIC_ACTION_IE_OFFSET_, - NULL, &p2p_ielen); - if (p2p_ie) { - if (rtw_get_p2p_attr23a_content(p2p_ie, p2p_ielen, P2P_ATTR_GROUP_ID, NULL, &contentlen)) - pwdev_priv->provdisc_req_issued = false;/* case: p2p_client join p2p GO */ - else - pwdev_priv->provdisc_req_issued = true;/* case: p2p_devices connection before Nego req. */ - } - } - break; - case P2P_PROVISION_DISC_RESP: - DBG_8723A("RTW_%s:P2P_PROVISION_DISC_RESP, dialogToken =%d\n", (tx == true)?"Tx":"Rx", dialogToken); - break; - default: - DBG_8723A("RTW_%s:OUI_Subtype =%d, dialogToken =%d\n", (tx == true)?"Tx":"Rx", OUI_Subtype, dialogToken); - break; - } - - } - - } - else if (category == WLAN_CATEGORY_VENDOR_SPECIFIC) - { - OUI_Subtype = frame_body[5]; - dialogToken = frame_body[6]; - - is_p2p_frame = OUI_Subtype; - - switch (OUI_Subtype) { - case P2P_NOTICE_OF_ABSENCE: - DBG_8723A("RTW_%s:P2P_NOTICE_OF_ABSENCE, dialogToken =%d\n", (tx == true)?"TX":"RX", dialogToken); - break; - case P2P_PRESENCE_REQUEST: - DBG_8723A("RTW_%s:P2P_PRESENCE_REQUEST, dialogToken =%d\n", (tx == true)?"TX":"RX", dialogToken); - break; - case P2P_PRESENCE_RESPONSE: - DBG_8723A("RTW_%s:P2P_PRESENCE_RESPONSE, dialogToken =%d\n", (tx == true)?"TX":"RX", dialogToken); - break; - case P2P_GO_DISC_REQUEST: - DBG_8723A("RTW_%s:P2P_GO_DISC_REQUEST, dialogToken =%d\n", (tx == true)?"TX":"RX", dialogToken); - break; - default: - DBG_8723A("RTW_%s:OUI_Subtype =%d, dialogToken =%d\n", (tx == true)?"TX":"RX", OUI_Subtype, dialogToken); - break; - } - - } else { - DBG_8723A("RTW_%s:action frame category =%d\n", (tx == true)?"TX":"RX", category); - } - return is_p2p_frame; -} - -void rtw_init_cfg80211_wifidirect_info(struct rtw_adapter *padapter) -{ - struct cfg80211_wifidirect_info *pcfg80211_wdinfo = &padapter->cfg80211_wdinfo; - - memset(pcfg80211_wdinfo, 0x00, sizeof(struct cfg80211_wifidirect_info)); - - setup_timer(&pcfg80211_wdinfo->remain_on_ch_timer, - ro_ch_timer_process, (unsigned long)padapter); -} - -void p2p_protocol_wk_hdl23a(struct rtw_adapter *padapter, int intCmdType) -{ - switch (intCmdType) { - case P2P_FIND_PHASE_WK: - find_phase_handler(padapter); - break; - case P2P_RESTORE_STATE_WK: - restore_p2p_state_handler(padapter); - break; - case P2P_PRE_TX_PROVDISC_PROCESS_WK: - pre_tx_provdisc_handler(padapter); - break; - case P2P_PRE_TX_INVITEREQ_PROCESS_WK: - pre_tx_invitereq_handler(padapter); - break; - case P2P_PRE_TX_NEGOREQ_PROCESS_WK: - pre_tx_negoreq_handler(padapter); - break; - case P2P_RO_CH_WK: - ro_ch_handler(padapter); - break; - } -} - -#ifdef CONFIG_8723AU_P2P -void process_p2p_ps_ie23a(struct rtw_adapter *padapter, u8 *IEs, u32 IELength) -{ - u8 * ies; - u32 ies_len; - u8 * p2p_ie; - u32 p2p_ielen = 0; - u8 noa_attr[MAX_P2P_IE_LEN] = { 0x00 };/* NoA length should be n*(13) + 2 */ - u32 attr_contentlen = 0; - - struct wifidirect_info *pwdinfo = &padapter->wdinfo; - u8 find_p2p = false, find_p2p_ps = false; - u8 noa_offset, noa_num, noa_index; - - - - if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)) - { - return; - } - if (IELength <= _BEACON_IE_OFFSET_) - return; - - ies = IEs + _BEACON_IE_OFFSET_; - ies_len = IELength - _BEACON_IE_OFFSET_; - - p2p_ie = rtw_get_p2p_ie23a(ies, ies_len, NULL, &p2p_ielen); - - while(p2p_ie) - { - find_p2p = true; - /* Get Notice of Absence IE. */ - if (rtw_get_p2p_attr23a_content(p2p_ie, p2p_ielen, P2P_ATTR_NOA, noa_attr, &attr_contentlen)) - { - find_p2p_ps = true; - noa_index = noa_attr[0]; - - if ((pwdinfo->p2p_ps_mode == P2P_PS_NONE) || - (noa_index != pwdinfo->noa_index))/* if index change, driver should reconfigure related setting. */ - { - pwdinfo->noa_index = noa_index; - pwdinfo->opp_ps = noa_attr[1] >> 7; - pwdinfo->ctwindow = noa_attr[1] & 0x7F; - - noa_offset = 2; - noa_num = 0; - /* NoA length should be n*(13) + 2 */ - if (attr_contentlen > 2) - { - while(noa_offset < attr_contentlen) - { - /* memcpy(&wifidirect_info->noa_count[noa_num], &noa_attr[noa_offset], 1); */ - pwdinfo->noa_count[noa_num] = noa_attr[noa_offset]; - noa_offset += 1; - - memcpy(&pwdinfo->noa_duration[noa_num], &noa_attr[noa_offset], 4); - noa_offset += 4; - - memcpy(&pwdinfo->noa_interval[noa_num], &noa_attr[noa_offset], 4); - noa_offset += 4; - - memcpy(&pwdinfo->noa_start_time[noa_num], &noa_attr[noa_offset], 4); - noa_offset += 4; - - noa_num++; - } - } - pwdinfo->noa_num = noa_num; - - if (pwdinfo->opp_ps == 1) - { - pwdinfo->p2p_ps_mode = P2P_PS_CTWINDOW; - /* driver should wait LPS for entering CTWindow */ - if (padapter->pwrctrlpriv.bFwCurrentInPSMode == true) - { - p2p_ps_wk_cmd23a(padapter, P2P_PS_ENABLE, 1); - } - } - else if (pwdinfo->noa_num > 0) - { - pwdinfo->p2p_ps_mode = P2P_PS_NOA; - p2p_ps_wk_cmd23a(padapter, P2P_PS_ENABLE, 1); - } - else if (pwdinfo->p2p_ps_mode > P2P_PS_NONE) - { - p2p_ps_wk_cmd23a(padapter, P2P_PS_DISABLE, 1); - } - } - - break; /* find target, just break. */ - } - - /* Get the next P2P IE */ - p2p_ie = rtw_get_p2p_ie23a(p2p_ie+p2p_ielen, ies_len -(p2p_ie -ies + p2p_ielen), NULL, &p2p_ielen); - - } - - if (find_p2p == true) - { - if ((pwdinfo->p2p_ps_mode > P2P_PS_NONE) && (find_p2p_ps == false)) - { - p2p_ps_wk_cmd23a(padapter, P2P_PS_DISABLE, 1); - } - } - - -} - -void p2p_ps_wk_hdl23a(struct rtw_adapter *padapter, u8 p2p_ps_state) -{ - struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv; - struct wifidirect_info *pwdinfo = &padapter->wdinfo; - - - - /* Pre action for p2p state */ - switch (p2p_ps_state) - { - case P2P_PS_DISABLE: - pwdinfo->p2p_ps_state = p2p_ps_state; - - rtl8723a_set_p2p_ps_offload_cmd(padapter, p2p_ps_state); - - pwdinfo->noa_index = 0; - pwdinfo->ctwindow = 0; - pwdinfo->opp_ps = 0; - pwdinfo->noa_num = 0; - pwdinfo->p2p_ps_mode = P2P_PS_NONE; - if (padapter->pwrctrlpriv.bFwCurrentInPSMode == true) { - if (pwrpriv->smart_ps == 0) { - pwrpriv->smart_ps = 2; - rtl8723a_set_FwPwrMode_cmd(padapter, padapter->pwrctrlpriv.pwr_mode); - } - } - break; - case P2P_PS_ENABLE: - if (pwdinfo->p2p_ps_mode > P2P_PS_NONE) { - pwdinfo->p2p_ps_state = p2p_ps_state; - - if (pwdinfo->ctwindow > 0) { - if (pwrpriv->smart_ps != 0) { - pwrpriv->smart_ps = 0; - DBG_8723A("%s(): Enter CTW, change " - "SmartPS\n", __func__); - rtl8723a_set_FwPwrMode_cmd(padapter, padapter->pwrctrlpriv.pwr_mode); - } - } - rtl8723a_set_p2p_ps_offload_cmd(padapter, - p2p_ps_state); - } - break; - case P2P_PS_SCAN: - case P2P_PS_SCAN_DONE: - case P2P_PS_ALLSTASLEEP: - if (pwdinfo->p2p_ps_mode > P2P_PS_NONE) { - pwdinfo->p2p_ps_state = p2p_ps_state; - rtl8723a_set_p2p_ps_offload_cmd(padapter, p2p_ps_state); - } - break; - default: - break; - } -} - -u8 p2p_ps_wk_cmd23a(struct rtw_adapter*padapter, u8 p2p_ps_state, u8 enqueue) -{ - struct cmd_obj *ph2c; - struct drvextra_cmd_parm *pdrvextra_cmd_parm; - struct wifidirect_info *pwdinfo = &padapter->wdinfo; - struct cmd_priv *pcmdpriv = &padapter->cmdpriv; - u8 res = _SUCCESS; - - - - if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)) - return res; - - if (enqueue) { - ph2c = (struct cmd_obj *)kzalloc(sizeof(struct cmd_obj), - GFP_ATOMIC); - if (!ph2c) { - res = _FAIL; - goto exit; - } - - pdrvextra_cmd_parm = (struct drvextra_cmd_parm *) - kzalloc(sizeof(struct drvextra_cmd_parm), GFP_ATOMIC); - if (pdrvextra_cmd_parm == NULL) { - kfree(ph2c); - res = _FAIL; - goto exit; - } - - pdrvextra_cmd_parm->ec_id = P2P_PS_WK_CID; - pdrvextra_cmd_parm->type_size = p2p_ps_state; - pdrvextra_cmd_parm->pbuf = NULL; - - init_h2fwcmd_w_parm_no_rsp(ph2c, pdrvextra_cmd_parm, GEN_CMD_CODE(_Set_Drv_Extra)); - - res = rtw_enqueue_cmd23a(pcmdpriv, ph2c); - } - else - { - p2p_ps_wk_hdl23a(padapter, p2p_ps_state); - } - -exit: - - - - return res; -} -#endif /* CONFIG_8723AU_P2P */ - -static void reset_ch_sitesurvey_timer_process(unsigned long data) -{ - struct rtw_adapter *adapter = (struct rtw_adapter *)data; - struct wifidirect_info *pwdinfo = &adapter->wdinfo; - - if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)) - return; - - DBG_8723A("[%s] In\n", __func__); - /* Reset the operation channel information */ - pwdinfo->rx_invitereq_info.operation_ch[0] = 0; - pwdinfo->rx_invitereq_info.scan_op_ch_only = 0; -} - -static void reset_ch_sitesurvey_timer_process2(unsigned long data) -{ - struct rtw_adapter *adapter = (struct rtw_adapter *)data; - struct wifidirect_info *pwdinfo = &adapter->wdinfo; - - if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)) - return; - - DBG_8723A("[%s] In\n", __func__); - /* Reset the operation channel information */ - pwdinfo->p2p_info.operation_ch[0] = 0; - pwdinfo->p2p_info.scan_op_ch_only = 0; -} - -static void restore_p2p_state_timer_process (unsigned long data) -{ - struct rtw_adapter *adapter = (struct rtw_adapter *)data; - struct wifidirect_info *pwdinfo = &adapter->wdinfo; - - if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)) - return; - - p2p_protocol_wk_cmd23a(adapter, P2P_RESTORE_STATE_WK); -} - -static void pre_tx_scan_timer_process (unsigned long data) -{ - struct rtw_adapter *adapter = (struct rtw_adapter *)data; - struct wifidirect_info *pwdinfo = &adapter->wdinfo; - struct mlme_priv *pmlmepriv = &adapter->mlmepriv; - - if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)) - return; - - spin_lock_bh(&pmlmepriv->lock); - - if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_TX_PROVISION_DIS_REQ)) - { - if (true == pwdinfo->tx_prov_disc_info.benable) /* the provision discovery request frame is trigger to send or not */ - { - p2p_protocol_wk_cmd23a(adapter, P2P_PRE_TX_PROVDISC_PROCESS_WK); - /* issue23a_probereq_p2p(adapter, NULL); */ - /* _set_timer(&pwdinfo->pre_tx_scan_timer, P2P_TX_PRESCAN_TIMEOUT); */ - } - } - else if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_GONEGO_ING)) - { - if (true == pwdinfo->nego_req_info.benable) - { - p2p_protocol_wk_cmd23a(adapter, P2P_PRE_TX_NEGOREQ_PROCESS_WK); - } - } - else if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_TX_INVITE_REQ)) - { - if (true == pwdinfo->invitereq_info.benable) - { - p2p_protocol_wk_cmd23a(adapter, P2P_PRE_TX_INVITEREQ_PROCESS_WK); - } - } - else - { - DBG_8723A("[%s] p2p_state is %d, ignore!!\n", __func__, rtw_p2p_state(pwdinfo)); - } - - spin_unlock_bh(&pmlmepriv->lock); -} - -static void find_phase_timer_process (unsigned long data) -{ - struct rtw_adapter *adapter = (struct rtw_adapter *)data; - struct wifidirect_info *pwdinfo = &adapter->wdinfo; - - if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)) - return; - - adapter->wdinfo.find_phase_state_exchange_cnt++; - - p2p_protocol_wk_cmd23a(adapter, P2P_FIND_PHASE_WK); -} - -void reset_global_wifidirect_info23a(struct rtw_adapter *padapter) -{ - struct wifidirect_info *pwdinfo; - - pwdinfo = &padapter->wdinfo; - pwdinfo->persistent_supported = 0; - pwdinfo->session_available = true; - pwdinfo->wfd_tdls_enable = 0; - pwdinfo->wfd_tdls_weaksec = 0; -} - -#ifdef CONFIG_8723AU_P2P -int rtw_init_wifi_display_info(struct rtw_adapter* padapter) -{ - int res = _SUCCESS; - struct wifi_display_info *pwfd_info = &padapter->wfd_info; - - /* Used in P2P and TDLS */ - pwfd_info->rtsp_ctrlport = 554; - pwfd_info->peer_rtsp_ctrlport = 0; /* Reset to 0 */ - pwfd_info->wfd_enable = false; - pwfd_info->wfd_device_type = WFD_DEVINFO_PSINK; - pwfd_info->scan_result_type = SCAN_RESULT_P2P_ONLY; - - /* Used in P2P */ - pwfd_info->peer_session_avail = true; - pwfd_info->wfd_pc = false; - - /* Used in TDLS */ - memset(pwfd_info->ip_address, 0x00, 4); - memset(pwfd_info->peer_ip_address, 0x00, 4); - return res; -} -#endif /* CONFIG_8723AU_P2P */ - -void rtw_init_wifidirect_timers23a(struct rtw_adapter* padapter) -{ - struct wifidirect_info *pwdinfo = &padapter->wdinfo; - - setup_timer(&pwdinfo->find_phase_timer, find_phase_timer_process, - (unsigned long)padapter); - setup_timer(&pwdinfo->restore_p2p_state_timer, - restore_p2p_state_timer_process, (unsigned long)padapter); - setup_timer(&pwdinfo->pre_tx_scan_timer, pre_tx_scan_timer_process, - (unsigned long)padapter); - setup_timer(&pwdinfo->reset_ch_sitesurvey, - reset_ch_sitesurvey_timer_process, (unsigned long)padapter); - setup_timer(&pwdinfo->reset_ch_sitesurvey2, - reset_ch_sitesurvey_timer_process2, - (unsigned long)padapter); -} - -void rtw_init_wifidirect_addrs23a(struct rtw_adapter* padapter, u8 *dev_addr, u8 *iface_addr) -{ -#ifdef CONFIG_8723AU_P2P - struct wifidirect_info *pwdinfo = &padapter->wdinfo; - - /*init device&interface address */ - if (dev_addr) { - memcpy(pwdinfo->device_addr, dev_addr, ETH_ALEN); - } - if (iface_addr) { - memcpy(pwdinfo->interface_addr, iface_addr, ETH_ALEN); - } -#endif -} - -void init_wifidirect_info23a(struct rtw_adapter *padapter, enum P2P_ROLE role) -{ - struct wifidirect_info *pwdinfo; -#ifdef CONFIG_8723AU_P2P - struct wifi_display_info *pwfd_info = &padapter->wfd_info; -#endif - - pwdinfo = &padapter->wdinfo; - - pwdinfo->padapter = padapter; - - /* 1, 6, 11 are the social channel defined in the WiFi Direct specification. */ - pwdinfo->social_chan[0] = 1; - pwdinfo->social_chan[1] = 6; - pwdinfo->social_chan[2] = 11; - pwdinfo->social_chan[3] = 0; /* channel 0 for scanning ending in site survey function. */ - - /* Use the channel 11 as the listen channel */ - pwdinfo->listen_channel = 11; - - if (role == P2P_ROLE_DEVICE) - { - rtw_p2p_set_role(pwdinfo, P2P_ROLE_DEVICE); - rtw_p2p_set_state(pwdinfo, P2P_STATE_LISTEN); - pwdinfo->intent = 1; - rtw_p2p_set_pre_state(pwdinfo, P2P_STATE_LISTEN); - } - else if (role == P2P_ROLE_CLIENT) - { - rtw_p2p_set_role(pwdinfo, P2P_ROLE_CLIENT); - rtw_p2p_set_state(pwdinfo, P2P_STATE_GONEGO_OK); - pwdinfo->intent = 1; - rtw_p2p_set_pre_state(pwdinfo, P2P_STATE_GONEGO_OK); - } - else if (role == P2P_ROLE_GO) - { - rtw_p2p_set_role(pwdinfo, P2P_ROLE_GO); - rtw_p2p_set_state(pwdinfo, P2P_STATE_GONEGO_OK); - pwdinfo->intent = 15; - rtw_p2p_set_pre_state(pwdinfo, P2P_STATE_GONEGO_OK); - } - -/* Use the OFDM rate in the P2P probe response frame. (6(B), 9(B), 12, 18, 24, 36, 48, 54) */ - pwdinfo->support_rate[0] = 0x8c; /* 6(B) */ - pwdinfo->support_rate[1] = 0x92; /* 9(B) */ - pwdinfo->support_rate[2] = 0x18; /* 12 */ - pwdinfo->support_rate[3] = 0x24; /* 18 */ - pwdinfo->support_rate[4] = 0x30; /* 24 */ - pwdinfo->support_rate[5] = 0x48; /* 36 */ - pwdinfo->support_rate[6] = 0x60; /* 48 */ - pwdinfo->support_rate[7] = 0x6c; /* 54 */ - - memcpy((void*) pwdinfo->p2p_wildcard_ssid, "DIRECT-", 7); - - memset(pwdinfo->device_name, 0x00, WPS_MAX_DEVICE_NAME_LEN); - pwdinfo->device_name_len = 0; - - memset(&pwdinfo->invitereq_info, 0x00, sizeof(struct tx_invite_req_info)); - pwdinfo->invitereq_info.token = 3; /* Token used for P2P invitation request frame. */ - - memset(&pwdinfo->inviteresp_info, 0x00, sizeof(struct tx_invite_resp_info)); - pwdinfo->inviteresp_info.token = 0; - - pwdinfo->profileindex = 0; - memset(&pwdinfo->profileinfo[ 0 ], 0x00, sizeof(struct profile_info) * P2P_MAX_PERSISTENT_GROUP_NUM); - - rtw_p2p_findphase_ex_set(pwdinfo, P2P_FINDPHASE_EX_NONE); - - pwdinfo->listen_dwell = (u8) ((jiffies % 3) + 1); - /* DBG_8723A("[%s] listen_dwell time is %d00ms\n", __func__, pwdinfo->listen_dwell); */ - - memset(&pwdinfo->tx_prov_disc_info, 0x00, sizeof(struct tx_provdisc_req_info)); - pwdinfo->tx_prov_disc_info.wps_config_method_request = WPS_CM_NONE; - - memset(&pwdinfo->nego_req_info, 0x00, sizeof(struct tx_nego_req_info)); - - pwdinfo->device_password_id_for_nego = WPS_DPID_PBC; - pwdinfo->negotiation_dialog_token = 1; - - memset(pwdinfo->nego_ssid, 0x00, IEEE80211_MAX_SSID_LEN); - pwdinfo->nego_ssidlen = 0; - - pwdinfo->ui_got_wps_info = P2P_NO_WPSINFO; -#ifdef CONFIG_8723AU_P2P - pwdinfo->supported_wps_cm = WPS_CONFIG_METHOD_DISPLAY | WPS_CONFIG_METHOD_PBC; - pwdinfo->wfd_info = pwfd_info; -#else - pwdinfo->supported_wps_cm = WPS_CONFIG_METHOD_DISPLAY | WPS_CONFIG_METHOD_PBC | WPS_CONFIG_METHOD_KEYPAD; -#endif /* CONFIG_8723AU_P2P */ - pwdinfo->channel_list_attr_len = 0; - memset(pwdinfo->channel_list_attr, 0x00, 100); - - memset(pwdinfo->rx_prov_disc_info.strconfig_method_desc_of_prov_disc_req, 0x00, 4); - memset(pwdinfo->rx_prov_disc_info.strconfig_method_desc_of_prov_disc_req, '0', 3); - memset(&pwdinfo->groupid_info, 0x00, sizeof(struct group_id_info)); - pwdinfo->wfd_tdls_enable = 0; - memset(pwdinfo->p2p_peer_interface_addr, 0x00, ETH_ALEN); - memset(pwdinfo->p2p_peer_device_addr, 0x00, ETH_ALEN); - - pwdinfo->rx_invitereq_info.operation_ch[0] = 0; - pwdinfo->rx_invitereq_info.operation_ch[1] = 0; /* Used to indicate the scan end in site survey function */ - pwdinfo->rx_invitereq_info.scan_op_ch_only = 0; - pwdinfo->p2p_info.operation_ch[0] = 0; - pwdinfo->p2p_info.operation_ch[1] = 0; /* Used to indicate the scan end in site survey function */ - pwdinfo->p2p_info.scan_op_ch_only = 0; -} - -int rtw_p2p_enable23a(struct rtw_adapter *padapter, enum P2P_ROLE role) -{ - struct wifidirect_info *pwdinfo = &padapter->wdinfo; - int ret = _SUCCESS; - - if (role == P2P_ROLE_DEVICE || role == P2P_ROLE_CLIENT || - role == P2P_ROLE_GO) { - /* leave IPS/Autosuspend */ - if (_FAIL == rtw_pwr_wakeup(padapter)) { - ret = _FAIL; - goto exit; - } - - /* Added by Albert 2011/03/22 */ - /* In the P2P mode, the driver should not support the b mode. */ - /* So, the Tx packet shouldn't use the CCK rate */ - update_tx_basic_rate23a(padapter, WIRELESS_11AGN); - - /* Enable P2P function */ - init_wifidirect_info23a(padapter, role); - - rtw_hal_set_odm_var23a(padapter, HAL_ODM_P2P_STATE, NULL, true); - #ifdef CONFIG_8723AU_P2P - rtw_hal_set_odm_var23a(padapter, HAL_ODM_WIFI_DISPLAY_STATE, NULL, true); - #endif - - } - else if (role == P2P_ROLE_DISABLE) - { - if (_FAIL == rtw_pwr_wakeup(padapter)) { - ret = _FAIL; - goto exit; - } - - /* Disable P2P function */ - if (!rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)) - { - del_timer_sync(&pwdinfo->find_phase_timer); - del_timer_sync(&pwdinfo->restore_p2p_state_timer); - del_timer_sync(&pwdinfo->pre_tx_scan_timer); - del_timer_sync(&pwdinfo->reset_ch_sitesurvey); - del_timer_sync(&pwdinfo->reset_ch_sitesurvey2); - reset_ch_sitesurvey_timer_process((unsigned long)padapter); - reset_ch_sitesurvey_timer_process2((unsigned long)padapter); - rtw_p2p_set_state(pwdinfo, P2P_STATE_NONE); - rtw_p2p_set_role(pwdinfo, P2P_ROLE_DISABLE); - memset(&pwdinfo->rx_prov_disc_info, 0x00, sizeof(struct rx_provdisc_req_info)); - } - - rtw_hal_set_odm_var23a(padapter, HAL_ODM_P2P_STATE, NULL, false); - #ifdef CONFIG_8723AU_P2P - rtw_hal_set_odm_var23a(padapter, HAL_ODM_WIFI_DISPLAY_STATE, NULL, false); - #endif - - /* Restore to initial setting. */ - update_tx_basic_rate23a(padapter, padapter->registrypriv.wireless_mode); - } - -exit: - return ret; -} - -#endif /* CONFIG_8723AU_P2P */ diff --git a/drivers/staging/rtl8723au/core/rtw_pwrctrl.c b/drivers/staging/rtl8723au/core/rtw_pwrctrl.c index c14b8193ce02..77880547e80f 100644 --- a/drivers/staging/rtl8723au/core/rtw_pwrctrl.c +++ b/drivers/staging/rtl8723au/core/rtw_pwrctrl.c @@ -109,33 +109,30 @@ static bool rtw_pwr_unassociated_idle(struct rtw_adapter *adapter) struct rtw_adapter *buddy = adapter->pbuddy_adapter; struct mlme_priv *pmlmepriv = &adapter->mlmepriv; struct xmit_priv *pxmit_priv = &adapter->xmitpriv; - struct wifidirect_info *pwdinfo = &adapter->wdinfo; bool ret = false; if (time_after_eq(adapter->pwrctrlpriv.ips_deny_time, jiffies)) goto exit; - if (check_fwstate(pmlmepriv, WIFI_ASOC_STATE|WIFI_SITE_MONITOR) - || check_fwstate(pmlmepriv, WIFI_UNDER_LINKING|WIFI_UNDER_WPS) - || check_fwstate(pmlmepriv, WIFI_AP_STATE) - || check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE|WIFI_ADHOC_STATE) - || !rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE) - ) { + if (check_fwstate(pmlmepriv, WIFI_ASOC_STATE|WIFI_SITE_MONITOR) || + check_fwstate(pmlmepriv, WIFI_UNDER_LINKING|WIFI_UNDER_WPS) || + check_fwstate(pmlmepriv, WIFI_AP_STATE) || + check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE|WIFI_ADHOC_STATE)){ goto exit; } /* consider buddy, if exist */ if (buddy) { struct mlme_priv *b_pmlmepriv = &buddy->mlmepriv; - struct wifidirect_info *b_pwdinfo = &buddy->wdinfo; - - if (check_fwstate(b_pmlmepriv, WIFI_ASOC_STATE|WIFI_SITE_MONITOR) - || check_fwstate(b_pmlmepriv, WIFI_UNDER_LINKING|WIFI_UNDER_WPS) - || check_fwstate(b_pmlmepriv, WIFI_AP_STATE) - || check_fwstate(b_pmlmepriv, WIFI_ADHOC_MASTER_STATE|WIFI_ADHOC_STATE) - || !rtw_p2p_chk_state(b_pwdinfo, P2P_STATE_NONE) - ) { + + if (check_fwstate(b_pmlmepriv, + WIFI_ASOC_STATE|WIFI_SITE_MONITOR) || + check_fwstate(b_pmlmepriv, + WIFI_UNDER_LINKING|WIFI_UNDER_WPS) || + check_fwstate(b_pmlmepriv, WIFI_AP_STATE) || + check_fwstate(b_pmlmepriv, + WIFI_ADHOC_MASTER_STATE|WIFI_ADHOC_STATE)) { goto exit; } } @@ -307,11 +304,6 @@ u8 PS_RDY_CHECK(struct rtw_adapter * padapter) void rtw_set_ps_mode23a(struct rtw_adapter *padapter, u8 ps_mode, u8 smart_ps, u8 bcn_ant_mode) { struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv; -#ifdef CONFIG_8723AU_P2P - struct wifidirect_info *pwdinfo = &padapter->wdinfo; -#endif /* CONFIG_8723AU_P2P */ - - RT_TRACE(_module_rtl871x_pwrctrl_c_, _drv_notice_, ("%s: PowerMode =%d Smart_PS =%d\n", @@ -334,17 +326,12 @@ void rtw_set_ps_mode23a(struct rtw_adapter *padapter, u8 ps_mode, u8 smart_ps, u } if (ps_mode == PS_MODE_ACTIVE) { -#ifdef CONFIG_8723AU_P2P - if (pwdinfo->opp_ps == 0) -#endif /* CONFIG_8723AU_P2P */ - { - DBG_8723A("rtw_set_ps_mode23a: Leave 802.11 power save\n"); + DBG_8723A("rtw_set_ps_mode23a: Leave 802.11 power save\n"); - pwrpriv->pwr_mode = ps_mode; - rtw_set_rpwm23a(padapter, PS_STATE_S4); - rtl8723a_set_FwPwrMode_cmd(padapter, ps_mode); - pwrpriv->bFwCurrentInPSMode = false; - } + pwrpriv->pwr_mode = ps_mode; + rtw_set_rpwm23a(padapter, PS_STATE_S4); + rtl8723a_set_FwPwrMode_cmd(padapter, ps_mode); + pwrpriv->bFwCurrentInPSMode = false; } else { if (PS_RDY_CHECK(padapter) #ifdef CONFIG_8723AU_BT_COEXIST @@ -359,12 +346,6 @@ void rtw_set_ps_mode23a(struct rtw_adapter *padapter, u8 ps_mode, u8 smart_ps, u pwrpriv->bcn_ant_mode = bcn_ant_mode; rtl8723a_set_FwPwrMode_cmd(padapter, ps_mode); -#ifdef CONFIG_8723AU_P2P - /* Set CTWindow after LPS */ - if (pwdinfo->opp_ps == 1) - p2p_ps_wk_cmd23a(padapter, P2P_PS_ENABLE, 0); -#endif /* CONFIG_8723AU_P2P */ - rtw_set_rpwm23a(padapter, PS_STATE_S2); } } @@ -464,10 +445,6 @@ void LeaveAllPowerSaveMode23a(struct rtw_adapter *Adapter) /* DBG_8723A("%s.....\n", __func__); */ if (check_fwstate(pmlmepriv, _FW_LINKED) == true) { /* connect */ -#ifdef CONFIG_8723AU_P2P - p2p_ps_wk_cmd23a(Adapter, P2P_PS_DISABLE, enqueue); -#endif /* CONFIG_8723AU_P2P */ - rtw_lps_ctrl_wk_cmd23a(Adapter, LPS_CTRL_LEAVE, enqueue); } diff --git a/drivers/staging/rtl8723au/core/rtw_wlan_util.c b/drivers/staging/rtl8723au/core/rtw_wlan_util.c index f774b03f23d9..17e32071b514 100644 --- a/drivers/staging/rtl8723au/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8723au/core/rtw_wlan_util.c @@ -498,32 +498,6 @@ void flush_all_cam_entry23a(struct rtw_adapter *padapter) memset((u8 *)(pmlmeinfo->FW_sta_info), 0, sizeof(pmlmeinfo->FW_sta_info)); } -#if defined(CONFIG_8723AU_P2P) && defined(CONFIG_8723AU_P2P) -int WFD_info_handler(struct rtw_adapter *padapter, struct ndis_802_11_var_ies * pIE) -{ - struct wifidirect_info *pwdinfo; - u8 wfd_ie[MAX_WFD_IE_LEN] = {0x00}; - u32 wfd_ielen = 0; - - pwdinfo = &padapter->wdinfo; - if (rtw_get_wfd_ie((u8 *) pIE, pIE->Length, wfd_ie, &wfd_ielen)) { - u8 attr_content[ 10 ] = { 0x00 }; - u32 attr_contentlen = 0; - - DBG_8723A("[%s] Found WFD IE\n", __func__); - rtw_get_wfd_attr_content(wfd_ie, wfd_ielen, WFD_ATTR_DEVICE_INFO, attr_content, &attr_contentlen); - if (attr_contentlen) { - pwdinfo->wfd_info->peer_rtsp_ctrlport = get_unaligned_be16(attr_content + 2); - DBG_8723A("[%s] Peer PORT NUM = %d\n", __func__, pwdinfo->wfd_info->peer_rtsp_ctrlport); - return true; - } - } else { - DBG_8723A("[%s] NO WFD IE\n", __func__); - } - return _FAIL; -} -#endif - int WMM_param_handler23a(struct rtw_adapter *padapter, struct ndis_802_11_var_ies * pIE) { /* struct registry_priv *pregpriv = &padapter->registrypriv; */ @@ -1371,15 +1345,6 @@ void set_sta_rate23a(struct rtw_adapter *padapter, struct sta_info *psta) void update_tx_basic_rate23a(struct rtw_adapter *padapter, u8 wirelessmode) { unsigned char supported_rates[NDIS_802_11_LENGTH_RATES_EX]; -#ifdef CONFIG_8723AU_P2P - struct wifidirect_info* pwdinfo = &padapter->wdinfo; - - /* Added by Albert 2011/03/22 */ - /* In the P2P mode, the driver should not support the b mode. */ - /* So, the Tx packet shouldn't use the CCK rate */ - if (!rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)) - return; -#endif /* CONFIG_8723AU_P2P */ memset(supported_rates, 0, NDIS_802_11_LENGTH_RATES_EX); diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_cmd.c b/drivers/staging/rtl8723au/hal/rtl8723a_cmd.c index 7a2284d96f4a..307963d9e7d0 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_cmd.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_cmd.c @@ -776,76 +776,3 @@ void rtl8723a_set_BTCoex_AP_mode_FwRsvdPkt_cmd(struct rtw_adapter *padapter) } } #endif - -#ifdef CONFIG_8723AU_P2P -void rtl8723a_set_p2p_ps_offload_cmd(struct rtw_adapter *padapter, u8 p2p_ps_state) -{ - struct hal_data_8723a *pHalData = GET_HAL_DATA(padapter); - struct wifidirect_info *pwdinfo = &padapter->wdinfo; - struct P2P_PS_Offload_t *p2p_ps_offload = &pHalData->p2p_ps_offload; - u8 i; - - switch (p2p_ps_state) { - case P2P_PS_DISABLE: - DBG_8723A("P2P_PS_DISABLE \n"); - memset(p2p_ps_offload, 0, 1); - break; - case P2P_PS_ENABLE: - DBG_8723A("P2P_PS_ENABLE \n"); - /* update CTWindow value. */ - if (pwdinfo->ctwindow > 0) { - p2p_ps_offload->CTWindow_En = 1; - rtw_write8(padapter, REG_P2P_CTWIN, pwdinfo->ctwindow); - } - - /* hw only support 2 set of NoA */ - for (i = 0; i < pwdinfo->noa_num; i++) { - /* To control the register setting for which NOA */ - rtw_write8(padapter, REG_NOA_DESC_SEL, (i << 4)); - if (i == 0) - p2p_ps_offload->NoA0_En = 1; - else - p2p_ps_offload->NoA1_En = 1; - - /* config P2P NoA Descriptor Register */ - rtw_write32(padapter, REG_NOA_DESC_DURATION, pwdinfo->noa_duration[i]); - - rtw_write32(padapter, REG_NOA_DESC_INTERVAL, pwdinfo->noa_interval[i]); - - rtw_write32(padapter, REG_NOA_DESC_START, pwdinfo->noa_start_time[i]); - - rtw_write8(padapter, REG_NOA_DESC_COUNT, pwdinfo->noa_count[i]); - } - - if ((pwdinfo->opp_ps == 1) || (pwdinfo->noa_num > 0)) { - /* rst p2p circuit */ - rtw_write8(padapter, REG_DUAL_TSF_RST, BIT(4)); - - p2p_ps_offload->Offload_En = 1; - - if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO)) { - p2p_ps_offload->role = 1; - p2p_ps_offload->AllStaSleep = 0; - } else { - p2p_ps_offload->role = 0; - } - - p2p_ps_offload->discovery = 0; - } - break; - case P2P_PS_SCAN: - DBG_8723A("P2P_PS_SCAN \n"); - p2p_ps_offload->discovery = 1; - break; - case P2P_PS_SCAN_DONE: - DBG_8723A("P2P_PS_SCAN_DONE \n"); - p2p_ps_offload->discovery = 0; - pwdinfo->p2p_ps_state = P2P_PS_ENABLE; - break; - default: - break; - } - - FillH2CCmd(padapter, P2P_PS_OFFLOAD_EID, 1, (u8 *)p2p_ps_offload); -} -#endif /* CONFIG_8723AU_P2P */ diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_dm.c b/drivers/staging/rtl8723au/hal/rtl8723a_dm.c index 71ee47abcace..4ca7b8ec7b38 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723a_dm.c +++ b/drivers/staging/rtl8723au/hal/rtl8723a_dm.c @@ -219,13 +219,6 @@ rtl8723a_HalDmWatchDog( bFwCurrentInPSMode = Adapter->pwrctrlpriv.bFwCurrentInPSMode; bFwPSAwake = rtl8723a_get_fwlps_rf_on(Adapter); -#ifdef CONFIG_8723AU_P2P - /* Fw is under p2p powersaving mode, driver should stop dynamic mechanism. */ - /* modifed by thomas. 2011.06.11. */ - if (Adapter->wdinfo.p2p_ps_mode) - bFwPSAwake = false; -#endif /* CONFIG_8723AU_P2P */ - if ((hw_init_completed) && ((!bFwCurrentInPSMode) && bFwPSAwake)) { /* Calculate Tx/Rx statistics. */ dm_CheckStatistics(Adapter); diff --git a/drivers/staging/rtl8723au/include/drv_types.h b/drivers/staging/rtl8723au/include/drv_types.h index 14c7f2e915e0..de25e1a5eee8 100644 --- a/drivers/staging/rtl8723au/include/drv_types.h +++ b/drivers/staging/rtl8723au/include/drv_types.h @@ -55,7 +55,6 @@ enum _NIC_VERSION { #include #include #include -#include #include #include "ioctl_cfg80211.h" @@ -258,13 +257,7 @@ struct rtw_adapter { struct hostapd_priv *phostapdpriv; #endif - struct cfg80211_wifidirect_info cfg80211_wdinfo; u32 setband; - struct wifidirect_info wdinfo; - -#ifdef CONFIG_8723AU_P2P - struct wifi_display_info wfd_info; -#endif /* CONFIG_8723AU_P2P */ void *HalData; u32 hal_data_sz; @@ -316,10 +309,6 @@ struct rtw_adapter { u8 bRxRSSIDisplay; /* The driver will show the desired chan nor when this flag is 1. */ u8 bNotifyChannelChange; -#ifdef CONFIG_8723AU_P2P - /* driver will show current P2P status when the application reads it*/ - u8 bShowGetP2PState; -#endif struct rtw_adapter *pbuddy_adapter; /* extend to support multi interface */ diff --git a/drivers/staging/rtl8723au/include/ieee80211.h b/drivers/staging/rtl8723au/include/ieee80211.h index 61326e5e089c..f2824c3c2f9c 100644 --- a/drivers/staging/rtl8723au/include/ieee80211.h +++ b/drivers/staging/rtl8723au/include/ieee80211.h @@ -563,20 +563,6 @@ u8 *rtw_get_wps_attr_content23a(u8 *wps_ie, uint wps_ielen, u16 target_attr_id , void dump_ies23a(u8 *buf, u32 buf_len); void dump_wps_ie23a(u8 *ie, u32 ie_len); -#ifdef CONFIG_8723AU_P2P -void dump_p2p_ie23a(u8 *ie, u32 ie_len); -u8 *rtw_get_p2p_ie23a(u8 *in_ie, int in_len, u8 *p2p_ie, uint *p2p_ielen); -u8 *rtw_get_p2p_attr23a(u8 *p2p_ie, uint p2p_ielen, u8 target_attr_id ,u8 *buf_attr, u32 *len_attr); -u8 *rtw_get_p2p_attr23a_content(u8 *p2p_ie, uint p2p_ielen, u8 target_attr_id ,u8 *buf_content, uint *len_content); -u32 rtw_set_p2p_attr_content23a(u8 *pbuf, u8 attr_id, u16 attr_len, u8 *pdata_attr); -void rtw_wlan_bssid_ex_remove_p2p_attr23a(struct wlan_bssid_ex *bss_ex, u8 attr_id); -#endif - -#ifdef CONFIG_8723AU_P2P -int rtw_get_wfd_ie(u8 *in_ie, int in_len, u8 *wfd_ie, uint *wfd_ielen); -int rtw_get_wfd_attr_content(u8 *wfd_ie, uint wfd_ielen, u8 target_attr_id ,u8 *attr_content, uint *attr_contentlen); -#endif /* CONFIG_8723AU_P2P */ - uint rtw_get_rateset_len23a(u8 *rateset); struct registry_priv; diff --git a/drivers/staging/rtl8723au/include/rtl8723a_cmd.h b/drivers/staging/rtl8723au/include/rtl8723a_cmd.h index 8fccbfc3a45c..09fa72340302 100644 --- a/drivers/staging/rtl8723au/include/rtl8723a_cmd.h +++ b/drivers/staging/rtl8723au/include/rtl8723a_cmd.h @@ -151,10 +151,6 @@ u8 rtl8723a_set_rssi_cmd(struct rtw_adapter * padapter, u8 *param); u8 rtl8723a_set_raid_cmd(struct rtw_adapter * padapter, u32 mask, u8 arg); void rtl8723a_add_rateatid(struct rtw_adapter * padapter, u32 bitmap, u8 arg, u8 rssi_level); -#ifdef CONFIG_8723AU_P2P -void rtl8723a_set_p2p_ps_offload_cmd(struct rtw_adapter * padapter, u8 p2p_ps_state); -#endif /* CONFIG_8723AU_P2P */ - void CheckFwRsvdPageContent23a(struct rtw_adapter *padapter); #endif diff --git a/drivers/staging/rtl8723au/include/rtl8723a_hal.h b/drivers/staging/rtl8723au/include/rtl8723a_hal.h index ce11245fefd7..f6b4b7c7c22d 100644 --- a/drivers/staging/rtl8723au/include/rtl8723a_hal.h +++ b/drivers/staging/rtl8723au/include/rtl8723a_hal.h @@ -424,11 +424,6 @@ struct hal_data_8723a { bool bMACFuncEnable; -#ifdef CONFIG_8723AU_P2P - struct P2P_PS_Offload_t p2p_ps_offload; -#endif - - /* */ /* For USB Interface HAL related */ /* */ diff --git a/drivers/staging/rtl8723au/include/rtw_cmd.h b/drivers/staging/rtl8723au/include/rtw_cmd.h index f9caa3e35f57..ba6d572b81b3 100644 --- a/drivers/staging/rtl8723au/include/rtw_cmd.h +++ b/drivers/staging/rtl8723au/include/rtw_cmd.h @@ -106,9 +106,6 @@ u32 rtw_init_evt_priv23a (struct evt_priv *pevtpriv); void rtw_free_evt_priv23a (struct evt_priv *pevtpriv); void rtw_cmd_clr_isr23a(struct cmd_priv *pcmdpriv); void rtw_evt_notify_isr(struct evt_priv *pevtpriv); -#ifdef CONFIG_8723AU_P2P -u8 p2p_protocol_wk_cmd23a(struct rtw_adapter*padapter, int intCmdType ); -#endif /* CONFIG_8723AU_P2P */ enum rtw_drvextra_cmd_id { diff --git a/drivers/staging/rtl8723au/include/rtw_mlme.h b/drivers/staging/rtl8723au/include/rtw_mlme.h index 2d4f61b91943..0b48b05fc1ad 100644 --- a/drivers/staging/rtl8723au/include/rtw_mlme.h +++ b/drivers/staging/rtl8723au/include/rtw_mlme.h @@ -148,30 +148,6 @@ struct tx_invite_resp_info { u8 token; /* Used to record the dialog token of p2p invitation request frame. */ }; -#ifdef CONFIG_8723AU_P2P - -struct wifi_display_info { - u16 wfd_enable; /* Enable/Disable the WFD function. */ - u16 rtsp_ctrlport; /* TCP port number at which the this WFD device listens for RTSP messages */ - u16 peer_rtsp_ctrlport; /* TCP port number at which the peer WFD device listens for RTSP messages */ - /* This filed should be filled when receiving the gropu negotiation request */ - - u8 peer_session_avail; /* WFD session is available or not for the peer wfd device. */ - /* This variable will be set when sending the provisioning discovery request to peer WFD device. */ - /* And this variable will be reset when it is read by using the iwpriv p2p_get wfd_sa command. */ - u8 ip_address[4]; - u8 peer_ip_address[4]; - u8 wfd_pc; /* WFD preferred connection */ - /* 0 -> Prefer to use the P2P for WFD connection on peer side. */ - /* 1 -> Prefer to use the TDLS for WFD connection on peer side. */ - - u8 wfd_device_type;/* WFD Device Type */ - /* 0 -> WFD Source Device */ - /* 1 -> WFD Primary Sink Device */ - enum SCAN_RESULT_TYPE scan_result_type; /* Used when P2P is enable. This parameter will impact the scan result. */ -}; -#endif /* CONFIG_8723AU_P2P */ - struct tx_provdisc_req_info { u16 wps_config_method_request; /* Used when sending the provisioning request frame */ u16 peer_channel_num[2]; /* The channel number which the receiver stands. */ @@ -203,102 +179,6 @@ struct scan_limit_info { u8 operation_ch[2]; /* Store the operation channel of invitation request frame */ }; -struct cfg80211_wifidirect_info { - struct timer_list remain_on_ch_timer; - u8 restore_channel; - struct ieee80211_channel remain_on_ch_channel; - enum nl80211_channel_type remain_on_ch_type; - u64 remain_on_ch_cookie; - bool is_ro_ch; -}; - -struct wifidirect_info { - struct rtw_adapter *padapter; - struct timer_list find_phase_timer; - struct timer_list restore_p2p_state_timer; - - /* Used to do the scanning. After confirming the peer is availalble, the driver transmits the P2P frame to peer. */ - struct timer_list pre_tx_scan_timer; - struct timer_list reset_ch_sitesurvey; - struct timer_list reset_ch_sitesurvey2; /* Just for resetting the scan limit function by using p2p nego */ - struct tx_provdisc_req_info tx_prov_disc_info; - struct rx_provdisc_req_info rx_prov_disc_info; - struct tx_invite_req_info invitereq_info; - struct profile_info profileinfo[P2P_MAX_PERSISTENT_GROUP_NUM]; /* Store the profile information of persistent group */ - struct tx_invite_resp_info inviteresp_info; - struct tx_nego_req_info nego_req_info; - struct group_id_info groupid_info; /* Store the group id information when doing the group negotiation handshake. */ - struct scan_limit_info rx_invitereq_info; /* Used for get the limit scan channel from the Invitation procedure */ - struct scan_limit_info p2p_info; /* Used for get the limit scan channel from the P2P negotiation handshake */ -#ifdef CONFIG_8723AU_P2P - struct wifi_display_info *wfd_info; -#endif - enum P2P_ROLE role; - enum P2P_STATE pre_p2p_state; - enum P2P_STATE p2p_state; - u8 device_addr[ETH_ALEN]; /* The device address should be the mac address of this device. */ - u8 interface_addr[ETH_ALEN]; - u8 social_chan[4]; - u8 listen_channel; - u8 operating_channel; - u8 listen_dwell; /* This value should be between 1 and 3 */ - u8 support_rate[8]; - u8 p2p_wildcard_ssid[P2P_WILDCARD_SSID_LEN]; - u8 intent; /* should only include the intent value. */ - u8 p2p_peer_interface_addr[ETH_ALEN]; - u8 p2p_peer_device_addr[ETH_ALEN]; - u8 peer_intent; /* Included the intent value and tie breaker value. */ - u8 device_name[WPS_MAX_DEVICE_NAME_LEN]; /* Device name for displaying on searching device screen */ - u8 device_name_len; - u8 profileindex; /* Used to point to the index of profileinfo array */ - u8 peer_operating_ch; - u8 find_phase_state_exchange_cnt; - u16 device_password_id_for_nego; /* The device password ID for group negotation */ - u8 negotiation_dialog_token; - /* SSID information for group negotitation */ - u8 nego_ssid[IEEE80211_MAX_SSID_LEN]; - u8 nego_ssidlen; - u8 p2p_group_ssid[IEEE80211_MAX_SSID_LEN]; - u8 p2p_group_ssid_len; - u8 persistent_supported; /* Flag to know the persistent function should be supported or not. */ - /* In the Sigma test, the Sigma will provide this enable from the sta_set_p2p CAPI. */ - /* 0: disable */ - /* 1: enable */ - u8 session_available; /* Flag to set the WFD session available to enable or disable "by Sigma" */ - /* In the Sigma test, the Sigma will disable the session available by using the sta_preset CAPI. */ - /* 0: disable */ - /* 1: enable */ - - u8 wfd_tdls_enable; /* Flag to enable or disable the TDLS by WFD Sigma */ - /* 0: disable */ - /* 1: enable */ - u8 wfd_tdls_weaksec; /* Flag to enable or disable the weak security function for TDLS by WFD Sigma */ - /* 0: disable */ - /* In this case, the driver can't issue the tdsl setup request frame. */ - /* 1: enable */ - /* In this case, the driver can issue the tdls setup request frame */ - /* even the current security is weak security. */ - - enum P2P_WPSINFO ui_got_wps_info; /* This field will store the WPS value (PIN value or PBC) that UI had got from the user. */ - u16 supported_wps_cm; /* This field describes the WPS config method which this driver supported. */ - /* The value should be the combination of config method defined in page104 of WPS v2.0 spec. */ - uint channel_list_attr_len; /* This field will contain the length of body of P2P Channel List attribute of group negotitation response frame. */ - u8 channel_list_attr[100]; /* This field will contain the body of P2P Channel List attribute of group negotitation response frame. */ - /* We will use the channel_cnt and channel_list fields when constructing the group negotitation confirm frame. */ -#ifdef CONFIG_8723AU_P2P - enum P2P_PS_MODE p2p_ps_mode; /* indicate p2p ps mode */ - enum P2P_PS_STATE p2p_ps_state; /* indicate p2p ps state */ - u8 noa_index; /* Identifies and instance of Notice of Absence timing. */ - u8 ctwindow; /* Client traffic window. A period of time in TU after TBTT. */ - u8 opp_ps; /* opportunistic power save. */ - u8 noa_num; /* number of NoA descriptor in P2P IE. */ - u8 noa_count[P2P_MAX_NOA_NUM]; /* Count for owner, Type of client. */ - u32 noa_duration[P2P_MAX_NOA_NUM]; /* Max duration for owner, preferred or min acceptable duration for client. */ - u32 noa_interval[P2P_MAX_NOA_NUM]; /* Length of interval for owner, preferred or max acceptable interval of client. */ - u32 noa_start_time[P2P_MAX_NOA_NUM]; /* schedule expressed in terms of the lower 4 bytes of the TSF timer. */ -#endif /* CONFIG_8723AU_P2P */ -}; - struct tdls_ss_record { /* signal strength record */ u8 macaddr[ETH_ALEN]; u8 RxPWDBAll; @@ -324,9 +204,6 @@ struct tdls_info { u8 watchdog_count; u8 dev_discovered; /* WFD_TDLS: for sigma test */ u8 enable; -#ifdef CONFIG_8723AU_P2P - struct wifi_display_info *wfd_info; -#endif }; struct mlme_priv { diff --git a/drivers/staging/rtl8723au/include/rtw_mlme_ext.h b/drivers/staging/rtl8723au/include/rtw_mlme_ext.h index 7729b2be25ae..9d9815dd6941 100644 --- a/drivers/staging/rtl8723au/include/rtw_mlme_ext.h +++ b/drivers/staging/rtl8723au/include/rtw_mlme_ext.h @@ -519,10 +519,6 @@ unsigned char check_assoc_AP23a(u8 *pframe, uint len); int WMM_param_handler23a(struct rtw_adapter *padapter, struct ndis_802_11_var_ies *pIE); -#ifdef CONFIG_8723AU_P2P -int WFD_info_handler(struct rtw_adapter *padapter, - struct ndis_802_11_var_ies *pIE); -#endif void WMMOnAssocRsp23a(struct rtw_adapter *padapter); void HT_caps_handler23a(struct rtw_adapter *padapter, @@ -587,18 +583,6 @@ s32 dump_mgntframe23a_and_wait(struct rtw_adapter *padapter, s32 dump_mgntframe23a_and_wait_ack23a(struct rtw_adapter *padapter, struct xmit_frame *pmgntframe); -#ifdef CONFIG_8723AU_P2P -void issue_probersp23a_p2p23a(struct rtw_adapter *padapter, unsigned char *da); -void issue_p2p_provision_request23a(struct rtw_adapter *padapter, u8 *pssid, - u8 ussidlen, u8* pdev_raddr); -void issue_p2p_GO_request23a(struct rtw_adapter *padapter, u8* raddr); -void issue23a_probereq_p2p(struct rtw_adapter *padapter, u8 *da); -int issue23a_probereq_p2p_ex(struct rtw_adapter *adapter, u8 *da, int try_cnt, - int wait_ms); -void issue_p2p_invitation_response23a(struct rtw_adapter *padapter, u8* raddr, - u8 dialogToken, u8 success); -void issue_p2p_invitation_request23a(struct rtw_adapter *padapter, u8* raddr); -#endif /* CONFIG_8723AU_P2P */ void issue_beacon23a(struct rtw_adapter *padapter, int timeout_ms); void issue_probersp23a(struct rtw_adapter *padapter, unsigned char *da, u8 is_valid_p2p_probereq); diff --git a/drivers/staging/rtl8723au/include/rtw_p2p.h b/drivers/staging/rtl8723au/include/rtw_p2p.h deleted file mode 100644 index 93fdc658ff4d..000000000000 --- a/drivers/staging/rtl8723au/include/rtw_p2p.h +++ /dev/null @@ -1,158 +0,0 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - ******************************************************************************/ -#ifndef __RTW_P2P_H_ -#define __RTW_P2P_H_ - -#include - -u32 build_beacon_p2p_ie23a(struct wifidirect_info *pwdinfo, u8 *pbuf); -u32 build_probe_resp_p2p_ie23a(struct wifidirect_info *pwdinfo, u8 *pbuf); -u32 build_prov_disc_request_p2p_ie23a(struct wifidirect_info *pwdinfo, u8 *pbuf, - u8 *pssid, u8 ussidlen, u8 *pdev_raddr); -u32 build_assoc_resp_p2p_ie23a(struct wifidirect_info *pwdinfo, u8 *pbuf, - u8 status_code); -u32 build_deauth_p2p_ie23a(struct wifidirect_info *pwdinfo, u8 *pbuf); -#ifdef CONFIG_8723AU_P2P -u32 build_probe_req_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf); -u32 build_probe_resp_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf, - u8 tunneled); -u32 build_beacon_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf); -u32 build_nego_req_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf); -u32 build_nego_resp_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf); -u32 build_nego_confirm_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf); -u32 build_invitation_req_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf); -u32 build_invitation_resp_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf); -u32 build_assoc_req_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf); -u32 build_assoc_resp_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf); -u32 build_provdisc_req_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf); -u32 build_provdisc_resp_wfd_ie(struct wifidirect_info *pwdinfo, u8 *pbuf); -#endif /* CONFIG_8723AU_P2P */ - -u32 process_probe_req_p2p_ie23a(struct wifidirect_info *pwdinfo, u8 *pframe, - uint len); -u32 process_assoc_req_p2p_ie23a(struct wifidirect_info *pwdinfo, u8 *pframe, - uint len, struct sta_info *psta); -u32 process_p2p_devdisc_req23a(struct wifidirect_info *pwdinfo, u8 *pframe, - uint len); -u32 process_p2p_devdisc_resp23a(struct wifidirect_info *pwdinfo, u8 *pframe, - uint len); -u8 process_p2p_provdisc_req23a(struct wifidirect_info *pwdinfo, u8 *pframe, - uint len); -u8 process_p2p_provdisc_resp23a(struct wifidirect_info *pwdinfo, u8 *pframe); -u8 process_p2p_group_negotation_req23a(struct wifidirect_info *pwdinfo, - u8 *pframe, uint len); -u8 process_p2p_group_negotation_resp23a(struct wifidirect_info *pwdinfo, - u8 *pframe, uint len); -u8 process_p2p_group_negotation_confirm23a(struct wifidirect_info *pwdinfo, - u8 *pframe, uint len); -u8 process_p2p_presence_req23a(struct wifidirect_info *pwdinfo, - u8 *pframe, uint len); - -void p2p_protocol_wk_hdl23a(struct rtw_adapter *padapter, int cmdtype); - -#ifdef CONFIG_8723AU_P2P -void process_p2p_ps_ie23a(struct rtw_adapter *padapter, u8 *IEs, u32 IELength); -void p2p_ps_wk_hdl23a(struct rtw_adapter *padapter, u8 p2p_ps_state); -u8 p2p_ps_wk_cmd23a(struct rtw_adapter *padapter, u8 p2p_ps_state, u8 enqueue); -#endif /* CONFIG_8723AU_P2P */ - -void rtw_init_cfg80211_wifidirect_info(struct rtw_adapter *padapter); -int rtw_p2p_check_frames(struct rtw_adapter *padapter, const u8 *buf, - u32 len, u8 tx); -void rtw_append_wfd_ie(struct rtw_adapter *padapter, u8 *buf, u32 *len); - -void reset_global_wifidirect_info23a(struct rtw_adapter *padapter); -int rtw_init_wifi_display_info(struct rtw_adapter *padapter); -void rtw_init_wifidirect_timers23a(struct rtw_adapter *padapter); -void rtw_init_wifidirect_addrs23a(struct rtw_adapter *padapter, u8 *dev_addr, - u8 *iface_addr); -void init_wifidirect_info23a(struct rtw_adapter *padapter, enum P2P_ROLE role); -int rtw_p2p_enable23a(struct rtw_adapter *padapter, enum P2P_ROLE role); - -static inline void _rtw_p2p_set_state(struct wifidirect_info *wdinfo, - enum P2P_STATE state) -{ - if (wdinfo->p2p_state != state) { - /* wdinfo->pre_p2p_state = wdinfo->p2p_state; */ - wdinfo->p2p_state = state; - } -} - -static inline void _rtw_p2p_set_pre_state(struct wifidirect_info *wdinfo, - enum P2P_STATE state) -{ - if (wdinfo->pre_p2p_state != state) - wdinfo->pre_p2p_state = state; -} - -static inline void _rtw_p2p_set_role(struct wifidirect_info *wdinfo, - enum P2P_ROLE role) -{ - if (wdinfo->role != role) - wdinfo->role = role; -} - -static inline int _rtw_p2p_state(struct wifidirect_info *wdinfo) -{ - return wdinfo->p2p_state; -} - -static inline int _rtw_p2p_pre_state(struct wifidirect_info *wdinfo) -{ - return wdinfo->pre_p2p_state; -} - -static inline int _rtw_p2p_role(struct wifidirect_info *wdinfo) -{ - return wdinfo->role; -} - -static inline bool _rtw_p2p_chk_state(struct wifidirect_info *wdinfo, - enum P2P_STATE state) -{ - return wdinfo->p2p_state == state; -} - -static inline bool _rtw_p2p_chk_role(struct wifidirect_info *wdinfo, - enum P2P_ROLE role) -{ - return wdinfo->role == role; -} - -#define rtw_p2p_set_state(wdinfo, state) _rtw_p2p_set_state(wdinfo, state) -#define rtw_p2p_set_pre_state(wdinfo, state) \ - _rtw_p2p_set_pre_state(wdinfo, state) -#define rtw_p2p_set_role(wdinfo, role) _rtw_p2p_set_role(wdinfo, role) - -#define rtw_p2p_state(wdinfo) _rtw_p2p_state(wdinfo) -#define rtw_p2p_pre_state(wdinfo) _rtw_p2p_pre_state(wdinfo) -#define rtw_p2p_role(wdinfo) _rtw_p2p_role(wdinfo) -#define rtw_p2p_chk_state(wdinfo, state) _rtw_p2p_chk_state(wdinfo, state) -#define rtw_p2p_chk_role(wdinfo, role) _rtw_p2p_chk_role(wdinfo, role) - -#define rtw_p2p_findphase_ex_set(wdinfo, value) \ - ((wdinfo)->find_phase_state_exchange_cnt = (value)) - -/* is this find phase exchange for social channel scan? */ -#define rtw_p2p_findphase_ex_is_social(wdinfo) \ - ((wdinfo)->find_phase_state_exchange_cnt >= \ - P2P_FINDPHASE_EX_SOCIAL_FIRST) - -/* should we need find phase exchange anymore? */ -#define rtw_p2p_findphase_ex_is_needed(wdinfo) \ - ((wdinfo)->find_phase_state_exchange_cnt < P2P_FINDPHASE_EX_MAX && \ - (wdinfo)->find_phase_state_exchange_cnt != P2P_FINDPHASE_EX_NONE) - -#endif diff --git a/drivers/staging/rtl8723au/include/wifi.h b/drivers/staging/rtl8723au/include/wifi.h index 57e394543ec1..41af702121c4 100644 --- a/drivers/staging/rtl8723au/include/wifi.h +++ b/drivers/staging/rtl8723au/include/wifi.h @@ -636,23 +636,6 @@ enum P2P_PROTO_WK_ID { P2P_RO_CH_WK = 6, }; -#ifdef CONFIG_8723AU_P2P -enum P2P_PS_STATE { - P2P_PS_DISABLE = 0, - P2P_PS_ENABLE = 1, - P2P_PS_SCAN = 2, - P2P_PS_SCAN_DONE = 3, - P2P_PS_ALLSTASLEEP = 4, /* for P2P GO */ -}; - -enum P2P_PS_MODE { - P2P_PS_NONE = 0, - P2P_PS_CTWINDOW = 1, - P2P_PS_NOA = 2, - P2P_PS_MIX = 3, /* CTWindow and NoA */ -}; -#endif /* CONFIG_8723AU_P2P */ - /* =====================WFD Section===================== */ /* For Wi-Fi Display */ #define WFD_ATTR_DEVICE_INFO 0x00 diff --git a/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c b/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c index a0d59c7963d1..a3e17f99a278 100644 --- a/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c +++ b/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c @@ -357,9 +357,6 @@ void rtw_cfg80211_indicate_connect(struct rtw_adapter *padapter) struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct wlan_network *cur_network = &pmlmepriv->cur_network; struct wireless_dev *pwdev = padapter->rtw_wdev; -#ifdef CONFIG_8723AU_P2P - struct wifidirect_info *pwdinfo = &padapter->wdinfo; -#endif DBG_8723A("%s(padapter =%p)\n", __func__, padapter); @@ -370,17 +367,6 @@ void rtw_cfg80211_indicate_connect(struct rtw_adapter *padapter) if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) return; -#ifdef CONFIG_8723AU_P2P - if (!rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)) { - rtw_p2p_set_pre_state(pwdinfo, rtw_p2p_state(pwdinfo)); - rtw_p2p_set_role(pwdinfo, P2P_ROLE_CLIENT); - rtw_p2p_set_state(pwdinfo, P2P_STATE_GONEGO_OK); - DBG_8723A("%s, role =%d, p2p_state =%d, pre_p2p_state =%d\n", - __func__, rtw_p2p_role(pwdinfo), - rtw_p2p_state(pwdinfo), rtw_p2p_pre_state(pwdinfo)); - } -#endif /* CONFIG_8723AU_P2P */ - if (rtw_to_roaming(padapter) > 0) { struct wiphy *wiphy = pwdev->wiphy; struct ieee80211_channel *notify_channel; @@ -429,9 +415,6 @@ void rtw_cfg80211_indicate_disconnect(struct rtw_adapter *padapter) { struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct wireless_dev *pwdev = padapter->rtw_wdev; -#ifdef CONFIG_8723AU_P2P - struct wifidirect_info *pwdinfo = &padapter->wdinfo; -#endif DBG_8723A("%s(padapter =%p)\n", __func__, padapter); @@ -442,21 +425,6 @@ void rtw_cfg80211_indicate_disconnect(struct rtw_adapter *padapter) if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) return; -#ifdef CONFIG_8723AU_P2P - if (!rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)) { - del_timer_sync(&pwdinfo->find_phase_timer); - del_timer_sync(&pwdinfo->restore_p2p_state_timer); - del_timer_sync(&pwdinfo->pre_tx_scan_timer); - - rtw_p2p_set_state(pwdinfo, rtw_p2p_pre_state(pwdinfo)); - rtw_p2p_set_role(pwdinfo, P2P_ROLE_DEVICE); - - DBG_8723A("%s, role =%d, p2p_state =%d, pre_p2p_state =%d\n", - __func__, rtw_p2p_role(pwdinfo), - rtw_p2p_state(pwdinfo), rtw_p2p_pre_state(pwdinfo)); - } -#endif /* CONFIG_8723AU_P2P */ - if (!padapter->mlmepriv.not_indic_disco) { if (check_fwstate(&padapter->mlmepriv, WIFI_UNDER_LINKING)) { cfg80211_connect_result(padapter->pnetdev, NULL, NULL, @@ -921,11 +889,6 @@ static int rtw_cfg80211_set_encryption(struct net_device *dev, struct rtw_adapter *padapter = netdev_priv(dev); struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct security_priv *psecuritypriv = &padapter->securitypriv; -#ifdef CONFIG_8723AU_P2P - struct wifidirect_info *pwdinfo = &padapter->wdinfo; -#endif /* CONFIG_8723AU_P2P */ - - DBG_8723A("%s\n", __func__); @@ -1080,15 +1043,6 @@ static int rtw_cfg80211_set_encryption(struct net_device *dev, rtw_set_key23a(padapter, &padapter->securitypriv, param->u.crypt.idx, 1); -#ifdef CONFIG_8723AU_P2P - if (rtw_p2p_chk_state - (pwdinfo, - P2P_STATE_PROVISIONING_ING)) { - rtw_p2p_set_state(pwdinfo, - P2P_STATE_PROVISIONING_DONE); - } -#endif /* CONFIG_8723AU_P2P */ - } } @@ -1350,9 +1304,6 @@ static int cfg80211_rtw_change_iface(struct wiphy *wiphy, struct rtw_adapter *padapter = wiphy_to_adapter(wiphy); struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct wireless_dev *rtw_wdev = wiphy_to_wdev(wiphy); -#ifdef CONFIG_8723AU_P2P - struct wifidirect_info *pwdinfo = &padapter->wdinfo; -#endif int ret = 0; u8 change = false; @@ -1384,34 +1335,10 @@ static int cfg80211_rtw_change_iface(struct wiphy *wiphy, case NL80211_IFTYPE_P2P_CLIENT: case NL80211_IFTYPE_STATION: networkType = Ndis802_11Infrastructure; -#ifdef CONFIG_8723AU_P2P - if (change && rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO)) { - del_timer_sync(&pwdinfo->find_phase_timer); - del_timer_sync(&pwdinfo->restore_p2p_state_timer); - del_timer_sync(&pwdinfo->pre_tx_scan_timer); - - /* it means remove GO and change mode from AP(GO) - to station(P2P DEVICE) */ - rtw_p2p_set_role(pwdinfo, P2P_ROLE_DEVICE); - rtw_p2p_set_state(pwdinfo, rtw_p2p_pre_state(pwdinfo)); - - DBG_8723A("%s, role =%d, p2p_state =%d, pre_p2p_state =" - "%d\n", __func__, rtw_p2p_role(pwdinfo), - rtw_p2p_state(pwdinfo), - rtw_p2p_pre_state(pwdinfo)); - } -#endif /* CONFIG_8723AU_P2P */ break; case NL80211_IFTYPE_P2P_GO: case NL80211_IFTYPE_AP: networkType = Ndis802_11APMode; -#ifdef CONFIG_8723AU_P2P - if (change && !rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)) { - /* it means P2P Group created, we will be GO - and change mode from P2P DEVICE to AP(GO) */ - rtw_p2p_set_role(pwdinfo, P2P_ROLE_GO); - } -#endif /* CONFIG_8723AU_P2P */ break; default: return -EOPNOTSUPP; @@ -1486,11 +1413,6 @@ static int rtw_cfg80211_set_probe_req_wpsp2pie(struct rtw_adapter *padapter, int ret = 0; uint wps_ielen = 0; u8 *wps_ie; -#ifdef CONFIG_8723AU_P2P - u32 p2p_ielen = 0; - u8 *p2p_ie; - u32 wfd_ielen = 0; -#endif struct mlme_priv *pmlmepriv = &padapter->mlmepriv; DBG_8723A("%s, ielen =%d\n", __func__, len); @@ -1516,56 +1438,6 @@ static int rtw_cfg80211_set_probe_req_wpsp2pie(struct rtw_adapter *padapter, memcpy(pmlmepriv->wps_probe_req_ie, wps_ie, wps_ielen); pmlmepriv->wps_probe_req_ie_len = wps_ielen; } -#ifdef CONFIG_8723AU_P2P - p2p_ie = rtw_get_p2p_ie23a(buf, len, NULL, &p2p_ielen); - if (p2p_ie) { - DBG_8723A("probe_req_p2p_ielen =%d\n", p2p_ielen); - - if (pmlmepriv->p2p_probe_req_ie) { - pmlmepriv->p2p_probe_req_ie_len = 0; - kfree(pmlmepriv->p2p_probe_req_ie); - pmlmepriv->p2p_probe_req_ie = NULL; - } - - pmlmepriv->p2p_probe_req_ie = - kmalloc(p2p_ielen, GFP_KERNEL); - if (pmlmepriv->p2p_probe_req_ie == NULL) { - DBG_8723A("%s()-%d: kmalloc() ERROR!\n", - __func__, __LINE__); - return -EINVAL; - - } - memcpy(pmlmepriv->p2p_probe_req_ie, p2p_ie, p2p_ielen); - pmlmepriv->p2p_probe_req_ie_len = p2p_ielen; - } -#endif /* CONFIG_8723AU_P2P */ - - /* buf += p2p_ielen; */ - /* len -= p2p_ielen; */ - -#ifdef CONFIG_8723AU_P2P - if (rtw_get_wfd_ie(buf, len, NULL, &wfd_ielen)) { - DBG_8723A("probe_req_wfd_ielen =%d\n", wfd_ielen); - - if (pmlmepriv->wfd_probe_req_ie) { - pmlmepriv->wfd_probe_req_ie_len = 0; - kfree(pmlmepriv->wfd_probe_req_ie); - pmlmepriv->wfd_probe_req_ie = NULL; - } - - pmlmepriv->wfd_probe_req_ie = - kmalloc(wfd_ielen, GFP_KERNEL); - if (pmlmepriv->wfd_probe_req_ie == NULL) { - DBG_8723A("%s()-%d: kmalloc() ERROR!\n", - __func__, __LINE__); - return -EINVAL; - - } - rtw_get_wfd_ie(buf, len, pmlmepriv->wfd_probe_req_ie, - &pmlmepriv->wfd_probe_req_ie_len); - } -#endif /* CONFIG_8723AU_P2P */ - } return ret; @@ -1583,10 +1455,6 @@ static int cfg80211_rtw_scan(struct wiphy *wiphy, struct rtw_ieee80211_channel ch[RTW_CHANNEL_SCAN_AMOUNT]; struct rtw_wdev_priv *pwdev_priv = wdev_to_priv(padapter->rtw_wdev); struct cfg80211_ssid *ssids = request->ssids; -#ifdef CONFIG_8723AU_P2P - struct wifidirect_info *pwdinfo = &padapter->wdinfo; - int social_channel = 0; -#endif /* CONFIG_8723AU_P2P */ bool need_indicate_scan_done = false; DBG_8723A(FUNC_ADPT_FMT "\n", FUNC_ADPT_ARG(padapter)); @@ -1605,27 +1473,6 @@ static int cfg80211_rtw_scan(struct wiphy *wiphy, need_indicate_scan_done = true; goto check_need_indicate_scan_done; } -#ifdef CONFIG_8723AU_P2P - if (!memcmp(ssids->ssid, "DIRECT-", 7) && - rtw_get_p2p_ie23a((u8 *) request->ie, request->ie_len, NULL, NULL)) { - if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)) { - rtw_p2p_enable23a(padapter, P2P_ROLE_DEVICE); - wdev_to_priv(padapter->rtw_wdev)->p2p_enabled = true; - } else { - rtw_p2p_set_pre_state(pwdinfo, rtw_p2p_state(pwdinfo)); - DBG_8723A("%s, role =%d, p2p_state =%d\n", __func__, - rtw_p2p_role(pwdinfo), - rtw_p2p_state(pwdinfo)); - } - rtw_p2p_set_state(pwdinfo, P2P_STATE_LISTEN); - - if (request->n_channels == 3 && - request->channels[0]->hw_value == 1 && - request->channels[1]->hw_value == 6 && - request->channels[2]->hw_value == 11) - social_channel = 1; - } -#endif /* CONFIG_8723AU_P2P */ if (request->ie && request->ie_len > 0) { rtw_cfg80211_set_probe_req_wpsp2pie(padapter, @@ -1651,20 +1498,6 @@ static int cfg80211_rtw_scan(struct wiphy *wiphy, need_indicate_scan_done = true; goto check_need_indicate_scan_done; } -#ifdef CONFIG_8723AU_P2P - if (!rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE) && - !rtw_p2p_chk_state(pwdinfo, P2P_STATE_IDLE)) { - rtw_p2p_set_state(pwdinfo, P2P_STATE_FIND_PHASE_SEARCH); - rtw_free_network_queue23a(padapter, true); - - if (social_channel == 0) - rtw_p2p_findphase_ex_set(pwdinfo, - P2P_FINDPHASE_EX_NONE); - else - rtw_p2p_findphase_ex_set(pwdinfo, - P2P_FINDPHASE_EX_SOCIAL_LAST); - } -#endif /* CONFIG_8723AU_P2P */ memset(ssid, 0, sizeof(struct cfg80211_ssid) * RTW_SSID_SCAN_AMOUNT); /* parsing request ssids, n_ssids */ @@ -2001,64 +1834,6 @@ static int rtw_cfg80211_set_wpa_ie(struct rtw_adapter *padapter, const u8 *pie, } } -#ifdef CONFIG_8723AU_P2P - { /* check p2p_ie for assoc req; */ - uint p2p_ielen = 0; - u8 *p2p_ie; - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - - p2p_ie = rtw_get_p2p_ie23a(buf, ielen, NULL, &p2p_ielen); - if (p2p_ie) { - DBG_8723A("%s p2p_assoc_req_ielen =%d\n", __func__, - p2p_ielen); - - if (pmlmepriv->p2p_assoc_req_ie) { - pmlmepriv->p2p_assoc_req_ie_len = 0; - kfree(pmlmepriv->p2p_assoc_req_ie); - pmlmepriv->p2p_assoc_req_ie = NULL; - } - - pmlmepriv->p2p_assoc_req_ie = - kmalloc(p2p_ielen, GFP_KERNEL); - if (pmlmepriv->p2p_assoc_req_ie == NULL) { - DBG_8723A("%s()-%d: kmalloc() ERROR!\n", - __func__, __LINE__); - goto exit; - } - memcpy(pmlmepriv->p2p_assoc_req_ie, p2p_ie, p2p_ielen); - pmlmepriv->p2p_assoc_req_ie_len = p2p_ielen; - } - } -#endif /* CONFIG_8723AU_P2P */ - -#ifdef CONFIG_8723AU_P2P - { /* check wfd_ie for assoc req; */ - uint wfd_ielen = 0; - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - - if (rtw_get_wfd_ie(buf, ielen, NULL, &wfd_ielen)) { - DBG_8723A("%s wfd_assoc_req_ielen =%d\n", __func__, - wfd_ielen); - - if (pmlmepriv->wfd_assoc_req_ie) { - pmlmepriv->wfd_assoc_req_ie_len = 0; - kfree(pmlmepriv->wfd_assoc_req_ie); - pmlmepriv->wfd_assoc_req_ie = NULL; - } - - pmlmepriv->wfd_assoc_req_ie = - kmalloc(wfd_ielen, GFP_KERNEL); - if (pmlmepriv->wfd_assoc_req_ie == NULL) { - DBG_8723A("%s()-%d: kmalloc() ERROR!\n", - __func__, __LINE__); - goto exit; - } - rtw_get_wfd_ie(buf, ielen, pmlmepriv->wfd_assoc_req_ie, - &pmlmepriv->wfd_assoc_req_ie_len); - } - } -#endif /* CONFIG_8723AU_P2P */ - /* TKIP and AES disallow multicast packets until installing group key */ if (padapter->securitypriv.dot11PrivacyAlgrthm == _TKIP_ || padapter->securitypriv.dot11PrivacyAlgrthm == _TKIP_WTMIC_ || @@ -2707,9 +2482,6 @@ static int rtw_cfg80211_monitor_if_xmit_entry(struct sk_buff *skb, struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; u32 len = skb->len; u8 category, action; -#ifdef CONFIG_8723AU_P2P - int type = -1; -#endif if (rtw_action_frame_parse23a(skb->data, len, &category, &action) == false) { @@ -2721,19 +2493,12 @@ static int rtw_cfg80211_monitor_if_xmit_entry(struct sk_buff *skb, DBG_8723A("RTW_Tx:da =" MAC_FMT " via " FUNC_NDEV_FMT "\n", MAC_ARG(dot11_hdr->addr1), FUNC_NDEV_ARG(ndev)); -#ifdef CONFIG_8723AU_P2P - type = rtw_p2p_check_frames(padapter, skb->data, len, true); - if (type >= 0) - goto dump; -#endif if (category == WLAN_CATEGORY_PUBLIC) DBG_8723A("RTW_Tx:%s\n", action_public_str23a(action)); else DBG_8723A("RTW_Tx:category(%u), action(%u)\n", category, action); -#ifdef CONFIG_8723AU_P2P -dump: -#endif + /* starting alloc mgmt frame to dump it */ pmgntframe = alloc_mgtxmitframe23a(pxmitpriv); if (pmgntframe == NULL) @@ -2749,16 +2514,6 @@ dump: pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET; memcpy(pframe, skb->data, len); -#ifdef CONFIG_8723AU_P2P - if (type >= 0) { - struct wifi_display_info *pwfd_info; - - pwfd_info = padapter->wdinfo.wfd_info; - - if (pwfd_info->wfd_enable) - rtw_append_wfd_ie(padapter, pframe, &len); - } -#endif /* CONFIG_8723AU_P2P */ pattrib->pktlen = len; /* update seq number */ @@ -2944,10 +2699,6 @@ static int rtw_add_beacon(struct rtw_adapter *adapter, const u8 *head, int ret = 0; u8 *pbuf = NULL; uint len, wps_ielen = 0; -#ifdef CONFIG_8723AU_P2P - uint p2p_ielen = 0; - u8 got_p2p_ie = false; -#endif struct mlme_priv *pmlmepriv = &adapter->mlmepriv; /* struct sta_priv *pstapriv = &padapter->stapriv; */ @@ -2975,16 +2726,6 @@ static int rtw_add_beacon(struct rtw_adapter *adapter, const u8 *head, &wps_ielen)) DBG_8723A("add bcn, wps_ielen =%d\n", wps_ielen); -#ifdef CONFIG_8723AU_P2P - /* check p2p ie if inclued */ - if (rtw_get_p2p_ie23a - (pbuf + _FIXED_IE_LENGTH_, len - _FIXED_IE_LENGTH_, NULL, - &p2p_ielen)) { - DBG_8723A("got p2p_ie, len =%d\n", p2p_ielen); - got_p2p_ie = true; - } -#endif - /* pbss_network->IEs will not include p2p_ie, wfd ie */ rtw_ies_remove_ie23a(pbuf, &len, _BEACON_IE_OFFSET_, WLAN_EID_VENDOR_SPECIFIC, P2P_OUI23A, 4); @@ -2992,38 +2733,7 @@ static int rtw_add_beacon(struct rtw_adapter *adapter, const u8 *head, WLAN_EID_VENDOR_SPECIFIC, WFD_OUI23A, 4); if (rtw_check_beacon_data23a(adapter, pbuf, len) == _SUCCESS) { -#ifdef CONFIG_8723AU_P2P - /* check p2p if enable */ - if (got_p2p_ie == true) { - struct mlme_ext_priv *pmlmeext = &adapter->mlmeextpriv; - struct wifidirect_info *pwdinfo = &adapter->wdinfo; - - if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)) { - DBG_8723A("Enable P2P function for the first " - "time\n"); - rtw_p2p_enable23a(adapter, P2P_ROLE_GO); - wdev_to_priv(adapter->rtw_wdev)->p2p_enabled = - true; - } else { - del_timer_sync(&pwdinfo->find_phase_timer); - del_timer_sync(&pwdinfo-> - restore_p2p_state_timer); - del_timer_sync(&pwdinfo->pre_tx_scan_timer); - - DBG_8723A("enter GO Mode, p2p_ielen =%d\n", - p2p_ielen); - - rtw_p2p_set_role(pwdinfo, P2P_ROLE_GO); - rtw_p2p_set_state(pwdinfo, P2P_STATE_GONEGO_OK); - pwdinfo->intent = 15; - } - - pwdinfo->operating_channel = pmlmeext->cur_channel; - } -#endif /* CONFIG_8723AU_P2P */ - ret = 0; - } else { ret = -EINVAL; } @@ -3220,9 +2930,6 @@ static int cfg80211_rtw_change_bss(struct wiphy *wiphy, struct net_device *ndev, void rtw_cfg80211_rx_action_p2p(struct rtw_adapter *padapter, u8 *pmgmt_frame, uint frame_len) { -#ifdef CONFIG_8723AU_P2P - int type; -#endif s32 freq; int channel; u8 category, action; @@ -3230,17 +2937,9 @@ void rtw_cfg80211_rx_action_p2p(struct rtw_adapter *padapter, u8 *pmgmt_frame, channel = rtw_get_oper_ch23a(padapter); DBG_8723A("RTW_Rx:cur_ch =%d\n", channel); -#ifdef CONFIG_8723AU_P2P - type = rtw_p2p_check_frames(padapter, pmgmt_frame, frame_len, false); - if (type >= 0) - goto indicate; -#endif rtw_action_frame_parse23a(pmgmt_frame, frame_len, &category, &action); DBG_8723A("RTW_Rx:category(%u), action(%u)\n", category, action); -#ifdef CONFIG_8723AU_P2P -indicate: -#endif if (channel <= RTW_CH_MAX_2G_CHANNEL) freq = ieee80211_channel_to_frequency(channel, IEEE80211_BAND_2GHZ); @@ -3255,9 +2954,6 @@ indicate: void rtw_cfg80211_rx_p2p_action_public(struct rtw_adapter *padapter, u8 *pmgmt_frame, uint frame_len) { -#ifdef CONFIG_8723AU_P2P - int type; -#endif s32 freq; int channel; u8 category, action; @@ -3265,23 +2961,9 @@ void rtw_cfg80211_rx_p2p_action_public(struct rtw_adapter *padapter, channel = rtw_get_oper_ch23a(padapter); DBG_8723A("RTW_Rx:cur_ch =%d\n", channel); -#ifdef CONFIG_8723AU_P2P - type = rtw_p2p_check_frames(padapter, pmgmt_frame, frame_len, false); - if (type >= 0) { - switch (type) { - case P2P_GO_NEGO_CONF: - case P2P_PROVISION_DISC_RESP: - rtw_clear_scan_deny(padapter); - } - goto indicate; - } -#endif rtw_action_frame_parse23a(pmgmt_frame, frame_len, &category, &action); DBG_8723A("RTW_Rx:category(%u), action(%u)\n", category, action); -#ifdef CONFIG_8723AU_P2P -indicate: -#endif if (channel <= RTW_CH_MAX_2G_CHANNEL) freq = ieee80211_channel_to_frequency(channel, IEEE80211_BAND_2GHZ); @@ -3321,346 +3003,6 @@ void rtw_cfg80211_rx_action(struct rtw_adapter *adapter, u8 *frame, rtw_cfg80211_rx_mgmt(adapter, freq, 0, frame, frame_len, GFP_ATOMIC); } -#ifdef CONFIG_8723AU_P2P -void rtw_cfg80211_issue_p2p_provision_request23a(struct rtw_adapter *padapter, - const u8 *buf, size_t len) -{ - u16 wps_devicepassword_id = 0x0000; - uint wps_devicepassword_id_len = 0; - u8 wpsie[255] = { 0x00 }, p2p_ie[255] = { 0x00 }; - uint p2p_ielen = 0; - uint wpsielen = 0; - u32 devinfo_contentlen = 0; - u8 devinfo_content[64] = { 0x00 }; - u16 capability = 0; - uint capability_len = 0; - - unsigned char category = WLAN_CATEGORY_PUBLIC; - u8 action = P2P_PUB_ACTION_ACTION; - u8 dialogToken = 1; - u32 p2poui = cpu_to_be32(P2POUI); - u8 oui_subtype = P2P_PROVISION_DISC_REQ; - u32 p2pielen = 0; -#ifdef CONFIG_8723AU_P2P - u32 wfdielen = 0; -#endif /* CONFIG_8723AU_P2P */ - - struct xmit_frame *pmgntframe; - struct pkt_attrib *pattrib; - unsigned char *pframe; - struct ieee80211_hdr *pwlanhdr, *hdr; - struct xmit_priv *pxmitpriv = &padapter->xmitpriv; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - - struct wifidirect_info *pwdinfo = &padapter->wdinfo; - u8 *frame_body = - (unsigned char *)(buf + sizeof(struct ieee80211_hdr_3addr)); - size_t frame_body_len = len - sizeof(struct ieee80211_hdr_3addr); - - DBG_8723A("[%s] In\n", __func__); - - hdr = (struct ieee80211_hdr *)buf; - /* prepare for building provision_request frame */ - memcpy(pwdinfo->tx_prov_disc_info.peerIFAddr, hdr->addr1, ETH_ALEN); - memcpy(pwdinfo->tx_prov_disc_info.peerDevAddr, hdr->addr1, ETH_ALEN); - - pwdinfo->tx_prov_disc_info.wps_config_method_request = - WPS_CM_PUSH_BUTTON; - - rtw_get_wps_ie23a(frame_body + _PUBLIC_ACTION_IE_OFFSET_, - frame_body_len - _PUBLIC_ACTION_IE_OFFSET_, wpsie, - &wpsielen); - rtw_get_wps_attr_content23a(wpsie, wpsielen, WPS_ATTR_DEVICE_PWID, - (u8 *)&wps_devicepassword_id, - &wps_devicepassword_id_len); - wps_devicepassword_id = be16_to_cpu(wps_devicepassword_id); - - switch (wps_devicepassword_id) { - case WPS_DPID_PIN: - pwdinfo->tx_prov_disc_info.wps_config_method_request = - WPS_CM_LABEL; - break; - case WPS_DPID_USER_SPEC: - pwdinfo->tx_prov_disc_info.wps_config_method_request = - WPS_CM_DISPLYA; - break; - case WPS_DPID_MACHINE_SPEC: - break; - case WPS_DPID_REKEY: - break; - case WPS_DPID_PBC: - pwdinfo->tx_prov_disc_info.wps_config_method_request = - WPS_CM_PUSH_BUTTON; - break; - case WPS_DPID_REGISTRAR_SPEC: - pwdinfo->tx_prov_disc_info.wps_config_method_request = - WPS_CM_KEYPAD; - break; - default: - break; - } - - if (rtw_get_p2p_ie23a(frame_body + _PUBLIC_ACTION_IE_OFFSET_, - frame_body_len - _PUBLIC_ACTION_IE_OFFSET_, - p2p_ie, &p2p_ielen)) { - rtw_get_p2p_attr23a_content(p2p_ie, p2p_ielen, - P2P_ATTR_DEVICE_INFO, devinfo_content, - &devinfo_contentlen); - rtw_get_p2p_attr23a_content(p2p_ie, p2p_ielen, P2P_ATTR_CAPABILITY, - (u8 *)&capability, &capability_len); - } - - /* start to build provision_request frame */ - memset(wpsie, 0, sizeof(wpsie)); - memset(p2p_ie, 0, sizeof(p2p_ie)); - p2p_ielen = 0; - - pmgntframe = alloc_mgtxmitframe23a(pxmitpriv); - if (pmgntframe == NULL) - return; - /* update attribute */ - pattrib = &pmgntframe->attrib; - update_mgntframe_attrib23a(padapter, pattrib); - - memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET); - - pframe = (u8 *) (pmgntframe->buf_addr) + TXDESC_OFFSET; - pwlanhdr = (struct ieee80211_hdr *)pframe; - - pwlanhdr->frame_control = 0; - - memcpy(pwlanhdr->addr1, pwdinfo->tx_prov_disc_info.peerDevAddr, - ETH_ALEN); - memcpy(pwlanhdr->addr2, myid(&padapter->eeprompriv), ETH_ALEN); - memcpy(pwlanhdr->addr3, pwdinfo->tx_prov_disc_info.peerDevAddr, - ETH_ALEN); - - SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq); - pmlmeext->mgnt_seq++; - SetFrameSubType(pframe, WIFI_ACTION); - - pframe += sizeof(struct ieee80211_hdr_3addr); - pattrib->pktlen = sizeof(struct ieee80211_hdr_3addr); - - pframe = rtw_set_fixed_ie23a(pframe, 1, &category, &pattrib->pktlen); - pframe = rtw_set_fixed_ie23a(pframe, 1, &action, &pattrib->pktlen); - pframe = rtw_set_fixed_ie23a(pframe, 4, (unsigned char *)&p2poui, - &pattrib->pktlen); - pframe = rtw_set_fixed_ie23a(pframe, 1, &oui_subtype, &pattrib->pktlen); - pframe = rtw_set_fixed_ie23a(pframe, 1, &dialogToken, &pattrib->pktlen); - - /* build_prov_disc_request_p2p_ie23a */ - /* P2P OUI */ - p2pielen = 0; - p2p_ie[p2pielen++] = 0x50; - p2p_ie[p2pielen++] = 0x6F; - p2p_ie[p2pielen++] = 0x9A; - p2p_ie[p2pielen++] = 0x09; /* WFA P2P v1.0 */ - - /* Commented by Albert 20110301 */ - /* According to the P2P Specification, the provision discovery request frame should contain 3 P2P attributes */ - /* 1. P2P Capability */ - /* 2. Device Info */ - /* 3. Group ID ( When joining an operating P2P Group ) */ - - /* P2P Capability ATTR */ - /* Type: */ - p2p_ie[p2pielen++] = P2P_ATTR_CAPABILITY; - - /* Length: */ - put_unaligned_le16(0x0002, p2p_ie + p2pielen); - p2pielen += 2; - - /* Value: */ - /* Device Capability Bitmap, 1 byte */ - /* Group Capability Bitmap, 1 byte */ - memcpy(p2p_ie + p2pielen, &capability, 2); - p2pielen += 2; - - /* Device Info ATTR */ - /* Type: */ - p2p_ie[p2pielen++] = P2P_ATTR_DEVICE_INFO; - - /* Length: */ - put_unaligned_le16(devinfo_contentlen, p2p_ie + p2pielen); - p2pielen += 2; - - /* Value: */ - memcpy(p2p_ie + p2pielen, devinfo_content, devinfo_contentlen); - p2pielen += devinfo_contentlen; - - pframe = rtw_set_ie23a(pframe, WLAN_EID_VENDOR_SPECIFIC, p2pielen, - (unsigned char *)p2p_ie, &p2p_ielen); - pattrib->pktlen += p2p_ielen; - - wpsielen = 0; - /* WPS OUI */ - *(u32 *)(wpsie) = cpu_to_be32(WPSOUI); - wpsielen += 4; - - /* WPS version */ - /* Type: */ - *(u16 *)(wpsie + wpsielen) = cpu_to_be16(WPS_ATTR_VER1); - wpsielen += 2; - - /* Length: */ - *(u16 *)(wpsie + wpsielen) = cpu_to_be16(0x0001); - wpsielen += 2; - - /* Value: */ - wpsie[wpsielen++] = WPS_VERSION_1; /* Version 1.0 */ - - /* Config Method */ - /* Type: */ - *(u16 *)(wpsie + wpsielen) = cpu_to_be16(WPS_ATTR_CONF_METHOD); - wpsielen += 2; - - /* Length: */ - *(u16 *)(wpsie + wpsielen) = cpu_to_be16(0x0002); - wpsielen += 2; - - /* Value: */ - *(u16 *)(wpsie + wpsielen) = - cpu_to_be16(pwdinfo->tx_prov_disc_info.wps_config_method_request); - wpsielen += 2; - - pframe = rtw_set_ie23a(pframe, WLAN_EID_VENDOR_SPECIFIC, wpsielen, - (unsigned char *)wpsie, &pattrib->pktlen); - -#ifdef CONFIG_8723AU_P2P - wfdielen = build_provdisc_req_wfd_ie(pwdinfo, pframe); - pframe += wfdielen; - pattrib->pktlen += wfdielen; -#endif /* CONFIG_8723AU_P2P */ - - pattrib->last_txcmdsz = pattrib->pktlen; - - /* dump_mgntframe23a(padapter, pmgntframe); */ - if (dump_mgntframe23a_and_wait_ack23a(padapter, pmgntframe) != _SUCCESS) - DBG_8723A("%s, ack to\n", __func__); -} - -static s32 cfg80211_rtw_remain_on_channel(struct wiphy *wiphy, - struct wireless_dev *wdev, - struct ieee80211_channel *channel, - unsigned int duration, u64 *cookie) -{ - s32 err = 0; - struct rtw_adapter *padapter = wiphy_to_adapter(wiphy); - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct wifidirect_info *pwdinfo = &padapter->wdinfo; - struct cfg80211_wifidirect_info *pcfg80211_wdinfo = - &padapter->cfg80211_wdinfo; - u8 remain_ch = - (u8) ieee80211_frequency_to_channel(channel->center_freq); - u8 ready_on_channel = false; - - DBG_8723A(FUNC_ADPT_FMT " ch:%u duration:%d\n", FUNC_ADPT_ARG(padapter), - remain_ch, duration); - - if (pcfg80211_wdinfo->is_ro_ch == true) { - DBG_8723A("%s, cancel ro ch timer\n", __func__); - - del_timer_sync(&padapter->cfg80211_wdinfo.remain_on_ch_timer); - -#ifdef CONFIG_8723AU_P2P - p2p_protocol_wk_hdl23a(padapter, P2P_RO_CH_WK); -#endif - } - - pcfg80211_wdinfo->is_ro_ch = true; - - if (_FAIL == rtw_pwr_wakeup(padapter)) { - err = -EFAULT; - goto exit; - } - - memcpy(&pcfg80211_wdinfo->remain_on_ch_channel, channel, - sizeof(struct ieee80211_channel)); - pcfg80211_wdinfo->remain_on_ch_cookie = *cookie; - - rtw_scan_abort23a(padapter); - if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)) { - rtw_p2p_enable23a(padapter, P2P_ROLE_DEVICE); - wdev_to_priv(padapter->rtw_wdev)->p2p_enabled = true; - } else { - rtw_p2p_set_pre_state(pwdinfo, rtw_p2p_state(pwdinfo)); - DBG_8723A("%s, role =%d, p2p_state =%d\n", __func__, - rtw_p2p_role(pwdinfo), rtw_p2p_state(pwdinfo)); - } - - rtw_p2p_set_state(pwdinfo, P2P_STATE_LISTEN); - - if (duration < 400) - duration = duration * 3; /* extend from exper. */ - - pcfg80211_wdinfo->restore_channel = pmlmeext->cur_channel; - - if (rtw_ch_set_search_ch23a(pmlmeext->channel_set, remain_ch) >= 0) { - if (remain_ch != pmlmeext->cur_channel) { - ready_on_channel = true; - } - } else { - DBG_8723A("%s remain_ch:%u not in channel plan!!!!\n", - __func__, remain_ch); - } - - /* call this after other things have been done */ - if (ready_on_channel == true) { - if (!check_fwstate(&padapter->mlmepriv, _FW_LINKED)) { - pmlmeext->cur_channel = remain_ch; - - set_channel_bwmode23a(padapter, remain_ch, - HAL_PRIME_CHNL_OFFSET_DONT_CARE, - HT_CHANNEL_WIDTH_20); - } - } - DBG_8723A("%s, set ro ch timer, duration =%d\n", __func__, duration); - mod_timer(&pcfg80211_wdinfo->remain_on_ch_timer, - jiffies + msecs_to_jiffies(duration)); - - rtw_cfg80211_ready_on_channel(padapter, *cookie, channel, channel_type, - duration, GFP_KERNEL); - - pwdinfo->listen_channel = pmlmeext->cur_channel; - -exit: - if (err) - pcfg80211_wdinfo->is_ro_ch = false; - - return err; -} - -static s32 cfg80211_rtw_cancel_remain_on_channel(struct wiphy *wiphy, - struct wireless_dev *wdev, - u64 cookie) -{ - s32 err = 0; - struct rtw_adapter *padapter = wiphy_to_adapter(wiphy); - struct wifidirect_info *pwdinfo = &padapter->wdinfo; - struct cfg80211_wifidirect_info *pcfg80211_wdinfo = - &padapter->cfg80211_wdinfo; - - DBG_8723A(FUNC_ADPT_FMT "\n", FUNC_ADPT_ARG(padapter)); - - if (pcfg80211_wdinfo->is_ro_ch == true) { - DBG_8723A("%s, cancel ro ch timer\n", __func__); - del_timer_sync(&padapter->cfg80211_wdinfo.remain_on_ch_timer); -#ifdef CONFIG_8723AU_P2P - p2p_protocol_wk_hdl23a(padapter, P2P_RO_CH_WK); -#endif - } - - rtw_p2p_set_state(pwdinfo, rtw_p2p_pre_state(pwdinfo)); - DBG_8723A("%s, role =%d, p2p_state =%d\n", __func__, - rtw_p2p_role(pwdinfo), rtw_p2p_state(pwdinfo)); - pcfg80211_wdinfo->is_ro_ch = false; - - return err; -} - -#endif /* CONFIG_8723AU_P2P */ - static int _cfg80211_rtw_mgmt_tx(struct rtw_adapter *padapter, u8 tx_ch, const u8 *buf, size_t len) { @@ -3672,7 +3014,6 @@ static int _cfg80211_rtw_mgmt_tx(struct rtw_adapter *padapter, u8 tx_ch, struct ieee80211_hdr *pwlanhdr; struct xmit_priv *pxmitpriv = &padapter->xmitpriv; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - /* struct cfg80211_wifidirect_info *pcfg80211_wdinfo = &padapter->cfg80211_wdinfo; */ if (_FAIL == rtw_pwr_wakeup(padapter)) { ret = -EFAULT; @@ -3717,18 +3058,6 @@ static int _cfg80211_rtw_mgmt_tx(struct rtw_adapter *padapter, u8 tx_ch, pattrib->seqnum = pmlmeext->mgnt_seq; pmlmeext->mgnt_seq++; -#ifdef CONFIG_8723AU_P2P - { - struct wifi_display_info *pwfd_info; - - pwfd_info = padapter->wdinfo.wfd_info; - - if (true == pwfd_info->wfd_enable) { - rtw_append_wfd_ie(padapter, pframe, &pattrib->pktlen); - } - } -#endif /* CONFIG_8723AU_P2P */ - pattrib->last_txcmdsz = pattrib->pktlen; if (dump_mgntframe23a_and_wait_ack23a(padapter, pmgntframe) != _SUCCESS) { @@ -3798,20 +3127,12 @@ static int cfg80211_rtw_mgmt_tx(struct wiphy *wiphy, struct wireless_dev *wdev, DBG_8723A("RTW_Tx:tx_ch =%d, da =" MAC_FMT "\n", tx_ch, MAC_ARG(hdr->addr1)); -#ifdef CONFIG_8723AU_P2P - type = rtw_p2p_check_frames(padapter, buf, len, true); - if (type >= 0) - goto dump; -#endif if (category == WLAN_CATEGORY_PUBLIC) DBG_8723A("RTW_Tx:%s\n", action_public_str23a(action)); else DBG_8723A("RTW_Tx:category(%u), action(%u)\n", category, action); -#ifdef CONFIG_8723AU_P2P -dump: -#endif do { dump_cnt++; tx_ret = _cfg80211_rtw_mgmt_tx(padapter, tx_ch, buf, len); @@ -3861,11 +3182,6 @@ static int rtw_cfg80211_set_beacon_wpsp2pie(struct net_device *ndev, char *buf, int ret = 0; uint wps_ielen = 0; u8 *wps_ie; -#ifdef CONFIG_8723AU_P2P - u32 p2p_ielen = 0; - u32 wfd_ielen = 0; - u8 *p2p_ie; -#endif #ifdef CONFIG_8723AU_AP_MODE u8 wps_oui[8] = { 0x0, 0x50, 0xf2, 0x04 }; #endif @@ -3901,55 +3217,6 @@ static int rtw_cfg80211_set_beacon_wpsp2pie(struct net_device *ndev, char *buf, wps_oui, true); #endif } -#ifdef CONFIG_8723AU_P2P - p2p_ie = rtw_get_p2p_ie23a(buf, len, NULL, &p2p_ielen); - if (p2p_ie) { - DBG_8723A("bcn_p2p_ielen =%d\n", p2p_ielen); - - if (pmlmepriv->p2p_beacon_ie) { - pmlmepriv->p2p_beacon_ie_len = 0; - kfree(pmlmepriv->p2p_beacon_ie); - pmlmepriv->p2p_beacon_ie = NULL; - } - - pmlmepriv->p2p_beacon_ie = - kmalloc(p2p_ielen, GFP_KERNEL); - if (pmlmepriv->p2p_beacon_ie == NULL) { - DBG_8723A("%s()-%d: kmalloc() ERROR!\n", - __func__, __LINE__); - return -EINVAL; - } - - memcpy(pmlmepriv->p2p_beacon_ie, p2p_ie, p2p_ielen); - pmlmepriv->p2p_beacon_ie_len = p2p_ielen; - } -#endif /* CONFIG_8723AU_P2P */ - - /* buf += p2p_ielen; */ - /* len -= p2p_ielen; */ - -#ifdef CONFIG_8723AU_P2P - if (rtw_get_wfd_ie(buf, len, NULL, &wfd_ielen)) { - DBG_8723A("bcn_wfd_ielen =%d\n", wfd_ielen); - - if (pmlmepriv->wfd_beacon_ie) { - pmlmepriv->wfd_beacon_ie_len = 0; - kfree(pmlmepriv->wfd_beacon_ie); - pmlmepriv->wfd_beacon_ie = NULL; - } - - pmlmepriv->wfd_beacon_ie = - kmalloc(wfd_ielen, GFP_KERNEL); - if (pmlmepriv->wfd_beacon_ie == NULL) { - DBG_8723A("%s()-%d: kmalloc() ERROR!\n", - __func__, __LINE__); - return -EINVAL; - - } - rtw_get_wfd_ie(buf, len, pmlmepriv->wfd_beacon_ie, - &pmlmepriv->wfd_beacon_ie_len); - } -#endif /* CONFIG_8723AU_P2P */ pmlmeext->bstart_bss = true; @@ -3963,11 +3230,6 @@ static int rtw_cfg80211_set_probe_resp_wpsp2pie(struct net_device *net, { struct rtw_adapter *padapter = netdev_priv(net); struct mlme_priv *pmlmepriv = &padapter->mlmepriv; -#ifdef CONFIG_8723AU_P2P - u32 p2p_ielen = 0; - u8 *p2p_ie; - u32 wfd_ielen = 0; -#endif int ret = 0; uint wps_ielen = 0; u8 *wps_ie; @@ -4011,100 +3273,6 @@ static int rtw_cfg80211_set_probe_resp_wpsp2pie(struct net_device *net, } - /* buf += wps_ielen; */ - /* len -= wps_ielen; */ - -#ifdef CONFIG_8723AU_P2P - p2p_ie = rtw_get_p2p_ie23a(buf, len, NULL, &p2p_ielen); - if (p2p_ie) { - u8 is_GO = false; - u32 attr_contentlen = 0; - u16 cap_attr = 0; - - DBG_8723A("probe_resp_p2p_ielen =%d\n", p2p_ielen); - - /* Check P2P Capability ATTR */ - if (rtw_get_p2p_attr23a_content(p2p_ie, p2p_ielen, - P2P_ATTR_CAPABILITY, - (u8 *) &cap_attr, - (uint *) &attr_contentlen)) { - u8 grp_cap = 0; - /* DBG_8723A( "[%s] Got P2P Capability Attr!!\n", __func__ ); */ - cap_attr = le16_to_cpu(cap_attr); - grp_cap = (u8) ((cap_attr >> 8) & 0xff); - - is_GO = (grp_cap & BIT(0)) ? true : false; - - if (is_GO) - DBG_8723A - ("Got P2P Capability Attr, grp_cap" - "= 0x%x, is_GO\n", grp_cap); - } - - if (is_GO == false) { - if (pmlmepriv->p2p_probe_resp_ie) { - pmlmepriv->p2p_probe_resp_ie_len = 0; - kfree(pmlmepriv->p2p_probe_resp_ie); - pmlmepriv->p2p_probe_resp_ie = NULL; - } - - pmlmepriv->p2p_probe_resp_ie = - kmalloc(p2p_ielen, GFP_KERNEL); - if (pmlmepriv->p2p_probe_resp_ie == NULL) { - DBG_8723A("%s()-%d: kmalloc() ERROR!\n", - __func__, __LINE__); - return -EINVAL; - } - memcpy(pmlmepriv->p2p_probe_resp_ie, p2p_ie, - p2p_ielen); - pmlmepriv->p2p_probe_resp_ie_len = p2p_ielen; - } else { - if (pmlmepriv->p2p_go_probe_resp_ie) { - pmlmepriv->p2p_go_probe_resp_ie_len = 0; - kfree(pmlmepriv->p2p_go_probe_resp_ie); - pmlmepriv->p2p_go_probe_resp_ie = NULL; - } - - pmlmepriv->p2p_go_probe_resp_ie = - kmalloc(p2p_ielen, GFP_KERNEL); - if (pmlmepriv->p2p_go_probe_resp_ie == NULL) { - DBG_8723A("%s()-%d: kmalloc() ERROR!\n", - __func__, __LINE__); - return -EINVAL; - - } - memcpy(pmlmepriv->p2p_go_probe_resp_ie, - p2p_ie, p2p_ielen); - pmlmepriv->p2p_go_probe_resp_ie_len = p2p_ielen; - } - } -#endif /* CONFIG_8723AU_P2P */ - - /* buf += p2p_ielen; */ - /* len -= p2p_ielen; */ - -#ifdef CONFIG_8723AU_P2P - if (rtw_get_wfd_ie(buf, len, NULL, &wfd_ielen)) { - DBG_8723A("probe_resp_wfd_ielen =%d\n", wfd_ielen); - - if (pmlmepriv->wfd_probe_resp_ie) { - pmlmepriv->wfd_probe_resp_ie_len = 0; - kfree(pmlmepriv->wfd_probe_resp_ie); - pmlmepriv->wfd_probe_resp_ie = NULL; - } - - pmlmepriv->wfd_probe_resp_ie = - kmalloc(wfd_ielen, GFP_KERNEL); - if (pmlmepriv->wfd_probe_resp_ie == NULL) { - DBG_8723A("%s()-%d: kmalloc() ERROR!\n", - __func__, __LINE__); - return -EINVAL; - - } - rtw_get_wfd_ie(buf, len, pmlmepriv->wfd_probe_resp_ie, - &pmlmepriv->wfd_probe_resp_ie_len); - } -#endif /* CONFIG_8723AU_P2P */ } return ret; @@ -4145,17 +3313,10 @@ int rtw_cfg80211_set_mgnt_wpsp2pie(struct net_device *net, char *buf, int len, { int ret = 0; uint wps_ielen = 0; -#ifdef CONFIG_8723AU_P2P - u32 p2p_ielen = 0; -#endif DBG_8723A("%s, ielen =%d\n", __func__, len); - if ((rtw_get_wps_ie23a(buf, len, NULL, &wps_ielen) && (wps_ielen > 0)) -#ifdef CONFIG_8723AU_P2P - || (rtw_get_p2p_ie23a(buf, len, NULL, &p2p_ielen) && (p2p_ielen > 0)) -#endif - ) { + if (rtw_get_wps_ie23a(buf, len, NULL, &wps_ielen) && (wps_ielen > 0)) { if (net) { switch (type) { case 0x1: /* BEACON */ @@ -4218,11 +3379,6 @@ static struct cfg80211_ops rtw_cfg80211_ops = { .change_bss = cfg80211_rtw_change_bss, #endif /* CONFIG_8723AU_AP_MODE */ -#ifdef CONFIG_8723AU_P2P - .remain_on_channel = cfg80211_rtw_remain_on_channel, - .cancel_remain_on_channel = cfg80211_rtw_cancel_remain_on_channel, -#endif - .mgmt_tx = cfg80211_rtw_mgmt_tx, .mgmt_frame_register = cfg80211_rtw_mgmt_frame_register, }; @@ -4325,9 +3481,6 @@ static void rtw_cfg80211_preinit_wiphy(struct rtw_adapter *padapter, BIT(NL80211_IFTYPE_ADHOC) | #ifdef CONFIG_8723AU_AP_MODE BIT(NL80211_IFTYPE_AP) | BIT(NL80211_IFTYPE_MONITOR) | -#endif -#if defined(CONFIG_8723AU_P2P) - BIT(NL80211_IFTYPE_P2P_CLIENT) | BIT(NL80211_IFTYPE_P2P_GO) | #endif 0; diff --git a/drivers/staging/rtl8723au/os_dep/os_intfs.c b/drivers/staging/rtl8723au/os_dep/os_intfs.c index 7c7c2c93e413..49da7dd18171 100644 --- a/drivers/staging/rtl8723au/os_dep/os_intfs.c +++ b/drivers/staging/rtl8723au/os_dep/os_intfs.c @@ -455,9 +455,6 @@ static u8 rtw_init_default_value(struct rtw_adapter *padapter) padapter->bWritePortCancel = false; padapter->bRxRSSIDisplay = 0; padapter->bNotifyChannelChange = 0; -#ifdef CONFIG_8723AU_P2P - padapter->bShowGetP2PState = 1; -#endif return ret; } @@ -520,17 +517,6 @@ u8 rtw_init_drv_sw23a(struct rtw_adapter *padapter) goto exit; } -#ifdef CONFIG_8723AU_P2P - rtw_init_wifidirect_timers23a(padapter); - init_wifidirect_info23a(padapter, P2P_ROLE_DISABLE); - reset_global_wifidirect_info23a(padapter); - rtw_init_cfg80211_wifidirect_info(padapter); -#ifdef CONFIG_8723AU_P2P - if (rtw_init_wifi_display_info(padapter) == _FAIL) - RT_TRACE(_module_os_intfs_c_, _drv_err_, - ("\n Can't init init_wifi_display_info\n")); -#endif -#endif /* CONFIG_8723AU_P2P */ if (init_mlme_ext_priv23a(padapter) == _FAIL) { RT_TRACE(_module_os_intfs_c_, _drv_err_, @@ -599,10 +585,6 @@ void rtw_cancel_all_timer23a(struct rtw_adapter *padapter) del_timer_sync(&padapter->pwrctrlpriv.pwr_state_check_timer); -#ifdef CONFIG_8723AU_P2P - del_timer_sync(&padapter->cfg80211_wdinfo.remain_on_ch_timer); -#endif /* CONFIG_8723AU_P2P */ - del_timer_sync(&padapter->mlmepriv.set_scan_deny_timer); rtw_clear_scan_deny(padapter); RT_TRACE(_module_os_intfs_c_, _drv_info_, @@ -615,26 +597,8 @@ void rtw_cancel_all_timer23a(struct rtw_adapter *padapter) u8 rtw_free_drv_sw23a(struct rtw_adapter *padapter) { -#ifdef CONFIG_8723AU_P2P - struct wifidirect_info *pwdinfo; -#endif - RT_TRACE(_module_os_intfs_c_, _drv_info_, ("==>rtw_free_drv_sw23a")); - /* we can call rtw_p2p_enable23a here, but: - * 1. rtw_p2p_enable23a may have IO operation - * 2. rtw_p2p_enable23a is bundled with wext interface - */ -#ifdef CONFIG_8723AU_P2P - pwdinfo = &padapter->wdinfo; - if (!rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)) { - del_timer_sync(&pwdinfo->find_phase_timer); - del_timer_sync(&pwdinfo->restore_p2p_state_timer); - del_timer_sync(&pwdinfo->pre_tx_scan_timer); - rtw_p2p_set_state(pwdinfo, P2P_STATE_NONE); - } -#endif - free_mlme_ext_priv23a(&padapter->mlmeextpriv); rtw_free_cmd_priv23a(&padapter->cmdpriv); @@ -945,12 +909,6 @@ static int netdev_close(struct net_device *pnetdev) rtw_led_control(padapter, LED_CTL_POWER_OFF); } -#ifdef CONFIG_8723AU_P2P - if (wdev_to_priv(padapter->rtw_wdev)->p2p_enabled) - wdev_to_priv(padapter->rtw_wdev)->p2p_enabled = false; - rtw_p2p_enable23a(padapter, P2P_ROLE_DISABLE); -#endif /* CONFIG_8723AU_P2P */ - rtw_scan_abort23a(padapter); /* set this at the end */ padapter->rtw_wdev->iftype = NL80211_IFTYPE_MONITOR; diff --git a/drivers/staging/rtl8723au/os_dep/usb_intf.c b/drivers/staging/rtl8723au/os_dep/usb_intf.c index dd5899f21388..31ab34601bab 100644 --- a/drivers/staging/rtl8723au/os_dep/usb_intf.c +++ b/drivers/staging/rtl8723au/os_dep/usb_intf.c @@ -662,10 +662,6 @@ static struct rtw_adapter *rtw_usb_if1_init(struct dvobj_priv *dvobj, /* set mac addr */ rtw_macaddr_cfg23a(padapter->eeprompriv.mac_addr); -#ifdef CONFIG_8723AU_P2P - rtw_init_wifidirect_addrs23a(padapter, padapter->eeprompriv.mac_addr, - padapter->eeprompriv.mac_addr); -#endif DBG_8723A("bDriverStopped:%d, bSurpriseRemoved:%d, bup:%d, hw_init_completed:%d\n", padapter->bDriverStopped, padapter->bSurpriseRemoved, -- cgit v1.2.3 From bad69af0b9fd3d20b74de1202cf13b0e6c4878bb Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:43:36 +0200 Subject: staging: rtl8723au: Remove another stack of unused P2P related #defines Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/include/wifi.h | 169 ------------------------------- 1 file changed, 169 deletions(-) diff --git a/drivers/staging/rtl8723au/include/wifi.h b/drivers/staging/rtl8723au/include/wifi.h index 41af702121c4..57ad44ec0aa8 100644 --- a/drivers/staging/rtl8723au/include/wifi.h +++ b/drivers/staging/rtl8723au/include/wifi.h @@ -459,72 +459,6 @@ struct ADDBA_request { #define WPS_ASSOC_STATE_ASSOCIATION_FAILURE 0x03 #define WPS_ASSOC_STATE_IP_FAILURE 0x04 -/* =====================P2P Section===================== */ -/* For P2P */ -#define P2POUI 0x506F9A09 - -/* P2P Attribute ID */ -#define P2P_ATTR_STATUS 0x00 -#define P2P_ATTR_MINOR_REASON_CODE 0x01 -#define P2P_ATTR_CAPABILITY 0x02 -#define P2P_ATTR_DEVICE_ID 0x03 -#define P2P_ATTR_GO_INTENT 0x04 -#define P2P_ATTR_CONF_TIMEOUT 0x05 -#define P2P_ATTR_LISTEN_CH 0x06 -#define P2P_ATTR_GROUP_BSSID 0x07 -#define P2P_ATTR_EX_LISTEN_TIMING 0x08 -#define P2P_ATTR_INTENTED_IF_ADDR 0x09 -#define P2P_ATTR_MANAGEABILITY 0x0A -#define P2P_ATTR_CH_LIST 0x0B -#define P2P_ATTR_NOA 0x0C -#define P2P_ATTR_DEVICE_INFO 0x0D -#define P2P_ATTR_GROUP_INFO 0x0E -#define P2P_ATTR_GROUP_ID 0x0F -#define P2P_ATTR_INTERFACE 0x10 -#define P2P_ATTR_OPERATING_CH 0x11 -#define P2P_ATTR_INVITATION_FLAGS 0x12 - -/* Value of Status Attribute */ -#define P2P_STATUS_SUCCESS 0x00 -#define P2P_STATUS_FAIL_INFO_UNAVAILABLE 0x01 -#define P2P_STATUS_FAIL_INCOMPATIBLE_PARAM 0x02 -#define P2P_STATUS_FAIL_LIMIT_REACHED 0x03 -#define P2P_STATUS_FAIL_INVALID_PARAM 0x04 -#define P2P_STATUS_FAIL_REQUEST_UNABLE 0x05 -#define P2P_STATUS_FAIL_PREVOUS_PROTO_ERR 0x06 -#define P2P_STATUS_FAIL_NO_COMMON_CH 0x07 -#define P2P_STATUS_FAIL_UNKNOWN_P2PGROUP 0x08 -#define P2P_STATUS_FAIL_BOTH_GOINTENT_15 0x09 -#define P2P_STATUS_FAIL_INCOMPATIBLE_PROVSION 0x0A -#define P2P_STATUS_FAIL_USER_REJECT 0x0B - -/* Value of Inviation Flags Attribute */ -#define P2P_INVITATION_FLAGS_PERSISTENT BIT(0) - -#define DMP_P2P_DEVCAP_SUPPORT (P2P_DEVCAP_SERVICE_DISCOVERY | \ - P2P_DEVCAP_CLIENT_DISCOVERABILITY | \ - P2P_DEVCAP_CONCURRENT_OPERATION | \ - P2P_DEVCAP_INVITATION_PROC) - -#define DMP_P2P_GRPCAP_SUPPORT (P2P_GRPCAP_INTRABSS) - -/* Value of Device Capability Bitmap */ -#define P2P_DEVCAP_SERVICE_DISCOVERY BIT(0) -#define P2P_DEVCAP_CLIENT_DISCOVERABILITY BIT(1) -#define P2P_DEVCAP_CONCURRENT_OPERATION BIT(2) -#define P2P_DEVCAP_INFRA_MANAGED BIT(3) -#define P2P_DEVCAP_DEVICE_LIMIT BIT(4) -#define P2P_DEVCAP_INVITATION_PROC BIT(5) - -/* Value of Group Capability Bitmap */ -#define P2P_GRPCAP_GO BIT(0) -#define P2P_GRPCAP_PERSISTENT_GROUP BIT(1) -#define P2P_GRPCAP_GROUP_LIMIT BIT(2) -#define P2P_GRPCAP_INTRABSS BIT(3) -#define P2P_GRPCAP_CROSS_CONN BIT(4) -#define P2P_GRPCAP_PERSISTENT_RECONN BIT(5) -#define P2P_GRPCAP_GROUP_FORMATION BIT(6) - /* P2P Public Action Frame ( Management Frame ) */ #define P2P_PUB_ACTION_ACTION 0x09 @@ -539,37 +473,6 @@ struct ADDBA_request { #define P2P_PROVISION_DISC_REQ 7 #define P2P_PROVISION_DISC_RESP 8 -/* P2P Action Frame Type */ -#define P2P_NOTICE_OF_ABSENCE 0 -#define P2P_PRESENCE_REQUEST 1 -#define P2P_PRESENCE_RESPONSE 2 -#define P2P_GO_DISC_REQUEST 3 - - -#define P2P_MAX_PERSISTENT_GROUP_NUM 10 - -#define P2P_PROVISIONING_SCAN_CNT 3 - -#define P2P_WILDCARD_SSID_LEN 7 - -#define P2P_FINDPHASE_EX_NONE 0 /* default value, used when: (1)p2p disabed or (2)p2p enabled but only do 1 scan phase */ -#define P2P_FINDPHASE_EX_FULL 1 /* used when p2p enabled and want to do 1 scan phase and P2P_FINDPHASE_EX_MAX-1 find phase */ -#define P2P_FINDPHASE_EX_SOCIAL_FIRST (P2P_FINDPHASE_EX_FULL+1) -#define P2P_FINDPHASE_EX_MAX 4 -#define P2P_FINDPHASE_EX_SOCIAL_LAST P2P_FINDPHASE_EX_MAX - -#define P2P_PROVISION_TIMEOUT 5000 /*5 sec timeout for sending the provision discovery request */ -#define P2P_CONCURRENT_PROVISION_TIMEOUT 3000 /*3 sec timeout for sending the provision discovery request under concurrent mode */ -#define P2P_GO_NEGO_TIMEOUT 5000 /*5 sec timeout for receiving the group negotation response */ -#define P2P_CONCURRENT_GO_NEGO_TIMEOUT 3000 /*3 sec timeout for sending the negotiation request under concurrent mode */ -#define P2P_TX_PRESCAN_TIMEOUT 100 /*100ms */ -#define P2P_INVITE_TIMEOUT 5000 /*5 sec timeout for sending the invitation request */ -#define P2P_CONCURRENT_INVITE_TIMEOUT 3000 /*3 sec timeout for sending the invitation request under concurrent mode */ -#define P2P_RESET_SCAN_CH 25000 /*25 sec t/o to reset the scan channel ( based on channel plan ) */ -#define P2P_MAX_INTENT 15 - -#define P2P_MAX_NOA_NUM 2 - /* WPS Configuration Method */ #define WPS_CM_NONE 0x0000 #define WPS_CM_LABEL 0x0004 @@ -584,76 +487,4 @@ struct ADDBA_request { #define WPS_CM_SW_DISPLAY_PIN 0x2008 #define WPS_CM_LCD_DISPLAY_PIN 0x4008 -enum P2P_ROLE { - P2P_ROLE_DISABLE = 0, - P2P_ROLE_DEVICE = 1, - P2P_ROLE_CLIENT = 2, - P2P_ROLE_GO = 3 -}; - -enum P2P_STATE { - P2P_STATE_NONE = 0, /*P2P disable */ - P2P_STATE_IDLE = 1, /*P2P had enabled and do nothing */ - P2P_STATE_LISTEN = 2, /*In pure listen state */ - P2P_STATE_SCAN = 3, /*In scan phase */ - P2P_STATE_FIND_PHASE_LISTEN = 4, /*In the listen state of find phase */ - P2P_STATE_FIND_PHASE_SEARCH = 5, /*In the search state of find phase */ - P2P_STATE_TX_PROVISION_DIS_REQ = 6, /*In P2P provisioning discovery */ - P2P_STATE_RX_PROVISION_DIS_RSP = 7, - P2P_STATE_RX_PROVISION_DIS_REQ = 8, - P2P_STATE_GONEGO_ING = 9, /*Doing the group owner negoitation handshake */ - P2P_STATE_GONEGO_OK = 10, /*finish the group negoitation handshake with success */ - P2P_STATE_GONEGO_FAIL = 11, /*finish the group negoitation handshake with failure */ - P2P_STATE_RECV_INVITE_REQ_MATCH = 12, /*receiving the P2P Inviation request and match with the profile. */ - P2P_STATE_PROVISIONING_ING = 13, /*Doing the P2P WPS */ - P2P_STATE_PROVISIONING_DONE = 14, /*Finish the P2P WPS */ - P2P_STATE_TX_INVITE_REQ = 15, /*Transmit the P2P Invitation request */ - P2P_STATE_RX_INVITE_RESP_OK = 16, /*Receiving the P2P Invitation response */ - P2P_STATE_RECV_INVITE_REQ_DISMATCH = 17,/*receiving the P2P Inviation request and dismatch with the profile. */ - P2P_STATE_RECV_INVITE_REQ_GO = 18, /*receiving the P2P Inviation request and this wifi is GO. */ - P2P_STATE_RECV_INVITE_REQ_JOIN = 19, /*receiving the P2P Inviation request to join an existing P2P Group. */ - P2P_STATE_RX_INVITE_RESP_FAIL = 20, /*receiving the P2P Inviation response with failure */ - P2P_STATE_RX_INFOR_NOREADY = 21, /*receiving p2p negotiation response with information is not available */ - P2P_STATE_TX_INFOR_NOREADY = 22, /*sending p2p negotiation response with information is not available */ -}; - -enum P2P_WPSINFO { - P2P_NO_WPSINFO = 0, - P2P_GOT_WPSINFO_PEER_DISPLAY_PIN = 1, - P2P_GOT_WPSINFO_SELF_DISPLAY_PIN = 2, - P2P_GOT_WPSINFO_PBC = 3, -}; - -#define P2P_PRIVATE_IOCTL_SET_LEN 64 - -enum P2P_PROTO_WK_ID { - P2P_FIND_PHASE_WK = 0, - P2P_RESTORE_STATE_WK = 1, - P2P_PRE_TX_PROVDISC_PROCESS_WK = 2, - P2P_PRE_TX_NEGOREQ_PROCESS_WK = 3, - P2P_PRE_TX_INVITEREQ_PROCESS_WK = 4, - P2P_AP_P2P_CH_SWITCH_PROCESS_WK = 5, - P2P_RO_CH_WK = 6, -}; - -/* =====================WFD Section===================== */ -/* For Wi-Fi Display */ -#define WFD_ATTR_DEVICE_INFO 0x00 -#define WFD_ATTR_ASSOC_BSSID 0x01 -#define WFD_ATTR_COUPLED_SINK_INFO 0x06 -#define WFD_ATTR_LOCAL_IP_ADDR 0x08 -#define WFD_ATTR_SESSION_INFO 0x09 -#define WFD_ATTR_ALTER_MAC 0x0a - -/* For WFD Device Information Attribute */ -#define WFD_DEVINFO_SOURCE 0x0000 -#define WFD_DEVINFO_PSINK 0x0001 -#define WFD_DEVINFO_SSINK 0x0002 -#define WFD_DEVINFO_DUAL 0x0003 - -#define WFD_DEVINFO_SESSION_AVAIL 0x0010 -#define WFD_DEVINFO_WSD 0x0040 -#define WFD_DEVINFO_PC_TDLS 0x0080 -#define WFD_DEVINFO_HDCP_SUPPORT 0x0100 - #endif /* _WIFI_H_ */ -- cgit v1.2.3 From 7c2f97b2485fde4026c92301ba4d1d975d52b845 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:43:37 +0200 Subject: staging: rtl8723au: rtw_restructure_ht_ie23a(): use cfg80211_find_ie() Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme.c b/drivers/staging/rtl8723au/core/rtw_mlme.c index 67df0d7bd116..d4a78c8b05be 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme.c @@ -2207,11 +2207,12 @@ void rtw_joinbss_reset23a(struct rtw_adapter *padapter) /* the fucntion is >= passive_level */ unsigned int rtw_restructure_ht_ie23a(struct rtw_adapter *padapter, u8 *in_ie, - u8 *out_ie, uint in_len, uint *pout_len) + u8 *out_ie, uint in_len, uint *pout_len) { - u32 ielen, out_len; + u32 out_len; int max_rx_ampdu_factor; - unsigned char *p, *pframe; + unsigned char *pframe; + const u8 *p; struct ieee80211_ht_cap ht_capie; unsigned char WMM_IE[] = {0x00, 0x50, 0xf2, 0x02, 0x00, 0x01, 0x00}; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; @@ -2220,10 +2221,9 @@ unsigned int rtw_restructure_ht_ie23a(struct rtw_adapter *padapter, u8 *in_ie, phtpriv->ht_option = false; - p = rtw_get_ie23a(in_ie + 12, WLAN_EID_HT_CAPABILITY, &ielen, - in_len - 12); + p = cfg80211_find_ie(WLAN_EID_HT_CAPABILITY, in_ie + 12, in_len -12); - if (p && ielen > 0) { + if (p && p[1] > 0) { u32 rx_packet_offset, max_recvbuf_sz; if (pqospriv->qos_option == 0) { out_len = *pout_len; @@ -2264,13 +2264,13 @@ unsigned int rtw_restructure_ht_ie23a(struct rtw_adapter *padapter, u8 *in_ie, phtpriv->ht_option = true; - p = rtw_get_ie23a(in_ie + 12, WLAN_EID_HT_OPERATION, &ielen, - in_len-12); - if (p && (ielen == sizeof(struct ieee80211_ht_addt_info))) { + p = cfg80211_find_ie(WLAN_EID_HT_OPERATION, in_ie + 12, + in_len -12); + if (p && (p[1] == sizeof(struct ieee80211_ht_addt_info))) { out_len = *pout_len; pframe = rtw_set_ie23a(out_ie + out_len, WLAN_EID_HT_OPERATION, - ielen, p + 2 , pout_len); + p[1], p + 2 , pout_len); } } -- cgit v1.2.3 From 2403ea62b5bf274f0044d3abf427372f891742f9 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:43:38 +0200 Subject: staging: rtl8723au: rtw_update_ht_ie23a(): use cfg80211_find_ie() Switch to using cfg80211_find_ie() and remove commented out code. Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme.c | 63 ++++++++++++++----------------- 1 file changed, 29 insertions(+), 34 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme.c b/drivers/staging/rtl8723au/core/rtw_mlme.c index d4a78c8b05be..24a4338aafe8 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme.c @@ -2280,18 +2280,14 @@ unsigned int rtw_restructure_ht_ie23a(struct rtw_adapter *padapter, u8 *in_ie, /* the fucntion is > passive_level (in critical_section) */ void rtw_update_ht_cap23a(struct rtw_adapter *padapter, u8 *pie, uint ie_len) { - u8 *p, max_ampdu_sz; - int len; - /* struct sta_info *bmc_sta, *psta; */ + u8 max_ampdu_sz; + const u8 *p; struct ieee80211_ht_cap *pht_capie; struct ieee80211_ht_addt_info *pht_addtinfo; - /* struct recv_reorder_ctrl *preorder_ctrl; */ - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct ht_priv *phtpriv = &pmlmepriv->htpriv; - /* struct recv_priv *precvpriv = &padapter->recvpriv; */ + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct ht_priv *phtpriv = &pmlmepriv->htpriv; struct registry_priv *pregistrypriv = &padapter->registrypriv; - /* struct wlan_network *pcur_network = &pmlmepriv->cur_network;; */ - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; if (!phtpriv->ht_option) @@ -2302,45 +2298,43 @@ void rtw_update_ht_cap23a(struct rtw_adapter *padapter, u8 *pie, uint ie_len) DBG_8723A("+rtw_update_ht_cap23a()\n"); + /* Adjust pie + ie_len for our searches */ + pie += sizeof (struct ndis_802_11_fixed_ies); + ie_len -= sizeof (struct ndis_802_11_fixed_ies); + /* maybe needs check if ap supports rx ampdu. */ - if ((phtpriv->ampdu_enable == false) && (pregistrypriv->ampdu_enable == 1)) { + if (phtpriv->ampdu_enable == false && + pregistrypriv->ampdu_enable == 1) { if (pregistrypriv->wifi_spec == 1) phtpriv->ampdu_enable = false; else phtpriv->ampdu_enable = true; - } else if (pregistrypriv->ampdu_enable == 2) { + } else if (pregistrypriv->ampdu_enable == 2) phtpriv->ampdu_enable = true; - } /* check Max Rx A-MPDU Size */ - len = 0; - p = rtw_get_ie23a(pie+sizeof (struct ndis_802_11_fixed_ies), - WLAN_EID_HT_CAPABILITY, &len, - ie_len-sizeof (struct ndis_802_11_fixed_ies)); - if (p && len > 0) { - pht_capie = (struct ieee80211_ht_cap *)(p+2); - max_ampdu_sz = (pht_capie->ampdu_params_info & IEEE80211_HT_AMPDU_PARM_FACTOR); - max_ampdu_sz = 1 << (max_ampdu_sz+3); /* max_ampdu_sz (kbytes); */ - - /* DBG_8723A("rtw_update_ht_cap23a(): max_ampdu_sz =%d\n", max_ampdu_sz); */ - phtpriv->rx_ampdu_maxlen = max_ampdu_sz; + p = cfg80211_find_ie(WLAN_EID_HT_CAPABILITY, pie, ie_len); + + if (p && p[1] > 0) { + pht_capie = (struct ieee80211_ht_cap *)(p + 2); + max_ampdu_sz = pht_capie->ampdu_params_info & + IEEE80211_HT_AMPDU_PARM_FACTOR; + /* max_ampdu_sz (kbytes); */ + max_ampdu_sz = 1 << (max_ampdu_sz + 3); + phtpriv->rx_ampdu_maxlen = max_ampdu_sz; } - len = 0; - p = rtw_get_ie23a(pie+sizeof (struct ndis_802_11_fixed_ies), - WLAN_EID_HT_OPERATION, &len, - ie_len-sizeof (struct ndis_802_11_fixed_ies)); - if (p && len>0) - { - pht_addtinfo = (struct ieee80211_ht_addt_info *)(p+2); + p = cfg80211_find_ie(WLAN_EID_HT_OPERATION, pie, ie_len); + if (p && p[1] > 0) { + pht_addtinfo = (struct ieee80211_ht_addt_info *)(p + 2); /* todo: */ } /* update cur_bwmode & cur_ch_offset */ - if ((pregistrypriv->cbw40_enable) && - (pmlmeinfo->HT_caps.u.HT_cap_element.HT_caps_info & BIT(1)) && - (pmlmeinfo->HT_info.infos[0] & BIT(2))) { + if (pregistrypriv->cbw40_enable && + (pmlmeinfo->HT_caps.u.HT_cap_element.HT_caps_info & BIT(1)) && + (pmlmeinfo->HT_info.infos[0] & BIT(2))) { int i; u8 rf_type; @@ -2375,7 +2369,8 @@ void rtw_update_ht_cap23a(struct rtw_adapter *padapter, u8 *pie, uint ie_len) /* */ /* Config SM Power Save setting */ /* */ - pmlmeinfo->SM_PS = (pmlmeinfo->HT_caps.u.HT_cap_element.HT_caps_info & 0x0C) >> 2; + pmlmeinfo->SM_PS = (pmlmeinfo->HT_caps.u.HT_cap_element.HT_caps_info & + 0x0C) >> 2; if (pmlmeinfo->SM_PS == WLAN_HT_CAP_SM_PS_STATIC) DBG_8723A("%s(): WLAN_HT_CAP_SM_PS_STATIC\n", __func__); -- cgit v1.2.3 From 9f0e58664b376d086f1b3ad8ca5e584d20ebd608 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:43:39 +0200 Subject: staging: rtl8723au: OnProbeReq23a() Use cfg80211_find_ie() Switch to using cfg80211_find_ie() and tidy of the code. Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 49 ++++++++++++--------------- 1 file changed, 21 insertions(+), 28 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index 084003943396..5e4a55783f60 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -640,8 +640,7 @@ Following are the callback functions for each subtype of the management frames unsigned int OnProbeReq23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) { - unsigned int ielen; - unsigned char *p; + const u8 *ie; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; @@ -652,44 +651,38 @@ unsigned int OnProbeReq23a(struct rtw_adapter *padapter, uint len = skb->len; u8 is_valid_p2p_probereq = false; - if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)) { + if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)) return _SUCCESS; - } - if (check_fwstate(pmlmepriv, _FW_LINKED) == false && - check_fwstate(pmlmepriv, - WIFI_ADHOC_MASTER_STATE|WIFI_AP_STATE) == false) { + if (!check_fwstate(pmlmepriv, _FW_LINKED) && + !check_fwstate(pmlmepriv, + WIFI_ADHOC_MASTER_STATE | WIFI_AP_STATE)) return _SUCCESS; - } - p = rtw_get_ie23a(pframe + sizeof(struct ieee80211_hdr_3addr) + - _PROBEREQ_IE_OFFSET_, WLAN_EID_SSID, (int *)&ielen, - len - sizeof(struct ieee80211_hdr_3addr) - - _PROBEREQ_IE_OFFSET_); + pframe += (sizeof(struct ieee80211_hdr_3addr) + _PROBEREQ_IE_OFFSET_); + len -= (sizeof(struct ieee80211_hdr_3addr) + _PROBEREQ_IE_OFFSET_); + + ie = cfg80211_find_ie(WLAN_EID_SSID, pframe, len); /* check (wildcard) SSID */ - if (p) { - if (is_valid_p2p_probereq == true) { - goto _issue_probersp23a; - } + if (!ie) + goto out; - if ((ielen != 0 && - memcmp((void *)(p+2), cur->Ssid.ssid, - cur->Ssid.ssid_len)) || - (ielen == 0 && pmlmeinfo->hidden_ssid_mode)) { + if (is_valid_p2p_probereq == false) { + if ((ie[1] && + memcmp(ie + 2, cur->Ssid.ssid, cur->Ssid.ssid_len)) || + (ie[1] == 0 && pmlmeinfo->hidden_ssid_mode)) { return _SUCCESS; } + } -_issue_probersp23a: - - if (check_fwstate(pmlmepriv, _FW_LINKED) == true && - pmlmepriv->cur_network.join_res == true) { - /* DBG_8723A("+issue_probersp23a during ap mode\n"); */ - issue_probersp23a(padapter, ieee80211_get_SA(hdr), - is_valid_p2p_probereq); - } + if (check_fwstate(pmlmepriv, _FW_LINKED) && + pmlmepriv->cur_network.join_res) { + issue_probersp23a(padapter, ieee80211_get_SA(hdr), + is_valid_p2p_probereq); } +out: return _SUCCESS; } -- cgit v1.2.3 From b1b2bbbdc0bc429638dbf32615805f9b07f7ae87 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:43:40 +0200 Subject: staging: rtl8723au: OnAuth23() Use cfg80211_find_ie() Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 49 +++++++++++++-------------- 1 file changed, 23 insertions(+), 26 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index 5e4a55783f60..8e7758fefe47 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -832,22 +832,23 @@ unsigned int OnAuth23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) { #ifdef CONFIG_8723AU_AP_MODE - unsigned int auth_mode, seq, ie_len; - unsigned char *sa, *p; - u16 algorithm; - int status; + unsigned int auth_mode, seq; + unsigned char *sa; + const u8 *p; + u16 algorithm; + int status; static struct sta_info stat; - struct sta_info *pstat = NULL; - struct sta_priv *pstapriv = &padapter->stapriv; + struct sta_info *pstat = NULL; + struct sta_priv *pstapriv = &padapter->stapriv; struct security_priv *psecuritypriv = &padapter->securitypriv; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; struct sk_buff *skb = precv_frame->pkt; struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; u8 *pframe = skb->data; uint len = skb->len; - if ((pmlmeinfo->state&0x03) != WIFI_FW_AP_STATE) + if ((pmlmeinfo->state & 0x03) != WIFI_FW_AP_STATE) return _FAIL; DBG_8723A("+OnAuth23a\n"); @@ -855,10 +856,12 @@ unsigned int OnAuth23a(struct rtw_adapter *padapter, sa = hdr->addr2; auth_mode = psecuritypriv->dot11AuthAlgrthm; - seq = cpu_to_le16(*(u16*)((unsigned long)pframe + - sizeof(struct ieee80211_hdr_3addr) + 2)); - algorithm = cpu_to_le16(*(u16*)((unsigned long)pframe + - sizeof(struct ieee80211_hdr_3addr))); + + pframe += sizeof(struct ieee80211_hdr_3addr); + len -= sizeof(struct ieee80211_hdr_3addr); + + seq = cpu_to_le16(*(u16 *)(pframe + 2)); + algorithm = cpu_to_le16(*(u16 *)pframe); DBG_8723A("auth alg =%x, seq =%X\n", algorithm, seq); @@ -909,8 +912,7 @@ unsigned int OnAuth23a(struct rtw_adapter *padapter, if (!list_empty(&pstat->asoc_list)) { list_del_init(&pstat->asoc_list); pstapriv->asoc_list_cnt--; - if (pstat->expire_to > 0) - { + if (pstat->expire_to > 0) { /* TODO: STA re_auth within expire_to */ } } @@ -962,23 +964,18 @@ unsigned int OnAuth23a(struct rtw_adapter *padapter, /* checking for challenging txt... */ DBG_8723A("checking for challenging txt...\n"); - p = rtw_get_ie23a(pframe + - sizeof(struct ieee80211_hdr_3addr) + - 4 + _AUTH_IE_OFFSET_, - WLAN_EID_CHALLENGE, - (int *)&ie_len, len - - sizeof(struct ieee80211_hdr_3addr) - - _AUTH_IE_OFFSET_ - 4); - - if ((p == NULL) || (ie_len<= 0)) { + p = cfg80211_find_ie(WLAN_EID_CHALLENGE, + pframe + 4 + _AUTH_IE_OFFSET_, + len - _AUTH_IE_OFFSET_ - 4); + if (!p || p[1] <= 0) { DBG_8723A("auth rejected because challenge " "failure!(1)\n"); status = WLAN_STATUS_CHALLENGE_FAIL; goto auth_fail; } - if (!memcmp((void *)(p + 2), pstat->chg_txt, 128)) { - pstat->state &= (~WIFI_FW_AUTH_STATE); + if (!memcmp(p + 2, pstat->chg_txt, 128)) { + pstat->state &= ~WIFI_FW_AUTH_STATE; pstat->state |= WIFI_FW_AUTH_SUCCESS; /* challenging txt is correct... */ pstat->expire_to = pstapriv->assoc_to; @@ -1000,7 +997,7 @@ unsigned int OnAuth23a(struct rtw_adapter *padapter, /* Now, we are going to issue_auth23a... */ pstat->auth_seq = seq + 1; - issue_auth23a(padapter, pstat, (unsigned short)WLAN_STATUS_SUCCESS); + issue_auth23a(padapter, pstat, WLAN_STATUS_SUCCESS); if (pstat->state & WIFI_FW_AUTH_SUCCESS) pstat->auth_seq = 0; -- cgit v1.2.3 From 781f65cbf58abe51071bc2c2a27dc89414027540 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:43:41 +0200 Subject: staging: rtl8723au: OnAuth23aClient23a() Use cfg80211_find_ie() Use cfg80211_find_ie() and tidy up the code Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 67 +++++++++++---------------- 1 file changed, 28 insertions(+), 39 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index 8e7758fefe47..6db3d4622bc9 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -1023,15 +1023,14 @@ auth_fail: unsigned int OnAuth23aClient23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) { - unsigned int seq, len, status, algthm, offset; - unsigned char *p; - unsigned int go2asoc = 0; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + unsigned int seq, status, algthm, offset; + unsigned int go2asoc = 0; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; struct sk_buff *skb = precv_frame->pkt; struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; - u8 *pframe = skb->data; - uint pkt_len = skb->len; + const u8 *p, *pframe = skb->data; + int pkt_len = skb->len; DBG_8723A("%s\n", __func__); @@ -1045,15 +1044,17 @@ unsigned int OnAuth23aClient23a(struct rtw_adapter *padapter, offset = ieee80211_has_protected(hdr->frame_control) ? 4: 0; - algthm = le16_to_cpu(*(unsigned short *)((unsigned long)pframe + sizeof(struct ieee80211_hdr_3addr) + offset)); - seq = le16_to_cpu(*(unsigned short *)((unsigned long)pframe + sizeof(struct ieee80211_hdr_3addr) + offset + 2)); - status = le16_to_cpu(*(unsigned short *)((unsigned long)pframe + sizeof(struct ieee80211_hdr_3addr) + offset + 4)); + pframe += sizeof(struct ieee80211_hdr_3addr); + pkt_len -= sizeof(struct ieee80211_hdr_3addr); - if (status != 0) - { + algthm = le16_to_cpu(*(u16 *)(pframe + offset)); + seq = le16_to_cpu(*(u16 *)(pframe + offset + 2)); + status = le16_to_cpu(*(u16 *)(pframe + offset + 4)); + + if (status) { DBG_8723A("clnt auth fail, status: %d\n", status); - if (status == 13)/* pmlmeinfo->auth_algo == dot11AuthAlgrthm_Auto) */ - { + /* pmlmeinfo->auth_algo == dot11AuthAlgrthm_Auto) */ + if (status == 13) { if (pmlmeinfo->auth_algo == dot11AuthAlgrthm_Shared) pmlmeinfo->auth_algo = dot11AuthAlgrthm_Open; else @@ -1065,53 +1066,41 @@ unsigned int OnAuth23aClient23a(struct rtw_adapter *padapter, goto authclnt_fail; } - if (seq == 2) - { - if (pmlmeinfo->auth_algo == dot11AuthAlgrthm_Shared) - { - /* legendary shared system */ - p = rtw_get_ie23a(pframe + sizeof(struct ieee80211_hdr_3addr) + _AUTH_IE_OFFSET_, WLAN_EID_CHALLENGE, (int *)&len, - pkt_len - sizeof(struct ieee80211_hdr_3addr) - _AUTH_IE_OFFSET_); + if (seq == 2) { + if (pmlmeinfo->auth_algo == dot11AuthAlgrthm_Shared) { + /* legendary shared system */ + p = cfg80211_find_ie(WLAN_EID_CHALLENGE, + pframe + _AUTH_IE_OFFSET_, + pkt_len - _AUTH_IE_OFFSET_); - if (p == NULL) - { + if (!p) { /* DBG_8723A("marc: no challenge text?\n"); */ goto authclnt_fail; } - memcpy((void *)(pmlmeinfo->chg_txt), (void *)(p + 2), len); + memcpy((void *)(pmlmeinfo->chg_txt), p + 2, p[1]); pmlmeinfo->auth_seq = 3; issue_auth23a(padapter, NULL, 0); set_link_timer(pmlmeext, REAUTH_TO); return _SUCCESS; - } - else - { + } else { /* open system */ go2asoc = 1; } - } - else if (seq == 4) - { + } else if (seq == 4) { if (pmlmeinfo->auth_algo == dot11AuthAlgrthm_Shared) - { go2asoc = 1; - } else - { goto authclnt_fail; - } - } - else - { + } else { /* this is also illegal */ - /* DBG_8723A("marc: clnt auth failed due to illegal seq =%x\n", seq); */ + /* DBG_8723A("marc: clnt auth failed due to illegal seq =%x\n", + seq); */ goto authclnt_fail; } - if (go2asoc) - { + if (go2asoc) { DBG_8723A_LEVEL(_drv_always_, "auth success, start assoc\n"); start_clnt_assoc23a(padapter); return _SUCCESS; -- cgit v1.2.3 From d7a159959ebf64f489fe1422710f65be6a0e71db Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:43:42 +0200 Subject: staging: rtl8723au: OnAssocRsp23a() use ieee80211 header defines Use the proper ieee80211.h structs to parse the response instead of hard coded offsets. Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index 6db3d4622bc9..934a470b6ebf 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -1596,19 +1596,20 @@ OnAssocReq23aFail: return _FAIL; } -unsigned int OnAssocRsp23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) +unsigned int OnAssocRsp23a(struct rtw_adapter *padapter, + struct recv_frame *precv_frame) { - uint i; - int res; - unsigned short status; struct ndis_802_11_var_ies *pIE; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; struct sk_buff *skb = precv_frame->pkt; struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; + struct ieee80211_mgmt *pmgmt = (struct ieee80211_mgmt *) skb->data; + int res, i; + unsigned short status; u8 *pframe = skb->data; - uint pkt_len = skb->len; + int pkt_len = skb->len; DBG_8723A("%s\n", __func__); @@ -1626,8 +1627,8 @@ unsigned int OnAssocRsp23a(struct rtw_adapter *padapter, struct recv_frame *prec del_timer_sync(&pmlmeext->link_timer); /* status */ - if ((status = le16_to_cpu(*(unsigned short *)(pframe + sizeof(struct ieee80211_hdr_3addr) + 2))) > 0) - { + status = le16_to_cpu(pmgmt->u.assoc_resp.status_code); + if (status > 0) { DBG_8723A("assoc reject, status code: %d\n", status); pmlmeinfo->state = WIFI_FW_NULL_STATE; res = -4; @@ -1635,18 +1636,19 @@ unsigned int OnAssocRsp23a(struct rtw_adapter *padapter, struct recv_frame *prec } /* get capabilities */ - pmlmeinfo->capability = le16_to_cpu(*(unsigned short *)(pframe + sizeof(struct ieee80211_hdr_3addr))); + pmlmeinfo->capability = le16_to_cpu(pmgmt->u.assoc_resp.capab_info); /* set slot time */ pmlmeinfo->slotTime = (pmlmeinfo->capability & BIT(10))? 9: 20; /* AID */ - res = pmlmeinfo->aid = (int)(le16_to_cpu(*(unsigned short *)(pframe + sizeof(struct ieee80211_hdr_3addr) + 4))&0x3fff); + res = pmlmeinfo->aid = le16_to_cpu(pmgmt->u.assoc_resp.aid) & 0x3fff; /* following are moved to join event callback function */ /* to handle HT, WMM, rate adaptive, update MAC reg */ /* for not to handle the synchronous IO in the tasklet */ - for (i = (6 + sizeof(struct ieee80211_hdr_3addr)); i < pkt_len;) { + for (i = offsetof(struct ieee80211_mgmt, u.assoc_resp.variable); + i < pkt_len;) { pIE = (struct ndis_802_11_var_ies *)(pframe + i); switch (pIE->ElementID) @@ -1674,7 +1676,7 @@ unsigned int OnAssocRsp23a(struct rtw_adapter *padapter, struct recv_frame *prec i += (pIE->Length + 2); } - pmlmeinfo->state &= (~WIFI_FW_ASSOC_STATE); + pmlmeinfo->state &= ~WIFI_FW_ASSOC_STATE; pmlmeinfo->state |= WIFI_FW_ASSOC_SUCCESS; /* Update Basic Rate Table for spec, 2010-12-28 , by thomas */ -- cgit v1.2.3 From be47f78295eca082f8263aaba8ad7d5ab5e865fd Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:43:43 +0200 Subject: staging: rtl8723au: OnDeAuth23a() use ieee80211 header defines Use the proper ieee80211.h structs to parse the response instead of hard coded offsets. Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index 934a470b6ebf..0d282aff9f06 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -1702,19 +1702,18 @@ report_assoc_result: unsigned int OnDeAuth23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) { - unsigned short reason; + unsigned short reason; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; struct sk_buff *skb = precv_frame->pkt; - struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; - u8 *pframe = skb->data; + struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *) skb->data; - /* check A3 */ - if (!ether_addr_equal(hdr->addr3, get_my_bssid23a(&pmlmeinfo->network))) + if (!ether_addr_equal(mgmt->bssid, + get_my_bssid23a(&pmlmeinfo->network))) return _SUCCESS; - reason = le16_to_cpu(*(unsigned short *)(pframe + sizeof(struct ieee80211_hdr_3addr))); + reason = le16_to_cpu(mgmt->u.deauth.reason_code); DBG_8723A("%s Reason code(%d)\n", __func__, reason); @@ -1724,9 +1723,9 @@ unsigned int OnDeAuth23a(struct rtw_adapter *padapter, struct sta_priv *pstapriv = &padapter->stapriv; DBG_8723A_LEVEL(_drv_always_, "ap recv deauth reason code(%d) " - "sta:%pM\n", reason, hdr->addr2); + "sta:%pM\n", reason, mgmt->sa); - psta = rtw_get_stainfo23a(pstapriv, hdr->addr2); + psta = rtw_get_stainfo23a(pstapriv, mgmt->sa); if (psta) { u8 updated = 0; @@ -1743,16 +1742,16 @@ unsigned int OnDeAuth23a(struct rtw_adapter *padapter, } return _SUCCESS; - } - else + } else #endif { DBG_8723A_LEVEL(_drv_always_, "sta recv deauth reason code(%d) " - "sta:%pM\n", reason, hdr->addr3); + "sta:%pM\n", reason, mgmt->bssid); - receive_disconnect23a(padapter, hdr->addr3, reason); + receive_disconnect23a(padapter, mgmt->bssid, reason); } pmlmepriv->LinkDetectInfo.bBusyTraffic = false; + return _SUCCESS; } -- cgit v1.2.3 From c8f260e3f6f581eb81349a3fdf43ad981ea34068 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:43:44 +0200 Subject: staging: rtl8723au: OnDisassoc23(): Use ieee80211_mgmt Use proper kernel ieee80211.h defined headers to parse the response. Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 28 +++++++++++++-------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index 0d282aff9f06..98a4e338d136 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -1755,22 +1755,21 @@ unsigned int OnDeAuth23a(struct rtw_adapter *padapter, return _SUCCESS; } -unsigned int OnDisassoc23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) +unsigned int OnDisassoc23a(struct rtw_adapter *padapter, + struct recv_frame *precv_frame) { unsigned short reason; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; struct sk_buff *skb = precv_frame->pkt; - struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; - u8 *pframe = skb->data; + struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *) skb->data; - /* check A3 */ - if (!ether_addr_equal(hdr->addr3, get_my_bssid23a(&pmlmeinfo->network))) + if (!ether_addr_equal(mgmt->bssid, + get_my_bssid23a(&pmlmeinfo->network))) return _SUCCESS; - reason = le16_to_cpu(*(unsigned short *) - (pframe + sizeof(struct ieee80211_hdr_3addr))); + reason = le16_to_cpu(mgmt->u.disassoc.reason_code); DBG_8723A("%s Reason code(%d)\n", __func__, reason); @@ -1780,9 +1779,9 @@ unsigned int OnDisassoc23a(struct rtw_adapter *padapter, struct recv_frame *prec struct sta_priv *pstapriv = &padapter->stapriv; DBG_8723A_LEVEL(_drv_always_, "ap recv disassoc reason code(%d)" - " sta:%pM\n", reason, hdr->addr2); + " sta:%pM\n", reason, mgmt->sa); - psta = rtw_get_stainfo23a(pstapriv, hdr->addr2); + psta = rtw_get_stainfo23a(pstapriv, mgmt->sa); if (psta) { u8 updated = 0; @@ -1791,7 +1790,7 @@ unsigned int OnDisassoc23a(struct rtw_adapter *padapter, struct recv_frame *prec list_del_init(&psta->asoc_list); pstapriv->asoc_list_cnt--; updated = ap_free_sta23a(padapter, psta, - false, reason); + false, reason); } spin_unlock_bh(&pstapriv->asoc_list_lock); @@ -1799,14 +1798,13 @@ unsigned int OnDisassoc23a(struct rtw_adapter *padapter, struct recv_frame *prec } return _SUCCESS; - } - else + } else #endif { DBG_8723A_LEVEL(_drv_always_, "ap recv disassoc reason " - "code(%d) sta:%pM\n", reason, hdr->addr3); + "code(%d) sta:%pM\n", reason, mgmt->bssid); - receive_disconnect23a(padapter, hdr->addr3, reason); + receive_disconnect23a(padapter, mgmt->bssid, reason); } pmlmepriv->LinkDetectInfo.bBusyTraffic = false; return _SUCCESS; -- cgit v1.2.3 From 7ffdc3f5811cec96b5aebd858e6de249db6bc29a Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:43:45 +0200 Subject: staging: rtl8723au: OnAction23_back23a() Use ieee80211_mgmt and bug fixes This converts OnAction23a_back23a() to using struct ieee80211_mgmt to parse the response packet. In addition this revealed a bug which has been fixed: case WLAN_ACTION_ADDBA_RESP: /* ADDBA response */ status = get_unaligned_le16(&frame_body[3]); tid = ((frame_body[5] >> 2) & 0x7); The above masks the tid to 3 bits, however per ieee80211.h, the tid is in fact 4 bits wide, as defined by IEEE80211_ADDBA_PARAM_TID_MASK (0x3c) Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 53 ++++++++++++++------------- 1 file changed, 27 insertions(+), 26 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index 98a4e338d136..fde6cd77e9fd 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -1831,23 +1831,23 @@ unsigned int OnAction23a_dls(struct rtw_adapter *padapter, struct recv_frame *pr return _SUCCESS; } -unsigned int OnAction23a_back23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) +unsigned int OnAction23a_back23a(struct rtw_adapter *padapter, + struct recv_frame *precv_frame) { u8 *addr; struct sta_info *psta = NULL; struct recv_reorder_ctrl *preorder_ctrl; - unsigned char *frame_body; - unsigned char category, action; - unsigned short tid, status, reason_code = 0; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + unsigned char *frame_body; + unsigned char category, action; + unsigned short tid, status, capab, params, reason_code = 0; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; struct sk_buff *skb = precv_frame->pkt; - struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; - u8 *pframe = skb->data; + struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *) skb->data; struct sta_priv *pstapriv = &padapter->stapriv; /* check RA matches or not */ - if (!ether_addr_equal(myid(&padapter->eeprompriv), hdr->addr1)) + if (!ether_addr_equal(myid(&padapter->eeprompriv), mgmt->da)) return _SUCCESS; DBG_8723A("%s\n", __func__); @@ -1856,16 +1856,15 @@ unsigned int OnAction23a_back23a(struct rtw_adapter *padapter, struct recv_frame if (!(pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS)) return _SUCCESS; - addr = hdr->addr2; + addr = mgmt->sa; psta = rtw_get_stainfo23a(pstapriv, addr); if (!psta) return _SUCCESS; - frame_body = (unsigned char *) - (pframe + sizeof(struct ieee80211_hdr_3addr)); + frame_body = &mgmt->u.action.category; - category = frame_body[0]; + category = mgmt->u.action.category; if (category == WLAN_CATEGORY_BACK) { /* representing Block Ack */ if (!pmlmeinfo->HT_enable) return _SUCCESS; @@ -1887,8 +1886,11 @@ unsigned int OnAction23a_back23a(struct rtw_adapter *padapter, struct recv_frame } break; case WLAN_ACTION_ADDBA_RESP: /* ADDBA response */ - status = get_unaligned_le16(&frame_body[3]); - tid = ((frame_body[5] >> 2) & 0x7); + status = get_unaligned_le16( + &mgmt->u.action.u.addba_resp.status); + capab = get_unaligned_le16( + &mgmt->u.action.u.addba_resp.capab); + tid = (capab & IEEE80211_ADDBA_PARAM_TID_MASK) >> 2; if (status == 0) { /* successful */ DBG_8723A("agg_enable for TID =%d\n", tid); psta->htpriv.agg_enable_bitmap |= 1 << tid; @@ -1899,22 +1901,21 @@ unsigned int OnAction23a_back23a(struct rtw_adapter *padapter, struct recv_frame break; case WLAN_ACTION_DELBA: /* DELBA */ - if ((frame_body[3] & BIT(3)) == 0) { - psta->htpriv.agg_enable_bitmap &= - ~(1 << ((frame_body[3] >> 4) & 0xf)); - psta->htpriv.candidate_tid_bitmap &= - ~(1 << ((frame_body[3] >> 4) & 0xf)); + params = get_unaligned_le16( + &mgmt->u.action.u.delba.params); + tid = params >> 12; - /* reason_code = frame_body[4] | (frame_body[5] << 8); */ - reason_code = get_unaligned_le16(&frame_body[4]); - } else if ((frame_body[3] & BIT(3)) == BIT(3)) { - tid = (frame_body[3] >> 4) & 0x0F; - - preorder_ctrl = &psta->recvreorder_ctrl[tid]; + if (params & IEEE80211_DELBA_PARAM_INITIATOR_MASK) { + preorder_ctrl = &psta->recvreorder_ctrl[tid]; preorder_ctrl->enable = false; preorder_ctrl->indicate_seq = 0xffff; + } else { + psta->htpriv.agg_enable_bitmap &= ~(1 << tid); + psta->htpriv.candidate_tid_bitmap &= + ~(1 << tid); } - + reason_code = get_unaligned_le16( + &mgmt->u.action.u.delba.reason_code); DBG_8723A("%s(): DELBA: %x(%x)\n", __func__, pmlmeinfo->agg_enable_bitmap, reason_code); /* todo: how to notify the host while receiving -- cgit v1.2.3 From f9df1ea120a9630e27e7519251d3101a8944c746 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:43:46 +0200 Subject: staging: rtl8723au: process_80211d() use cfg80211_find_ie() Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 152 ++++++++++++++------------ 1 file changed, 84 insertions(+), 68 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index fde6cd77e9fd..a8814d4bd575 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -4721,7 +4721,8 @@ unsigned int receive_disconnect23a(struct rtw_adapter *padapter, unsigned char * return _SUCCESS; } -static void process_80211d(struct rtw_adapter *padapter, struct wlan_bssid_ex *bssid) +static void process_80211d(struct rtw_adapter *padapter, + struct wlan_bssid_ex *bssid) { struct registry_priv *pregistrypriv; struct mlme_ext_priv *pmlmeext; @@ -4734,10 +4735,8 @@ static void process_80211d(struct rtw_adapter *padapter, struct wlan_bssid_ex *b /* Adjust channel plan by AP Country IE */ if (pregistrypriv->enable80211d && - (!pmlmeext->update_channel_plan_by_ap_done)) - { - u8 *ie, *p; - u32 len; + !pmlmeext->update_channel_plan_by_ap_done) { + const u8 *ie, *p; struct rt_channel_plan chplan_ap; struct rt_channel_info chplan_sta[MAX_CHANNEL_NUM]; u8 country[4]; @@ -4745,33 +4744,34 @@ static void process_80211d(struct rtw_adapter *padapter, struct wlan_bssid_ex *b u8 noc; /* number of channel */ u8 j, k; - ie = rtw_get_ie23a(bssid->IEs + _FIXED_IE_LENGTH_, - WLAN_EID_COUNTRY, &len, - bssid->IELength - _FIXED_IE_LENGTH_); - if (!ie) return; - if (len < 6) return; + ie = cfg80211_find_ie(WLAN_EID_COUNTRY, + bssid->IEs + _FIXED_IE_LENGTH_, + bssid->IELength - _FIXED_IE_LENGTH_); + if (!ie || ie[1] < IEEE80211_COUNTRY_IE_MIN_LEN) + return; ie += 2; p = ie; - ie += len; + ie += ie[1]; - memset(country, 0, 4); memcpy(country, p, 3); + country[3] = '\0'; + p += 3; RT_TRACE(_module_rtl871x_mlme_c_, _drv_notice_, - ("%s: 802.11d country =%s\n", __func__, country)); + ("%s: 802.11d country =%s\n", __func__, country)); i = 0; - while ((ie - p) >= 3) - { + while ((ie - p) >= 3) { fcn = *(p++); noc = *(p++); p++; - for (j = 0; j < noc; j++) - { - if (fcn <= 14) channel = fcn + j; /* 2.4 GHz */ - else channel = fcn + j*4; /* 5 GHz */ + for (j = 0; j < noc; j++) { + if (fcn <= 14) + channel = fcn + j; /* 2.4 GHz */ + else + channel = fcn + j * 4; /* 5 GHz */ chplan_ap.Channel[i++] = channel; } @@ -4785,45 +4785,55 @@ static void process_80211d(struct rtw_adapter *padapter, struct wlan_bssid_ex *b i = j = k = 0; if (pregistrypriv->wireless_mode & WIRELESS_11G) { do { - if ((i == MAX_CHANNEL_NUM) || - (chplan_sta[i].ChannelNum == 0) || - (chplan_sta[i].ChannelNum > 14)) + if (i == MAX_CHANNEL_NUM || + chplan_sta[i].ChannelNum == 0 || + chplan_sta[i].ChannelNum > 14) break; - if ((j == chplan_ap.Len) || (chplan_ap.Channel[j] > 14)) + if (j == chplan_ap.Len || + chplan_ap.Channel[j] > 14) break; - if (chplan_sta[i].ChannelNum == chplan_ap.Channel[j]) { - chplan_new[k].ChannelNum = chplan_ap.Channel[j]; + if (chplan_sta[i].ChannelNum == + chplan_ap.Channel[j]) { + chplan_new[k].ChannelNum = + chplan_ap.Channel[j]; chplan_new[k].ScanType = SCAN_ACTIVE; i++; j++; k++; - } else if (chplan_sta[i].ChannelNum < chplan_ap.Channel[j]) { - chplan_new[k].ChannelNum = chplan_sta[i].ChannelNum; - chplan_new[k].ScanType = SCAN_PASSIVE; + } else if (chplan_sta[i].ChannelNum < + chplan_ap.Channel[j]) { + chplan_new[k].ChannelNum = + chplan_sta[i].ChannelNum; + chplan_new[k].ScanType = + SCAN_PASSIVE; i++; k++; - } else if (chplan_sta[i].ChannelNum > chplan_ap.Channel[j]) { - chplan_new[k].ChannelNum = chplan_ap.Channel[j]; - chplan_new[k].ScanType = SCAN_ACTIVE; + } else if (chplan_sta[i].ChannelNum > + chplan_ap.Channel[j]) { + chplan_new[k].ChannelNum = + chplan_ap.Channel[j]; + chplan_new[k].ScanType = + SCAN_ACTIVE; j++; k++; } } while (1); /* change AP not support channel to Passive scan */ - while ((i < MAX_CHANNEL_NUM) && - (chplan_sta[i].ChannelNum != 0) && - (chplan_sta[i].ChannelNum <= 14)) { - chplan_new[k].ChannelNum = chplan_sta[i].ChannelNum; + while (i < MAX_CHANNEL_NUM && + chplan_sta[i].ChannelNum != 0 && + chplan_sta[i].ChannelNum <= 14) { + chplan_new[k].ChannelNum = + chplan_sta[i].ChannelNum; chplan_new[k].ScanType = SCAN_PASSIVE; i++; k++; } /* add channel AP supported */ - while ((j < chplan_ap.Len) && (chplan_ap.Channel[j] <= 14)) { + while (j < chplan_ap.Len && chplan_ap.Channel[j] <= 14){ chplan_new[k].ChannelNum = chplan_ap.Channel[j]; chplan_new[k].ScanType = SCAN_ACTIVE; j++; @@ -4831,49 +4841,50 @@ static void process_80211d(struct rtw_adapter *padapter, struct wlan_bssid_ex *b } } else { /* keep original STA 2.4G channel plan */ - while ((i < MAX_CHANNEL_NUM) && - (chplan_sta[i].ChannelNum != 0) && - (chplan_sta[i].ChannelNum <= 14)) { - chplan_new[k].ChannelNum = chplan_sta[i].ChannelNum; + while (i < MAX_CHANNEL_NUM && + chplan_sta[i].ChannelNum != 0 && + chplan_sta[i].ChannelNum <= 14) { + chplan_new[k].ChannelNum = + chplan_sta[i].ChannelNum; chplan_new[k].ScanType = chplan_sta[i].ScanType; i++; k++; } /* skip AP 2.4G channel plan */ - while ((j < chplan_ap.Len) && (chplan_ap.Channel[j] <= 14)) { + while (j < chplan_ap.Len && chplan_ap.Channel[j] <= 14) j++; - } } if (pregistrypriv->wireless_mode & WIRELESS_11A) { do { - if ((i == MAX_CHANNEL_NUM) || - (chplan_sta[i].ChannelNum == 0)) + if (i == MAX_CHANNEL_NUM || + chplan_sta[i].ChannelNum == 0) break; - if ((j == chplan_ap.Len) || (chplan_ap.Channel[j] == 0)) + if (j == chplan_ap.Len || + chplan_ap.Channel[j] == 0) break; - if (chplan_sta[i].ChannelNum == chplan_ap.Channel[j]) - { - chplan_new[k].ChannelNum = chplan_ap.Channel[j]; + if (chplan_sta[i].ChannelNum == + chplan_ap.Channel[j]) { + chplan_new[k].ChannelNum = + chplan_ap.Channel[j]; chplan_new[k].ScanType = SCAN_ACTIVE; i++; j++; k++; - } - else if (chplan_sta[i].ChannelNum < chplan_ap.Channel[j]) - { - chplan_new[k].ChannelNum = chplan_sta[i].ChannelNum; -/* chplan_new[k].ScanType = chplan_sta[i].ScanType; */ + } else if (chplan_sta[i].ChannelNum < + chplan_ap.Channel[j]) { + chplan_new[k].ChannelNum = + chplan_sta[i].ChannelNum; chplan_new[k].ScanType = SCAN_PASSIVE; i++; k++; - } - else if (chplan_sta[i].ChannelNum > chplan_ap.Channel[j]) - { - chplan_new[k].ChannelNum = chplan_ap.Channel[j]; + } else if (chplan_sta[i].ChannelNum > + chplan_ap.Channel[j]) { + chplan_new[k].ChannelNum = + chplan_ap.Channel[j]; chplan_new[k].ScanType = SCAN_ACTIVE; j++; k++; @@ -4881,15 +4892,17 @@ static void process_80211d(struct rtw_adapter *padapter, struct wlan_bssid_ex *b } while (1); /* change AP not support channel to Passive scan */ - while ((i < MAX_CHANNEL_NUM) && (chplan_sta[i].ChannelNum != 0)) { - chplan_new[k].ChannelNum = chplan_sta[i].ChannelNum; + while (i < MAX_CHANNEL_NUM && + chplan_sta[i].ChannelNum != 0) { + chplan_new[k].ChannelNum = + chplan_sta[i].ChannelNum; chplan_new[k].ScanType = SCAN_PASSIVE; i++; k++; } /* add channel AP supported */ - while ((j < chplan_ap.Len) && (chplan_ap.Channel[j] != 0)) { + while (j < chplan_ap.Len && chplan_ap.Channel[j] != 0) { chplan_new[k].ChannelNum = chplan_ap.Channel[j]; chplan_new[k].ScanType = SCAN_ACTIVE; j++; @@ -4897,8 +4910,10 @@ static void process_80211d(struct rtw_adapter *padapter, struct wlan_bssid_ex *b } } else { /* keep original STA 5G channel plan */ - while ((i < MAX_CHANNEL_NUM) && (chplan_sta[i].ChannelNum != 0)) { - chplan_new[k].ChannelNum = chplan_sta[i].ChannelNum; + while (i < MAX_CHANNEL_NUM && + chplan_sta[i].ChannelNum != 0) { + chplan_new[k].ChannelNum = + chplan_sta[i].ChannelNum; chplan_new[k].ScanType = chplan_sta[i].ScanType; i++; k++; @@ -4911,18 +4926,19 @@ static void process_80211d(struct rtw_adapter *padapter, struct wlan_bssid_ex *b channel = bssid->Configuration.DSConfig; chplan_new = pmlmeext->channel_set; i = 0; - while ((i < MAX_CHANNEL_NUM) && (chplan_new[i].ChannelNum != 0)) { - if (chplan_new[i].ChannelNum == channel) - { + while (i < MAX_CHANNEL_NUM && chplan_new[i].ChannelNum != 0) { + if (chplan_new[i].ChannelNum == channel) { if (chplan_new[i].ScanType == SCAN_PASSIVE) { - /* 5G Bnad 2, 3 (DFS) doesn't change to active scan */ + /* 5G Bnad 2, 3 (DFS) doesn't change + to active scan */ if (channel >= 52 && channel <= 144) break; chplan_new[i].ScanType = SCAN_ACTIVE; RT_TRACE(_module_rtl871x_mlme_c_, _drv_notice_, - ("%s: change channel %d scan type from passive to active\n", - __func__, channel)); + ("%s: change channel %d scan type " + "from passive to active\n", + __func__, channel)); } break; } -- cgit v1.2.3 From f73255d4d8d42967d8daa060d04e5dc2c50d984f Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:43:47 +0200 Subject: staging: rtl8723au: collect_bss_info23a(): Convert to use cfg80211_fine_ie() Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 157 +++++++++++++------------- 1 file changed, 76 insertions(+), 81 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index a8814d4bd575..81bdc915af92 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -4343,25 +4343,25 @@ void site_survey23a(struct rtw_adapter *padapter) } /* collect bss info from Beacon and Probe request/response frames. */ -u8 collect_bss_info23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame, struct wlan_bssid_ex *bssid) +u8 collect_bss_info23a(struct rtw_adapter *padapter, + struct recv_frame *precv_frame, + struct wlan_bssid_ex *bssid) { - int i; - u32 len; - u8 *p; - u16 val16; + int i, length; + const u8 *p; + u16 val16; struct sk_buff *skb = precv_frame->pkt; struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; - u8 *pframe = skb->data; - u32 packet_len = skb->len; + u8 *pframe = skb->data; + int packet_len = skb->len; u8 ie_offset; - struct registry_priv *pregistrypriv = &padapter->registrypriv; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct registry_priv *pregistrypriv = &padapter->registrypriv; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; - len = packet_len - sizeof(struct ieee80211_hdr_3addr); + length = packet_len - sizeof(struct ieee80211_hdr_3addr); - if (len > MAX_IE_SZ) - { + if (length > MAX_IE_SZ) { /* DBG_8723A("IE too long for survey event\n"); */ return _FAIL; } @@ -4385,99 +4385,92 @@ u8 collect_bss_info23a(struct rtw_adapter *padapter, struct recv_frame *precv_fr } } - bssid->Length = sizeof(struct wlan_bssid_ex) - MAX_IE_SZ + len; + bssid->Length = sizeof(struct wlan_bssid_ex) - MAX_IE_SZ + length; /* below is to copy the information element */ - bssid->IELength = len; - memcpy(bssid->IEs, (pframe + sizeof(struct ieee80211_hdr_3addr)), bssid->IELength); + bssid->IELength = length; + memcpy(bssid->IEs, pframe + sizeof(struct ieee80211_hdr_3addr), + bssid->IELength); /* get the signal strength */ - bssid->Rssi = precv_frame->attrib.phy_info.RecvSignalPower; /* in dBM.raw data */ - bssid->PhyInfo.SignalQuality = precv_frame->attrib.phy_info.SignalQuality;/* in percentage */ - bssid->PhyInfo.SignalStrength = precv_frame->attrib.phy_info.SignalStrength;/* in percentage */ + /* in dBM.raw data */ + bssid->Rssi = precv_frame->attrib.phy_info.RecvSignalPower; + bssid->PhyInfo.SignalQuality = + precv_frame->attrib.phy_info.SignalQuality;/* in percentage */ + bssid->PhyInfo.SignalStrength = + precv_frame->attrib.phy_info.SignalStrength;/* in percentage */ /* checking SSID */ - if ((p = rtw_get_ie23a(bssid->IEs + ie_offset, WLAN_EID_SSID, &len, - bssid->IELength - ie_offset)) == NULL) - { + p = cfg80211_find_ie(WLAN_EID_SSID, bssid->IEs + ie_offset, + bssid->IELength - ie_offset); + + if (!p) { DBG_8723A("marc: cannot find SSID for survey event\n"); return _FAIL; } - if (*(p + 1)) { - if (len > IEEE80211_MAX_SSID_LEN) { - DBG_8723A("%s()-%d: IE too long (%d) for survey " - "event\n", __func__, __LINE__, len); - return _FAIL; - } - memcpy(bssid->Ssid.ssid, (p + 2), *(p + 1)); - bssid->Ssid.ssid_len = *(p + 1); - } else { - bssid->Ssid.ssid_len = 0; + if (p[1] > IEEE80211_MAX_SSID_LEN) { + DBG_8723A("%s()-%d: IE too long (%d) for survey " + "event\n", __func__, __LINE__, p[1]); + return _FAIL; } + memcpy(bssid->Ssid.ssid, p + 2, p[1]); + bssid->Ssid.ssid_len = p[1]; memset(bssid->SupportedRates, 0, NDIS_802_11_LENGTH_RATES_EX); /* checking rate info... */ i = 0; - p = rtw_get_ie23a(bssid->IEs + ie_offset, WLAN_EID_SUPP_RATES, &len, - bssid->IELength - ie_offset); - if (p != NULL) - { - if (len > NDIS_802_11_LENGTH_RATES_EX) - { - DBG_8723A("%s()-%d: IE too long (%d) for survey event\n", __func__, __LINE__, len); + p = cfg80211_find_ie(WLAN_EID_SUPP_RATES, bssid->IEs + ie_offset, + bssid->IELength - ie_offset); + if (p) { + if (p[1] > NDIS_802_11_LENGTH_RATES_EX) { + DBG_8723A("%s()-%d: IE too long (%d) for survey " + "event\n", __func__, __LINE__, p[1]); return _FAIL; } - memcpy(bssid->SupportedRates, (p + 2), len); - i = len; + memcpy(bssid->SupportedRates, p + 2, p[1]); + i = p[1]; } - p = rtw_get_ie23a(bssid->IEs + ie_offset, WLAN_EID_EXT_SUPP_RATES, - &len, bssid->IELength - ie_offset); - if (p != NULL) - { - if (len > (NDIS_802_11_LENGTH_RATES_EX-i)) - { - DBG_8723A("%s()-%d: IE too long (%d) for survey event\n", __func__, __LINE__, len); + p = cfg80211_find_ie(WLAN_EID_EXT_SUPP_RATES, bssid->IEs + ie_offset, + bssid->IELength - ie_offset); + if (p) { + if (p[1] > (NDIS_802_11_LENGTH_RATES_EX-i)) { + DBG_8723A("%s()-%d: IE too long (%d) for survey " + "event\n", __func__, __LINE__, p[1]); return _FAIL; } - memcpy(bssid->SupportedRates + i, (p + 2), len); + memcpy(bssid->SupportedRates + i, p + 2, p[1]); } - /* todo: */ - { - bssid->NetworkTypeInUse = Ndis802_11OFDM24; - } + bssid->NetworkTypeInUse = Ndis802_11OFDM24; if (bssid->IELength < 12) return _FAIL; /* Checking for DSConfig */ - p = rtw_get_ie23a(bssid->IEs + ie_offset, WLAN_EID_DS_PARAMS, &len, - bssid->IELength - ie_offset); + p = cfg80211_find_ie(WLAN_EID_DS_PARAMS, bssid->IEs + ie_offset, + bssid->IELength - ie_offset); bssid->Configuration.DSConfig = 0; bssid->Configuration.Length = 0; - if (p) - { - bssid->Configuration.DSConfig = *(p + 2); - } - else - {/* In 5G, some ap do not have DSSET IE */ + if (p) { + bssid->Configuration.DSConfig = p[2]; + } else {/* In 5G, some ap do not have DSSET IE */ /* checking HT info for channel */ - p = rtw_get_ie23a(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); - bssid->Configuration.DSConfig = HT_info->primary_channel; - } - else - { /* use current channel */ - bssid->Configuration.DSConfig = rtw_get_oper_ch23a(padapter); + p = cfg80211_find_ie(WLAN_EID_HT_OPERATION, + bssid->IEs + ie_offset, + bssid->IELength - ie_offset); + if (p) { + struct HT_info_element *HT_info = + (struct HT_info_element *)(p + 2); + bssid->Configuration.DSConfig = + HT_info->primary_channel; + } else { /* use current channel */ + bssid->Configuration.DSConfig = + rtw_get_oper_ch23a(padapter); } } @@ -4489,8 +4482,10 @@ u8 collect_bss_info23a(struct rtw_adapter *padapter, struct recv_frame *precv_fr return _SUCCESS; } - memcpy(&bssid->Configuration.BeaconPeriod, rtw_get_beacon_interval23a_from_ie(bssid->IEs), 2); - bssid->Configuration.BeaconPeriod = le32_to_cpu(bssid->Configuration.BeaconPeriod); + memcpy(&bssid->Configuration.BeaconPeriod, + rtw_get_beacon_interval23a_from_ie(bssid->IEs), 2); + bssid->Configuration.BeaconPeriod = + le32_to_cpu(bssid->Configuration.BeaconPeriod); val16 = rtw_get_capability23a(bssid); @@ -4510,21 +4505,21 @@ u8 collect_bss_info23a(struct rtw_adapter *padapter, struct recv_frame *precv_fr bssid->Configuration.ATIMWindow = 0; /* 20/40 BSS Coexistence check */ - if ((pregistrypriv->wifi_spec == 1) && (false == pmlmeinfo->bwmode_updated)) - { + if (pregistrypriv->wifi_spec == 1 && + pmlmeinfo->bwmode_updated == false) { struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - p = rtw_get_ie23a(bssid->IEs + ie_offset, WLAN_EID_HT_CAPABILITY, &len, bssid->IELength - ie_offset); - if (p && len > 0) { - struct HT_caps_element *pHT_caps; - pHT_caps = (struct HT_caps_element *)(p + 2); + p = cfg80211_find_ie(WLAN_EID_HT_CAPABILITY, + bssid->IEs + ie_offset, + bssid->IELength - ie_offset); + if (p && p[1] > 0) { + struct HT_caps_element *pHT_caps; + pHT_caps = (struct HT_caps_element *)(p + 2); if (pHT_caps->u.HT_cap_element.HT_caps_info & BIT(14)) pmlmepriv->num_FortyMHzIntolerant++; } else - { pmlmepriv->num_sta_no_ht++; - } } -- cgit v1.2.3 From 78b7d04719249ba495696210d39de8c07ab028b5 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:43:48 +0200 Subject: staging: rtl8723au: issue_action_BSSCoexistPacket(): Clean + use cfg80211_find_ie() Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 127 ++++++++++++-------------- 1 file changed, 57 insertions(+), 70 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index 81bdc915af92..188cccc616c1 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -4014,24 +4014,26 @@ static void issue_action_BSSCoexistPacket(struct rtw_adapter *padapter) { struct list_head *plist, *phead, *ptmp; unsigned char category, action; - struct xmit_frame *pmgntframe; - struct pkt_attrib *pattrib; - unsigned char *pframe; - struct ieee80211_hdr *pwlanhdr; - unsigned short *fctrl; - struct wlan_network *pnetwork = NULL; + struct xmit_frame *pmgntframe; + struct pkt_attrib *pattrib; + u8 *pframe; + struct ieee80211_hdr *pwlanhdr; + unsigned short *fctrl; + struct wlan_network *pnetwork; struct xmit_priv *pxmitpriv = &padapter->xmitpriv; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; - struct rtw_queue *queue = &pmlmepriv->scanned_queue; + struct rtw_queue *queue = &pmlmepriv->scanned_queue; u8 InfoContent[16] = {0}; u8 ICS[8][15]; + int i; - if ((pmlmepriv->num_FortyMHzIntolerant == 0) || (pmlmepriv->num_sta_no_ht == 0)) + if (pmlmepriv->num_FortyMHzIntolerant == 0 || + pmlmepriv->num_sta_no_ht == 0) return; - if (true == pmlmeinfo->bwmode_updated) + if (pmlmeinfo->bwmode_updated) return; DBG_8723A("%s\n", __func__); @@ -4039,10 +4041,9 @@ static void issue_action_BSSCoexistPacket(struct rtw_adapter *padapter) category = WLAN_CATEGORY_PUBLIC; action = ACT_PUBLIC_BSSCOEXIST; - if ((pmgntframe = alloc_mgtxmitframe23a(pxmitpriv)) == NULL) - { + pmgntframe = alloc_mgtxmitframe23a(pxmitpriv); + if (!pmgntframe) return; - } /* update attribute */ pattrib = &pmgntframe->attrib; @@ -4050,7 +4051,7 @@ static void issue_action_BSSCoexistPacket(struct rtw_adapter *padapter) memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET); - pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET; + pframe = (u8 *)pmgntframe->buf_addr + TXDESC_OFFSET; pwlanhdr = (struct ieee80211_hdr *)pframe; fctrl = &pwlanhdr->frame_control; @@ -4070,88 +4071,74 @@ static void issue_action_BSSCoexistPacket(struct rtw_adapter *padapter) pframe = rtw_set_fixed_ie23a(pframe, 1, &category, &pattrib->pktlen); pframe = rtw_set_fixed_ie23a(pframe, 1, &action, &pattrib->pktlen); - /* */ - if (pmlmepriv->num_FortyMHzIntolerant>0) - { - u8 iedata = 0; - - iedata |= BIT(2);/* 20 MHz BSS Width Request */ + if (pmlmepriv->num_FortyMHzIntolerant > 0) { + u8 iedata = BIT(2);/* 20 MHz BSS Width Request */ - pframe = rtw_set_ie23a(pframe, WLAN_EID_BSS_COEX_2040, 1, + pframe = rtw_set_ie23a(pframe, WLAN_EID_BSS_COEX_2040, 1, &iedata, &pattrib->pktlen); } - /* */ - memset(ICS, 0, sizeof(ICS)); - if (pmlmepriv->num_sta_no_ht>0) - { - int i; + if (pmlmepriv->num_sta_no_ht <= 0) + goto out; - spin_lock_bh(&pmlmepriv->scanned_queue.lock); + memset(ICS, 0, sizeof(ICS)); - phead = get_list_head(queue); - plist = phead->next; + spin_lock_bh(&pmlmepriv->scanned_queue.lock); - list_for_each_safe(plist, ptmp, phead) { - int len; - u8 *p; - struct wlan_bssid_ex *pbss_network; + phead = get_list_head(queue); + plist = phead->next; - pnetwork = container_of(plist, struct wlan_network, - list); + list_for_each_safe(plist, ptmp, phead) { + const u8 *p; + struct wlan_bssid_ex *pbss_network; - pbss_network = &pnetwork->network; + pnetwork = container_of(plist, struct wlan_network, list); - p = rtw_get_ie23a(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)) - continue; + pbss_network = &pnetwork->network; - ICS[0][pbss_network->Configuration.DSConfig]= 1; + p = cfg80211_find_ie(WLAN_EID_HT_CAPABILITY, + pbss_network->IEs + _FIXED_IE_LENGTH_, + pbss_network->IELength -_FIXED_IE_LENGTH_); + if (!p || !p[1]) { /* non-HT */ + if (pbss_network->Configuration.DSConfig <= 0 || + pbss_network->Configuration.DSConfig > 14) + continue; - if (ICS[0][0] == 0) - ICS[0][0] = 1; - } + ICS[0][pbss_network->Configuration.DSConfig] = 1; + if (ICS[0][0] == 0) + ICS[0][0] = 1; } - spin_unlock_bh(&pmlmepriv->scanned_queue.lock); + } - for (i = 0;i<8;i++) - { - if (ICS[i][0] == 1) - { - int j, k = 0; + spin_unlock_bh(&pmlmepriv->scanned_queue.lock); - InfoContent[k] = i; - /* SET_BSS_INTOLERANT_ELE_REG_CLASS(InfoContent, i); */ - k++; + for (i = 0; i < 8;i++) { + if (ICS[i][0] == 1) { + int j, k = 0; - for (j = 1;j<= 14;j++) - { - if (ICS[i][j]== 1) - { - if (k<16) - { - InfoContent[k] = j; /* channel number */ - /* SET_BSS_INTOLERANT_ELE_CHANNEL(InfoContent+k, j); */ - k++; - } + InfoContent[k] = i; + /* SET_BSS_INTOLERANT_ELE_REG_CLASS(InfoContent, i); */ + k++; + + for (j = 1; j <= 14; j++) { + if (ICS[i][j] == 1) { + if (k < 16) { + /* channel number */ + InfoContent[k] = j; + k++; } } - - pframe = rtw_set_ie23a(pframe, EID_BSSIntolerantChlReport, k, InfoContent, &pattrib->pktlen); - } + pframe = rtw_set_ie23a(pframe, + EID_BSSIntolerantChlReport, k, + InfoContent, &pattrib->pktlen); } - } +out: pattrib->last_txcmdsz = pattrib->pktlen; dump_mgntframe23a(padapter, pmgntframe); -- cgit v1.2.3 From 0b2b676d590a07a3a4c1c5aceab59bbeea65a965 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:43:49 +0200 Subject: staging: rtl8723au: issue_assocreq23a(): General cleanups and use cfg80211_find_ie() Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 77 +++++++++++++-------------- 1 file changed, 36 insertions(+), 41 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index 188cccc616c1..368c7de03234 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -3136,11 +3136,11 @@ void issue_assocreq23a(struct rtw_adapter *padapter) int ret = _FAIL; struct xmit_frame *pmgntframe; struct pkt_attrib *pattrib; - unsigned char *pframe, *p; + unsigned char *pframe; + const u8 *p; struct ieee80211_hdr *pwlanhdr; unsigned short *fctrl; - unsigned short val16; - unsigned int i, j, ie_len, index = 0; + unsigned int i, j, index = 0; unsigned char rf_type, bssrate[NumRates], sta_bssrate[NumRates]; struct ndis_802_11_var_ies *pIE; struct registry_priv *pregpriv = &padapter->registrypriv; @@ -3148,9 +3148,11 @@ void issue_assocreq23a(struct rtw_adapter *padapter) struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; - int bssrate_len = 0, sta_bssrate_len = 0; + int bssrate_len = 0, sta_bssrate_len = 0, pie_len; + u8 * pie; - if ((pmgntframe = alloc_mgtxmitframe23a(pxmitpriv)) == NULL) + pmgntframe = alloc_mgtxmitframe23a(pxmitpriv); + if (!pmgntframe) goto exit; /* update attribute */ @@ -3159,7 +3161,7 @@ void issue_assocreq23a(struct rtw_adapter *padapter) memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET); - pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET; + pframe = (u8 *)pmgntframe->buf_addr + TXDESC_OFFSET; pwlanhdr = (struct ieee80211_hdr *)pframe; fctrl = &pwlanhdr->frame_control; @@ -3176,16 +3178,15 @@ void issue_assocreq23a(struct rtw_adapter *padapter) pattrib->pktlen = sizeof(struct ieee80211_hdr_3addr); /* caps */ - memcpy(pframe, rtw_get_capability23a_from_ie(pmlmeinfo->network.IEs), - 2); + memcpy(pframe, + rtw_get_capability23a_from_ie(pmlmeinfo->network.IEs), 2); pframe += 2; pattrib->pktlen += 2; /* listen interval */ /* todo: listen interval for power saving */ - val16 = cpu_to_le16(3); - memcpy(pframe, (unsigned char *)&val16, 2); + put_unaligned_le16(3, pframe); pframe += 2; pattrib->pktlen += 2; @@ -3225,7 +3226,7 @@ void issue_assocreq23a(struct rtw_adapter *padapter) Handlink WSG-4000 AP */ if ((pmlmeinfo->network.SupportedRates[i] | IEEE80211_BASIC_RATE_MASK) == - (sta_bssrate[j]|IEEE80211_BASIC_RATE_MASK)) { + (sta_bssrate[j] | IEEE80211_BASIC_RATE_MASK)) { /* DBG_8723A("match i = %d, j =%d\n", i, j); */ break; } @@ -3262,23 +3263,21 @@ void issue_assocreq23a(struct rtw_adapter *padapter) bssrate_len, bssrate, &pattrib->pktlen); /* RSN */ - p = rtw_get_ie23a((pmlmeinfo->network.IEs + - sizeof(struct ndis_802_11_fixed_ies)), WLAN_EID_RSN, - &ie_len, (pmlmeinfo->network.IELength - - sizeof(struct ndis_802_11_fixed_ies))); + pie = pmlmeinfo->network.IEs + sizeof(struct ndis_802_11_fixed_ies); + pie_len = pmlmeinfo->network.IELength - + sizeof(struct ndis_802_11_fixed_ies); + + p = cfg80211_find_ie(WLAN_EID_RSN, pie, pie_len); if (p) - pframe = rtw_set_ie23a(pframe, WLAN_EID_RSN, ie_len, (p + 2), + pframe = rtw_set_ie23a(pframe, WLAN_EID_RSN, p[1], p + 2, &pattrib->pktlen); /* HT caps */ if (padapter->mlmepriv.htpriv.ht_option == true) { - p = rtw_get_ie23a((pmlmeinfo->network.IEs + - sizeof(struct ndis_802_11_fixed_ies)), - WLAN_EID_HT_CAPABILITY, &ie_len, - (pmlmeinfo->network.IELength - - sizeof(struct ndis_802_11_fixed_ies))); - if ((p != NULL) && (!(is_ap_in_tkip23a(padapter)))) { - memcpy(&pmlmeinfo->HT_caps, (p + 2), + p = cfg80211_find_ie(WLAN_EID_HT_CAPABILITY, pie, pie_len); + + if (p && !is_ap_in_tkip23a(padapter)) { + memcpy(&pmlmeinfo->HT_caps, p + 2, sizeof(struct HT_caps_element)); /* to disable 40M Hz support while gd_bw_40MHz_en = 0 */ @@ -3294,12 +3293,11 @@ void issue_assocreq23a(struct rtw_adapter *padapter) rf_type = rtl8723a_get_rf_type(padapter); /* switch (pregpriv->rf_config) */ - switch (rf_type) - { + switch (rf_type) { case RF_1T1R: - + /* RX STBC One spatial stream */ if (pregpriv->rx_stbc) - pmlmeinfo->HT_caps.u.HT_cap_element.HT_caps_info |= cpu_to_le16(0x0100);/* RX STBC One spatial stream */ + pmlmeinfo->HT_caps.u.HT_cap_element.HT_caps_info |= cpu_to_le16(0x0100); memcpy(pmlmeinfo->HT_caps.u.HT_cap_element.MCS_rate, MCS_rate_1R23A, 16); break; @@ -3307,18 +3305,17 @@ void issue_assocreq23a(struct rtw_adapter *padapter) case RF_2T2R: case RF_1T2R: default: - /* enable for 2.4/5 GHz */ - if ((pregpriv->rx_stbc == 0x3) || - ((pmlmeext->cur_wireless_mode & - WIRELESS_11_24N) && + if (pregpriv->rx_stbc == 0x3 || + (pmlmeext->cur_wireless_mode & + WIRELESS_11_24N && /* enable for 2.4GHz */ - (pregpriv->rx_stbc == 0x1)) || - ((pmlmeext->cur_wireless_mode & - WIRELESS_11_5N) && - (pregpriv->rx_stbc == 0x2)) || + pregpriv->rx_stbc == 0x1) || + (pmlmeext->cur_wireless_mode & + WIRELESS_11_5N && + pregpriv->rx_stbc == 0x2) || /* enable for 5GHz */ - (pregpriv->wifi_spec == 1)) { + pregpriv->wifi_spec == 1) { DBG_8723A("declare supporting RX " "STBC\n"); pmlmeinfo->HT_caps.u.HT_cap_element.HT_caps_info |= cpu_to_le16(0x0200);/* RX STBC two spatial stream */ @@ -3338,8 +3335,7 @@ void issue_assocreq23a(struct rtw_adapter *padapter) #endif pframe = rtw_set_ie23a(pframe, WLAN_EID_HT_CAPABILITY, - ie_len, - (u8 *)&pmlmeinfo->HT_caps, + p[1], (u8 *)&pmlmeinfo->HT_caps, &pattrib->pktlen); } } @@ -3375,7 +3371,7 @@ void issue_assocreq23a(struct rtw_adapter *padapter) break; } - i += (pIE->Length + 2); + i += pIE->Length + 2; } if (pmlmeinfo->assoc_AP_vendor == HT_IOT_PEER_REALTEK) @@ -3393,8 +3389,7 @@ exit: kfree(pmlmepriv->assoc_req); pmlmepriv->assoc_req = kmalloc(pattrib->pktlen, GFP_ATOMIC); if (pmlmepriv->assoc_req) { - memcpy(pmlmepriv->assoc_req, pwlanhdr, - pattrib->pktlen); + memcpy(pmlmepriv->assoc_req, pwlanhdr, pattrib->pktlen); pmlmepriv->assoc_req_len = pattrib->pktlen; } } else -- cgit v1.2.3 From cfe4ecdc806bfdb49cf7c6d5bd5251d1d0e4ff63 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:43:50 +0200 Subject: staging: rtl8723au: issue_asocrsp23a(): Use cfg80211_find_ie() and cleanups Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 63 ++++++++++++++------------- 1 file changed, 33 insertions(+), 30 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index 368c7de03234..e5e6aa5f90c6 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -2993,18 +2993,20 @@ void issue_asocrsp23a(struct rtw_adapter *padapter, unsigned short status, struct xmit_frame *pmgntframe; struct ieee80211_hdr *pwlanhdr; struct pkt_attrib *pattrib; - unsigned char *pbuf, *pframe; + unsigned char *pframe; unsigned short val; struct xmit_priv *pxmitpriv = &padapter->xmitpriv; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; struct wlan_bssid_ex *pnetwork = &pmlmeinfo->network; + const u8 *p; u8 *ie = pnetwork->IEs; DBG_8723A("%s\n", __func__); - if ((pmgntframe = alloc_mgtxmitframe23a(pxmitpriv)) == NULL) + pmgntframe = alloc_mgtxmitframe23a(pxmitpriv); + if (!pmgntframe) return; /* update attribute */ @@ -3024,7 +3026,7 @@ void issue_asocrsp23a(struct rtw_adapter *padapter, unsigned short status, SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq); pmlmeext->mgnt_seq++; - if ((pkt_type == WIFI_ASSOCRSP) || (pkt_type == WIFI_REASSOCRSP)) + if (pkt_type == WIFI_ASSOCRSP || pkt_type == WIFI_REASSOCRSP) SetFrameSubType(pwlanhdr, pkt_type); else return; @@ -3060,52 +3062,53 @@ void issue_asocrsp23a(struct rtw_adapter *padapter, unsigned short status, pstat->bssrateset + 8, &pattrib->pktlen); } - if ((pstat->flags & WLAN_STA_HT) && (pmlmepriv->htpriv.ht_option)) { - uint ie_len = 0; - + if (pstat->flags & WLAN_STA_HT && pmlmepriv->htpriv.ht_option) { /* FILL HT CAP INFO IE */ /* p = hostapd_eid_ht_capabilities_info(hapd, p); */ - pbuf = rtw_get_ie23a(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); - pattrib->pktlen += (ie_len + 2); + p = cfg80211_find_ie(WLAN_EID_HT_CAPABILITY, + ie + _BEACON_IE_OFFSET_, + pnetwork->IELength -_BEACON_IE_OFFSET_); + if (p && p[1]) { + memcpy(pframe, p, p[1] + 2); + pframe += (p[1] + 2); + pattrib->pktlen += (p[1] + 2); } /* FILL HT ADD INFO IE */ /* p = hostapd_eid_ht_operation(hapd, p); */ - pbuf = rtw_get_ie23a(ie + _BEACON_IE_OFFSET_, - WLAN_EID_HT_OPERATION, &ie_len, + p = cfg80211_find_ie(WLAN_EID_HT_OPERATION, + ie + _BEACON_IE_OFFSET_, pnetwork->IELength - _BEACON_IE_OFFSET_); - if (pbuf && ie_len > 0) { - memcpy(pframe, pbuf, ie_len + 2); - pframe += (ie_len + 2); - pattrib->pktlen += (ie_len + 2); + if (p && p[1] > 0) { + memcpy(pframe, p, p[1] + 2); + pframe += (p[1] + 2); + pattrib->pktlen += (p[1] + 2); } } /* FILL WMM IE */ - if ((pstat->flags & WLAN_STA_WME) && pmlmepriv->qospriv.qos_option) { - uint ie_len = 0; + if (pstat->flags & WLAN_STA_WME && pmlmepriv->qospriv.qos_option) { unsigned char WMM_PARA_IE[] = {0x00, 0x50, 0xf2, 0x02, 0x01, 0x01}; - - for (pbuf = ie + _BEACON_IE_OFFSET_; ; pbuf += (ie_len + 2)) { - pbuf = rtw_get_ie23a(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); + int ie_len = 0; + + for (p = ie + _BEACON_IE_OFFSET_; ; p += (ie_len + 2)) { + p = cfg80211_find_ie(WLAN_EID_VENDOR_SPECIFIC, p, + pnetwork->IELength - + _BEACON_IE_OFFSET_ - (ie_len + 2)); + if (p) + ie_len = p[1]; + else + ie_len = 0; + if (p && !memcmp(p + 2, WMM_PARA_IE, 6)) { + memcpy(pframe, p, ie_len + 2); pframe += (ie_len + 2); pattrib->pktlen += (ie_len + 2); break; } - if ((!pbuf) || (ie_len == 0)) + if (!p || ie_len == 0) break; } } -- cgit v1.2.3 From 858e66584090b666d2f984864104bf31b70e65bb Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:43:51 +0200 Subject: staging: rtl8723au: issue_probersp23a(): various cleanups Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 35 +++++++++++++-------------- 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index e5e6aa5f90c6..a66216fffaca 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -2484,8 +2484,8 @@ void issue_probersp23a(struct rtw_adapter *padapter, unsigned char *da, /* DBG_8723A("%s\n", __func__); */ - if ((pmgntframe = alloc_mgtxmitframe23a(pxmitpriv)) == NULL) - { + pmgntframe = alloc_mgtxmitframe23a(pxmitpriv); + if (!pmgntframe) { DBG_8723A("%s, alloc mgnt frame fail\n", __func__); return; } @@ -2496,7 +2496,7 @@ void issue_probersp23a(struct rtw_adapter *padapter, unsigned char *da, memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET); - pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET; + pframe = (u8 *)pmgntframe->buf_addr + TXDESC_OFFSET; pwlanhdr = (struct ieee80211_hdr *)pframe; mac = myid(&padapter->eeprompriv); @@ -2528,8 +2528,7 @@ void issue_probersp23a(struct rtw_adapter *padapter, unsigned char *da, &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; @@ -2546,14 +2545,14 @@ void issue_probersp23a(struct rtw_adapter *padapter, unsigned char *da, /* to get ie data len */ wps_ielen = (uint)pmlmepriv->wps_probe_resp_ie[1]; - if ((wps_offset+wps_ielen+2)<= MAX_IE_SZ) { + if (wps_offset + wps_ielen + 2 <= MAX_IE_SZ) { memcpy(pframe, pmlmepriv->wps_probe_resp_ie, wps_ielen+2); pframe += wps_ielen+2; pattrib->pktlen += wps_ielen+2; } - if ((wps_offset+wps_ielen+2+remainder_ielen) <= + if (wps_offset + wps_ielen + 2 + remainder_ielen <= MAX_IE_SZ) { memcpy(pframe, premainder_ie, remainder_ielen); pframe += remainder_ielen; @@ -2569,9 +2568,9 @@ void issue_probersp23a(struct rtw_adapter *padapter, unsigned char *da, ies = pmgntframe->buf_addr + TXDESC_OFFSET + sizeof(struct ieee80211_hdr_3addr); - ssid_ie = rtw_get_ie23a(ies+_FIXED_IE_LENGTH_, WLAN_EID_SSID, + ssid_ie = rtw_get_ie23a(ies + _FIXED_IE_LENGTH_, WLAN_EID_SSID, &ssid_ielen, - (pframe-ies)-_FIXED_IE_LENGTH_); + pframe - ies - _FIXED_IE_LENGTH_); ssid_ielen_diff = cur_network->Ssid.ssid_len - ssid_ielen; @@ -2579,20 +2578,19 @@ void issue_probersp23a(struct rtw_adapter *padapter, unsigned char *da, uint remainder_ielen; u8 *remainder_ie; remainder_ie = ssid_ie + 2; - remainder_ielen = (pframe-remainder_ie); + remainder_ielen = pframe - remainder_ie; DBG_8723A_LEVEL(_drv_warning_, FUNC_ADPT_FMT " remainder_ielen > MAX_IE_SZ\n", FUNC_ADPT_ARG(padapter)); - if (remainder_ielen > MAX_IE_SZ) { + if (remainder_ielen > MAX_IE_SZ) remainder_ielen = MAX_IE_SZ; - } memcpy(buf, remainder_ie, remainder_ielen); - memcpy(remainder_ie+ssid_ielen_diff, buf, + memcpy(remainder_ie + ssid_ielen_diff, buf, remainder_ielen); - *(ssid_ie+1) = cur_network->Ssid.ssid_len; - memcpy(ssid_ie+2, cur_network->Ssid.ssid, + *(ssid_ie + 1) = cur_network->Ssid.ssid_len; + memcpy(ssid_ie + 2, cur_network->Ssid.ssid, cur_network->Ssid.ssid_len); pframe += ssid_ielen_diff; @@ -2626,8 +2624,9 @@ void issue_probersp23a(struct rtw_adapter *padapter, unsigned char *da, /* SSID */ pframe = rtw_set_ie23a(pframe, WLAN_EID_SSID, - cur_network->Ssid.ssid_len, - cur_network->Ssid.ssid, &pattrib->pktlen); + cur_network->Ssid.ssid_len, + cur_network->Ssid.ssid, + &pattrib->pktlen); /* supported rates... */ rate_len = rtw_get_rateset_len23a(cur_network->SupportedRates); @@ -2642,7 +2641,7 @@ void issue_probersp23a(struct rtw_adapter *padapter, unsigned char *da, &cur_network->Configuration.DSConfig, &pattrib->pktlen); - if ((pmlmeinfo->state&0x03) == WIFI_FW_ADHOC_STATE) { + if ((pmlmeinfo->state & 0x03) == WIFI_FW_ADHOC_STATE) { u8 erpinfo = 0; u32 ATIMWindow; /* IBSS Parameter Set... */ -- cgit v1.2.3 From da290c54610f49ef475f7f88668259216b08fc36 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:43:52 +0200 Subject: staging: rtl8723au: OnAssocReq23a(): Clean up and use more ieee80211.h This converts it to use struct ieee80211_mgmt and cfg80211_find_ie(). In addition fix a potential buffer overrun in the last loop searching through list WLAN_EID_VENDOR_SPECIFIC elements. Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 276 ++++++++++++-------------- 1 file changed, 131 insertions(+), 145 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index a66216fffaca..5264c24470b0 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -1119,13 +1119,12 @@ unsigned int OnAssocReq23a(struct rtw_adapter *padapter, struct recv_frame *prec u16 capab_info, listen_interval; struct rtw_ieee802_11_elems elems; struct sta_info *pstat; - unsigned char reassoc, *p, *pos, *wpa_ie; + unsigned char reassoc, *wpa_ie; unsigned char WMM_IE[] = {0x00, 0x50, 0xf2, 0x02, 0x00, 0x01}; - int i, ie_len, wpa_ie_len, left; - unsigned char supportRate[16]; - int supportRateNum; - unsigned short status = WLAN_STATUS_SUCCESS; - unsigned short ie_offset; + int i, wpa_ie_len, left; + unsigned char supportRate[16]; + int supportRateNum; + unsigned short status = WLAN_STATUS_SUCCESS; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct security_priv *psecuritypriv = &padapter->securitypriv; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; @@ -1133,61 +1132,56 @@ unsigned int OnAssocReq23a(struct rtw_adapter *padapter, struct recv_frame *prec struct wlan_bssid_ex *cur = &pmlmeinfo->network; struct sta_priv *pstapriv = &padapter->stapriv; struct sk_buff *skb = precv_frame->pkt; + struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *) skb->data; + const u8 *p; + u8 *pos; u8 *pframe = skb->data; uint pkt_len = skb->len; - struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; - u16 frame_control; - if ((pmlmeinfo->state&0x03) != WIFI_FW_AP_STATE) + if ((pmlmeinfo->state & 0x03) != WIFI_FW_AP_STATE) return _FAIL; - frame_control = hdr->frame_control; - if (ieee80211_is_assoc_req(frame_control)) { + left = pkt_len - sizeof(struct ieee80211_hdr_3addr); + if (ieee80211_is_assoc_req(mgmt->frame_control)) { reassoc = 0; - ie_offset = _ASOCREQ_IE_OFFSET_; + pos = mgmt->u.assoc_req.variable; + left -= _ASOCREQ_IE_OFFSET_; } else { /* WIFI_REASSOCREQ */ reassoc = 1; - ie_offset = _REASOCREQ_IE_OFFSET_; + pos = mgmt->u.reassoc_req.variable; + left -= _REASOCREQ_IE_OFFSET_; } - if (pkt_len < sizeof(struct ieee80211_hdr_3addr) + ie_offset) { - DBG_8723A("handle_assoc(reassoc =%d) - too short payload (len =%lu)" - "\n", reassoc, (unsigned long)pkt_len); + if (left < 0) { + DBG_8723A("handle_assoc(reassoc =%d) - too short payload " + "(len =%lu)\n", reassoc, (unsigned long)pkt_len); return _FAIL; } - pstat = rtw_get_stainfo23a(pstapriv, hdr->addr2); + pstat = rtw_get_stainfo23a(pstapriv, mgmt->sa); if (!pstat) { status = WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA; goto asoc_class2_error; } - capab_info = get_unaligned_le16(pframe + sizeof(struct ieee80211_hdr_3addr)); - /* capab_info = le16_to_cpu(*(unsigned short *)(pframe + sizeof(struct ieee80211_hdr_3addr))); */ - /* listen_interval = le16_to_cpu(*(unsigned short *)(pframe + sizeof(struct ieee80211_hdr_3addr)+2)); */ - listen_interval = get_unaligned_le16(pframe + sizeof(struct ieee80211_hdr_3addr)+2); - - left = pkt_len - (sizeof(struct ieee80211_hdr_3addr) + ie_offset); - pos = pframe + (sizeof(struct ieee80211_hdr_3addr) + ie_offset); + /* These two are located at the same offsets whether it's an + * assoc_req or a reassoc_req */ + capab_info = get_unaligned_le16(&mgmt->u.assoc_req.capab_info); + listen_interval = + get_unaligned_le16(&mgmt->u.assoc_req.listen_interval); DBG_8723A("%s\n", __func__); /* check if this stat has been successfully authenticated/assocated */ - if (!((pstat->state) & WIFI_FW_AUTH_SUCCESS)) - { - if (!((pstat->state) & WIFI_FW_ASSOC_SUCCESS)) - { + if (!(pstat->state & WIFI_FW_AUTH_SUCCESS)) { + if (!(pstat->state & WIFI_FW_ASSOC_SUCCESS)) { status = WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA; goto asoc_class2_error; - } - else - { + } else { pstat->state &= (~WIFI_FW_ASSOC_SUCCESS); pstat->state |= WIFI_FW_ASSOC_STATE; } - } - else - { + } else { pstat->state &= (~WIFI_FW_AUTH_SUCCESS); pstat->state |= WIFI_FW_ASSOC_STATE; } @@ -1195,42 +1189,37 @@ unsigned int OnAssocReq23a(struct rtw_adapter *padapter, struct recv_frame *prec pstat->capability = capab_info; /* now parse all ieee802_11 ie to point to elems */ - if (rtw_ieee802_11_parse_elems23a(pos, left, &elems, 1) == ParseFailed || - !elems.ssid) { + if (rtw_ieee802_11_parse_elems23a(pos, left, &elems, 1) == + ParseFailed || !elems.ssid) { DBG_8723A("STA " MAC_FMT " sent invalid association request\n", - MAC_ARG(pstat->hwaddr)); + MAC_ARG(pstat->hwaddr)); status = WLAN_STATUS_UNSPECIFIED_FAILURE; goto OnAssocReq23aFail; } /* now we should check all the fields... */ /* checking SSID */ - p = rtw_get_ie23a(pframe + sizeof(struct ieee80211_hdr_3addr) + - ie_offset, WLAN_EID_SSID, &ie_len, pkt_len - - sizeof(struct ieee80211_hdr_3addr) - ie_offset); - if (p == NULL) - { - status = WLAN_STATUS_UNSPECIFIED_FAILURE; - } - - if (ie_len == 0) /* broadcast ssid, however it is not allowed in assocreq */ + p = cfg80211_find_ie(WLAN_EID_SSID, pos, left); + if (!p || p[1] == 0) { + /* broadcast ssid, however it is not allowed in assocreq */ status = WLAN_STATUS_UNSPECIFIED_FAILURE; - else { + } else { /* check if ssid match */ - if (memcmp((void *)(p+2), cur->Ssid.ssid, cur->Ssid.ssid_len)) + if (memcmp(p + 2, cur->Ssid.ssid, cur->Ssid.ssid_len)) status = WLAN_STATUS_UNSPECIFIED_FAILURE; - if (ie_len != cur->Ssid.ssid_len) + if (p[1] != cur->Ssid.ssid_len) status = WLAN_STATUS_UNSPECIFIED_FAILURE; } - if (WLAN_STATUS_SUCCESS != status) + if (status != WLAN_STATUS_SUCCESS) goto OnAssocReq23aFail; /* check if the supported rate is ok */ - p = rtw_get_ie23a(pframe + sizeof(struct ieee80211_hdr_3addr) + ie_offset, WLAN_EID_SUPP_RATES, &ie_len, pkt_len - sizeof(struct ieee80211_hdr_3addr) - ie_offset); - if (p == NULL) { - DBG_8723A("Rx a sta assoc-req which supported rate is empty!\n"); + p = cfg80211_find_ie(WLAN_EID_SUPP_RATES, pos, left); + if (!p) { + DBG_8723A("Rx a sta assoc-req which supported rate is " + "empty!\n"); /* use our own rate set as statoin used */ /* memcpy(supportRate, AP_BSSRATE, AP_BSSRATE_LEN); */ /* supportRateNum = AP_BSSRATE_LEN; */ @@ -1238,17 +1227,14 @@ unsigned int OnAssocReq23a(struct rtw_adapter *padapter, struct recv_frame *prec status = WLAN_STATUS_UNSPECIFIED_FAILURE; goto OnAssocReq23aFail; } else { - memcpy(supportRate, p+2, ie_len); - supportRateNum = ie_len; - - p = rtw_get_ie23a(pframe + sizeof(struct ieee80211_hdr_3addr) + ie_offset, WLAN_EID_EXT_SUPP_RATES, &ie_len, - pkt_len - sizeof(struct ieee80211_hdr_3addr) - ie_offset); - if (p != NULL) { - - if (supportRateNum<= sizeof(supportRate)) - { - memcpy(supportRate+supportRateNum, p+2, ie_len); - supportRateNum += ie_len; + memcpy(supportRate, p + 2, p[1]); + supportRateNum = p[1]; + + p = cfg80211_find_ie(WLAN_EID_EXT_SUPP_RATES, pos, left); + if (!p) { + if (supportRateNum <= sizeof(supportRate)) { + memcpy(supportRate+supportRateNum, p + 2, p[1]); + supportRateNum += p[1]; } } } @@ -1269,42 +1255,46 @@ unsigned int OnAssocReq23a(struct rtw_adapter *padapter, struct recv_frame *prec pstat->wpa_pairwise_cipher = 0; pstat->wpa2_pairwise_cipher = 0; memset(pstat->wpa_ie, 0, sizeof(pstat->wpa_ie)); - if ((psecuritypriv->wpa_psk & BIT(1)) && elems.rsn_ie) { - + if (psecuritypriv->wpa_psk & BIT(1) && elems.rsn_ie) { int group_cipher = 0, pairwise_cipher = 0; wpa_ie = elems.rsn_ie; wpa_ie_len = elems.rsn_ie_len; - if (rtw_parse_wpa2_ie23a(wpa_ie-2, wpa_ie_len+2, &group_cipher, &pairwise_cipher, NULL) == _SUCCESS) { + if (rtw_parse_wpa2_ie23a(wpa_ie - 2, wpa_ie_len + 2, + &group_cipher, &pairwise_cipher, + NULL) == _SUCCESS) { pstat->dot8021xalg = 1;/* psk, todo:802.1x */ pstat->wpa_psk |= BIT(1); - pstat->wpa2_group_cipher = group_cipher&psecuritypriv->wpa2_group_cipher; - pstat->wpa2_pairwise_cipher = pairwise_cipher&psecuritypriv->wpa2_pairwise_cipher; + pstat->wpa2_group_cipher = + group_cipher&psecuritypriv->wpa2_group_cipher; + pstat->wpa2_pairwise_cipher = + pairwise_cipher&psecuritypriv->wpa2_pairwise_cipher; if (!pstat->wpa2_group_cipher) status = WLAN_REASON_INVALID_GROUP_CIPHER; if (!pstat->wpa2_pairwise_cipher) status = WLAN_REASON_INVALID_PAIRWISE_CIPHER; - } else { + } else status = WLAN_STATUS_INVALID_IE; - } - - } else if ((psecuritypriv->wpa_psk & BIT(0)) && elems.wpa_ie) { - + } else if (psecuritypriv->wpa_psk & BIT(0) && elems.wpa_ie) { int group_cipher = 0, pairwise_cipher = 0; wpa_ie = elems.wpa_ie; wpa_ie_len = elems.wpa_ie_len; - if (rtw_parse_wpa_ie23a(wpa_ie-2, wpa_ie_len+2, &group_cipher, &pairwise_cipher, NULL) == _SUCCESS) { + if (rtw_parse_wpa_ie23a(wpa_ie - 2, wpa_ie_len + 2, + &group_cipher, &pairwise_cipher, + NULL) == _SUCCESS) { pstat->dot8021xalg = 1;/* psk, todo:802.1x */ pstat->wpa_psk |= BIT(0); - pstat->wpa_group_cipher = group_cipher&psecuritypriv->wpa_group_cipher; - pstat->wpa_pairwise_cipher = pairwise_cipher&psecuritypriv->wpa_pairwise_cipher; + pstat->wpa_group_cipher = + group_cipher&psecuritypriv->wpa_group_cipher; + pstat->wpa_pairwise_cipher = + pairwise_cipher&psecuritypriv->wpa_pairwise_cipher; if (!pstat->wpa_group_cipher) status = WLAN_STATUS_INVALID_GROUP_CIPHER; @@ -1312,10 +1302,8 @@ unsigned int OnAssocReq23a(struct rtw_adapter *padapter, struct recv_frame *prec if (!pstat->wpa_pairwise_cipher) status = WLAN_STATUS_INVALID_PAIRWISE_CIPHER; - } else { + } else status = WLAN_STATUS_INVALID_IE; - } - } else { wpa_ie = NULL; wpa_ie_len = 0; @@ -1325,34 +1313,37 @@ unsigned int OnAssocReq23a(struct rtw_adapter *padapter, struct recv_frame *prec goto OnAssocReq23aFail; pstat->flags &= ~(WLAN_STA_WPS | WLAN_STA_MAYBE_WPS); - if (wpa_ie == NULL) { + if (!wpa_ie) { if (elems.wps_ie) { - DBG_8723A("STA included WPS IE in " - "(Re)Association Request - assume WPS is " - "used\n"); + DBG_8723A("STA included WPS IE in (Re)Association " + "Request - assume WPS is used\n"); pstat->flags |= WLAN_STA_WPS; } else { - DBG_8723A("STA did not include WPA/RSN IE " - "in (Re)Association Request - possible WPS " - "use\n"); + DBG_8723A("STA did not include WPA/RSN IE in (Re)" + "Association Request - possible WPS use\n"); pstat->flags |= WLAN_STA_MAYBE_WPS; } - /* AP support WPA/RSN, and sta is going to do WPS, but AP is not ready */ + /* AP support WPA/RSN, and sta is going to do WPS, but AP + is not ready */ /* that the selected registrar of AP is _FLASE */ - if ((psecuritypriv->wpa_psk > 0) && - (pstat->flags & (WLAN_STA_WPS|WLAN_STA_MAYBE_WPS))) { + if (psecuritypriv->wpa_psk > 0 && + pstat->flags & (WLAN_STA_WPS|WLAN_STA_MAYBE_WPS)) { if (pmlmepriv->wps_beacon_ie) { u8 selected_registrar = 0; - rtw_get_wps_attr_content23a(pmlmepriv->wps_beacon_ie, pmlmepriv->wps_beacon_ie_len, - WPS_ATTR_SELECTED_REGISTRAR, &selected_registrar, NULL); + rtw_get_wps_attr_content23a( + pmlmepriv->wps_beacon_ie, + pmlmepriv->wps_beacon_ie_len, + WPS_ATTR_SELECTED_REGISTRAR, + &selected_registrar, NULL); if (!selected_registrar) { - DBG_8723A("selected_registrar is false , or AP is not ready to do WPS\n"); + DBG_8723A("selected_registrar is false," + "or AP is not ready to do " + "WPS\n"); status = WLAN_STATUS_AP_UNABLE_TO_HANDLE_NEW_STA; - goto OnAssocReq23aFail; } } @@ -1362,7 +1353,8 @@ unsigned int OnAssocReq23a(struct rtw_adapter *padapter, struct recv_frame *prec if (psecuritypriv->wpa_psk == 0) { DBG_8723A("STA " MAC_FMT ": WPA/RSN IE in association " - "request, but AP don't support WPA/RSN\n", MAC_ARG(pstat->hwaddr)); + "request, but AP don't support WPA/RSN\n", + MAC_ARG(pstat->hwaddr)); status = WLAN_STATUS_INVALID_IE; @@ -1376,11 +1368,12 @@ unsigned int OnAssocReq23a(struct rtw_adapter *padapter, struct recv_frame *prec pstat->flags |= WLAN_STA_WPS; copy_len = 0; } else { - copy_len = ((wpa_ie_len+2) > sizeof(pstat->wpa_ie)) ? (sizeof(pstat->wpa_ie)):(wpa_ie_len+2); + copy_len = ((wpa_ie_len + 2) > sizeof(pstat->wpa_ie)) ? + sizeof(pstat->wpa_ie) : (wpa_ie_len + 2); } - if (copy_len>0) - memcpy(pstat->wpa_ie, wpa_ie-2, copy_len); + if (copy_len > 0) + memcpy(pstat->wpa_ie, wpa_ie - 2, copy_len); } @@ -1393,48 +1386,45 @@ unsigned int OnAssocReq23a(struct rtw_adapter *padapter, struct recv_frame *prec pstat->uapsd_vi = 0; pstat->uapsd_be = 0; pstat->uapsd_bk = 0; - if (pmlmepriv->qospriv.qos_option) - { - p = pframe + sizeof(struct ieee80211_hdr_3addr) + ie_offset; ie_len = 0; - for (;;) - { - p = rtw_get_ie23a(p, WLAN_EID_VENDOR_SPECIFIC, &ie_len, - pkt_len - - sizeof(struct ieee80211_hdr_3addr) - - ie_offset); - if (p != NULL) { - if (!memcmp(p+2, WMM_IE, 6)) { - + if (pmlmepriv->qospriv.qos_option) { + u8 *end = pos + left; + p = pos; + + for (;;) { + left = end - p; + p = cfg80211_find_ie(WLAN_EID_VENDOR_SPECIFIC, p, left); + if (p) { + if (!memcmp(p + 2, WMM_IE, 6)) { pstat->flags |= WLAN_STA_WME; pstat->qos_option = 1; - pstat->qos_info = *(p+8); + pstat->qos_info = *(p + 8); - pstat->max_sp_len = (pstat->qos_info>>5)&0x3; + pstat->max_sp_len = + (pstat->qos_info >> 5) & 0x3; - if ((pstat->qos_info&0xf) != 0xf) + if ((pstat->qos_info & 0xf) != 0xf) pstat->has_legacy_ac = true; else pstat->has_legacy_ac = false; - if (pstat->qos_info&0xf) - { - if (pstat->qos_info&BIT(0)) + if (pstat->qos_info & 0xf) { + if (pstat->qos_info & BIT(0)) pstat->uapsd_vo = BIT(0)|BIT(1); else pstat->uapsd_vo = 0; - if (pstat->qos_info&BIT(1)) + if (pstat->qos_info & BIT(1)) pstat->uapsd_vi = BIT(0)|BIT(1); else pstat->uapsd_vi = 0; - if (pstat->qos_info&BIT(2)) + if (pstat->qos_info & BIT(2)) pstat->uapsd_bk = BIT(0)|BIT(1); else pstat->uapsd_bk = 0; - if (pstat->qos_info&BIT(3)) + if (pstat->qos_info & BIT(3)) pstat->uapsd_be = BIT(0)|BIT(1); else pstat->uapsd_be = 0; @@ -1443,45 +1433,41 @@ unsigned int OnAssocReq23a(struct rtw_adapter *padapter, struct recv_frame *prec break; } - } - else { + } else { break; } - p = p + ie_len + 2; + p = p + p[1] + 2; } } /* save HT capabilities in the sta object */ memset(&pstat->htpriv.ht_cap, 0, sizeof(struct ieee80211_ht_cap)); - if (elems.ht_capabilities && elems.ht_capabilities_len >= 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 ieee80211_ht_cap)); - + memcpy(&pstat->htpriv.ht_cap, elems.ht_capabilities, + sizeof(struct ieee80211_ht_cap)); } else pstat->flags &= ~WLAN_STA_HT; - if ((pmlmepriv->htpriv.ht_option == false) && (pstat->flags&WLAN_STA_HT)) - { + if (pmlmepriv->htpriv.ht_option == false && pstat->flags & WLAN_STA_HT){ status = WLAN_STATUS_UNSPECIFIED_FAILURE; goto OnAssocReq23aFail; } - if ((pstat->flags & WLAN_STA_HT) && - ((pstat->wpa2_pairwise_cipher&WPA_CIPHER_TKIP) || - (pstat->wpa_pairwise_cipher&WPA_CIPHER_TKIP))) - { - DBG_8723A("HT: " MAC_FMT " tried to " - "use TKIP with HT association\n", MAC_ARG(pstat->hwaddr)); + if (pstat->flags & WLAN_STA_HT && + (pstat->wpa2_pairwise_cipher & WPA_CIPHER_TKIP || + pstat->wpa_pairwise_cipher & WPA_CIPHER_TKIP)) { + DBG_8723A("HT: " MAC_FMT " tried to use TKIP with HT " + "association\n", MAC_ARG(pstat->hwaddr)); /* status = WLAN_STATUS_CIPHER_REJECTED_PER_POLICY; */ /* goto OnAssocReq23aFail; */ } - /* */ pstat->flags |= WLAN_STA_NONERP; for (i = 0; i < pstat->bssratelen; i++) { if ((pstat->bssrateset[i] & 0x7f) > 22) { @@ -1523,14 +1509,13 @@ unsigned int OnAssocReq23a(struct rtw_adapter *padapter, struct recv_frame *prec status = WLAN_STATUS_AP_UNABLE_TO_HANDLE_NEW_STA; goto OnAssocReq23aFail; - } else { pstapriv->sta_aid[pstat->aid - 1] = pstat; DBG_8723A("allocate new AID = (%d)\n", pstat->aid); } } - pstat->state &= (~WIFI_FW_ASSOC_STATE); + pstat->state &= ~WIFI_FW_ASSOC_STATE; pstat->state |= WIFI_FW_ASSOC_SUCCESS; spin_lock_bh(&pstapriv->auth_list_lock); @@ -1549,18 +1534,20 @@ unsigned int OnAssocReq23a(struct rtw_adapter *padapter, struct recv_frame *prec spin_unlock_bh(&pstapriv->asoc_list_lock); /* now the station is qualified to join our BSS... */ - if (pstat && (pstat->state & WIFI_FW_ASSOC_SUCCESS) && - (WLAN_STATUS_SUCCESS == status)) { + if (pstat && pstat->state & WIFI_FW_ASSOC_SUCCESS && + status == WLAN_STATUS_SUCCESS) { #ifdef CONFIG_8723AU_AP_MODE /* 1 bss_cap_update & sta_info_update23a */ bss_cap_update_on_sta_join23a(padapter, pstat); sta_info_update23a(padapter, pstat); /* issue assoc rsp before notify station join event. */ - if (ieee80211_is_assoc_req(frame_control)) - issue_asocrsp23a(padapter, status, pstat, WIFI_ASSOCRSP); + if (ieee80211_is_assoc_req(mgmt->frame_control)) + issue_asocrsp23a(padapter, status, pstat, + WIFI_ASSOCRSP); else - issue_asocrsp23a(padapter, status, pstat, WIFI_REASSOCRSP); + issue_asocrsp23a(padapter, status, pstat, + WIFI_REASSOCRSP); /* 2 - report to upper layer */ DBG_8723A("indicate_sta_join_event to upper layer - hostapd\n"); @@ -1576,16 +1563,15 @@ unsigned int OnAssocReq23a(struct rtw_adapter *padapter, struct recv_frame *prec asoc_class2_error: #ifdef CONFIG_8723AU_AP_MODE - issue_deauth23a(padapter, hdr->addr2, status); + issue_deauth23a(padapter, mgmt->sa, status); #endif - return _FAIL; OnAssocReq23aFail: #ifdef CONFIG_8723AU_AP_MODE pstat->aid = 0; - if (ieee80211_is_assoc_req(frame_control)) + if (ieee80211_is_assoc_req(mgmt->frame_control)) issue_asocrsp23a(padapter, status, pstat, WIFI_ASSOCRSP); else issue_asocrsp23a(padapter, status, pstat, WIFI_REASSOCRSP); -- cgit v1.2.3 From e0facfa97c02330ca7f7e0751ab73175463bb85b Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:43:53 +0200 Subject: staging: rtl8723au: Make mlme_handlers and action_handlers return int In addition, make them all static and move the prototypes to rtw_mlme_ext.c. Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 96 +++++++++++++++--------- drivers/staging/rtl8723au/include/rtw_mlme_ext.h | 26 +------ 2 files changed, 63 insertions(+), 59 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index 5264c24470b0..7452b03ab74c 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -27,6 +27,28 @@ #include #endif +static int OnAssocReq23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame); +static int OnAssocRsp23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame); +static int OnProbeReq23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame); +static int OnProbeRsp23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame); +static int DoReserved23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame); +static int OnBeacon23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame); +static int OnAtim23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame); +static int OnDisassoc23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame); +static int OnAuth23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame); +static int OnAuth23aClient23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame); +static int OnDeAuth23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame); +static int OnAction23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame); + +static int on_action_spct23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame); +static int OnAction23a_qos(struct rtw_adapter *padapter, struct recv_frame *precv_frame); +static int OnAction23a_dls(struct rtw_adapter *padapter, struct recv_frame *precv_frame); +static int OnAction23a_back23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame); +static int on_action_public23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame); +static int OnAction23a_ht(struct rtw_adapter *padapter, struct recv_frame *precv_frame); +static int OnAction23a_wmm(struct rtw_adapter *padapter, struct recv_frame *precv_frame); +static int OnAction23a_p2p(struct rtw_adapter *padapter, struct recv_frame *precv_frame); + static struct mlme_handler mlme_sta_tbl[]={ {"OnAssocReq23a", &OnAssocReq23a}, {"OnAssocRsp23a", &OnAssocRsp23a}, @@ -637,8 +659,8 @@ Following are the callback functions for each subtype of the management frames *****************************************************************************/ -unsigned int OnProbeReq23a(struct rtw_adapter *padapter, - struct recv_frame *precv_frame) +static int +OnProbeReq23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) { const u8 *ie; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; @@ -686,8 +708,8 @@ out: return _SUCCESS; } -unsigned int OnProbeRsp23a(struct rtw_adapter *padapter, - struct recv_frame *precv_frame) +static int +OnProbeRsp23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) { struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; @@ -699,8 +721,8 @@ unsigned int OnProbeRsp23a(struct rtw_adapter *padapter, return _SUCCESS; } -unsigned int OnBeacon23a(struct rtw_adapter *padapter, - struct recv_frame *precv_frame) +static int +OnBeacon23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) { int cam_idx; struct sta_info *psta; @@ -828,8 +850,8 @@ _END_ONBEACON_: return _SUCCESS; } -unsigned int OnAuth23a(struct rtw_adapter *padapter, - struct recv_frame *precv_frame) +static int +OnAuth23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) { #ifdef CONFIG_8723AU_AP_MODE unsigned int auth_mode, seq; @@ -1020,8 +1042,8 @@ auth_fail: return _FAIL; } -unsigned int OnAuth23aClient23a(struct rtw_adapter *padapter, - struct recv_frame *precv_frame) +static int +OnAuth23aClient23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) { unsigned int seq, status, algthm, offset; unsigned int go2asoc = 0; @@ -1113,7 +1135,8 @@ authclnt_fail: return _FAIL; } -unsigned int OnAssocReq23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) +static int +OnAssocReq23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) { #ifdef CONFIG_8723AU_AP_MODE u16 capab_info, listen_interval; @@ -1582,8 +1605,8 @@ OnAssocReq23aFail: return _FAIL; } -unsigned int OnAssocRsp23a(struct rtw_adapter *padapter, - struct recv_frame *precv_frame) +static int +OnAssocRsp23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) { struct ndis_802_11_var_ies *pIE; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; @@ -1685,8 +1708,8 @@ report_assoc_result: return _SUCCESS; } -unsigned int OnDeAuth23a(struct rtw_adapter *padapter, - struct recv_frame *precv_frame) +static int +OnDeAuth23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) { unsigned short reason; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; @@ -1741,8 +1764,8 @@ unsigned int OnDeAuth23a(struct rtw_adapter *padapter, return _SUCCESS; } -unsigned int OnDisassoc23a(struct rtw_adapter *padapter, - struct recv_frame *precv_frame) +static int +OnDisassoc23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) { unsigned short reason; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; @@ -1796,29 +1819,33 @@ unsigned int OnDisassoc23a(struct rtw_adapter *padapter, return _SUCCESS; } -unsigned int OnAtim23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) +static int +OnAtim23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) { DBG_8723A("%s\n", __func__); return _SUCCESS; } -unsigned int on_action_spct23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) +static int +on_action_spct23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) { return _FAIL; } -unsigned int OnAction23a_qos(struct rtw_adapter *padapter, struct recv_frame *precv_frame) +static int +OnAction23a_qos(struct rtw_adapter *padapter, struct recv_frame *precv_frame) { return _SUCCESS; } -unsigned int OnAction23a_dls(struct rtw_adapter *padapter, struct recv_frame *precv_frame) +static int +OnAction23a_dls(struct rtw_adapter *padapter, struct recv_frame *precv_frame) { return _SUCCESS; } -unsigned int OnAction23a_back23a(struct rtw_adapter *padapter, - struct recv_frame *precv_frame) +static int OnAction23a_back23a(struct rtw_adapter *padapter, + struct recv_frame *precv_frame) { u8 *addr; struct sta_info *psta = NULL; @@ -2014,8 +2041,8 @@ exit: return ret; } -unsigned int on_action_public23a(struct rtw_adapter *padapter, - struct recv_frame *precv_frame) +static int on_action_public23a(struct rtw_adapter *padapter, + struct recv_frame *precv_frame) { unsigned int ret = _FAIL; struct sk_buff *skb = precv_frame->pkt; @@ -2046,26 +2073,26 @@ exit: return ret; } -unsigned int OnAction23a_ht(struct rtw_adapter *padapter, - struct recv_frame *precv_frame) +static int +OnAction23a_ht(struct rtw_adapter *padapter, struct recv_frame *precv_frame) { return _SUCCESS; } -unsigned int OnAction23a_wmm(struct rtw_adapter *padapter, - struct recv_frame *precv_frame) +static int +OnAction23a_wmm(struct rtw_adapter *padapter, struct recv_frame *precv_frame) { return _SUCCESS; } -unsigned int OnAction23a_p2p(struct rtw_adapter *padapter, - struct recv_frame *precv_frame) +static int +OnAction23a_p2p(struct rtw_adapter *padapter, struct recv_frame *precv_frame) { return _SUCCESS; } -unsigned int OnAction23a(struct rtw_adapter *padapter, - struct recv_frame *precv_frame) +static int +OnAction23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) { int i; unsigned char category; @@ -2090,8 +2117,7 @@ unsigned int OnAction23a(struct rtw_adapter *padapter, return _SUCCESS; } -unsigned int DoReserved23a(struct rtw_adapter *padapter, - struct recv_frame *precv_frame) +int DoReserved23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) { return _SUCCESS; } diff --git a/drivers/staging/rtl8723au/include/rtw_mlme_ext.h b/drivers/staging/rtl8723au/include/rtw_mlme_ext.h index 9d9815dd6941..7f1cef124ee8 100644 --- a/drivers/staging/rtl8723au/include/rtw_mlme_ext.h +++ b/drivers/staging/rtl8723au/include/rtw_mlme_ext.h @@ -262,13 +262,13 @@ enum SCAN_STATE { struct mlme_handler { char *str; - unsigned int (*func)(struct rtw_adapter *padapter, struct recv_frame *precv_frame); + int (*func)(struct rtw_adapter *padapter, struct recv_frame *precv_frame); }; struct action_handler { unsigned int num; char* str; - unsigned int (*func)(struct rtw_adapter *padapter, struct recv_frame *precv_frame); + int (*func)(struct rtw_adapter *padapter, struct recv_frame *precv_frame); }; struct ss_res @@ -615,28 +615,6 @@ void start_clnt_auth23a(struct rtw_adapter *padapter); void start_clnt_join23a(struct rtw_adapter *padapter); void start_create_ibss23a(struct rtw_adapter *padapter); -unsigned int OnAssocReq23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame); -unsigned int OnAssocRsp23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame); -unsigned int OnProbeReq23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame); -unsigned int OnProbeRsp23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame); -unsigned int DoReserved23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame); -unsigned int OnBeacon23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame); -unsigned int OnAtim23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame); -unsigned int OnDisassoc23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame); -unsigned int OnAuth23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame); -unsigned int OnAuth23aClient23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame); -unsigned int OnDeAuth23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame); -unsigned int OnAction23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame); - -unsigned int on_action_spct23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame); -unsigned int OnAction23a_qos(struct rtw_adapter *padapter, struct recv_frame *precv_frame); -unsigned int OnAction23a_dls(struct rtw_adapter *padapter, struct recv_frame *precv_frame); -unsigned int OnAction23a_back23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame); -unsigned int on_action_public23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame); -unsigned int OnAction23a_ht(struct rtw_adapter *padapter, struct recv_frame *precv_frame); -unsigned int OnAction23a_wmm(struct rtw_adapter *padapter, struct recv_frame *precv_frame); -unsigned int OnAction23a_p2p(struct rtw_adapter *padapter, struct recv_frame *precv_frame); - void mlmeext_joinbss_event_callback23a(struct rtw_adapter *padapter, int join_res); void mlmeext_sta_del_event_callback23a(struct rtw_adapter *padapter); -- cgit v1.2.3 From 4bf954b2f93e5c0e5389d40fb34a0595038dc817 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:43:54 +0200 Subject: staging: rtl8723au: rtw_update_protection23a(): Use cfg80211_find_ie() Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_xmit.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_xmit.c b/drivers/staging/rtl8723au/core/rtw_xmit.c index c0eaf5e21057..e7252d16c989 100644 --- a/drivers/staging/rtl8723au/core/rtw_xmit.c +++ b/drivers/staging/rtl8723au/core/rtw_xmit.c @@ -1319,11 +1319,10 @@ s32 rtw_put_snap23a(u8 *data, u16 h_proto) void rtw_update_protection23a(struct rtw_adapter *padapter, u8 *ie, uint ie_len) { - struct xmit_priv *pxmitpriv = &padapter->xmitpriv; - struct registry_priv *pregistrypriv = &padapter->registrypriv; - uint protection; - u8 *perp; - int erp_len; + struct xmit_priv *pxmitpriv = &padapter->xmitpriv; + struct registry_priv *pregistrypriv = &padapter->registrypriv; + uint protection; + const u8 *p; switch (pxmitpriv->vcs_setting) { case DISABLE_VCS: @@ -1333,11 +1332,11 @@ void rtw_update_protection23a(struct rtw_adapter *padapter, u8 *ie, uint ie_len) break; case AUTO_VCS: default: - perp = rtw_get_ie23a(ie, WLAN_EID_ERP_INFO, &erp_len, ie_len); - if (perp == NULL) { + p = cfg80211_find_ie(WLAN_EID_ERP_INFO, ie, ie_len); + if (!p) pxmitpriv->vcs = NONE_VCS; - } else { - protection = (*(perp + 2)) & BIT(1); + else { + protection = (*(p + 2)) & BIT(1); if (protection) { if (pregistrypriv->vcs_type == RTS_CTS) pxmitpriv->vcs = RTS_CTS; -- cgit v1.2.3 From f0fcc4f0fa2bc42f22cc4df664876571a13a7ff8 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:43:55 +0200 Subject: staging: rtl8723au: rtw_get_cur_max_rate23a(): use cfg80211_find_ie() Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_ioctl_set.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_ioctl_set.c b/drivers/staging/rtl8723au/core/rtw_ioctl_set.c index 6468c1ca2528..619bef3af153 100644 --- a/drivers/staging/rtl8723au/core/rtw_ioctl_set.c +++ b/drivers/staging/rtl8723au/core/rtw_ioctl_set.c @@ -539,7 +539,7 @@ exit: u16 rtw_get_cur_max_rate23a(struct rtw_adapter *adapter) { int i = 0; - u8 *p; + const u8 *p; u16 rate = 0, max_rate = 0; struct mlme_ext_priv *pmlmeext = &adapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; @@ -550,16 +550,16 @@ u16 rtw_get_cur_max_rate23a(struct rtw_adapter *adapter) u8 rf_type = 0; u8 bw_40MHz = 0, short_GI_20 = 0, short_GI_40 = 0; u16 mcs_rate = 0; - u32 ht_ielen = 0; if (!check_fwstate(pmlmepriv, _FW_LINKED) && !check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)) return 0; if (pmlmeext->cur_wireless_mode & (WIRELESS_11_24N|WIRELESS_11_5N)) { - p = rtw_get_ie23a(&pcur_bss->IEs[12], WLAN_EID_HT_CAPABILITY, - &ht_ielen, pcur_bss->IELength - 12); - if (p && ht_ielen > 0) { + p = cfg80211_find_ie(WLAN_EID_HT_CAPABILITY, + &pcur_bss->IEs[12], + pcur_bss->IELength - 12); + if (p && p[1] > 0) { pht_capie = (struct ieee80211_ht_cap *)(p + 2); memcpy(&mcs_rate, &pht_capie->mcs, 2); -- cgit v1.2.3 From ee79b56c0ef14d0a343982b292ccbeb91a98190f Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:43:56 +0200 Subject: staging: rtl8723au: OnBeacon23a(): Use struct ieee80211_mgmt We always receive a struct ieee80211_mgmt frame here, using just ieee80211_hdr doesn't make sense. Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index 7452b03ab74c..fc0c938a8fce 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -731,7 +731,7 @@ OnBeacon23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct sta_priv *pstapriv = &padapter->stapriv; struct sk_buff *skb = precv_frame->pkt; - struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; + struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *) skb->data; u8 *pframe = skb->data; uint len = skb->len; struct wlan_bssid_ex *pbss; @@ -752,7 +752,7 @@ OnBeacon23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) DBG_8723A("[WIFIDBG] Error in ESR IE is detected in " "Beacon of BSSID: %pM. Fix the length of " "ESR IE to avoid failed Beacon parsing.\n", - hdr->addr3); + mgmt->bssid); *(p + 1) = ielen - 1; } } @@ -762,7 +762,8 @@ OnBeacon23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) return _SUCCESS; } - if (ether_addr_equal(hdr->addr3, get_my_bssid23a(&pmlmeinfo->network))){ + if (ether_addr_equal(mgmt->bssid, + get_my_bssid23a(&pmlmeinfo->network))){ if (pmlmeinfo->state & WIFI_FW_AUTH_NULL) { /* we should update current network before auth, or some IE is wrong */ @@ -792,7 +793,7 @@ OnBeacon23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) if (((pmlmeinfo->state&0x03) == WIFI_FW_STATION_STATE) && (pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS)) { - psta = rtw_get_stainfo23a(pstapriv, hdr->addr2); + psta = rtw_get_stainfo23a(pstapriv, mgmt->sa); if (psta) { ret = rtw_check_bcn_info23a(padapter, pframe, len); @@ -813,7 +814,7 @@ OnBeacon23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) } } } else if ((pmlmeinfo->state&0x03) == WIFI_FW_ADHOC_STATE) { - psta = rtw_get_stainfo23a(pstapriv, hdr->addr2); + psta = rtw_get_stainfo23a(pstapriv, mgmt->sa); if (psta) { /* update WMM, ERP in the beacon */ /* todo: the timer is used instead of the @@ -839,7 +840,7 @@ OnBeacon23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) update_TSF23a(pmlmeext, pframe, len); /* report sta add event */ - report_add_sta_event23a(padapter, hdr->addr2, + report_add_sta_event23a(padapter, mgmt->sa, cam_idx); } } -- cgit v1.2.3 From f96355b8f001a8142d46e69d828d4ab3ef694f91 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:43:57 +0200 Subject: staging: rtl8723au: OnBeacon23a(): Use ieee80211_mgmt to calculate ie location Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 30 ++++++++++++++------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index fc0c938a8fce..f810d8f8e384 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -726,23 +726,23 @@ OnBeacon23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) { int cam_idx; struct sta_info *psta; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct sta_priv *pstapriv = &padapter->stapriv; struct sk_buff *skb = precv_frame->pkt; struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *) skb->data; u8 *pframe = skb->data; - uint len = skb->len; + int pkt_len = skb->len; struct wlan_bssid_ex *pbss; int ret = _SUCCESS; - u8 *p = NULL; + u8 *p, *pie; + int pie_len; u32 ielen = 0; - p = rtw_get_ie23a(pframe + sizeof(struct ieee80211_hdr_3addr) + - _BEACON_IE_OFFSET_, WLAN_EID_EXT_SUPP_RATES, &ielen, - len - sizeof(struct ieee80211_hdr_3addr) - - _BEACON_IE_OFFSET_); + pie = mgmt->u.beacon.variable; + pie_len = pkt_len - offsetof(struct ieee80211_mgmt, u.beacon.variable); + p = rtw_get_ie23a(pie, WLAN_EID_EXT_SUPP_RATES, &ielen, pie_len); if ((p != NULL) && (ielen > 0)) { if ((*(p + 1 + ielen) == 0x2D) && (*(p + 2 + ielen) != 0x2D)) { /* Invalid value 0x2D is detected in Extended Supported @@ -780,10 +780,10 @@ OnBeacon23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) } /* check the vendor of the assoc AP */ - pmlmeinfo->assoc_AP_vendor = check_assoc_AP23a(pframe + sizeof(struct ieee80211_hdr_3addr), len-sizeof(struct ieee80211_hdr_3addr)); + pmlmeinfo->assoc_AP_vendor = check_assoc_AP23a(pframe + sizeof(struct ieee80211_hdr_3addr), pkt_len-sizeof(struct ieee80211_hdr_3addr)); /* update TSF Value */ - update_TSF23a(pmlmeext, pframe, len); + update_TSF23a(pmlmeext, pframe, pkt_len); /* start auth */ start_clnt_auth23a(padapter); @@ -796,7 +796,7 @@ OnBeacon23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) psta = rtw_get_stainfo23a(pstapriv, mgmt->sa); if (psta) { ret = rtw_check_bcn_info23a(padapter, pframe, - len); + pkt_len); if (!ret) { DBG_8723A_LEVEL(_drv_always_, "ap has changed, " @@ -810,7 +810,7 @@ OnBeacon23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) if ((sta_rx_pkts(psta) & 0xf) == 0) { /* DBG_8723A("update_bcn_info\n"); */ update_beacon23a_info(padapter, pframe, - len, psta); + pkt_len, psta); } } } else if ((pmlmeinfo->state&0x03) == WIFI_FW_ADHOC_STATE) { @@ -822,7 +822,7 @@ OnBeacon23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) if ((sta_rx_pkts(psta) & 0xf) == 0) { /* DBG_8723A("update_bcn_info\n"); */ update_beacon23a_info(padapter, pframe, - len, psta); + pkt_len, psta); } } else { /* allocate a new CAM entry for IBSS station */ @@ -831,13 +831,15 @@ OnBeacon23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) goto _END_ONBEACON_; /* get supported rate */ - if (update_sta_support_rate23a(padapter, (pframe + sizeof(struct ieee80211_hdr_3addr) + _BEACON_IE_OFFSET_), (len - sizeof(struct ieee80211_hdr_3addr) - _BEACON_IE_OFFSET_), cam_idx) == _FAIL) { + if (update_sta_support_rate23a(padapter, pie, + pie_len, + cam_idx) == _FAIL) { pmlmeinfo->FW_sta_info[cam_idx].status = 0; goto _END_ONBEACON_; } /* update TSF Value */ - update_TSF23a(pmlmeext, pframe, len); + update_TSF23a(pmlmeext, pframe, pkt_len); /* report sta add event */ report_add_sta_event23a(padapter, mgmt->sa, -- cgit v1.2.3 From c146551f1a96eba625e80889fb947e7bd769bb78 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:43:58 +0200 Subject: staging: rtl8723au: Make rtw_check_bcn_info23() take a ieee80211_mgmt pointer Clean up the code by passing a struct ieee80211_mgmt pointer instead of a raw frame pointer. In addition check we receive a beacon frame, anything else here is an error. Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 2 +- drivers/staging/rtl8723au/core/rtw_wlan_util.c | 24 +++++++++++++++--------- drivers/staging/rtl8723au/include/rtw_mlme_ext.h | 3 ++- 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index f810d8f8e384..a79861e4250c 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -795,7 +795,7 @@ OnBeacon23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) (pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS)) { psta = rtw_get_stainfo23a(pstapriv, mgmt->sa); if (psta) { - ret = rtw_check_bcn_info23a(padapter, pframe, + ret = rtw_check_bcn_info23a(padapter, mgmt, pkt_len); if (!ret) { DBG_8723A_LEVEL(_drv_always_, diff --git a/drivers/staging/rtl8723au/core/rtw_wlan_util.c b/drivers/staging/rtl8723au/core/rtw_wlan_util.c index 17e32071b514..ac9d39a7c4f4 100644 --- a/drivers/staging/rtl8723au/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8723au/core/rtw_wlan_util.c @@ -856,7 +856,8 @@ void VCS_update23a(struct rtw_adapter *padapter, struct sta_info *psta) } } -int rtw_check_bcn_info23a(struct rtw_adapter *Adapter, u8 *pframe, u32 packet_len) +int rtw_check_bcn_info23a(struct rtw_adapter *Adapter, + struct ieee80211_mgmt *mgmt, u32 packet_len) { unsigned int len; unsigned char *p; @@ -874,12 +875,16 @@ int rtw_check_bcn_info23a(struct rtw_adapter *Adapter, u8 *pframe, u32 packet_le u32 bcn_channel; unsigned short ht_cap_info; unsigned char ht_info_infos_0; - struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) pframe; - u8 *pbssid = hdr->addr3; if (is_client_associated_to_ap23a(Adapter) == false) return true; + if (unlikely(!ieee80211_is_beacon(mgmt->frame_control))) { + printk(KERN_WARNING "%s: received a non beacon frame!\n", + __func__); + return false; + } + len = packet_len - sizeof(struct ieee80211_hdr_3addr); if (len > MAX_IE_SZ) { @@ -887,23 +892,24 @@ int rtw_check_bcn_info23a(struct rtw_adapter *Adapter, u8 *pframe, u32 packet_le return _FAIL; } - if (memcmp(cur_network->network.MacAddress, pbssid, 6)) { - DBG_8723A("Oops: rtw_check_network_encrypt linked but recv other bssid bcn\n" MAC_FMT MAC_FMT, - MAC_ARG(pbssid), MAC_ARG(cur_network->network.MacAddress)); + if (memcmp(cur_network->network.MacAddress, mgmt->bssid, 6)) { + DBG_8723A("Oops: rtw_check_network_encrypt linked but recv " + "other bssid bcn\n" MAC_FMT MAC_FMT, + MAC_ARG(mgmt->bssid), + MAC_ARG(cur_network->network.MacAddress)); return true; } bssid = (struct wlan_bssid_ex *)kzalloc(sizeof(struct wlan_bssid_ex), GFP_ATOMIC); - if (ieee80211_is_beacon(hdr->frame_control)) - bssid->reserved = 1; + bssid->reserved = 1; bssid->Length = sizeof(struct wlan_bssid_ex) - MAX_IE_SZ + len; /* below is to copy the information element */ bssid->IELength = len; - memcpy(bssid->IEs, (pframe + sizeof(struct ieee80211_hdr_3addr)), bssid->IELength); + memcpy(bssid->IEs, &mgmt->u, bssid->IELength); /* check bw and channel offset */ /* parsing HT_CAP_IE */ diff --git a/drivers/staging/rtl8723au/include/rtw_mlme_ext.h b/drivers/staging/rtl8723au/include/rtw_mlme_ext.h index 7f1cef124ee8..275f891b6c64 100644 --- a/drivers/staging/rtl8723au/include/rtw_mlme_ext.h +++ b/drivers/staging/rtl8723au/include/rtw_mlme_ext.h @@ -533,7 +533,8 @@ void VCS_update23a(struct rtw_adapter *padapter, struct sta_info *psta); void update_beacon23a_info(struct rtw_adapter *padapter, u8 *pframe, uint len, struct sta_info *psta); -int rtw_check_bcn_info23a(struct rtw_adapter *Adapter, u8 *pframe, u32 packet_len); +int rtw_check_bcn_info23a(struct rtw_adapter *Adapter, + struct ieee80211_mgmt *mgmt, u32 packet_len); void update_IOT_info23a(struct rtw_adapter *padapter); void update_capinfo23a(struct rtw_adapter *Adapter, u16 updateCap); void update_wireless_mode23a(struct rtw_adapter * padapter); -- cgit v1.2.3 From 3ffa4355a212434a4884946996cbed76d255765f Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:43:59 +0200 Subject: staging: rtl8723au: rtw_check_bcn_info23a(): Use cfg80211_find_ie() Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_wlan_util.c | 117 +++++++++++++------------ 1 file changed, 62 insertions(+), 55 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_wlan_util.c b/drivers/staging/rtl8723au/core/rtw_wlan_util.c index ac9d39a7c4f4..ff5cbc99dc47 100644 --- a/drivers/staging/rtl8723au/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8723au/core/rtw_wlan_util.c @@ -857,10 +857,8 @@ void VCS_update23a(struct rtw_adapter *padapter, struct sta_info *psta) } int rtw_check_bcn_info23a(struct rtw_adapter *Adapter, - struct ieee80211_mgmt *mgmt, u32 packet_len) + struct ieee80211_mgmt *mgmt, u32 pkt_len) { - unsigned int len; - unsigned char *p; unsigned short val16; struct wlan_network *cur_network = &Adapter->mlmepriv.cur_network; u16 wpa_len = 0, rsn_len = 0; @@ -875,6 +873,9 @@ int rtw_check_bcn_info23a(struct rtw_adapter *Adapter, u32 bcn_channel; unsigned short ht_cap_info; unsigned char ht_info_infos_0; + int len, pie_len, ie_offset; + const u8 *p; + u8 *pie; if (is_client_associated_to_ap23a(Adapter) == false) return true; @@ -885,7 +886,7 @@ int rtw_check_bcn_info23a(struct rtw_adapter *Adapter, return false; } - len = packet_len - sizeof(struct ieee80211_hdr_3addr); + len = pkt_len - sizeof(struct ieee80211_hdr_3addr); if (len > MAX_IE_SZ) { DBG_8723A("%s IE too long for survey event\n", __func__); @@ -913,70 +914,76 @@ int rtw_check_bcn_info23a(struct rtw_adapter *Adapter, /* check bw and channel offset */ /* parsing HT_CAP_IE */ - p = rtw_get_ie23a(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 = pht_cap->cap_info; - } else { - ht_cap_info = 0; - } + ie_offset = offsetof(struct ieee80211_mgmt, u.beacon.variable) - + offsetof(struct ieee80211_mgmt, u); + pie = bssid->IEs + ie_offset; + pie_len = pkt_len - ie_offset; + + p = cfg80211_find_ie(WLAN_EID_HT_CAPABILITY, pie, pie_len); + if (p && p[1] > 0) { + pht_cap = (struct ieee80211_ht_cap *)(p + 2); + ht_cap_info = pht_cap->cap_info; + } else + ht_cap_info = 0; + /* parsing HT_INFO_IE */ - p = rtw_get_ie23a(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]; - } else { - ht_info_infos_0 = 0; - } + p = cfg80211_find_ie(WLAN_EID_HT_OPERATION, pie, pie_len); + if (p && p[1] > 0) { + pht_info = (struct HT_info_element *)(p + 2); + ht_info_infos_0 = pht_info->infos[0]; + } else + ht_info_infos_0 = 0; + if (ht_cap_info != cur_network->BcnInfo.ht_cap_info || - ((ht_info_infos_0&0x03) != (cur_network->BcnInfo.ht_info_infos_0&0x03))) { - DBG_8723A("%s bcn now: ht_cap_info:%x ht_info_infos_0:%x\n", __func__, - ht_cap_info, ht_info_infos_0); - DBG_8723A("%s bcn link: ht_cap_info:%x ht_info_infos_0:%x\n", __func__, - cur_network->BcnInfo.ht_cap_info, cur_network->BcnInfo.ht_info_infos_0); - DBG_8723A("%s bw mode change, disconnect\n", __func__); - /* bcn_info_update */ - cur_network->BcnInfo.ht_cap_info = ht_cap_info; - cur_network->BcnInfo.ht_info_infos_0 = ht_info_infos_0; - /* to do : need to check that whether modify related register of BB or not */ + ((ht_info_infos_0 & 0x03) != + (cur_network->BcnInfo.ht_info_infos_0 & 0x03))) { + DBG_8723A("%s bcn now: ht_cap_info:%x ht_info_infos_0:%x\n", + __func__, ht_cap_info, ht_info_infos_0); + DBG_8723A("%s bcn link: ht_cap_info:%x ht_info_infos_0:%x\n", + __func__, cur_network->BcnInfo.ht_cap_info, + cur_network->BcnInfo.ht_info_infos_0); + DBG_8723A("%s bw mode change, disconnect\n", __func__); + /* bcn_info_update */ + cur_network->BcnInfo.ht_cap_info = ht_cap_info; + cur_network->BcnInfo.ht_info_infos_0 = ht_info_infos_0; + /* to do : need to check that whether modify related + register of BB or not */ } /* Checking for channel */ - p = rtw_get_ie23a(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 */ - p = rtw_get_ie23a(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 */ - DBG_8723A("Oops: %s we don't find channel IE, so don't check it\n", __func__); - bcn_channel = Adapter->mlmeextpriv.cur_channel; - } + p = cfg80211_find_ie(WLAN_EID_DS_PARAMS, pie, pie_len); + if (p) + bcn_channel = p[2]; + else { + /* In 5G, some ap do not have DSSET IE checking HT + info for channel */ + p = cfg80211_find_ie(WLAN_EID_HT_OPERATION, pie, pie_len); + + if (pht_info) + bcn_channel = pht_info->primary_channel; + else { /* we don't find channel IE, so don't check it */ + DBG_8723A("Oops: %s we don't find channel IE, so don't " + "check it\n", __func__); + bcn_channel = Adapter->mlmeextpriv.cur_channel; + } } if (bcn_channel != Adapter->mlmeextpriv.cur_channel) { - DBG_8723A("%s beacon channel:%d cur channel:%d disconnect\n", __func__, - bcn_channel, Adapter->mlmeextpriv.cur_channel); - goto _mismatch; + DBG_8723A("%s beacon channel:%d cur channel:%d disconnect\n", + __func__, bcn_channel, + Adapter->mlmeextpriv.cur_channel); + goto _mismatch; } /* checking SSID */ - if ((p = rtw_get_ie23a(bssid->IEs + _FIXED_IE_LENGTH_, WLAN_EID_SSID, - &len, bssid->IELength - _FIXED_IE_LENGTH_)) == - NULL) { - DBG_8723A("%s marc: cannot find SSID for survey event\n", __func__); + p = cfg80211_find_ie(WLAN_EID_SSID, pie, pie_len); + if (!p) { + DBG_8723A("%s marc: cannot find SSID for survey event\n", + __func__); hidden_ssid = true; - } else { + } else hidden_ssid = false; - } - if ((NULL != p) && (false == hidden_ssid && (*(p + 1)))) { + if (p && (hidden_ssid == false && *(p + 1))) { memcpy(bssid->Ssid.ssid, (p + 2), *(p + 1)); bssid->Ssid.ssid_len = *(p + 1); } else { -- cgit v1.2.3 From 82695d5ca3a5633dbc2395e2bc9982520362a5f2 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:44:00 +0200 Subject: staging: rtl8723au: rtw_check_bcn_info23a(): Clean up code obfuscation There is no point doing a double check of the IE, either we found an WLAN_EID_SSID or we didn't. Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_wlan_util.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_wlan_util.c b/drivers/staging/rtl8723au/core/rtw_wlan_util.c index ff5cbc99dc47..43bfefcc1b7b 100644 --- a/drivers/staging/rtl8723au/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8723au/core/rtw_wlan_util.c @@ -867,7 +867,6 @@ int rtw_check_bcn_info23a(struct rtw_adapter *Adapter, int group_cipher = 0, pairwise_cipher = 0, is_8021x = 0; unsigned char *pbuf; u32 wpa_ielen = 0; - u32 hidden_ssid = 0; struct HT_info_element *pht_info = NULL; struct ieee80211_ht_cap *pht_cap = NULL; u32 bcn_channel; @@ -976,17 +975,12 @@ int rtw_check_bcn_info23a(struct rtw_adapter *Adapter, /* checking SSID */ p = cfg80211_find_ie(WLAN_EID_SSID, pie, pie_len); - if (!p) { + if (p && p[1]) { + memcpy(bssid->Ssid.ssid, p + 2, p[1]); + bssid->Ssid.ssid_len = p[1]; + } else { DBG_8723A("%s marc: cannot find SSID for survey event\n", __func__); - hidden_ssid = true; - } else - hidden_ssid = false; - - if (p && (hidden_ssid == false && *(p + 1))) { - memcpy(bssid->Ssid.ssid, (p + 2), *(p + 1)); - bssid->Ssid.ssid_len = *(p + 1); - } else { bssid->Ssid.ssid_len = 0; bssid->Ssid.ssid[0] = '\0'; } -- cgit v1.2.3 From bf3502742533fea36d41f71dc1c341e0a0a2e167 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:44:01 +0200 Subject: staging: rtl8723au: update_sta_support_rate23a(): Use cfg80211_find_ie() Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_wlan_util.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_wlan_util.c b/drivers/staging/rtl8723au/core/rtw_wlan_util.c index 43bfefcc1b7b..909acb97f16e 100644 --- a/drivers/staging/rtl8723au/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8723au/core/rtw_wlan_util.c @@ -1570,26 +1570,25 @@ void update_bmc_sta_support_rate23a(struct rtw_adapter *padapter, u32 mac_id) } } -int update_sta_support_rate23a(struct rtw_adapter *padapter, u8 *pvar_ie, uint var_ie_len, int cam_idx) +int update_sta_support_rate23a(struct rtw_adapter *padapter, u8 *pvar_ie, + uint var_ie_len, int cam_idx) { - unsigned int ie_len; - struct ndis_802_11_var_ies *pIE; - int supportRateNum = 0; + int supportRateNum = 0; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; + const u8 *p; - pIE = (struct ndis_802_11_var_ies *)rtw_get_ie23a(pvar_ie, - WLAN_EID_SUPP_RATES, - &ie_len, var_ie_len); - if (pIE == NULL) + p = cfg80211_find_ie(WLAN_EID_SUPP_RATES, pvar_ie, var_ie_len); + if (!p) return _FAIL; - memcpy(pmlmeinfo->FW_sta_info[cam_idx].SupportedRates, pIE->data, ie_len); - supportRateNum = ie_len; + memcpy(pmlmeinfo->FW_sta_info[cam_idx].SupportedRates, p + 2, p[1]); + supportRateNum = p[1]; - pIE = (struct ndis_802_11_var_ies *)rtw_get_ie23a(pvar_ie, WLAN_EID_EXT_SUPP_RATES, &ie_len, var_ie_len); - if (pIE) - memcpy((pmlmeinfo->FW_sta_info[cam_idx].SupportedRates + supportRateNum), pIE->data, ie_len); + p = cfg80211_find_ie(WLAN_EID_EXT_SUPP_RATES, pvar_ie, var_ie_len); + if (p) + memcpy(pmlmeinfo->FW_sta_info[cam_idx].SupportedRates + + supportRateNum, p + 2, p[1]); return _SUCCESS; } -- cgit v1.2.3 From 731f9da74b49a939d2d8cc0197b4246b614bd2d6 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:44:02 +0200 Subject: staging: rtl8723au: start_bss_network(): Use cfg80211_find_ie() Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_ap.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_ap.c b/drivers/staging/rtl8723au/core/rtw_ap.c index f04d9dfb4446..d049ba770900 100644 --- a/drivers/staging/rtl8723au/core/rtw_ap.c +++ b/drivers/staging/rtl8723au/core/rtw_ap.c @@ -646,11 +646,10 @@ static void update_hw_ht_param(struct rtw_adapter *padapter) static void start_bss_network(struct rtw_adapter *padapter, u8 *pbuf) { - u8 *p; + const u8 *p; u8 val8, cur_channel, cur_bwmode, cur_ch_offset; u16 bcn_interval; u32 acparm; - int ie_len; struct registry_priv *pregpriv = &padapter->registrypriv; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct security_priv* psecuritypriv = &padapter->securitypriv; @@ -727,18 +726,21 @@ static void start_bss_network(struct rtw_adapter *padapter, u8 *pbuf) DYNAMIC_ALL_FUNC_ENABLE); } /* set channel, bwmode */ - p = rtw_get_ie23a((pnetwork->IEs + sizeof(struct ndis_802_11_fixed_ies)), - WLAN_EID_HT_OPERATION, &ie_len, (pnetwork->IELength - - sizeof(struct ndis_802_11_fixed_ies))); - if (p && ie_len) { - pht_info = (struct HT_info_element *)(p+2); - - if ((pregpriv->cbw40_enable) && (pht_info->infos[0] & BIT(2))) { + p = cfg80211_find_ie(WLAN_EID_HT_OPERATION, + pnetwork->IEs + + sizeof(struct ndis_802_11_fixed_ies), + pnetwork->IELength - + sizeof(struct ndis_802_11_fixed_ies)); + if (p && p[1]) { + pht_info = (struct HT_info_element *)(p + 2); + + if (pregpriv->cbw40_enable && pht_info->infos[0] & BIT(2)) { /* switch to the 40M Hz mode */ cur_bwmode = HT_CHANNEL_WIDTH_40; switch (pht_info->infos[0] & 0x3) { case 1: - /* pmlmeext->cur_ch_offset = HAL_PRIME_CHNL_OFFSET_LOWER; */ + /* pmlmeext->cur_ch_offset = + HAL_PRIME_CHNL_OFFSET_LOWER; */ cur_ch_offset = HAL_PRIME_CHNL_OFFSET_LOWER; break; case 3: -- cgit v1.2.3 From 95c4345abf22a447c39efe41d3f66bfb645ce13c Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:44:03 +0200 Subject: staging: rtl8723au: Use const * for parsing wpa IEs Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_ieee80211.c | 15 ++++++++------- drivers/staging/rtl8723au/include/ieee80211.h | 8 ++++---- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_ieee80211.c b/drivers/staging/rtl8723au/core/rtw_ieee80211.c index d7a6b47b49b3..88631a713a5d 100644 --- a/drivers/staging/rtl8723au/core/rtw_ieee80211.c +++ b/drivers/staging/rtl8723au/core/rtw_ieee80211.c @@ -514,7 +514,7 @@ unsigned char *rtw_get_wpa2_ie23a(unsigned char *pie, int *rsn_ie_len, int limit return rtw_get_ie23a(pie, _WPA2_IE_ID_, rsn_ie_len, limit); } -int rtw_get_wpa_cipher_suite23a(u8 *s) +int rtw_get_wpa_cipher_suite23a(const u8 *s) { if (!memcmp(s, WPA_CIPHER_SUITE_NONE23A, WPA_SELECTOR_LEN)) return WPA_CIPHER_NONE; @@ -530,7 +530,7 @@ int rtw_get_wpa_cipher_suite23a(u8 *s) return 0; } -int rtw_get_wpa2_cipher_suite23a(u8 *s) +int rtw_get_wpa2_cipher_suite23a(const u8 *s) { if (!memcmp(s, RSN_CIPHER_SUITE_NONE23A, RSN_SELECTOR_LEN)) return WPA_CIPHER_NONE; @@ -546,11 +546,11 @@ int rtw_get_wpa2_cipher_suite23a(u8 *s) return 0; } -int rtw_parse_wpa_ie23a(u8* wpa_ie, int wpa_ie_len, int *group_cipher, int *pairwise_cipher, int *is_8021x) +int rtw_parse_wpa_ie23a(const u8* wpa_ie, int wpa_ie_len, int *group_cipher, int *pairwise_cipher, int *is_8021x) { int i, ret = _SUCCESS; int left, count; - u8 *pos; + const u8 *pos; u8 SUITE_1X[4] = {0x00, 0x50, 0xf2, 1}; if (wpa_ie_len <= 0) { @@ -626,12 +626,12 @@ int rtw_parse_wpa_ie23a(u8* wpa_ie, int wpa_ie_len, int *group_cipher, int *pair return ret; } -int rtw_parse_wpa2_ie23a(u8* rsn_ie, int rsn_ie_len, int *group_cipher, +int rtw_parse_wpa2_ie23a(const u8* rsn_ie, int rsn_ie_len, int *group_cipher, int *pairwise_cipher, int *is_8021x) { int i, ret = _SUCCESS; int left, count; - u8 *pos; + const u8 *pos; u8 SUITE_1X[4] = {0x00, 0x0f, 0xac, 0x01}; if (rsn_ie_len <= 0) { @@ -1277,10 +1277,11 @@ int ieee80211_is_empty_essid23a(const char *essid, int essid_len) static int rtw_get_cipher_info(struct wlan_network *pnetwork) { u32 wpa_ielen; - unsigned char *pbuf; + const u8 *pbuf; int group_cipher = 0, pairwise_cipher = 0, is8021x = 0; int ret = _FAIL; int r; + pbuf = rtw_get_wpa_ie23a(&pnetwork->network.IEs[12], &wpa_ielen, pnetwork->network.IELength - 12); diff --git a/drivers/staging/rtl8723au/include/ieee80211.h b/drivers/staging/rtl8723au/include/ieee80211.h index f2824c3c2f9c..b82f3150cfcf 100644 --- a/drivers/staging/rtl8723au/include/ieee80211.h +++ b/drivers/staging/rtl8723au/include/ieee80211.h @@ -539,10 +539,10 @@ void rtw_set_supported_rate23a(u8* SupportedRates, uint mode) ; unsigned char *rtw_get_wpa_ie23a(unsigned char *pie, int *wpa_ie_len, int limit); unsigned char *rtw_get_wpa2_ie23a(unsigned char *pie, int *rsn_ie_len, int limit); -int rtw_get_wpa_cipher_suite23a(u8 *s); -int rtw_get_wpa2_cipher_suite23a(u8 *s); -int rtw_parse_wpa_ie23a(u8* wpa_ie, int wpa_ie_len, int *group_cipher, int *pairwise_cipher, int *is_8021x); -int rtw_parse_wpa2_ie23a(u8* wpa_ie, int wpa_ie_len, int *group_cipher, int *pairwise_cipher, int *is_8021x); +int rtw_get_wpa_cipher_suite23a(const u8 *s); +int rtw_get_wpa2_cipher_suite23a(const u8 *s); +int rtw_parse_wpa_ie23a(const u8* wpa_ie, int wpa_ie_len, int *group_cipher, int *pairwise_cipher, int *is_8021x); +int rtw_parse_wpa2_ie23a(const u8* wpa_ie, int wpa_ie_len, int *group_cipher, int *pairwise_cipher, int *is_8021x); int rtw_get_sec_ie23a(u8 *in_ie,uint in_len,u8 *rsn_ie,u16 *rsn_len,u8 *wpa_ie,u16 *wpa_len); -- cgit v1.2.3 From d7f03698271d71e510a0650c22c0155711ca9d0f Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:44:04 +0200 Subject: staging: rtl8723au: rtw_get_cipher_info(): Convert to use cfg80211_* API Use cfg80211_find_ie() and cfg80211_find_vendor_ie() rather than own hacks. Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_ieee80211.c | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_ieee80211.c b/drivers/staging/rtl8723au/core/rtw_ieee80211.c index 88631a713a5d..f3904ec93917 100644 --- a/drivers/staging/rtl8723au/core/rtw_ieee80211.c +++ b/drivers/staging/rtl8723au/core/rtw_ieee80211.c @@ -1276,19 +1276,24 @@ int ieee80211_is_empty_essid23a(const char *essid, int essid_len) static int rtw_get_cipher_info(struct wlan_network *pnetwork) { - u32 wpa_ielen; const u8 *pbuf; int group_cipher = 0, pairwise_cipher = 0, is8021x = 0; int ret = _FAIL; - int r; + int r, offset, plen; + char *pie; - pbuf = rtw_get_wpa_ie23a(&pnetwork->network.IEs[12], &wpa_ielen, - pnetwork->network.IELength - 12); + offset = offsetof(struct ieee80211_mgmt, u.beacon.variable) - + offsetof(struct ieee80211_mgmt, u); + pie = &pnetwork->network.IEs[offset]; + plen = pnetwork->network.IELength - offset; - if (pbuf && (wpa_ielen > 0)) { + pbuf = cfg80211_find_vendor_ie(WLAN_OUI_MICROSOFT, + WLAN_OUI_TYPE_MICROSOFT_WPA, pie, plen); + + if (pbuf && pbuf[1] > 0) { RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, - ("rtw_get_cipher_info: wpa_ielen: %d", wpa_ielen)); - r = rtw_parse_wpa_ie23a(pbuf, wpa_ielen + 2, &group_cipher, + ("rtw_get_cipher_info: wpa_ielen: %d", pbuf[1])); + r = rtw_parse_wpa_ie23a(pbuf, pbuf[1] + 2, &group_cipher, &pairwise_cipher, &is8021x); if (r == _SUCCESS) { pnetwork->BcnInfo.pairwise_cipher = pairwise_cipher; @@ -1302,13 +1307,12 @@ static int rtw_get_cipher_info(struct wlan_network *pnetwork) ret = _SUCCESS; } } else { - pbuf = rtw_get_wpa2_ie23a(&pnetwork->network.IEs[12], &wpa_ielen, - pnetwork->network.IELength - 12); + pbuf = cfg80211_find_ie(WLAN_EID_RSN, pie, plen); - if (pbuf && (wpa_ielen > 0)) { + if (pbuf && pbuf[1] > 0) { RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("get RSN IE\n")); - r = rtw_parse_wpa2_ie23a(pbuf, wpa_ielen + 2, + r = rtw_parse_wpa2_ie23a(pbuf, pbuf[1] + 2, &group_cipher, &pairwise_cipher, &is8021x); if (r == _SUCCESS) { -- cgit v1.2.3 From c37618360ef53c814177357299b789db0db041a8 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:44:05 +0200 Subject: staging: rtl8723au: rtw_check_bcn_info23a(): Remove excessive brackets Remove excessive brackets and some general cleanups Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_wlan_util.c | 96 ++++++++++++++++---------- 1 file changed, 61 insertions(+), 35 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_wlan_util.c b/drivers/staging/rtl8723au/core/rtw_wlan_util.c index 909acb97f16e..9ed25c62918f 100644 --- a/drivers/staging/rtl8723au/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8723au/core/rtw_wlan_util.c @@ -859,22 +859,22 @@ void VCS_update23a(struct rtw_adapter *padapter, struct sta_info *psta) int rtw_check_bcn_info23a(struct rtw_adapter *Adapter, struct ieee80211_mgmt *mgmt, u32 pkt_len) { - unsigned short val16; struct wlan_network *cur_network = &Adapter->mlmepriv.cur_network; - u16 wpa_len = 0, rsn_len = 0; - u8 encryp_protocol = 0; + struct HT_info_element *pht_info; + struct ieee80211_ht_cap *pht_cap; struct wlan_bssid_ex *bssid; - int group_cipher = 0, pairwise_cipher = 0, is_8021x = 0; - unsigned char *pbuf; + unsigned short val16; + u16 wpa_len = 0, rsn_len = 0; + u8 encryp_protocol; + int group_cipher = 0, pairwise_cipher = 0, is_8021x = 0, r; u32 wpa_ielen = 0; - struct HT_info_element *pht_info = NULL; - struct ieee80211_ht_cap *pht_cap = NULL; u32 bcn_channel; - unsigned short ht_cap_info; - unsigned char ht_info_infos_0; + unsigned short ht_cap_info; + unsigned char ht_info_infos_0; int len, pie_len, ie_offset; const u8 *p; u8 *pie; + unsigned char *pbuf; if (is_client_associated_to_ap23a(Adapter) == false) return true; @@ -922,16 +922,20 @@ int rtw_check_bcn_info23a(struct rtw_adapter *Adapter, if (p && p[1] > 0) { pht_cap = (struct ieee80211_ht_cap *)(p + 2); ht_cap_info = pht_cap->cap_info; - } else + } else { + pht_cap = NULL; ht_cap_info = 0; + } /* parsing HT_INFO_IE */ p = cfg80211_find_ie(WLAN_EID_HT_OPERATION, pie, pie_len); if (p && p[1] > 0) { pht_info = (struct HT_info_element *)(p + 2); ht_info_infos_0 = pht_info->infos[0]; - } else + } else { + pht_info = NULL; ht_info_infos_0 = 0; + } if (ht_cap_info != cur_network->BcnInfo.ht_cap_info || ((ht_info_infos_0 & 0x03) != @@ -1011,60 +1015,82 @@ int rtw_check_bcn_info23a(struct rtw_adapter *Adapter, bssid->Privacy = 0; RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, - ("%s(): cur_network->network.Privacy is %d, bssid.Privacy is %d\n", - __func__, cur_network->network.Privacy, bssid->Privacy)); + ("%s(): cur_network->network.Privacy is %d, bssid.Privacy " + "is %d\n", __func__, cur_network->network.Privacy, + bssid->Privacy)); if (cur_network->network.Privacy != bssid->Privacy) { DBG_8723A("%s(), privacy is not match return FAIL\n", __func__); goto _mismatch; } - rtw_get_sec_ie23a(bssid->IEs, bssid->IELength, NULL,&rsn_len, NULL,&wpa_len); + rtw_get_sec_ie23a(bssid->IEs, bssid->IELength, NULL, &rsn_len, NULL, + &wpa_len); - if (rsn_len > 0) { + if (rsn_len > 0) encryp_protocol = ENCRYP_PROTOCOL_WPA2; - } else if (wpa_len > 0) { + else if (wpa_len > 0) encryp_protocol = ENCRYP_PROTOCOL_WPA; - } else { + else { if (bssid->Privacy) encryp_protocol = ENCRYP_PROTOCOL_WEP; + else + encryp_protocol = ENCRYP_PROTOCOL_OPENSYS; } if (cur_network->BcnInfo.encryp_protocol != encryp_protocol) { - DBG_8723A("%s(): enctyp is not match , return FAIL\n", __func__); + DBG_8723A("%s(): enctyp is not match, return FAIL\n", __func__); goto _mismatch; } - if (encryp_protocol == ENCRYP_PROTOCOL_WPA || encryp_protocol == ENCRYP_PROTOCOL_WPA2) { + if (encryp_protocol == ENCRYP_PROTOCOL_WPA || + encryp_protocol == ENCRYP_PROTOCOL_WPA2) { pbuf = rtw_get_wpa_ie23a(&bssid->IEs[12], &wpa_ielen, bssid->IELength-12); if (pbuf && (wpa_ielen>0)) { - if (_SUCCESS == rtw_parse_wpa_ie23a(pbuf, wpa_ielen+2, &group_cipher, &pairwise_cipher, &is_8021x)) { + r = rtw_parse_wpa_ie23a(pbuf, wpa_ielen+2, + &group_cipher, + &pairwise_cipher, &is_8021x); + if (r == _SUCCESS) RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, - ("%s pnetwork->pairwise_cipher: %d, group_cipher is %d, is_8021x is %d\n", __func__, - pairwise_cipher, group_cipher, is_8021x)); - } + ("%s pnetwork->pairwise_cipher: %d, " + "group_cipher is %d, is_8021x is " + "%d\n", __func__, pairwise_cipher, + group_cipher, is_8021x)); } else { pbuf = rtw_get_wpa2_ie23a(&bssid->IEs[12], &wpa_ielen, bssid->IELength-12); - if (pbuf && (wpa_ielen>0)) { - if (_SUCCESS == rtw_parse_wpa2_ie23a(pbuf, wpa_ielen+2, &group_cipher, &pairwise_cipher, &is_8021x)) { - RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, - ("%s pnetwork->pairwise_cipher: %d, pnetwork->group_cipher is %d, is_802x is %d\n", - __func__, pairwise_cipher, group_cipher, is_8021x)); - } + if (pbuf && wpa_ielen > 0) { + r = rtw_parse_wpa2_ie23a(pbuf, wpa_ielen + 2, + &group_cipher, + &pairwise_cipher, + &is_8021x); + if (r == _SUCCESS) + RT_TRACE(_module_rtl871x_mlme_c_, + _drv_info_, + ("%s pnetwork->pairwise_cipher" + ": %d, pnetwork->group_cipher" + " is %d, is_802x is %d\n", + __func__, pairwise_cipher, + group_cipher, is_8021x)); } } RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, - ("%s cur_network->group_cipher is %d: %d\n", __func__, cur_network->BcnInfo.group_cipher, group_cipher)); - if (pairwise_cipher != cur_network->BcnInfo.pairwise_cipher || group_cipher != cur_network->BcnInfo.group_cipher) { - DBG_8723A("%s pairwise_cipher(%x:%x) or group_cipher(%x:%x) is not match , return FAIL\n", __func__, - pairwise_cipher, cur_network->BcnInfo.pairwise_cipher, - group_cipher, cur_network->BcnInfo.group_cipher); + ("%s cur_network->group_cipher is %d: %d\n", __func__, + cur_network->BcnInfo.group_cipher, group_cipher)); + if (pairwise_cipher != cur_network->BcnInfo.pairwise_cipher || + group_cipher != cur_network->BcnInfo.group_cipher) { + DBG_8723A("%s pairwise_cipher(%x:%x) or group_cipher " + "(%x:%x) is not match, return FAIL\n", + __func__, pairwise_cipher, + cur_network->BcnInfo.pairwise_cipher, + group_cipher, + cur_network->BcnInfo.group_cipher); goto _mismatch; } if (is_8021x != cur_network->BcnInfo.is_8021x) { - DBG_8723A("%s authentication is not match , return FAIL\n", __func__); + DBG_8723A("%s authentication is not match, return " + "FAIL\n", __func__); goto _mismatch; } } -- cgit v1.2.3 From f88ca60404f53af18e7a17a9ffab87c59410737c Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:44:06 +0200 Subject: staging: rtl8723au: rtw_check_bcn_info23a(): Use cfg80211 to find WPA info Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_wlan_util.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_wlan_util.c b/drivers/staging/rtl8723au/core/rtw_wlan_util.c index 9ed25c62918f..e8127cb6c33a 100644 --- a/drivers/staging/rtl8723au/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8723au/core/rtw_wlan_util.c @@ -867,14 +867,12 @@ int rtw_check_bcn_info23a(struct rtw_adapter *Adapter, u16 wpa_len = 0, rsn_len = 0; u8 encryp_protocol; int group_cipher = 0, pairwise_cipher = 0, is_8021x = 0, r; - u32 wpa_ielen = 0; u32 bcn_channel; unsigned short ht_cap_info; unsigned char ht_info_infos_0; int len, pie_len, ie_offset; const u8 *p; u8 *pie; - unsigned char *pbuf; if (is_client_associated_to_ap23a(Adapter) == false) return true; @@ -1044,10 +1042,11 @@ int rtw_check_bcn_info23a(struct rtw_adapter *Adapter, if (encryp_protocol == ENCRYP_PROTOCOL_WPA || encryp_protocol == ENCRYP_PROTOCOL_WPA2) { - pbuf = rtw_get_wpa_ie23a(&bssid->IEs[12], &wpa_ielen, bssid->IELength-12); - if (pbuf && (wpa_ielen>0)) { - r = rtw_parse_wpa_ie23a(pbuf, wpa_ielen+2, - &group_cipher, + p = cfg80211_find_vendor_ie(WLAN_OUI_MICROSOFT, + WLAN_OUI_TYPE_MICROSOFT_WPA, + pie, pie_len); + if (p && p[1] > 0) { + r = rtw_parse_wpa_ie23a(p, p[1] + 2, &group_cipher, &pairwise_cipher, &is_8021x); if (r == _SUCCESS) RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, @@ -1056,10 +1055,10 @@ int rtw_check_bcn_info23a(struct rtw_adapter *Adapter, "%d\n", __func__, pairwise_cipher, group_cipher, is_8021x)); } else { - pbuf = rtw_get_wpa2_ie23a(&bssid->IEs[12], &wpa_ielen, bssid->IELength-12); + p = cfg80211_find_ie(WLAN_EID_RSN, pie, pie_len); - if (pbuf && wpa_ielen > 0) { - r = rtw_parse_wpa2_ie23a(pbuf, wpa_ielen + 2, + if (p && p[1] > 0) { + r = rtw_parse_wpa2_ie23a(p, p[1] + 2, &group_cipher, &pairwise_cipher, &is_8021x); -- cgit v1.2.3 From 58aedb498f8a9870ff871058d4b91d77457fc14c Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:44:07 +0200 Subject: staging: rtl8723au: rtw_cfg80211_set_wpa_ie(): Use cfg80211_ API Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c | 34 +++++++++++------------ 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c b/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c index a3e17f99a278..e5c0ba74ea66 100644 --- a/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c +++ b/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c @@ -1686,9 +1686,7 @@ static int rtw_cfg80211_set_wpa_ie(struct rtw_adapter *padapter, const u8 *pie, u8 *buf = NULL, *pos = NULL; int group_cipher = 0, pairwise_cipher = 0; int ret = 0; - int wpa_ielen = 0; - int wpa2_ielen = 0; - u8 *pwpa, *pwpa2; + const u8 *pwpa, *pwpa2; int i; if (!pie || !ielen) { @@ -1723,33 +1721,35 @@ static int rtw_cfg80211_set_wpa_ie(struct rtw_adapter *padapter, const u8 *pie, goto exit; } - pwpa = rtw_get_wpa_ie23a(buf, &wpa_ielen, ielen); - if (pwpa && wpa_ielen > 0) { - if (rtw_parse_wpa_ie23a(pwpa, wpa_ielen + 2, &group_cipher, - &pairwise_cipher, NULL) == _SUCCESS) { + pwpa = cfg80211_find_vendor_ie(WLAN_OUI_MICROSOFT, + WLAN_OUI_TYPE_MICROSOFT_WPA, + buf, ielen); + if (pwpa && pwpa[1] > 0) { + if (rtw_parse_wpa_ie23a(pwpa, pwpa[1] + 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); + memcpy(padapter->securitypriv.supplicant_ie, pwpa, + pwpa[1] + 2); - DBG_8723A("got wpa_ie, wpa_ielen:%u\n", wpa_ielen); + DBG_8723A("got wpa_ie, wpa_ielen:%u\n", pwpa[1]); } } - pwpa2 = rtw_get_wpa2_ie23a(buf, &wpa2_ielen, ielen); - if (pwpa2 && wpa2_ielen > 0) { - if (rtw_parse_wpa2_ie23a (pwpa2, wpa2_ielen + 2, &group_cipher, - &pairwise_cipher, NULL) == _SUCCESS) { + pwpa2 = cfg80211_find_ie(WLAN_EID_RSN, buf, ielen); + if (pwpa2 && pwpa2[1] > 0) { + if (rtw_parse_wpa2_ie23a (pwpa2, pwpa2[1] + 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); + memcpy(padapter->securitypriv.supplicant_ie, pwpa2, + pwpa2[1] + 2); - DBG_8723A("got wpa2_ie, wpa2_ielen:%u\n", wpa2_ielen); + DBG_8723A("got wpa2_ie, wpa2_ielen:%u\n", pwpa2[1]); } } -- cgit v1.2.3 From 9bf29cb9404c8368d7a501e5266e0cfcf0bce702 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:44:08 +0200 Subject: staging: rtl8723au: rtw_cfg80211_set_wpa_ie(): Remove unused variable 'pos' Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c b/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c index e5c0ba74ea66..888077be6e8b 100644 --- a/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c +++ b/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c @@ -1683,7 +1683,7 @@ static int rtw_cfg80211_set_key_mgt(struct security_priv *psecuritypriv, static int rtw_cfg80211_set_wpa_ie(struct rtw_adapter *padapter, const u8 *pie, size_t ielen) { - u8 *buf = NULL, *pos = NULL; + u8 *buf = NULL; int group_cipher = 0, pairwise_cipher = 0; int ret = 0; const u8 *pwpa, *pwpa2; @@ -1713,7 +1713,6 @@ static int rtw_cfg80211_set_wpa_ie(struct rtw_adapter *padapter, const u8 *pie, buf[i], buf[i + 1], buf[i + 2], buf[i + 3], buf[i + 4], buf[i + 5], buf[i + 6], buf[i + 7]); - pos = buf; if (ielen < RSN_HEADER_LEN) { RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_err_, ("Ie len too short %d\n", (int)ielen)); -- cgit v1.2.3 From fcff60e9209004b79f0c16845e83c08e1fefeaba Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:44:09 +0200 Subject: staging: rtl8723au: Remove obsolete rtw_get_wpa{2,}_ie23a() functions Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_ieee80211.c | 54 -------------------------- drivers/staging/rtl8723au/include/ieee80211.h | 2 - 2 files changed, 56 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_ieee80211.c b/drivers/staging/rtl8723au/core/rtw_ieee80211.c index f3904ec93917..a28b81667993 100644 --- a/drivers/staging/rtl8723au/core/rtw_ieee80211.c +++ b/drivers/staging/rtl8723au/core/rtw_ieee80211.c @@ -460,60 +460,6 @@ int rtw_generate_ie23a(struct registry_priv *pregistrypriv) return sz; } -unsigned char *rtw_get_wpa_ie23a(unsigned char *pie, int *wpa_ie_len, int limit) -{ - int len; - u16 val16; - unsigned char wpa_oui_type[] = {0x00, 0x50, 0xf2, 0x01}; - u8 *pbuf = pie; - int limit_new = limit; - - while(1) { - pbuf = rtw_get_ie23a(pbuf, WLAN_EID_VENDOR_SPECIFIC, - &len, limit_new); - - if (pbuf) { - /* check if oui matches... */ - if (memcmp((pbuf + 2), wpa_oui_type, - sizeof(wpa_oui_type))) { - goto check_next_ie; - } - - /* check version... */ - memcpy((u8 *)&val16, (pbuf + 6), sizeof(val16)); - - val16 = le16_to_cpu(val16); - if (val16 != 0x0001) - goto check_next_ie; - - *wpa_ie_len = *(pbuf + 1); - - return pbuf; - } else { - *wpa_ie_len = 0; - return NULL; - } - -check_next_ie: - - limit_new = limit - (pbuf - pie) - 2 - len; - - if (limit_new <= 0) - break; - - pbuf += (2 + len); - } - - *wpa_ie_len = 0; - - return NULL; -} - -unsigned char *rtw_get_wpa2_ie23a(unsigned char *pie, int *rsn_ie_len, int limit) -{ - return rtw_get_ie23a(pie, _WPA2_IE_ID_, rsn_ie_len, limit); -} - int rtw_get_wpa_cipher_suite23a(const u8 *s) { if (!memcmp(s, WPA_CIPHER_SUITE_NONE23A, WPA_SELECTOR_LEN)) diff --git a/drivers/staging/rtl8723au/include/ieee80211.h b/drivers/staging/rtl8723au/include/ieee80211.h index b82f3150cfcf..e1117382e8fe 100644 --- a/drivers/staging/rtl8723au/include/ieee80211.h +++ b/drivers/staging/rtl8723au/include/ieee80211.h @@ -537,8 +537,6 @@ int rtw_ies_remove_ie23a(u8 *ies, uint *ies_len, uint offset, u8 eid, u8 *oui, u void rtw_set_supported_rate23a(u8* SupportedRates, uint mode) ; -unsigned char *rtw_get_wpa_ie23a(unsigned char *pie, int *wpa_ie_len, int limit); -unsigned char *rtw_get_wpa2_ie23a(unsigned char *pie, int *rsn_ie_len, int limit); int rtw_get_wpa_cipher_suite23a(const u8 *s); int rtw_get_wpa2_cipher_suite23a(const u8 *s); int rtw_parse_wpa_ie23a(const u8* wpa_ie, int wpa_ie_len, int *group_cipher, int *pairwise_cipher, int *is_8021x); -- cgit v1.2.3 From daa5d2f867f4a6e6a1c9b57c831c1fc2f59dedba Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:44:10 +0200 Subject: staging: rtl8723au: Remove unused for_each_ie() and dump_ies23a() Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_ieee80211.c | 15 --------------- drivers/staging/rtl8723au/include/ieee80211.h | 10 ---------- 2 files changed, 25 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_ieee80211.c b/drivers/staging/rtl8723au/core/rtw_ieee80211.c index a28b81667993..930a9b189998 100644 --- a/drivers/staging/rtl8723au/core/rtw_ieee80211.c +++ b/drivers/staging/rtl8723au/core/rtw_ieee80211.c @@ -1164,21 +1164,6 @@ void rtw_macaddr_cfg23a(u8 *mac_addr) MAC_ARG(mac_addr)); } -void dump_ies23a(u8 *buf, u32 buf_len) { - u8* pos = (u8*)buf; - u8 id, len; - - while (pos-buf <= buf_len) { - id = *pos; - len = *(pos + 1); - - DBG_8723A("%s ID:%u, LEN:%u\n", __func__, id, len); - dump_wps_ie23a(pos, len); - - pos += (2 + len); - } -} - void dump_wps_ie23a(u8 *ie, u32 ie_len) { u8* pos = (u8*)ie; u16 id; diff --git a/drivers/staging/rtl8723au/include/ieee80211.h b/drivers/staging/rtl8723au/include/ieee80211.h index e1117382e8fe..bfa7e2dbbdcc 100644 --- a/drivers/staging/rtl8723au/include/ieee80211.h +++ b/drivers/staging/rtl8723au/include/ieee80211.h @@ -549,16 +549,6 @@ u8 *rtw_get_wps_ie23a(u8 *in_ie, uint in_len, u8 *wps_ie, uint *wps_ielen); u8 *rtw_get_wps_attr23a(u8 *wps_ie, uint wps_ielen, u16 target_attr_id ,u8 *buf_attr, u32 *len_attr); u8 *rtw_get_wps_attr_content23a(u8 *wps_ie, uint wps_ielen, u16 target_attr_id ,u8 *buf_content, uint *len_content); -/** - * for_each_ie - iterate over continuous IEs - * @ie: - * @buf: - * @buf_len: - */ -#define for_each_ie(ie, buf, buf_len) \ - for (ie = (void*)buf; (((u8*)ie) - ((u8*)buf) + 1) < buf_len; ie = (void*)(((u8*)ie) + *(((u8*)ie)+1) + 2)) - -void dump_ies23a(u8 *buf, u32 buf_len); void dump_wps_ie23a(u8 *ie, u32 ie_len); uint rtw_get_rateset_len23a(u8 *rateset); -- cgit v1.2.3 From 7964eba0d8df78cae4c843330153554c8e775de6 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:44:11 +0200 Subject: staging: rtl8723au: Remove multiple duplicate defines of the WPA OUI Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_ap.c | 3 +-- drivers/staging/rtl8723au/core/rtw_ieee80211.c | 7 ++----- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 3 +-- drivers/staging/rtl8723au/core/rtw_wlan_util.c | 6 +++--- drivers/staging/rtl8723au/include/osdep_service.h | 1 - drivers/staging/rtl8723au/include/rtw_mlme_ext.h | 1 - 6 files changed, 7 insertions(+), 14 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_ap.c b/drivers/staging/rtl8723au/core/rtw_ap.c index d049ba770900..bbf8b2eabdb3 100644 --- a/drivers/staging/rtl8723au/core/rtw_ap.c +++ b/drivers/staging/rtl8723au/core/rtw_ap.c @@ -21,7 +21,6 @@ #ifdef CONFIG_8723AU_AP_MODE -extern unsigned char RTW_WPA_OUI23A[]; extern unsigned char WMM_OUI23A[]; extern unsigned char WPS_OUI23A[]; extern unsigned char P2P_OUI23A[]; @@ -1303,7 +1302,7 @@ static void update_bcn_vendor_spec_ie(struct rtw_adapter *padapter, u8*oui) { DBG_8723A("%s\n", __func__); - if (!memcmp(RTW_WPA_OUI23A, oui, 4)) + if (!memcmp(RTW_WPA_OUI23A_TYPE, oui, 4)) { update_bcn_wpa_ie(padapter); } diff --git a/drivers/staging/rtl8723au/core/rtw_ieee80211.c b/drivers/staging/rtl8723au/core/rtw_ieee80211.c index 930a9b189998..8fc54c806e7d 100644 --- a/drivers/staging/rtl8723au/core/rtw_ieee80211.c +++ b/drivers/staging/rtl8723au/core/rtw_ieee80211.c @@ -497,7 +497,6 @@ int rtw_parse_wpa_ie23a(const u8* wpa_ie, int wpa_ie_len, int *group_cipher, int int i, ret = _SUCCESS; int left, count; const u8 *pos; - u8 SUITE_1X[4] = {0x00, 0x50, 0xf2, 1}; if (wpa_ie_len <= 0) { /* No WPA IE - fail silently */ @@ -560,7 +559,7 @@ int rtw_parse_wpa_ie23a(const u8* wpa_ie, int wpa_ie_len, int *group_cipher, int if (is_8021x) { if (left >= 6) { pos += 2; - if (!memcmp(pos, SUITE_1X, 4)) { + if (!memcmp(pos, RTW_WPA_OUI23A_TYPE, 4)) { RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("%s : there has 802.1x auth\n", __func__)); @@ -653,11 +652,9 @@ int rtw_get_sec_ie23a(u8 *in_ie, uint in_len, u8 *rsn_ie, u16 *rsn_len, u8 *wpa_ie, u16 *wpa_len) { u8 authmode, sec_idx, i; - u8 wpa_oui[4] = {0x0, 0x50, 0xf2, 0x01}; uint cnt; - /* Search required WPA or WPA2 IE and copy to sec_ie[ ] */ cnt = (_TIMESTAMP_ + _BEACON_ITERVAL_ + _CAPABILITY_); @@ -668,7 +665,7 @@ int rtw_get_sec_ie23a(u8 *in_ie, uint in_len, u8 *rsn_ie, u16 *rsn_len, authmode = in_ie[cnt]; if ((authmode == WLAN_EID_VENDOR_SPECIFIC) && - !memcmp(&in_ie[cnt+2], &wpa_oui[0], 4)) { + !memcmp(&in_ie[cnt+2], RTW_WPA_OUI23A_TYPE, 4)) { RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("\n rtw_get_wpa_ie23a: sec_idx =%d " "in_ie[cnt+1]+2 =%d\n", diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index a79861e4250c..d08f12f6e9d3 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -87,7 +87,6 @@ static u8 null_addr[ETH_ALEN]= {0, 0, 0, 0, 0, 0}; /************************************************** OUI definitions for the vendor specific IE ***************************************************/ -unsigned char RTW_WPA_OUI23A[] = {0x00, 0x50, 0xf2, 0x01}; unsigned char WMM_OUI23A[] = {0x00, 0x50, 0xf2, 0x02}; unsigned char WPS_OUI23A[] = {0x00, 0x50, 0xf2, 0x04}; unsigned char P2P_OUI23A[] = {0x50, 0x6F, 0x9A, 0x09}; @@ -3366,7 +3365,7 @@ void issue_assocreq23a(struct rtw_adapter *padapter) switch (pIE->ElementID) { case WLAN_EID_VENDOR_SPECIFIC: - if (!memcmp(pIE->data, RTW_WPA_OUI23A, 4) || + if (!memcmp(pIE->data, RTW_WPA_OUI23A_TYPE, 4) || !memcmp(pIE->data, WMM_OUI23A, 4) || !memcmp(pIE->data, WPS_OUI23A, 4)) { if (!padapter->registrypriv.wifi_spec) { diff --git a/drivers/staging/rtl8723au/core/rtw_wlan_util.c b/drivers/staging/rtl8723au/core/rtw_wlan_util.c index e8127cb6c33a..84753f5ee231 100644 --- a/drivers/staging/rtl8723au/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8723au/core/rtw_wlan_util.c @@ -1145,7 +1145,7 @@ unsigned int is_ap_in_tkip23a(struct rtw_adapter *padapter) switch (pIE->ElementID) { case WLAN_EID_VENDOR_SPECIFIC: - if ((!memcmp(pIE->data, RTW_WPA_OUI23A, 4)) && (!memcmp((pIE->data + 12), WPA_TKIP_CIPHER23A, 4))) + if ((!memcmp(pIE->data, RTW_WPA_OUI23A_TYPE, 4)) && (!memcmp((pIE->data + 12), WPA_TKIP_CIPHER23A, 4))) return true; break; case WLAN_EID_RSN: @@ -1176,7 +1176,7 @@ unsigned int should_forbid_n_rate23a(struct rtw_adapter * padapter) switch (pIE->ElementID) { case WLAN_EID_VENDOR_SPECIFIC: - if (!memcmp(pIE->data, RTW_WPA_OUI23A, 4) && + if (!memcmp(pIE->data, RTW_WPA_OUI23A_TYPE, 4) && ((!memcmp((pIE->data + 12), WPA_CIPHER_SUITE_CCMP23A, 4)) || (!memcmp((pIE->data + 16), WPA_CIPHER_SUITE_CCMP23A, 4)))) return false; @@ -1211,7 +1211,7 @@ unsigned int is_ap_in_wep23a(struct rtw_adapter *padapter) switch (pIE->ElementID) { case WLAN_EID_VENDOR_SPECIFIC: - if (!memcmp(pIE->data, RTW_WPA_OUI23A, 4)) + if (!memcmp(pIE->data, RTW_WPA_OUI23A_TYPE, 4)) return false; break; case WLAN_EID_RSN: diff --git a/drivers/staging/rtl8723au/include/osdep_service.h b/drivers/staging/rtl8723au/include/osdep_service.h index 92c954eb2179..40445bbafe77 100644 --- a/drivers/staging/rtl8723au/include/osdep_service.h +++ b/drivers/staging/rtl8723au/include/osdep_service.h @@ -137,7 +137,6 @@ void _rtw_vmfree(u8 *pbuf, u32 sz); extern unsigned char REALTEK_96B_IE23A[]; extern unsigned char MCS_rate_2R23A[16]; -extern unsigned char RTW_WPA_OUI23A[]; extern unsigned char WPA_TKIP_CIPHER23A[4]; extern unsigned char RSN_TKIP_CIPHER23A[4]; diff --git a/drivers/staging/rtl8723au/include/rtw_mlme_ext.h b/drivers/staging/rtl8723au/include/rtw_mlme_ext.h index 275f891b6c64..13f580d9d96f 100644 --- a/drivers/staging/rtl8723au/include/rtw_mlme_ext.h +++ b/drivers/staging/rtl8723au/include/rtw_mlme_ext.h @@ -89,7 +89,6 @@ #define _54M_RATE_ 11 -extern unsigned char RTW_WPA_OUI23A[]; extern unsigned char WMM_OUI23A[]; extern unsigned char WPS_OUI23A[]; extern unsigned char WFD_OUI23A[]; -- cgit v1.2.3 From ab6fb7a503b03850524f70272545b6f4d6c747bb Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:44:12 +0200 Subject: staging: rtl8723au: update_bcn_vendor_spec_ie(): Go easy on those brackets Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_ap.c | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_ap.c b/drivers/staging/rtl8723au/core/rtw_ap.c index bbf8b2eabdb3..207a19e4dc9f 100644 --- a/drivers/staging/rtl8723au/core/rtw_ap.c +++ b/drivers/staging/rtl8723au/core/rtw_ap.c @@ -1303,25 +1303,15 @@ static void update_bcn_vendor_spec_ie(struct rtw_adapter *padapter, u8*oui) DBG_8723A("%s\n", __func__); if (!memcmp(RTW_WPA_OUI23A_TYPE, oui, 4)) - { update_bcn_wpa_ie(padapter); - } else if (!memcmp(WMM_OUI23A, oui, 4)) - { update_bcn_wmm_ie(padapter); - } else if (!memcmp(WPS_OUI23A, oui, 4)) - { update_bcn_wps_ie(padapter); - } else if (!memcmp(P2P_OUI23A, oui, 4)) - { update_bcn_p2p_ie(padapter); - } else - { DBG_8723A("unknown OUI type!\n"); - } } void update_beacon23a(struct rtw_adapter *padapter, u8 ie_id, u8 *oui, u8 tx) -- cgit v1.2.3 From 7d6925306c68c15a579e831d71bafe99a05eb9fa Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:44:13 +0200 Subject: staging: rtl8723au: OnAssocReq23a(): Simplify parsing crypto info from the IE This reduces the dependency of rtw_ieee802_11_parse_elems23a() which is only used in this function. Follow-on patches will remove the remaining dependencies and get rid of the function. Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 107 +++++++++++++------------- 1 file changed, 54 insertions(+), 53 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index d08f12f6e9d3..fecbf2a300f3 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -1144,7 +1144,7 @@ OnAssocReq23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) u16 capab_info, listen_interval; struct rtw_ieee802_11_elems elems; struct sta_info *pstat; - unsigned char reassoc, *wpa_ie; + unsigned char reassoc; unsigned char WMM_IE[] = {0x00, 0x50, 0xf2, 0x02, 0x00, 0x01}; int i, wpa_ie_len, left; unsigned char supportRate[16]; @@ -1158,10 +1158,11 @@ OnAssocReq23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) struct sta_priv *pstapriv = &padapter->stapriv; struct sk_buff *skb = precv_frame->pkt; struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *) skb->data; - const u8 *p; + const u8 *p, *wpa_ie, *wps_ie; u8 *pos; u8 *pframe = skb->data; uint pkt_len = skb->len; + int r; if ((pmlmeinfo->state & 0x03) != WIFI_FW_AP_STATE) return _FAIL; @@ -1280,66 +1281,68 @@ OnAssocReq23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) pstat->wpa_pairwise_cipher = 0; pstat->wpa2_pairwise_cipher = 0; memset(pstat->wpa_ie, 0, sizeof(pstat->wpa_ie)); - if (psecuritypriv->wpa_psk & BIT(1) && elems.rsn_ie) { - int group_cipher = 0, pairwise_cipher = 0; - - wpa_ie = elems.rsn_ie; - wpa_ie_len = elems.rsn_ie_len; - - if (rtw_parse_wpa2_ie23a(wpa_ie - 2, wpa_ie_len + 2, - &group_cipher, &pairwise_cipher, - NULL) == _SUCCESS) { - pstat->dot8021xalg = 1;/* psk, todo:802.1x */ - pstat->wpa_psk |= BIT(1); - pstat->wpa2_group_cipher = - group_cipher&psecuritypriv->wpa2_group_cipher; - pstat->wpa2_pairwise_cipher = - pairwise_cipher&psecuritypriv->wpa2_pairwise_cipher; - - if (!pstat->wpa2_group_cipher) - status = WLAN_REASON_INVALID_GROUP_CIPHER; - - if (!pstat->wpa2_pairwise_cipher) - status = WLAN_REASON_INVALID_PAIRWISE_CIPHER; - } else - status = WLAN_STATUS_INVALID_IE; - } else if (psecuritypriv->wpa_psk & BIT(0) && elems.wpa_ie) { + wpa_ie = cfg80211_find_ie(WLAN_EID_RSN, pos, left); + if (!wpa_ie) + wpa_ie = cfg80211_find_vendor_ie(WLAN_OUI_MICROSOFT, + WLAN_OUI_TYPE_MICROSOFT_WPA, + pos, left); + if (wpa_ie) { int group_cipher = 0, pairwise_cipher = 0; - wpa_ie = elems.wpa_ie; - wpa_ie_len = elems.wpa_ie_len; - - if (rtw_parse_wpa_ie23a(wpa_ie - 2, wpa_ie_len + 2, - &group_cipher, &pairwise_cipher, - NULL) == _SUCCESS) { - pstat->dot8021xalg = 1;/* psk, todo:802.1x */ - pstat->wpa_psk |= BIT(0); - - pstat->wpa_group_cipher = - group_cipher&psecuritypriv->wpa_group_cipher; - pstat->wpa_pairwise_cipher = - pairwise_cipher&psecuritypriv->wpa_pairwise_cipher; - + wpa_ie_len = wpa_ie[1]; + if (psecuritypriv->wpa_psk & BIT(1)) { + r = rtw_parse_wpa2_ie23a(wpa_ie, wpa_ie_len + 2, + &group_cipher, + &pairwise_cipher, NULL); + if (r == _SUCCESS) { + pstat->dot8021xalg = 1;/* psk, todo:802.1x */ + pstat->wpa_psk |= BIT(1); + + pstat->wpa2_group_cipher = group_cipher & + psecuritypriv->wpa2_group_cipher; + pstat->wpa2_pairwise_cipher = pairwise_cipher & + psecuritypriv->wpa2_pairwise_cipher; + } else + status = WLAN_STATUS_INVALID_IE; + } else if (psecuritypriv->wpa_psk & BIT(0)) { + r = rtw_parse_wpa_ie23a(wpa_ie, wpa_ie_len + 2, + &group_cipher, &pairwise_cipher, + NULL); + if (r == _SUCCESS) { + pstat->dot8021xalg = 1;/* psk, todo:802.1x */ + pstat->wpa_psk |= BIT(0); + + pstat->wpa_group_cipher = group_cipher & + psecuritypriv->wpa_group_cipher; + pstat->wpa_pairwise_cipher = pairwise_cipher & + psecuritypriv->wpa_pairwise_cipher; + } else + status = WLAN_STATUS_INVALID_IE; + } else { + wpa_ie = NULL; + wpa_ie_len = 0; + } + if (wpa_ie && status == WLAN_STATUS_SUCCESS) { if (!pstat->wpa_group_cipher) status = WLAN_STATUS_INVALID_GROUP_CIPHER; if (!pstat->wpa_pairwise_cipher) status = WLAN_STATUS_INVALID_PAIRWISE_CIPHER; - - } else - status = WLAN_STATUS_INVALID_IE; - } else { - wpa_ie = NULL; - wpa_ie_len = 0; + } } - if (WLAN_STATUS_SUCCESS != status) + if (status != WLAN_STATUS_SUCCESS) goto OnAssocReq23aFail; pstat->flags &= ~(WLAN_STA_WPS | WLAN_STA_MAYBE_WPS); + + wps_ie = cfg80211_find_vendor_ie(WLAN_OUI_MICROSOFT, + WLAN_OUI_TYPE_MICROSOFT_WPS, + pos, left); + if (!wpa_ie) { - if (elems.wps_ie) { + if (wps_ie) { DBG_8723A("STA included WPS IE in (Re)Association " "Request - assume WPS is used\n"); pstat->flags |= WLAN_STA_WPS; @@ -1386,10 +1389,9 @@ OnAssocReq23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) goto OnAssocReq23aFail; } - if (elems.wps_ie) { - DBG_8723A("STA included WPS IE in " - "(Re)Association Request - WPS is " - "used\n"); + if (wps_ie) { + DBG_8723A("STA included WPS IE in (Re)Association " + "Request - WPS is used\n"); pstat->flags |= WLAN_STA_WPS; copy_len = 0; } else { @@ -1399,7 +1401,6 @@ OnAssocReq23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) if (copy_len > 0) memcpy(pstat->wpa_ie, wpa_ie - 2, copy_len); - } /* check if there is WMM IE & support WWM-PS */ -- cgit v1.2.3 From 49ae9a5c69e771383c10b78cfce8f1426bdecff0 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:44:14 +0200 Subject: staging: rtl8723au: OnAssocReq23a(): Don't check for presence of BSSID twice Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index fecbf2a300f3..e1e8f2831478 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -1216,7 +1216,7 @@ OnAssocReq23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) /* now parse all ieee802_11 ie to point to elems */ if (rtw_ieee802_11_parse_elems23a(pos, left, &elems, 1) == - ParseFailed || !elems.ssid) { + ParseFailed) { DBG_8723A("STA " MAC_FMT " sent invalid association request\n", MAC_ARG(pstat->hwaddr)); status = WLAN_STATUS_UNSPECIFIED_FAILURE; @@ -1227,8 +1227,11 @@ OnAssocReq23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) /* checking SSID */ p = cfg80211_find_ie(WLAN_EID_SSID, pos, left); if (!p || p[1] == 0) { - /* broadcast ssid, however it is not allowed in assocreq */ + /* broadcast ssid, however it is not allowed in assocreq */ + DBG_8723A("STA " MAC_FMT " sent invalid association request " + "lacking an SSID\n", MAC_ARG(pstat->hwaddr)); status = WLAN_STATUS_UNSPECIFIED_FAILURE; + goto OnAssocReq23aFail; } else { /* check if ssid match */ if (memcmp(p + 2, cur->Ssid.ssid, cur->Ssid.ssid_len)) -- cgit v1.2.3 From 57ed7bbf7be701ce932512159afc09f4031ad165 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:44:15 +0200 Subject: staging: rtl8723au: OnAssocReq23a(): Use cfg80211_find_ie() to locate HT caps Use cfg80211 interface to search for HT capabilities. This was the last user of struct rtw_ieee802_11_elems, which can now be removed. Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index e1e8f2831478..f0e24e33f5d8 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -1471,13 +1471,14 @@ OnAssocReq23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) /* save HT capabilities in the sta object */ memset(&pstat->htpriv.ht_cap, 0, sizeof(struct ieee80211_ht_cap)); - if (elems.ht_capabilities && elems.ht_capabilities_len >= - sizeof(struct ieee80211_ht_cap)) { + p = cfg80211_find_ie(WLAN_EID_HT_CAPABILITY, pos, left); + + if (p && p[1] >= sizeof(struct ieee80211_ht_cap)) { pstat->flags |= WLAN_STA_HT; pstat->flags |= WLAN_STA_WME; - memcpy(&pstat->htpriv.ht_cap, elems.ht_capabilities, + memcpy(&pstat->htpriv.ht_cap, p + 2, sizeof(struct ieee80211_ht_cap)); } else pstat->flags &= ~WLAN_STA_HT; -- cgit v1.2.3 From 7e07583247d0b80e3ebb5ea7585ba2d29d26dec7 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:44:16 +0200 Subject: staging: rtl8723au: Remove struct rtw_ieee802_11_elems and related code This removes the double content tracking of data from IE elements. The relevant code to validate IEs is moved to rtw_mlme_ext.c as this is the only place where it is used. Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_ieee80211.c | 231 ------------------------- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 145 +++++++++++++++- drivers/staging/rtl8723au/include/ieee80211.h | 60 ------- 3 files changed, 139 insertions(+), 297 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_ieee80211.c b/drivers/staging/rtl8723au/core/rtw_ieee80211.c index 8fc54c806e7d..b430e10214f3 100644 --- a/drivers/staging/rtl8723au/core/rtw_ieee80211.c +++ b/drivers/staging/rtl8723au/core/rtw_ieee80211.c @@ -884,237 +884,6 @@ u8 *rtw_get_wps_attr_content23a(u8 *wps_ie, uint wps_ielen, u16 target_attr_id, return NULL; } -static int -rtw_ieee802_11_parse_vendor_specific(u8 *pos, uint elen, - struct rtw_ieee802_11_elems *elems, - int show_errors) -{ - unsigned int oui; - - /* first 3 bytes in vendor specific information element are the IEEE - * OUI of the vendor. The following byte is used a vendor specific - * sub-type. */ - if (elen < 4) { - if (show_errors) { - DBG_8723A("short vendor specific " - "information element ignored (len =%lu)\n", - (unsigned long) elen); - } - return -1; - } - - oui = RTW_GET_BE24(pos); - switch (oui) { - case WLAN_OUI_MICROSOFT: - /* Microsoft/Wi-Fi information elements are further typed and - * subtyped */ - switch (pos[3]) { - case 1: - /* Microsoft OUI (00:50:F2) with OUI Type 1: - * real WPA information element */ - elems->wpa_ie = pos; - elems->wpa_ie_len = elen; - break; - case WME_OUI_TYPE: /* this is a Wi-Fi WME info. element */ - if (elen < 5) { - DBG_8723A("short WME " - "information element ignored " - "(len =%lu)\n", - (unsigned long) elen); - return -1; - } - switch (pos[4]) { - case WME_OUI_SUBTYPE_INFORMATION_ELEMENT: - case WME_OUI_SUBTYPE_PARAMETER_ELEMENT: - elems->wme = pos; - elems->wme_len = elen; - break; - case WME_OUI_SUBTYPE_TSPEC_ELEMENT: - elems->wme_tspec = pos; - elems->wme_tspec_len = elen; - break; - default: - DBG_8723A("unknown WME " - "information element ignored " - "(subtype =%d len =%lu)\n", - pos[4], (unsigned long) elen); - return -1; - } - break; - case 4: - /* Wi-Fi Protected Setup (WPS) IE */ - elems->wps_ie = pos; - elems->wps_ie_len = elen; - break; - default: - DBG_8723A("Unknown Microsoft " - "information element ignored " - "(type =%d len =%lu)\n", - pos[3], (unsigned long) elen); - return -1; - } - break; - - case OUI_BROADCOM: - switch (pos[3]) { - case VENDOR_HT_CAPAB_OUI_TYPE: - elems->vendor_ht_cap = pos; - elems->vendor_ht_cap_len = elen; - break; - default: - DBG_8723A("Unknown Broadcom " - "information element ignored " - "(type =%d len =%lu)\n", - pos[3], (unsigned long) elen); - return -1; - } - break; - - default: - DBG_8723A("unknown vendor specific information " - "element ignored (vendor OUI %02x:%02x:%02x " - "len =%lu)\n", - pos[0], pos[1], pos[2], (unsigned long) elen); - return -1; - } - - return 0; -} - -/** - * ieee802_11_parse_elems - Parse information elements in management frames - * @start: Pointer to the start of IEs - * @len: Length of IE buffer in octets - * @elems: Data structure for parsed elements - * @show_errors: Whether to show parsing errors in debug log - * Returns: Parsing result - */ -enum parse_res rtw_ieee802_11_parse_elems23a(u8 *start, uint len, - struct rtw_ieee802_11_elems *elems, - int show_errors) -{ - uint left = len; - u8 *pos = start; - int unknown = 0; - - memset(elems, 0, sizeof(*elems)); - - while (left >= 2) { - u8 id, elen; - - id = *pos++; - elen = *pos++; - left -= 2; - - if (elen > left) { - if (show_errors) { - DBG_8723A("IEEE 802.11 element " - "parse failed (id =%d elen =%d " - "left =%lu)\n", - id, elen, (unsigned long) left); - } - return ParseFailed; - } - - switch (id) { - case WLAN_EID_SSID: - elems->ssid = pos; - elems->ssid_len = elen; - break; - case WLAN_EID_SUPP_RATES: - elems->supp_rates = pos; - elems->supp_rates_len = elen; - break; - case WLAN_EID_FH_PARAMS: - elems->fh_params = pos; - elems->fh_params_len = elen; - break; - case WLAN_EID_DS_PARAMS: - elems->ds_params = pos; - elems->ds_params_len = elen; - break; - case WLAN_EID_CF_PARAMS: - elems->cf_params = pos; - elems->cf_params_len = elen; - break; - case WLAN_EID_TIM: - elems->tim = pos; - elems->tim_len = elen; - break; - case WLAN_EID_IBSS_PARAMS: - elems->ibss_params = pos; - elems->ibss_params_len = elen; - break; - case WLAN_EID_CHALLENGE: - elems->challenge = pos; - elems->challenge_len = elen; - break; - case WLAN_EID_ERP_INFO: - elems->erp_info = pos; - elems->erp_info_len = elen; - break; - case WLAN_EID_EXT_SUPP_RATES: - elems->ext_supp_rates = pos; - elems->ext_supp_rates_len = elen; - break; - case WLAN_EID_VENDOR_SPECIFIC: - if (rtw_ieee802_11_parse_vendor_specific(pos, elen, - elems, - show_errors)) - unknown++; - break; - case WLAN_EID_RSN: - elems->rsn_ie = pos; - elems->rsn_ie_len = elen; - break; - case WLAN_EID_PWR_CAPABILITY: - elems->power_cap = pos; - elems->power_cap_len = elen; - break; - case WLAN_EID_SUPPORTED_CHANNELS: - elems->supp_channels = pos; - elems->supp_channels_len = elen; - break; - case WLAN_EID_MOBILITY_DOMAIN: - elems->mdie = pos; - elems->mdie_len = elen; - break; - case WLAN_EID_FAST_BSS_TRANSITION: - elems->ftie = pos; - elems->ftie_len = elen; - break; - case WLAN_EID_TIMEOUT_INTERVAL: - elems->timeout_int = pos; - elems->timeout_int_len = elen; - break; - case WLAN_EID_HT_CAPABILITY: - elems->ht_capabilities = pos; - elems->ht_capabilities_len = elen; - break; - case WLAN_EID_HT_OPERATION: - elems->ht_operation = pos; - elems->ht_operation_len = elen; - break; - default: - unknown++; - if (!show_errors) - break; - DBG_8723A("IEEE 802.11 element parse " - "ignored unknown element (id =%d elen =%d)\n", - id, elen); - break; - } - - left -= elen; - pos += elen; - } - - if (left) - return ParseFailed; - - return unknown ? ParseUnknown : ParseOK; -} - static u8 key_char2num(u8 ch) { if ((ch >= '0') && (ch <= '9')) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index f0e24e33f5d8..8c48ca4a4905 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -1137,12 +1137,146 @@ authclnt_fail: return _FAIL; } +#ifdef CONFIG_8723AU_AP_MODE +static int rtw_validate_vendor_specific_ies(const u8 *pos, int elen) +{ + unsigned int oui; + + /* first 3 bytes in vendor specific information element are the IEEE + * OUI of the vendor. The following byte is used a vendor specific + * sub-type. */ + if (elen < 4) { + DBG_8723A("short vendor specific information element " + "ignored (len =%i)\n", elen); + return -EINVAL; + } + + oui = RTW_GET_BE24(pos); + switch (oui) { + case WLAN_OUI_MICROSOFT: + /* Microsoft/Wi-Fi information elements are further typed and + * subtyped */ + switch (pos[3]) { + case 1: + /* Microsoft OUI (00:50:F2) with OUI Type 1: + * real WPA information element */ + break; + case WME_OUI_TYPE: /* this is a Wi-Fi WME info. element */ + if (elen < 5) { + DBG_8723A("short WME information element " + "ignored (len =%i)\n", elen); + return -EINVAL; + } + switch (pos[4]) { + case WME_OUI_SUBTYPE_INFORMATION_ELEMENT: + case WME_OUI_SUBTYPE_PARAMETER_ELEMENT: + break; + case WME_OUI_SUBTYPE_TSPEC_ELEMENT: + break; + default: + DBG_8723A("unknown WME information element " + "ignored (subtype =%d len =%i)\n", + pos[4], elen); + return -EINVAL; + } + break; + case 4: + /* Wi-Fi Protected Setup (WPS) IE */ + break; + default: + DBG_8723A("Unknown Microsoft information element " + "ignored (type =%d len =%i)\n", + pos[3], elen); + return -EINVAL; + } + break; + + case OUI_BROADCOM: + switch (pos[3]) { + case VENDOR_HT_CAPAB_OUI_TYPE: + break; + default: + DBG_8723A("Unknown Broadcom information element " + "ignored (type =%d len =%i)\n", pos[3], elen); + return -EINVAL; + } + break; + + default: + DBG_8723A("unknown vendor specific information element " + "ignored (vendor OUI %02x:%02x:%02x len =%i)\n", + pos[0], pos[1], pos[2], elen); + return -EINVAL; + } + + return 0; +} + +static int rtw_validate_frame_ies(const u8 *start, uint len) +{ + const u8 *pos = start; + int left = len; + int unknown = 0; + + while (left >= 2) { + u8 id, elen; + + id = *pos++; + elen = *pos++; + left -= 2; + + if (elen > left) { + DBG_8723A("%s: IEEE 802.11 failed (id =%d elen =%d " + "left =%i)\n", __func__, id, elen, left); + return -EINVAL; + } + + switch (id) { + case WLAN_EID_SSID: + case WLAN_EID_SUPP_RATES: + case WLAN_EID_FH_PARAMS: + case WLAN_EID_DS_PARAMS: + case WLAN_EID_CF_PARAMS: + case WLAN_EID_TIM: + case WLAN_EID_IBSS_PARAMS: + case WLAN_EID_CHALLENGE: + case WLAN_EID_ERP_INFO: + case WLAN_EID_EXT_SUPP_RATES: + case WLAN_EID_VENDOR_SPECIFIC: + if (rtw_validate_vendor_specific_ies(pos, elen)) + unknown++; + break; + case WLAN_EID_RSN: + case WLAN_EID_PWR_CAPABILITY: + case WLAN_EID_SUPPORTED_CHANNELS: + case WLAN_EID_MOBILITY_DOMAIN: + case WLAN_EID_FAST_BSS_TRANSITION: + case WLAN_EID_TIMEOUT_INTERVAL: + case WLAN_EID_HT_CAPABILITY: + case WLAN_EID_HT_OPERATION: + default: + unknown++; + DBG_8723A("%s IEEE 802.11 ignored unknown element " + "(id =%d elen =%d)\n", __func__, id, elen); + break; + } + + left -= elen; + pos += elen; + } + + if (left) + return -EINVAL; + + return 0; +} +#endif + static int OnAssocReq23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) { #ifdef CONFIG_8723AU_AP_MODE u16 capab_info, listen_interval; - struct rtw_ieee802_11_elems elems; struct sta_info *pstat; unsigned char reassoc; unsigned char WMM_IE[] = {0x00, 0x50, 0xf2, 0x02, 0x00, 0x01}; @@ -1158,8 +1292,7 @@ OnAssocReq23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) struct sta_priv *pstapriv = &padapter->stapriv; struct sk_buff *skb = precv_frame->pkt; struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *) skb->data; - const u8 *p, *wpa_ie, *wps_ie; - u8 *pos; + const u8 *pos, *p, *wpa_ie, *wps_ie; u8 *pframe = skb->data; uint pkt_len = skb->len; int r; @@ -1215,8 +1348,8 @@ OnAssocReq23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) pstat->capability = capab_info; /* now parse all ieee802_11 ie to point to elems */ - if (rtw_ieee802_11_parse_elems23a(pos, left, &elems, 1) == - ParseFailed) { + + if (rtw_validate_frame_ies(pos, left)) { DBG_8723A("STA " MAC_FMT " sent invalid association request\n", MAC_ARG(pstat->hwaddr)); status = WLAN_STATUS_UNSPECIFIED_FAILURE; @@ -1416,7 +1549,7 @@ OnAssocReq23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) pstat->uapsd_be = 0; pstat->uapsd_bk = 0; if (pmlmepriv->qospriv.qos_option) { - u8 *end = pos + left; + const u8 *end = pos + left; p = pos; for (;;) { diff --git a/drivers/staging/rtl8723au/include/ieee80211.h b/drivers/staging/rtl8723au/include/ieee80211.h index bfa7e2dbbdcc..fcbe6ba59c27 100644 --- a/drivers/staging/rtl8723au/include/ieee80211.h +++ b/drivers/staging/rtl8723au/include/ieee80211.h @@ -457,66 +457,6 @@ struct rtw_ieee80211_channel { /*, (channel)->orig_mag*/ \ /*, (channel)->orig_mpwr*/ \ -/* Parsed Information Elements */ -struct rtw_ieee802_11_elems { - u8 *ssid; - u8 ssid_len; - u8 *supp_rates; - u8 supp_rates_len; - u8 *fh_params; - u8 fh_params_len; - u8 *ds_params; - u8 ds_params_len; - u8 *cf_params; - u8 cf_params_len; - u8 *tim; - u8 tim_len; - u8 *ibss_params; - u8 ibss_params_len; - u8 *challenge; - u8 challenge_len; - u8 *erp_info; - u8 erp_info_len; - u8 *ext_supp_rates; - u8 ext_supp_rates_len; - u8 *wpa_ie; - u8 wpa_ie_len; - u8 *rsn_ie; - u8 rsn_ie_len; - u8 *wme; - u8 wme_len; - u8 *wme_tspec; - u8 wme_tspec_len; - u8 *wps_ie; - u8 wps_ie_len; - u8 *power_cap; - u8 power_cap_len; - u8 *supp_channels; - u8 supp_channels_len; - u8 *mdie; - u8 mdie_len; - u8 *ftie; - u8 ftie_len; - u8 *timeout_int; - u8 timeout_int_len; - u8 *ht_capabilities; - u8 ht_capabilities_len; - u8 *ht_operation; - u8 ht_operation_len; - u8 *vendor_ht_cap; - u8 vendor_ht_cap_len; -}; - -enum parse_res { - ParseOK = 0, - ParseUnknown = 1, - ParseFailed = -1 -}; - -enum parse_res rtw_ieee802_11_parse_elems23a(u8 *start, uint len, - struct rtw_ieee802_11_elems *elems, - int show_errors); - u8 *rtw_set_fixed_ie23a(unsigned char *pbuf, unsigned int len, unsigned char *source, unsigned int *frlen); u8 *rtw_set_ie23a(u8 *pbuf, int index, uint len, const u8 *source, uint *frlen); -- cgit v1.2.3 From 5951a5c1b8b2a2d0dc106817c92658efddfbf922 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:44:17 +0200 Subject: staging: rtl8723au: Remove unused dump_wpsie23a() Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_ieee80211.c | 24 ------------------------ drivers/staging/rtl8723au/include/ieee80211.h | 2 -- 2 files changed, 26 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_ieee80211.c b/drivers/staging/rtl8723au/core/rtw_ieee80211.c index b430e10214f3..e3fdbeba24fa 100644 --- a/drivers/staging/rtl8723au/core/rtw_ieee80211.c +++ b/drivers/staging/rtl8723au/core/rtw_ieee80211.c @@ -930,30 +930,6 @@ void rtw_macaddr_cfg23a(u8 *mac_addr) MAC_ARG(mac_addr)); } -void dump_wps_ie23a(u8 *ie, u32 ie_len) { - u8* pos = (u8*)ie; - u16 id; - u16 len; - - u8 *wps_ie; - uint wps_ielen; - - wps_ie = rtw_get_wps_ie23a(ie, ie_len, NULL, &wps_ielen); - if (wps_ie != ie || wps_ielen == 0) - return; - - pos+= 6; - while (pos-ie < ie_len) { - id = get_unaligned_be16(pos); - len = get_unaligned_be16(pos + 2); - - DBG_8723A("%s ID:0x%04x, LEN:%u\n", __func__, id, len); - - pos += (4 + len); - } -} - - /* Baron adds to avoid FreeBSD warning */ int ieee80211_is_empty_essid23a(const char *essid, int essid_len) { diff --git a/drivers/staging/rtl8723au/include/ieee80211.h b/drivers/staging/rtl8723au/include/ieee80211.h index fcbe6ba59c27..de7c1a7f6b0a 100644 --- a/drivers/staging/rtl8723au/include/ieee80211.h +++ b/drivers/staging/rtl8723au/include/ieee80211.h @@ -489,8 +489,6 @@ u8 *rtw_get_wps_ie23a(u8 *in_ie, uint in_len, u8 *wps_ie, uint *wps_ielen); u8 *rtw_get_wps_attr23a(u8 *wps_ie, uint wps_ielen, u16 target_attr_id ,u8 *buf_attr, u32 *len_attr); u8 *rtw_get_wps_attr_content23a(u8 *wps_ie, uint wps_ielen, u16 target_attr_id ,u8 *buf_content, uint *len_content); -void dump_wps_ie23a(u8 *ie, u32 ie_len); - uint rtw_get_rateset_len23a(u8 *rateset); struct registry_priv; -- cgit v1.2.3 From 30947bbc2711b0b96e2e0329a0e8df2991fdb80f Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:44:18 +0200 Subject: staging: rtl8723au: Remove unused ieee880211_is_empty_essid() Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_ieee80211.c | 17 ----------------- drivers/staging/rtl8723au/include/ieee80211.h | 3 --- 2 files changed, 20 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_ieee80211.c b/drivers/staging/rtl8723au/core/rtw_ieee80211.c index e3fdbeba24fa..8f91bdbc2bbf 100644 --- a/drivers/staging/rtl8723au/core/rtw_ieee80211.c +++ b/drivers/staging/rtl8723au/core/rtw_ieee80211.c @@ -930,23 +930,6 @@ void rtw_macaddr_cfg23a(u8 *mac_addr) MAC_ARG(mac_addr)); } -/* Baron adds to avoid FreeBSD warning */ -int ieee80211_is_empty_essid23a(const char *essid, int essid_len) -{ - /* Single white space is for Linksys APs */ - if (essid_len == 1 && essid[0] == ' ') - return 1; - - /* Otherwise, if the entire essid is 0, we assume it is hidden */ - while (essid_len) { - essid_len--; - if (essid[essid_len] != '\0') - return 0; - } - - return 1; -} - static int rtw_get_cipher_info(struct wlan_network *pnetwork) { const u8 *pbuf; diff --git a/drivers/staging/rtl8723au/include/ieee80211.h b/drivers/staging/rtl8723au/include/ieee80211.h index de7c1a7f6b0a..35fa3a6bf8ed 100644 --- a/drivers/staging/rtl8723au/include/ieee80211.h +++ b/drivers/staging/rtl8723au/include/ieee80211.h @@ -382,9 +382,6 @@ join_res: #define IEEE_G (1<<2) #define IEEE_MODE_MASK (IEEE_A|IEEE_B|IEEE_G) -/* Baron move to ieee80211.c */ -int ieee80211_is_empty_essid23a(const char *essid, int essid_len); - enum _PUBLIC_ACTION{ ACT_PUBLIC_BSSCOEXIST = 0, /* 20/40 BSS Coexistence */ ACT_PUBLIC_DSE_ENABLE = 1, -- cgit v1.2.3 From 29f79e057fcca0d45000b0260ac0d519985606eb Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:44:19 +0200 Subject: staging: rtl8723au: Remove some unused ieee80211 structs These are duplicated from the kernel headers and not used anymore Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/include/ieee80211.h | 47 --------------------------- 1 file changed, 47 deletions(-) diff --git a/drivers/staging/rtl8723au/include/ieee80211.h b/drivers/staging/rtl8723au/include/ieee80211.h index 35fa3a6bf8ed..76875f651d82 100644 --- a/drivers/staging/rtl8723au/include/ieee80211.h +++ b/drivers/staging/rtl8723au/include/ieee80211.h @@ -298,53 +298,6 @@ struct ieee80211_snap_hdr { #define WEP_KEY_LEN 13 - -/* - - 802.11 data frame from AP - - ,-------------------------------------------------------------------. -Bytes | 2 | 2 | 6 | 6 | 6 | 2 | 0..2312 | 4 | - |------|------|---------|---------|---------|------|---------|------| -Desc. | ctrl | dura | DA/RA | TA | SA | Sequ | frame | fcs | - | | tion | (BSSID) | | | ence | data | | - `-------------------------------------------------------------------' - -Total: 28-2340 bytes - -*/ - -struct ieee80211_header_data { - u16 frame_ctl; - u16 duration_id; - u8 addr1[6]; - u8 addr2[6]; - u8 addr3[6]; - u16 seq_ctrl; -}; - -struct ieee80211_info_element_hdr { - u8 id; - u8 len; -} __attribute__ ((packed)); - -struct ieee80211_info_element { - u8 id; - u8 len; - u8 data[0]; -} __attribute__ ((packed)); - - -struct ieee80211_txb { - u8 nr_frags; - u8 encrypted; - u16 reserved; - u16 frag_size; - u16 payload_size; - struct sk_buff *fragments[0]; -}; - - /* MAX_RATES_LENGTH needs to be 12. The spec says 8, and many APs * only use 8, and then use extended rates for the remaining supported * rates. Other APs, however, stick all of their supported rates on the -- cgit v1.2.3 From 43c34be13047dd53e70bc4759ff314424db7036b Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:44:20 +0200 Subject: staging: rtl8723au: ioctl_cfg80211.c: Use eth_{zero,broadcast},addr() Use kernel provided macros instead of own hacks. Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c b/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c index 888077be6e8b..cf44d295b66a 100644 --- a/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c +++ b/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c @@ -263,7 +263,6 @@ static int rtw_cfg80211_inform_bss(struct rtw_adapter *padapter, size_t len, bssinf_len = 0; struct ieee80211_hdr *pwlanhdr; unsigned short *fctrl; - u8 bc_addr[] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; struct wireless_dev *wdev = padapter->rtw_wdev; struct wiphy *wiphy = wdev->wiphy; @@ -321,7 +320,7 @@ static int rtw_cfg80211_inform_bss(struct rtw_adapter *padapter, SetSeqNum(pwlanhdr, 0); if (pnetwork->network.reserved == 1) { /* WIFI_BEACON */ - memcpy(pwlanhdr->addr1, bc_addr, ETH_ALEN); + eth_broadcast_addr(pwlanhdr->addr1); SetFrameSubType(pbuf, WIFI_BEACON); } else { memcpy(pwlanhdr->addr1, myid(&padapter->eeprompriv), ETH_ALEN); @@ -1101,7 +1100,7 @@ static int cfg80211_rtw_add_key(struct wiphy *wiphy, struct net_device *ndev, return -1; param->cmd = IEEE_CMD_SET_ENCRYPTION; - memset(param->sta_addr, 0xff, ETH_ALEN); + eth_broadcast_addr(param->sta_addr); switch (params->cipher) { case IW_AUTH_CIPHER_NONE: @@ -2255,8 +2254,7 @@ static int cfg80211_rtw_del_pmksa(struct wiphy *wiphy, if (!memcmp(psecuritypriv->PMKIDList[index].Bssid, pmksa->bssid, ETH_ALEN)) { /* BSSID is matched, the same AP => Remove this PMKID information and reset it. */ - memset(psecuritypriv->PMKIDList[index].Bssid, 0x00, - ETH_ALEN); + eth_zero_addr(psecuritypriv->PMKIDList[index].Bssid); memset(psecuritypriv->PMKIDList[index].PMKID, 0x00, WLAN_PMKID_LEN); psecuritypriv->PMKIDList[index].bUsed = false; -- cgit v1.2.3 From 07d2c3b8411a3674866a7e5b64a248db5ff3dc10 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:44:21 +0200 Subject: staging: rtl8723au: OnAssocReq23a(): use ieee80211_mgmt to calculate offset Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index 8c48ca4a4905..0277ee63db0e 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -1304,11 +1304,11 @@ OnAssocReq23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) if (ieee80211_is_assoc_req(mgmt->frame_control)) { reassoc = 0; pos = mgmt->u.assoc_req.variable; - left -= _ASOCREQ_IE_OFFSET_; + left -= offsetof(struct ieee80211_mgmt, u.assoc_req.variable); } else { /* WIFI_REASSOCREQ */ reassoc = 1; pos = mgmt->u.reassoc_req.variable; - left -= _REASOCREQ_IE_OFFSET_; + left -= offsetof(struct ieee80211_mgmt, u.reassoc_req.variable); } if (left < 0) { -- cgit v1.2.3 From d3c6094950589f034b2dc5c5e1cefa5b160a20e8 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:44:22 +0200 Subject: staging: rtl8723au: OnProbeReq23a(): Use struct ieee80211_mgmt Simplify parsing of probe request frame Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index 0277ee63db0e..0264eda4bf62 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -667,9 +667,8 @@ OnProbeReq23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; struct wlan_bssid_ex *cur = &pmlmeinfo->network; struct sk_buff *skb = precv_frame->pkt; - struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; - u8 *pframe = skb->data; - uint len = skb->len; + struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *) skb->data; + int len = skb->len; u8 is_valid_p2p_probereq = false; if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)) @@ -680,10 +679,15 @@ OnProbeReq23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) WIFI_ADHOC_MASTER_STATE | WIFI_AP_STATE)) return _SUCCESS; - pframe += (sizeof(struct ieee80211_hdr_3addr) + _PROBEREQ_IE_OFFSET_); - len -= (sizeof(struct ieee80211_hdr_3addr) + _PROBEREQ_IE_OFFSET_); + if (unlikely(!ieee80211_is_probe_req(mgmt->frame_control))) { + printk(KERN_WARNING "%s: Received non probe request frame\n", + __func__); + return _FAIL; + } - ie = cfg80211_find_ie(WLAN_EID_SSID, pframe, len); + len -= offsetof(struct ieee80211_mgmt, u.probe_req.variable); + + ie = cfg80211_find_ie(WLAN_EID_SSID, mgmt->u.probe_req.variable, len); /* check (wildcard) SSID */ if (!ie) @@ -698,10 +702,8 @@ OnProbeReq23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) } if (check_fwstate(pmlmepriv, _FW_LINKED) && - pmlmepriv->cur_network.join_res) { - issue_probersp23a(padapter, ieee80211_get_SA(hdr), - is_valid_p2p_probereq); - } + pmlmepriv->cur_network.join_res) + issue_probersp23a(padapter, mgmt->sa, is_valid_p2p_probereq); out: return _SUCCESS; -- cgit v1.2.3 From 8e64bc584d58a26d894eb51894c4d7e9b77411db Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:44:23 +0200 Subject: staging: rtl8723au: OnProbeReq23a(): is_valid_p2p_probereq is always false Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index 0264eda4bf62..dd18dd9f8bfa 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -669,7 +669,6 @@ OnProbeReq23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) struct sk_buff *skb = precv_frame->pkt; struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *) skb->data; int len = skb->len; - u8 is_valid_p2p_probereq = false; if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)) return _SUCCESS; @@ -693,17 +692,14 @@ OnProbeReq23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) if (!ie) goto out; - if (is_valid_p2p_probereq == false) { - if ((ie[1] && - memcmp(ie + 2, cur->Ssid.ssid, cur->Ssid.ssid_len)) || - (ie[1] == 0 && pmlmeinfo->hidden_ssid_mode)) { - return _SUCCESS; - } + if ((ie[1] && memcmp(ie + 2, cur->Ssid.ssid, cur->Ssid.ssid_len)) || + (ie[1] == 0 && pmlmeinfo->hidden_ssid_mode)) { + return _SUCCESS; } if (check_fwstate(pmlmepriv, _FW_LINKED) && pmlmepriv->cur_network.join_res) - issue_probersp23a(padapter, mgmt->sa, is_valid_p2p_probereq); + issue_probersp23a(padapter, mgmt->sa, false); out: return _SUCCESS; -- cgit v1.2.3 From 959226ac54b1b4cf9d6d2b496e097a29b4b1d338 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:44:24 +0200 Subject: staging: rtl8723au: Remove buggy function _rtw_report_sec_ie() This function was extremely buggy calling kmalloc(GFP_KERNEL) while holding a spin lock and then potentially overflowing the buffer it had allocated. Since the generated output wasn't used for anything, simply rip the whole thing out. Reported-by: Dan Carpenter Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme.c | 43 ------------------------------- 1 file changed, 43 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme.c b/drivers/staging/rtl8723au/core/rtw_mlme.c index 24a4338aafe8..3599d0287365 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme.c @@ -1987,47 +1987,6 @@ static int rtw_append_pmkid(struct rtw_adapter *Adapter, int iEntry, return ie_len; } -static void -_rtw_report_sec_ie(struct rtw_adapter *adapter, u8 authmode, u8 *sec_ie) -{ - uint len; - u8 *buff, *p, i; - union iwreq_data wrqu; - - RT_TRACE(_module_mlme_osdep_c_, _drv_info_, - ("+_rtw_report_sec_ie, authmode =%d\n", authmode)); - - buff = NULL; - if (authmode == WLAN_EID_VENDOR_SPECIFIC) { - RT_TRACE(_module_mlme_osdep_c_, _drv_info_, - ("_rtw_report_sec_ie, authmode =%d\n", authmode)); - - buff = kzalloc(IW_CUSTOM_MAX, GFP_KERNEL); - if (!buff) - return; - p = buff; - - p += sprintf(p, "ASSOCINFO(ReqIEs ="); - - len = sec_ie[1]+2; - len = (len < IW_CUSTOM_MAX) ? len : IW_CUSTOM_MAX; - - for (i = 0; i < len; i++) - p += sprintf(p, "%02x", sec_ie[i]); - - p += sprintf(p, ")"); - - memset(&wrqu, 0, sizeof(wrqu)); - - wrqu.data.length = p-buff; - - wrqu.data.length = (wrqu.data.length < IW_CUSTOM_MAX) ? - wrqu.data.length : IW_CUSTOM_MAX; - - kfree(buff); - } -} - int rtw_restruct_sec_ie23a(struct rtw_adapter *adapter, u8 *in_ie, u8 *out_ie, uint in_len) { @@ -2064,8 +2023,6 @@ int rtw_restruct_sec_ie23a(struct rtw_adapter *adapter, u8 *in_ie, u8 *out_ie, memcpy(&out_ie[ielength], &psecuritypriv->supplicant_ie[0], psecuritypriv->supplicant_ie[1] + 2); ielength += psecuritypriv->supplicant_ie[1] + 2; - _rtw_report_sec_ie(adapter, authmode, - psecuritypriv->supplicant_ie); } iEntry = SecIsInPMKIDList(adapter, pmlmepriv->assoc_bssid); -- cgit v1.2.3 From 9aac910a1238c2cb15cdfe2b4529302b8a94f294 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:44:25 +0200 Subject: staging: rtl8723au: rtw_mlme.c: remove commented out debug code Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme.c b/drivers/staging/rtl8723au/core/rtw_mlme.c index 3599d0287365..8c11fa18fe89 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme.c @@ -1591,8 +1591,6 @@ void rtw_clear_scan_deny(struct rtw_adapter *adapter) { struct mlme_priv *mlmepriv = &adapter->mlmepriv; atomic_set(&mlmepriv->set_scan_deny, 0); - if (0) - DBG_8723A(FUNC_ADPT_FMT"\n", FUNC_ADPT_ARG(adapter)); } void rtw_set_scan_deny_timer_hdl(unsigned long data) @@ -1605,12 +1603,9 @@ void rtw_set_scan_deny(struct rtw_adapter *adapter, u32 ms) { struct mlme_priv *mlmepriv = &adapter->mlmepriv; - if (0) - DBG_8723A(FUNC_ADPT_FMT"\n", FUNC_ADPT_ARG(adapter)); atomic_set(&mlmepriv->set_scan_deny, 1); mod_timer(&mlmepriv->set_scan_deny_timer, jiffies + msecs_to_jiffies(ms)); - } #if defined(IEEE80211_SCAN_RESULT_EXPIRE) -- cgit v1.2.3 From 9af36808d9697f48cbe5a0700b24fea33073290c Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:44:26 +0200 Subject: staging: rtl8723au: OnBeacon23a() tidy up code Clean up the excessive if() levels at the end, and use struct ieee80211_mgmt to calculate pointers passed on to check_assoc_AP23a() Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 157 +++++++++++++------------- 1 file changed, 79 insertions(+), 78 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index dd18dd9f8bfa..945b59271b11 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -740,8 +740,8 @@ OnBeacon23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) pie = mgmt->u.beacon.variable; pie_len = pkt_len - offsetof(struct ieee80211_mgmt, u.beacon.variable); p = rtw_get_ie23a(pie, WLAN_EID_EXT_SUPP_RATES, &ielen, pie_len); - if ((p != NULL) && (ielen > 0)) { - if ((*(p + 1 + ielen) == 0x2D) && (*(p + 2 + ielen) != 0x2D)) { + 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. @@ -750,7 +750,7 @@ OnBeacon23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) "Beacon of BSSID: %pM. Fix the length of " "ESR IE to avoid failed Beacon parsing.\n", mgmt->bssid); - *(p + 1) = ielen - 1; + p[1] = ielen - 1; } } @@ -759,93 +759,94 @@ OnBeacon23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) return _SUCCESS; } - if (ether_addr_equal(mgmt->bssid, - get_my_bssid23a(&pmlmeinfo->network))){ - if (pmlmeinfo->state & WIFI_FW_AUTH_NULL) { - /* we should update current network before auth, - or some IE is wrong */ - pbss = (struct wlan_bssid_ex *) - kmalloc(sizeof(struct wlan_bssid_ex), - GFP_ATOMIC); - if (pbss) { - if (collect_bss_info23a(padapter, precv_frame, - pbss) == _SUCCESS) { - update_network23a(&pmlmepriv->cur_network.network, pbss, padapter, true); - rtw_get_bcn_info23a(&pmlmepriv->cur_network); - } - kfree(pbss); + if (!ether_addr_equal(mgmt->bssid, + get_my_bssid23a(&pmlmeinfo->network))) + goto out; + + if (pmlmeinfo->state & WIFI_FW_AUTH_NULL) { + /* we should update current network before auth, + or some IE is wrong */ + pbss = (struct wlan_bssid_ex *) + kmalloc(sizeof(struct wlan_bssid_ex), GFP_ATOMIC); + if (pbss) { + if (collect_bss_info23a(padapter, precv_frame, pbss) == + _SUCCESS) { + update_network23a( + &pmlmepriv->cur_network.network, pbss, + padapter, true); + rtw_get_bcn_info23a(&pmlmepriv->cur_network); } + kfree(pbss); + } - /* check the vendor of the assoc AP */ - pmlmeinfo->assoc_AP_vendor = check_assoc_AP23a(pframe + sizeof(struct ieee80211_hdr_3addr), pkt_len-sizeof(struct ieee80211_hdr_3addr)); + /* check the vendor of the assoc AP */ + pmlmeinfo->assoc_AP_vendor = + check_assoc_AP23a((u8 *)&mgmt->u.beacon, pkt_len - + offsetof(struct ieee80211_mgmt, u)); - /* update TSF Value */ - update_TSF23a(pmlmeext, pframe, pkt_len); + /* update TSF Value */ + update_TSF23a(pmlmeext, pframe, pkt_len); - /* start auth */ - start_clnt_auth23a(padapter); + /* start auth */ + start_clnt_auth23a(padapter); - return _SUCCESS; - } + return _SUCCESS; + } - if (((pmlmeinfo->state&0x03) == WIFI_FW_STATION_STATE) && - (pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS)) { - psta = rtw_get_stainfo23a(pstapriv, mgmt->sa); - if (psta) { - ret = rtw_check_bcn_info23a(padapter, mgmt, - pkt_len); - if (!ret) { - DBG_8723A_LEVEL(_drv_always_, - "ap has changed, " - "disconnect now\n"); - receive_disconnect23a(padapter, pmlmeinfo->network.MacAddress, 65535); - return _SUCCESS; - } - /* 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) { - /* DBG_8723A("update_bcn_info\n"); */ - update_beacon23a_info(padapter, pframe, - pkt_len, psta); - } + if (((pmlmeinfo->state & 0x03) == WIFI_FW_STATION_STATE) && + (pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS)) { + psta = rtw_get_stainfo23a(pstapriv, mgmt->sa); + if (psta) { + ret = rtw_check_bcn_info23a(padapter, mgmt, pkt_len); + if (!ret) { + DBG_8723A_LEVEL(_drv_always_, "ap has changed, " + "disconnect now\n"); + receive_disconnect23a(padapter, pmlmeinfo->network.MacAddress, 65535); + return _SUCCESS; + } + /* 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) { + /* DBG_8723A("update_bcn_info\n"); */ + update_beacon23a_info(padapter, pframe, + pkt_len, psta); + } + } + } else if ((pmlmeinfo->state&0x03) == WIFI_FW_ADHOC_STATE) { + psta = rtw_get_stainfo23a(pstapriv, mgmt->sa); + 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) { + /* DBG_8723A("update_bcn_info\n"); */ + update_beacon23a_info(padapter, pframe, + pkt_len, psta); + } + } else { + /* allocate a new CAM entry for IBSS station */ + cam_idx = allocate_fw_sta_entry23a(padapter); + if (cam_idx == NUM_STA) + goto out; + + /* get supported rate */ + if (update_sta_support_rate23a(padapter, pie, pie_len, + cam_idx) == _FAIL) { + pmlmeinfo->FW_sta_info[cam_idx].status = 0; + goto out; } - } else if ((pmlmeinfo->state&0x03) == WIFI_FW_ADHOC_STATE) { - psta = rtw_get_stainfo23a(pstapriv, mgmt->sa); - 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) { - /* DBG_8723A("update_bcn_info\n"); */ - update_beacon23a_info(padapter, pframe, - pkt_len, psta); - } - } else { - /* allocate a new CAM entry for IBSS station */ - cam_idx = allocate_fw_sta_entry23a(padapter); - if (cam_idx == NUM_STA) - goto _END_ONBEACON_; - - /* get supported rate */ - if (update_sta_support_rate23a(padapter, pie, - pie_len, - cam_idx) == _FAIL) { - pmlmeinfo->FW_sta_info[cam_idx].status = 0; - goto _END_ONBEACON_; - } - /* update TSF Value */ - update_TSF23a(pmlmeext, pframe, pkt_len); + /* update TSF Value */ + update_TSF23a(pmlmeext, pframe, pkt_len); - /* report sta add event */ - report_add_sta_event23a(padapter, mgmt->sa, - cam_idx); - } + /* report sta add event */ + report_add_sta_event23a(padapter, mgmt->sa, + cam_idx); } } -_END_ONBEACON_: +out: return _SUCCESS; } -- cgit v1.2.3 From 04fad92a9e85f934c893a008de5d0f19dcf59f29 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:44:27 +0200 Subject: staging: rtl8723au: clean up update_TSF() Clean up and simplify update_TSF() using proper Linux functions and move it to rtw_mlme_ext.c which is the only user of it. Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 13 ++++++++----- drivers/staging/rtl8723au/core/rtw_wlan_util.c | 15 --------------- drivers/staging/rtl8723au/include/rtw_mlme_ext.h | 1 - 3 files changed, 8 insertions(+), 21 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index 945b59271b11..cb341529a1f3 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -249,6 +249,12 @@ static struct fwevent wlanevents[] = }; +static void +rtw_update_TSF(struct mlme_ext_priv *pmlmeext, struct ieee80211_mgmt *mgmt) +{ + pmlmeext->TSFValue = get_unaligned_le64(&mgmt->u.beacon.timestamp); +} + /* * Search the @param channel_num in given @param channel_set * @ch_set: the given channel set @@ -785,7 +791,7 @@ OnBeacon23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) offsetof(struct ieee80211_mgmt, u)); /* update TSF Value */ - update_TSF23a(pmlmeext, pframe, pkt_len); + rtw_update_TSF(pmlmeext, mgmt); /* start auth */ start_clnt_auth23a(padapter); @@ -838,7 +844,7 @@ OnBeacon23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) } /* update TSF Value */ - update_TSF23a(pmlmeext, pframe, pkt_len); + rtw_update_TSF(pmlmeext, mgmt); /* report sta add event */ report_add_sta_event23a(padapter, mgmt->sa, @@ -5492,9 +5498,6 @@ void mlmeext_sta_add_event_callback23a(struct rtw_adapter *padapter, struct sta_ } else/* adhoc client */ { - /* update TSF Value */ - /* update_TSF23a(pmlmeext, pframe, len); */ - /* correcting TSF */ correct_TSF23a(padapter, pmlmeext); diff --git a/drivers/staging/rtl8723au/core/rtw_wlan_util.c b/drivers/staging/rtl8723au/core/rtw_wlan_util.c index 84753f5ee231..bf53973b2204 100644 --- a/drivers/staging/rtl8723au/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8723au/core/rtw_wlan_util.c @@ -1643,21 +1643,6 @@ void process_addba_req23a(struct rtw_adapter *padapter, u8 *paddba_req, u8 *addr } } -void update_TSF23a(struct mlme_ext_priv *pmlmeext, u8 *pframe, uint len) -{ - u8 *pIE; - u32 *pbuf; - - pIE = pframe + sizeof(struct ieee80211_hdr_3addr); - pbuf = (u32 *)pIE; - - pmlmeext->TSFValue = le32_to_cpu(*(pbuf+1)); - - pmlmeext->TSFValue = pmlmeext->TSFValue << 32; - - pmlmeext->TSFValue |= le32_to_cpu(*pbuf); -} - void correct_TSF23a(struct rtw_adapter *padapter, struct mlme_ext_priv *pmlmeext) { diff --git a/drivers/staging/rtl8723au/include/rtw_mlme_ext.h b/drivers/staging/rtl8723au/include/rtw_mlme_ext.h index 13f580d9d96f..cbea64938c54 100644 --- a/drivers/staging/rtl8723au/include/rtw_mlme_ext.h +++ b/drivers/staging/rtl8723au/include/rtw_mlme_ext.h @@ -635,7 +635,6 @@ int cckratesonly_included23a(unsigned char *rate, int ratelen); void process_addba_req23a(struct rtw_adapter *padapter, u8 *paddba_req, u8 *addr); -void update_TSF23a(struct mlme_ext_priv *pmlmeext, u8 *pframe, uint len); void correct_TSF23a(struct rtw_adapter *padapter, struct mlme_ext_priv *pmlmeext); struct cmd_hdl { -- cgit v1.2.3 From 0e9596992cfc1b3804d436ccbea97b66aeca00c0 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:44:28 +0200 Subject: staging: rtl8723au: update_TSF() remove unused argument and move to rtw_mlme_ext.c This is only called from rtw_mlme_ext.c, so move it that and declare it static. Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 9 +++++++-- drivers/staging/rtl8723au/core/rtw_wlan_util.c | 6 ------ 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index cb341529a1f3..2a3d3f7527c9 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -249,6 +249,11 @@ static struct fwevent wlanevents[] = }; +static void rtw_correct_TSF(struct rtw_adapter *padapter) +{ + hw_var_set_correct_tsf(padapter); +} + static void rtw_update_TSF(struct mlme_ext_priv *pmlmeext, struct ieee80211_mgmt *mgmt) { @@ -5472,7 +5477,7 @@ void mlmeext_joinbss_event_callback23a(struct rtw_adapter *padapter, int join_re if ((pmlmeinfo->state&0x03) == WIFI_FW_STATION_STATE) { /* correcting TSF */ - correct_TSF23a(padapter, pmlmeext); + rtw_correct_TSF(padapter); /* set_link_timer(pmlmeext, DISCONNECT_TO); */ } @@ -5499,7 +5504,7 @@ void mlmeext_sta_add_event_callback23a(struct rtw_adapter *padapter, struct sta_ else/* adhoc client */ { /* correcting TSF */ - correct_TSF23a(padapter, pmlmeext); + rtw_correct_TSF(padapter); /* start beacon */ if (send_beacon23a(padapter) == _FAIL) diff --git a/drivers/staging/rtl8723au/core/rtw_wlan_util.c b/drivers/staging/rtl8723au/core/rtw_wlan_util.c index bf53973b2204..8824dd4fb55d 100644 --- a/drivers/staging/rtl8723au/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8723au/core/rtw_wlan_util.c @@ -1643,12 +1643,6 @@ void process_addba_req23a(struct rtw_adapter *padapter, u8 *paddba_req, u8 *addr } } -void correct_TSF23a(struct rtw_adapter *padapter, - struct mlme_ext_priv *pmlmeext) -{ - hw_var_set_correct_tsf(padapter); -} - void beacon_timing_control23a(struct rtw_adapter *padapter) { rtw_hal_bcn_related_reg_setting23a(padapter); -- cgit v1.2.3 From f5f05715b2d2092e56d018bf2097bf03f1d147f5 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:44:29 +0200 Subject: staging: rtl8723au: OnAction23a(): Use struct ieee80211_mgmt instead of hardcoded offsets Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index 2a3d3f7527c9..c113fe3afe2b 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -2245,16 +2245,12 @@ static int OnAction23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) { int i; - unsigned char category; + u8 category; struct action_handler *ptable; - unsigned char *frame_body; struct sk_buff *skb = precv_frame->pkt; - u8 *pframe = skb->data; - - frame_body = (unsigned char *) - (pframe + sizeof(struct ieee80211_hdr_3addr)); + struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *) skb->data; - category = frame_body[0]; + category = mgmt->u.action.category; for (i = 0; i < sizeof(OnAction23a_tbl) / sizeof(struct action_handler); i++) { -- cgit v1.2.3 From b30f74e0e06697e984c06b056769f52fc4354c0d Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:44:30 +0200 Subject: staging: rtl8723au: OnAction23a_back23a(): Use struct ieee8011_mgmt to parse action frames Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index c113fe3afe2b..ab6b00e2568d 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -2000,7 +2000,6 @@ static int OnAction23a_back23a(struct rtw_adapter *padapter, u8 *addr; struct sta_info *psta = NULL; struct recv_reorder_ctrl *preorder_ctrl; - unsigned char *frame_body; unsigned char category, action; unsigned short tid, status, capab, params, reason_code = 0; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; @@ -2025,17 +2024,18 @@ static int OnAction23a_back23a(struct rtw_adapter *padapter, if (!psta) return _SUCCESS; - frame_body = &mgmt->u.action.category; - category = mgmt->u.action.category; if (category == WLAN_CATEGORY_BACK) { /* representing Block Ack */ if (!pmlmeinfo->HT_enable) return _SUCCESS; - action = frame_body[1]; + /* action_code is located in the same place for all + action events, so pick any */ + action = mgmt->u.action.u.wme_action.action_code; DBG_8723A("%s, action =%d\n", __func__, action); switch (action) { case WLAN_ACTION_ADDBA_REQ: /* ADDBA request */ - memcpy(&pmlmeinfo->ADDBA_req, &frame_body[2], + memcpy(&pmlmeinfo->ADDBA_req, + &mgmt->u.action.u.addba_req.dialog_token, sizeof(struct ADDBA_request)); process_addba_req23a(padapter, (u8 *)&pmlmeinfo->ADDBA_req, addr); -- cgit v1.2.3 From 6c8207a68545d0a63e5acca0df26e6523a1f7837 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:44:31 +0200 Subject: staging: rtl8723au: OnAssocRsp23a() use ieee80211_mgmt to obtain DA Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index ab6b00e2568d..b5c1ab0bf0be 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -1763,7 +1763,6 @@ OnAssocRsp23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; struct sk_buff *skb = precv_frame->pkt; - struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; struct ieee80211_mgmt *pmgmt = (struct ieee80211_mgmt *) skb->data; int res, i; unsigned short status; @@ -1773,8 +1772,7 @@ OnAssocRsp23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) DBG_8723A("%s\n", __func__); /* check A1 matches or not */ - if (!ether_addr_equal(myid(&padapter->eeprompriv), - ieee80211_get_DA(hdr))) + if (!ether_addr_equal(myid(&padapter->eeprompriv), pmgmt->da)) return _SUCCESS; if (!(pmlmeinfo->state & (WIFI_FW_AUTH_SUCCESS | WIFI_FW_ASSOC_STATE))) -- cgit v1.2.3 From 580e756c603772a9a6732709da4389014d423132 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:44:32 +0200 Subject: staging: rtl8723au: OnAuth23aClient23a(): Clean up using struct ieee80211_mgmt Use 80211_mgmt to determine offsets within the received frame. This also removes a suspicious offset adjustment: offset = ieee80211_has_protected(hdr->frame_control) ? 4: 0; which didn't make any sense, since it was only applied to determining the auth, sequence number, and status, but wasn't applied to the location of the IEs. Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 30 ++++++++++++--------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index b5c1ab0bf0be..cfb4660f5765 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -1057,38 +1057,36 @@ auth_fail: static int OnAuth23aClient23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) { - unsigned int seq, status, algthm, offset; + unsigned int seq, status, algthm; unsigned int go2asoc = 0; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; struct sk_buff *skb = precv_frame->pkt; - struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; - const u8 *p, *pframe = skb->data; - int pkt_len = skb->len; + struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *) skb->data; + const u8 *p; + u8 *pie; + int plen = skb->len; DBG_8723A("%s\n", __func__); /* check A1 matches or not */ - if (!ether_addr_equal(myid(&padapter->eeprompriv), - ieee80211_get_DA(hdr))) + if (!ether_addr_equal(myid(&padapter->eeprompriv), mgmt->da)) return _SUCCESS; if (!(pmlmeinfo->state & WIFI_FW_AUTH_STATE)) return _SUCCESS; - offset = ieee80211_has_protected(hdr->frame_control) ? 4: 0; - - pframe += sizeof(struct ieee80211_hdr_3addr); - pkt_len -= sizeof(struct ieee80211_hdr_3addr); + pie = mgmt->u.auth.variable; + plen -= offsetof(struct ieee80211_mgmt, u.auth.variable); - algthm = le16_to_cpu(*(u16 *)(pframe + offset)); - seq = le16_to_cpu(*(u16 *)(pframe + offset + 2)); - status = le16_to_cpu(*(u16 *)(pframe + offset + 4)); + algthm = le16_to_cpu(mgmt->u.auth.auth_alg); + seq = le16_to_cpu(mgmt->u.auth.auth_transaction); + status = le16_to_cpu(mgmt->u.auth.status_code); if (status) { DBG_8723A("clnt auth fail, status: %d\n", status); /* pmlmeinfo->auth_algo == dot11AuthAlgrthm_Auto) */ - if (status == 13) { + if (status == WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG) { if (pmlmeinfo->auth_algo == dot11AuthAlgrthm_Shared) pmlmeinfo->auth_algo = dot11AuthAlgrthm_Open; else @@ -1103,9 +1101,7 @@ OnAuth23aClient23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) if (seq == 2) { if (pmlmeinfo->auth_algo == dot11AuthAlgrthm_Shared) { /* legendary shared system */ - p = cfg80211_find_ie(WLAN_EID_CHALLENGE, - pframe + _AUTH_IE_OFFSET_, - pkt_len - _AUTH_IE_OFFSET_); + p = cfg80211_find_ie(WLAN_EID_CHALLENGE, pie, plen); if (!p) { /* DBG_8723A("marc: no challenge text?\n"); */ -- cgit v1.2.3 From 78d23509822b05cedafbcbebee528c470690938a Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:44:33 +0200 Subject: staging: rtl8723au: OnAuth23a(): ieee80211.h-ify Switch to using struct ieee80211_mgmt to obtain offsets. Again a bizarre +4 offset was applied for the IE scan which doesn't make sense, since this offset wasn't applied for the auth struct elements. Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 34 ++++++++++++--------------- 1 file changed, 15 insertions(+), 19 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index cfb4660f5765..4b20f07412f9 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -866,11 +866,6 @@ static int OnAuth23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) { #ifdef CONFIG_8723AU_AP_MODE - unsigned int auth_mode, seq; - unsigned char *sa; - const u8 *p; - u16 algorithm; - int status; static struct sta_info stat; struct sta_info *pstat = NULL; struct sta_priv *pstapriv = &padapter->stapriv; @@ -878,24 +873,27 @@ OnAuth23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; struct sk_buff *skb = precv_frame->pkt; - struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; - u8 *pframe = skb->data; - uint len = skb->len; + struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *) skb->data; + u8 *pframe; + const u8 *p; + unsigned char *sa; + u16 auth_mode, seq, algorithm; + int status, len = skb->len; if ((pmlmeinfo->state & 0x03) != WIFI_FW_AP_STATE) return _FAIL; DBG_8723A("+OnAuth23a\n"); - sa = hdr->addr2; + sa = mgmt->sa; auth_mode = psecuritypriv->dot11AuthAlgrthm; - pframe += sizeof(struct ieee80211_hdr_3addr); - len -= sizeof(struct ieee80211_hdr_3addr); + pframe = mgmt->u.auth.variable; + len = skb->len - offsetof(struct ieee80211_mgmt, u.auth.variable); - seq = cpu_to_le16(*(u16 *)(pframe + 2)); - algorithm = cpu_to_le16(*(u16 *)pframe); + seq = le16_to_cpu(mgmt->u.auth.auth_transaction); + algorithm = le16_to_cpu(mgmt->u.auth.auth_alg); DBG_8723A("auth alg =%x, seq =%X\n", algorithm, seq); @@ -906,8 +904,8 @@ OnAuth23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) /* rx a shared-key auth but shared not enabled, or */ /* rx a open-system auth but shared-key is enabled */ - if ((algorithm > 0 && auth_mode == 0) || - (algorithm == 0 && auth_mode == 1)) { + if ((algorithm != WLAN_AUTH_OPEN && auth_mode == 0) || + (algorithm == WLAN_AUTH_OPEN && auth_mode == 1)) { DBG_8723A("auth rejected due to bad alg [alg =%d, auth_mib " "=%d] %02X%02X%02X%02X%02X%02X\n", algorithm, auth_mode, @@ -974,7 +972,7 @@ OnAuth23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) goto auth_fail; } - if (algorithm == 0 && (auth_mode == 0 || auth_mode == 2)) { + if (algorithm == WLAN_AUTH_OPEN && (auth_mode == 0 || auth_mode == 2)) { if (seq == 1) { pstat->state &= ~WIFI_FW_AUTH_NULL; pstat->state |= WIFI_FW_AUTH_SUCCESS; @@ -998,9 +996,7 @@ OnAuth23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) /* checking for challenging txt... */ DBG_8723A("checking for challenging txt...\n"); - p = cfg80211_find_ie(WLAN_EID_CHALLENGE, - pframe + 4 + _AUTH_IE_OFFSET_, - len - _AUTH_IE_OFFSET_ - 4); + p = cfg80211_find_ie(WLAN_EID_CHALLENGE, pframe, len); if (!p || p[1] <= 0) { DBG_8723A("auth rejected because challenge " "failure!(1)\n"); -- cgit v1.2.3 From 34df0dd99b9a9ab5d990adbe85c264a45010641c Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:44:34 +0200 Subject: staging: rtl8723au: mgmt_dispatcher23a(): Use struct ieee80211_mgmt Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index 4b20f07412f9..3f2f8f91d056 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -578,28 +578,28 @@ _mgt_dispatcher23a(struct rtw_adapter *padapter, struct mlme_handler *ptable, void mgt_dispatcher23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) { - int index; struct mlme_handler *ptable; #ifdef CONFIG_8723AU_AP_MODE struct mlme_priv *pmlmepriv = &padapter->mlmepriv; #endif /* CONFIG_8723AU_AP_MODE */ struct sk_buff *skb = precv_frame->pkt; - struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; - u16 stype; + struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *) skb->data; struct sta_info *psta; + u16 stype; + int index; - if (!ieee80211_is_mgmt(hdr->frame_control)) + if (!ieee80211_is_mgmt(mgmt->frame_control)) return; /* receive the frames that ra(a1) is my address or ra(a1) is bc address. */ - if (!ether_addr_equal(hdr->addr1, myid(&padapter->eeprompriv)) && - !is_broadcast_ether_addr(hdr->addr1)) + if (!ether_addr_equal(mgmt->da, myid(&padapter->eeprompriv)) && + !is_broadcast_ether_addr(mgmt->da)) return; ptable = mlme_sta_tbl; - stype = le16_to_cpu(hdr->frame_control) & IEEE80211_FCTL_STYPE; + stype = le16_to_cpu(mgmt->frame_control) & IEEE80211_FCTL_STYPE; index = stype >> 4; if (index > 13) { @@ -610,10 +610,10 @@ void mgt_dispatcher23a(struct rtw_adapter *padapter, } ptable += index; - psta = rtw_get_stainfo23a(&padapter->stapriv, hdr->addr2); + psta = rtw_get_stainfo23a(&padapter->stapriv, mgmt->sa); if (psta) { - if (ieee80211_has_retry(hdr->frame_control)) { + if (ieee80211_has_retry(mgmt->frame_control)) { if (precv_frame->attrib.seq_num == psta->RxMgmtFrameSeqNum) { /* drop the duplicate management frame */ -- cgit v1.2.3 From 68e6831e6394cba73cf64f071a8a02f83c13c659 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:44:35 +0200 Subject: staging: rtl8723au: init_channel_set(): Restructure variable names Shorten variable names allowing for fewer broken lines due to the large number of indents. Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 96 ++++++++++++--------------- 1 file changed, 44 insertions(+), 52 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index 3f2f8f91d056..c2ab4c66607c 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -419,96 +419,88 @@ static void init_channel_list(struct rtw_adapter *padapter, channel_list->reg_classes = cla; } -static u8 init_channel_set(struct rtw_adapter* padapter, u8 ChannelPlan, - struct rt_channel_info *channel_set) +static u8 init_channel_set(struct rtw_adapter* padapter, u8 cplan, + struct rt_channel_info *c_set) { - u8 index, chanset_size = 0; - u8 b5GBand = false, b2_4GBand = false; - u8 Index2G = 0, Index5G = 0; + u8 i, ch_size = 0; + u8 b5GBand = false, b2_4GBand = false; + u8 Index2G = 0, Index5G = 0; - memset(channel_set, 0, sizeof(struct rt_channel_info)*MAX_CHANNEL_NUM); + memset(c_set, 0, sizeof(struct rt_channel_info) * MAX_CHANNEL_NUM); - if (ChannelPlan >= RT_CHANNEL_DOMAIN_MAX && - ChannelPlan != RT_CHANNEL_DOMAIN_REALTEK_DEFINE) { - DBG_8723A("ChannelPlan ID %x error !!!!!\n", ChannelPlan); - return chanset_size; + if (cplan >= RT_CHANNEL_DOMAIN_MAX && + cplan != RT_CHANNEL_DOMAIN_REALTEK_DEFINE) { + DBG_8723A("ChannelPlan ID %x error !!!!!\n", cplan); + return ch_size; } if (padapter->registrypriv.wireless_mode & WIRELESS_11G) { b2_4GBand = true; - if (RT_CHANNEL_DOMAIN_REALTEK_DEFINE == ChannelPlan) + if (RT_CHANNEL_DOMAIN_REALTEK_DEFINE == cplan) Index2G = RTW_CHANNEL_PLAN_MAP_REALTEK_DEFINE.Index2G; else - Index2G = RTW_ChannelPlanMap[ChannelPlan].Index2G; + Index2G = RTW_ChannelPlanMap[cplan].Index2G; } if (padapter->registrypriv.wireless_mode & WIRELESS_11A) { b5GBand = true; - if (RT_CHANNEL_DOMAIN_REALTEK_DEFINE == ChannelPlan) + if (RT_CHANNEL_DOMAIN_REALTEK_DEFINE == cplan) Index5G = RTW_CHANNEL_PLAN_MAP_REALTEK_DEFINE.Index5G; else - Index5G = RTW_ChannelPlanMap[ChannelPlan].Index5G; + Index5G = RTW_ChannelPlanMap[cplan].Index5G; } if (b2_4GBand) { - for (index = 0; index= 1 && - channel_set[chanset_size].ChannelNum <= 11) - channel_set[chanset_size].ScanType = - SCAN_ACTIVE; - else if ((channel_set[chanset_size].ChannelNum >= 12 && - channel_set[chanset_size].ChannelNum <= 14)) - channel_set[chanset_size].ScanType = - SCAN_PASSIVE; - } else if (RT_CHANNEL_DOMAIN_WORLD_WIDE_13 == - ChannelPlan || - RT_CHANNEL_DOMAIN_WORLD_WIDE_5G == - ChannelPlan || + RT_CHANNEL_DOMAIN_GLOBAL_DOAMIN_2G == cplan) { + if (c_set[ch_size].ChannelNum >= 1 && + c_set[ch_size].ChannelNum <= 11) + c_set[ch_size].ScanType = SCAN_ACTIVE; + else if (c_set[ch_size].ChannelNum >= 12 && + c_set[ch_size].ChannelNum <= 14) + c_set[ch_size].ScanType = SCAN_PASSIVE; + } else if (RT_CHANNEL_DOMAIN_WORLD_WIDE_13 == cplan || + RT_CHANNEL_DOMAIN_WORLD_WIDE_5G == cplan || RT_CHANNEL_DOMAIN_2G_WORLD == Index2G) { /* channel 12~13, passive scan */ - if (channel_set[chanset_size].ChannelNum <= 11) - channel_set[chanset_size].ScanType = - SCAN_ACTIVE; + if (c_set[ch_size].ChannelNum <= 11) + c_set[ch_size].ScanType = SCAN_ACTIVE; else - channel_set[chanset_size].ScanType = - SCAN_PASSIVE; + c_set[ch_size].ScanType = SCAN_PASSIVE; } else - channel_set[chanset_size].ScanType = - SCAN_ACTIVE; + c_set[ch_size].ScanType = SCAN_ACTIVE; - chanset_size++; + ch_size++; } } if (b5GBand) { - for (index = 0;index= 149) { - channel_set[chanset_size].ChannelNum = - RTW_ChannelPlan5G[Index5G].Channel[index]; - if (RT_CHANNEL_DOMAIN_WORLD_WIDE_5G == - ChannelPlan) { + for (i = 0; i < RTW_ChannelPlan5G[Index5G].Len; i++) { + if (RTW_ChannelPlan5G[Index5G].Channel[i] <= 48 || + RTW_ChannelPlan5G[Index5G].Channel[i] >= 149) { + c_set[ch_size].ChannelNum = + RTW_ChannelPlan5G[Index5G].Channel[i]; + if (RT_CHANNEL_DOMAIN_WORLD_WIDE_5G == cplan) { /* passive scan for all 5G channels */ - channel_set[chanset_size].ScanType = + c_set[ch_size].ScanType = SCAN_PASSIVE; } else - channel_set[chanset_size].ScanType = + c_set[ch_size].ScanType = SCAN_ACTIVE; DBG_8723A("%s(): channel_set[%d].ChannelNum = " - "%d\n", __func__, chanset_size, - channel_set[chanset_size].ChannelNum); - chanset_size++; + "%d\n", __func__, ch_size, + c_set[ch_size].ChannelNum); + ch_size++; } } } - return chanset_size; + return ch_size; } int init_mlme_ext_priv23a(struct rtw_adapter* padapter) -- cgit v1.2.3 From bc55ae446ffff66afa1744320331893ea39557ab Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:44:36 +0200 Subject: staging: rtl8723au: os_intfs.c: Declare a couple of local variables static Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/include/hal_intf.h | 4 ---- drivers/staging/rtl8723au/os_dep/os_intfs.c | 6 +++--- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/drivers/staging/rtl8723au/include/hal_intf.h b/drivers/staging/rtl8723au/include/hal_intf.h index 0b07e8b1f068..89516467f241 100644 --- a/drivers/staging/rtl8723au/include/hal_intf.h +++ b/drivers/staging/rtl8723au/include/hal_intf.h @@ -215,10 +215,6 @@ enum hardware_type { #define GET_EEPROM_EFUSE_PRIV(adapter) (&adapter->eeprompriv) -extern int rtw_ht_enable23A; -extern int rtw_cbw40_enable23A; -extern int rtw_ampdu_enable23A;/* for enable tx_ampdu */ - void rtw_hal_def_value_init23a(struct rtw_adapter *padapter); int pm_netdev_open23a(struct net_device *pnetdev, u8 bnormal); int rtw_resume_process23a(struct rtw_adapter *padapter); diff --git a/drivers/staging/rtl8723au/os_dep/os_intfs.c b/drivers/staging/rtl8723au/os_dep/os_intfs.c index 49da7dd18171..26882aac414f 100644 --- a/drivers/staging/rtl8723au/os_dep/os_intfs.c +++ b/drivers/staging/rtl8723au/os_dep/os_intfs.c @@ -65,10 +65,10 @@ static int rtw_acm_method;/* 0:By SW 1:By HW. */ static int rtw_wmm_enable = 1;/* default is set to enable the wmm. */ static int rtw_uapsd_enable; -int rtw_ht_enable23A = 1; +static int rtw_ht_enable23A = 1; /* 0 :diable, bit(0): enable 2.4g, bit(1): enable 5g */ -int rtw_cbw40_enable23A = 3; -int rtw_ampdu_enable23A = 1;/* for enable tx_ampdu */ +static int rtw_cbw40_enable23A = 3; +static int rtw_ampdu_enable23A = 1;/* for enable tx_ampdu */ /* 0: disable, bit(0):enable 2.4g, bit(1):enable 5g, default is set to enable * 2.4GHZ for IOT issue with bufflao's AP at 5GHZ */ -- cgit v1.2.3 From b809fc44c6220d5dd33796022d28f4c4fc461485 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:44:37 +0200 Subject: staging: rtl8188eu: usb_intf.c: No point processing an empty table In addition, this would globally disable HT if one device in the system would mark it unsupported. If any device ended up requiring this, it should be handled on a per-instance basis. Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/os_dep/usb_intf.c | 29 ----------------------------- 1 file changed, 29 deletions(-) diff --git a/drivers/staging/rtl8188eu/os_dep/usb_intf.c b/drivers/staging/rtl8188eu/os_dep/usb_intf.c index 2e49cd583212..49a4ce44ada6 100644 --- a/drivers/staging/rtl8188eu/os_dep/usb_intf.c +++ b/drivers/staging/rtl8188eu/os_dep/usb_intf.c @@ -62,10 +62,6 @@ static struct usb_device_id rtw_usb_id_tbl[] = { MODULE_DEVICE_TABLE(usb, rtw_usb_id_tbl); -static struct specific_device_id specific_device_id_tbl[] = { - {} /* empty table for now */ -}; - struct rtw_usb_drv { struct usb_driver usbdrv; int drv_registered; @@ -360,28 +356,6 @@ static void rtw_dev_unload(struct adapter *padapter) RT_TRACE(_module_hci_intfs_c_, _drv_err_, ("-rtw_dev_unload\n")); } -static void process_spec_devid(const struct usb_device_id *pdid) -{ - u16 vid, pid; - u32 flags; - int i; - int num = sizeof(specific_device_id_tbl) / - sizeof(struct specific_device_id); - - for (i = 0; i < num; i++) { - vid = specific_device_id_tbl[i].idVendor; - pid = specific_device_id_tbl[i].idProduct; - flags = specific_device_id_tbl[i].flags; - - if ((pdid->idVendor == vid) && (pdid->idProduct == pid) && - (flags&SPEC_DEV_ID_DISABLE_HT)) { - rtw_ht_enable = 0; - rtw_cbw40_enable = 0; - rtw_ampdu_enable = 0; - } - } -} - int rtw_hw_suspend(struct adapter *padapter) { struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv; @@ -781,9 +755,6 @@ static int rtw_drv_init(struct usb_interface *pusb_intf, const struct usb_device RT_TRACE(_module_hci_intfs_c_, _drv_err_, ("+rtw_drv_init\n")); - /* step 0. */ - process_spec_devid(pdid); - /* Initialize dvobj_priv */ dvobj = usb_dvobj_init(pusb_intf); if (dvobj == NULL) { -- cgit v1.2.3 From 987bc3fed6e35aab00b9cef6d92607236ce719c3 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:44:38 +0200 Subject: staging: rtl8188eu: os_intfs.c: Mark a couple of variables static Mark these variables local to avoid namespace clash with other RTL drivers. Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/include/xmit_osdep.h | 4 ---- drivers/staging/rtl8188eu/os_dep/os_intfs.c | 6 +++--- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/drivers/staging/rtl8188eu/include/xmit_osdep.h b/drivers/staging/rtl8188eu/include/xmit_osdep.h index 2ff622ba24f0..48bc5fca996d 100644 --- a/drivers/staging/rtl8188eu/include/xmit_osdep.h +++ b/drivers/staging/rtl8188eu/include/xmit_osdep.h @@ -32,10 +32,6 @@ struct pkt_file { size_t buf_len; }; -extern int rtw_ht_enable; -extern int rtw_cbw40_enable; -extern int rtw_ampdu_enable;/* for enable tx_ampdu */ - #define NR_XMITFRAME 256 struct xmit_priv; diff --git a/drivers/staging/rtl8188eu/os_dep/os_intfs.c b/drivers/staging/rtl8188eu/os_dep/os_intfs.c index b225d1c07210..9edb8e880ae8 100644 --- a/drivers/staging/rtl8188eu/os_dep/os_intfs.c +++ b/drivers/staging/rtl8188eu/os_dep/os_intfs.c @@ -84,9 +84,9 @@ static int rtw_uapsd_acbe_en; static int rtw_uapsd_acvi_en; static int rtw_uapsd_acvo_en; -int rtw_ht_enable = 1; -int rtw_cbw40_enable = 3; /* 0 :disable, bit(0): enable 2.4g, bit(1): enable 5g */ -int rtw_ampdu_enable = 1;/* for enable tx_ampdu */ +static int rtw_ht_enable = 1; +static int rtw_cbw40_enable = 3; /* 0 :disable, bit(0): enable 2.4g, bit(1): enable 5g */ +static int rtw_ampdu_enable = 1;/* for enable tx_ampdu */ static int rtw_rx_stbc = 1;/* 0: disable, bit(0):enable 2.4g, bit(1):enable 5g, default is set to enable 2.4GHZ for IOT issue with bufflao's AP at 5GHZ */ static int rtw_ampdu_amsdu;/* 0: disabled, 1:enabled, 2:auto */ -- cgit v1.2.3 From 76dc444185adc5f2a12dc713a337274593c76333 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:44:39 +0200 Subject: staging: rtl8723au: Clean up namespace clashes with rtl8188eu driver Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/os_dep/os_intfs.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/staging/rtl8723au/os_dep/os_intfs.c b/drivers/staging/rtl8723au/os_dep/os_intfs.c index 26882aac414f..fd9de2a60bf7 100644 --- a/drivers/staging/rtl8723au/os_dep/os_intfs.c +++ b/drivers/staging/rtl8723au/os_dep/os_intfs.c @@ -65,10 +65,10 @@ static int rtw_acm_method;/* 0:By SW 1:By HW. */ static int rtw_wmm_enable = 1;/* default is set to enable the wmm. */ static int rtw_uapsd_enable; -static int rtw_ht_enable23A = 1; +static int rtw_ht_enable = 1; /* 0 :diable, bit(0): enable 2.4g, bit(1): enable 5g */ -static int rtw_cbw40_enable23A = 3; -static int rtw_ampdu_enable23A = 1;/* for enable tx_ampdu */ +static int rtw_cbw40_enable = 3; +static int rtw_ampdu_enable = 1;/* for enable tx_ampdu */ /* 0: disable, bit(0):enable 2.4g, bit(1):enable 5g, default is set to enable * 2.4GHZ for IOT issue with bufflao's AP at 5GHZ */ @@ -129,9 +129,9 @@ module_param(rtw_wmm_enable, int, 0644); module_param(rtw_vrtl_carrier_sense, int, 0644); module_param(rtw_vcs_type, int, 0644); module_param(rtw_busy_thresh, int, 0644); -module_param(rtw_ht_enable23A, int, 0644); -module_param(rtw_cbw40_enable23A, int, 0644); -module_param(rtw_ampdu_enable23A, int, 0644); +module_param(rtw_ht_enable, int, 0644); +module_param(rtw_cbw40_enable, int, 0644); +module_param(rtw_ampdu_enable, int, 0644); module_param(rtw_rx_stbc, int, 0644); module_param(rtw_ampdu_amsdu, int, 0644); @@ -202,9 +202,9 @@ static uint loadparam(struct rtw_adapter *padapter, struct net_device *pnetdev) /* UAPSD */ registry_par->wmm_enable = (u8)rtw_wmm_enable; registry_par->uapsd_enable = (u8)rtw_uapsd_enable; - registry_par->ht_enable = (u8)rtw_ht_enable23A; - registry_par->cbw40_enable = (u8)rtw_cbw40_enable23A; - registry_par->ampdu_enable = (u8)rtw_ampdu_enable23A; + registry_par->ht_enable = (u8)rtw_ht_enable; + registry_par->cbw40_enable = (u8)rtw_cbw40_enable; + registry_par->ampdu_enable = (u8)rtw_ampdu_enable; registry_par->rx_stbc = (u8)rtw_rx_stbc; registry_par->ampdu_amsdu = (u8)rtw_ampdu_amsdu; registry_par->lowrate_two_xmit = (u8)rtw_lowrate_two_xmit; -- cgit v1.2.3 From 35a5c6f3a3c697c858b721aaf52218629286b5d7 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:44:40 +0200 Subject: staging: rtl8723au: Remove unused function rtw_os_read_port23a() Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/include/recv_osdep.h | 2 -- drivers/staging/rtl8723au/os_dep/recv_linux.c | 12 ------------ 2 files changed, 14 deletions(-) diff --git a/drivers/staging/rtl8723au/include/recv_osdep.h b/drivers/staging/rtl8723au/include/recv_osdep.h index 15c94b6168bf..037ce5a64b92 100644 --- a/drivers/staging/rtl8723au/include/recv_osdep.h +++ b/drivers/staging/rtl8723au/include/recv_osdep.h @@ -38,8 +38,6 @@ void rtw_os_recv_resource_free(struct recv_priv *precvpriv); int rtw_os_recvbuf_resource_alloc23a(struct rtw_adapter *padapter, struct recv_buf *precvbuf); int rtw_os_recvbuf_resource_free23a(struct rtw_adapter *padapter, struct recv_buf *precvbuf); -void rtw_os_read_port23a(struct rtw_adapter *padapter, struct recv_buf *precvbuf); - void rtw_init_recv_timer23a(struct recv_reorder_ctrl *preorder_ctrl); #endif diff --git a/drivers/staging/rtl8723au/os_dep/recv_linux.c b/drivers/staging/rtl8723au/os_dep/recv_linux.c index 18572090ac48..1d54f9e4c4a9 100644 --- a/drivers/staging/rtl8723au/os_dep/recv_linux.c +++ b/drivers/staging/rtl8723au/os_dep/recv_linux.c @@ -204,18 +204,6 @@ _recv_indicatepkt_drop: return _FAIL; } -void rtw_os_read_port23a(struct rtw_adapter *padapter, struct recv_buf *precvbuf) -{ - struct recv_priv *precvpriv = &padapter->recvpriv; - - /* free skb in recv_buf */ - dev_kfree_skb_any(precvbuf->pskb); - - precvbuf->pskb = NULL; - - rtw_read_port(padapter, precvpriv->ff_hwaddr, 0, precvbuf); -} - void rtw_init_recv_timer23a(struct recv_reorder_ctrl *preorder_ctrl) { setup_timer(&preorder_ctrl->reordering_ctrl_timer, -- cgit v1.2.3 From 09ae6d750c267452060beceab2c27b7a03badf89 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:44:41 +0200 Subject: staging: rtl8723au: Remove unnecessary abstraction rtw_os_recv_resource_alloc23a() No point calling a function to NULL a pointer that was just cleared in the malloc call. Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_recv.c | 2 -- drivers/staging/rtl8723au/include/recv_osdep.h | 2 -- drivers/staging/rtl8723au/os_dep/recv_linux.c | 11 ----------- 3 files changed, 15 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_recv.c b/drivers/staging/rtl8723au/core/rtw_recv.c index 5d81a8c18218..644c3a132e59 100644 --- a/drivers/staging/rtl8723au/core/rtw_recv.c +++ b/drivers/staging/rtl8723au/core/rtw_recv.c @@ -79,8 +79,6 @@ int _rtw_init_recv_priv23a(struct recv_priv *precvpriv, list_add_tail(&precvframe->list, &precvpriv->free_recv_queue.queue); - res = rtw_os_recv_resource_alloc23a(padapter, precvframe); - precvframe->adapter = padapter; precvframe++; } diff --git a/drivers/staging/rtl8723au/include/recv_osdep.h b/drivers/staging/rtl8723au/include/recv_osdep.h index 037ce5a64b92..39809befb88c 100644 --- a/drivers/staging/rtl8723au/include/recv_osdep.h +++ b/drivers/staging/rtl8723au/include/recv_osdep.h @@ -32,8 +32,6 @@ int rtw_init_recv_priv(struct recv_priv *precvpriv, struct rtw_adapter *padapter void rtw_free_recv_priv (struct recv_priv *precvpriv); int rtw_os_recv_resource_init(struct recv_priv *precvpriv, struct rtw_adapter *padapter); -int rtw_os_recv_resource_alloc23a(struct rtw_adapter *padapter, struct recv_frame *precvframe); -void rtw_os_recv_resource_free(struct recv_priv *precvpriv); int rtw_os_recvbuf_resource_alloc23a(struct rtw_adapter *padapter, struct recv_buf *precvbuf); int rtw_os_recvbuf_resource_free23a(struct rtw_adapter *padapter, struct recv_buf *precvbuf); diff --git a/drivers/staging/rtl8723au/os_dep/recv_linux.c b/drivers/staging/rtl8723au/os_dep/recv_linux.c index 1d54f9e4c4a9..321aa282e3f2 100644 --- a/drivers/staging/rtl8723au/os_dep/recv_linux.c +++ b/drivers/staging/rtl8723au/os_dep/recv_linux.c @@ -24,17 +24,6 @@ #include -/* alloc os related resource in struct recv_frame */ -int rtw_os_recv_resource_alloc23a(struct rtw_adapter *padapter, - struct recv_frame *precvframe) -{ - int res = _SUCCESS; - - precvframe->pkt = NULL; - - return res; -} - /* alloc os related resource in struct recv_buf */ int rtw_os_recvbuf_resource_alloc23a(struct rtw_adapter *padapter, struct recv_buf *precvbuf) -- cgit v1.2.3 From f466c400e78f785dee0b16b7198df0d4c601b162 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:44:42 +0200 Subject: staging: rtl8723au: Fold some resource allocation abstraction into their callers Fold rtw_os_recvbuf_resource_alloc23a() and rtw_os_recvbuf_resource_free23a() into the functions calling them. Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/hal/rtl8723au_recv.c | 10 ++++++--- drivers/staging/rtl8723au/include/recv_osdep.h | 3 --- drivers/staging/rtl8723au/os_dep/recv_linux.c | 29 -------------------------- 3 files changed, 7 insertions(+), 35 deletions(-) diff --git a/drivers/staging/rtl8723au/hal/rtl8723au_recv.c b/drivers/staging/rtl8723au/hal/rtl8723au_recv.c index a7568bb65e2a..e1f17af78a12 100644 --- a/drivers/staging/rtl8723au/hal/rtl8723au_recv.c +++ b/drivers/staging/rtl8723au/hal/rtl8723au_recv.c @@ -65,8 +65,8 @@ int rtl8723au_init_recv_priv(struct rtw_adapter *padapter) for (i = 0; i < NR_RECVBUFF; i++) { INIT_LIST_HEAD(&precvbuf->list); - res = rtw_os_recvbuf_resource_alloc23a(padapter, precvbuf); - if (res == _FAIL) + precvbuf->purb = usb_alloc_urb(0, GFP_KERNEL); + if (!precvbuf->purb) break; precvbuf->adapter = padapter; @@ -109,7 +109,11 @@ void rtl8723au_free_recv_priv(struct rtw_adapter *padapter) precvbuf = (struct recv_buf *)precvpriv->precv_buf; for (i = 0; i < NR_RECVBUFF; i++) { - rtw_os_recvbuf_resource_free23a(padapter, precvbuf); + usb_free_urb(precvbuf->purb); + + if (precvbuf->pskb) + dev_kfree_skb_any(precvbuf->pskb); + precvbuf++; } diff --git a/drivers/staging/rtl8723au/include/recv_osdep.h b/drivers/staging/rtl8723au/include/recv_osdep.h index 39809befb88c..3a2cd8a3058d 100644 --- a/drivers/staging/rtl8723au/include/recv_osdep.h +++ b/drivers/staging/rtl8723au/include/recv_osdep.h @@ -33,9 +33,6 @@ void rtw_free_recv_priv (struct recv_priv *precvpriv); int rtw_os_recv_resource_init(struct recv_priv *precvpriv, struct rtw_adapter *padapter); -int rtw_os_recvbuf_resource_alloc23a(struct rtw_adapter *padapter, struct recv_buf *precvbuf); -int rtw_os_recvbuf_resource_free23a(struct rtw_adapter *padapter, struct recv_buf *precvbuf); - void rtw_init_recv_timer23a(struct recv_reorder_ctrl *preorder_ctrl); #endif diff --git a/drivers/staging/rtl8723au/os_dep/recv_linux.c b/drivers/staging/rtl8723au/os_dep/recv_linux.c index 321aa282e3f2..8fecbe38ca27 100644 --- a/drivers/staging/rtl8723au/os_dep/recv_linux.c +++ b/drivers/staging/rtl8723au/os_dep/recv_linux.c @@ -24,35 +24,6 @@ #include -/* alloc os related resource in struct recv_buf */ -int rtw_os_recvbuf_resource_alloc23a(struct rtw_adapter *padapter, - struct recv_buf *precvbuf) -{ - int res = _SUCCESS; - - precvbuf->purb = usb_alloc_urb(0, GFP_KERNEL); - if (precvbuf->purb == NULL) - res = _FAIL; - - precvbuf->pskb = NULL; - - return res; -} - -/* free os related resource in struct recv_buf */ -int rtw_os_recvbuf_resource_free23a(struct rtw_adapter *padapter, - struct recv_buf *precvbuf) -{ - int ret = _SUCCESS; - - usb_free_urb(precvbuf->purb); - - if (precvbuf->pskb) - dev_kfree_skb_any(precvbuf->pskb); - - return ret; -} - void rtw_handle_tkip_mic_err23a(struct rtw_adapter *padapter, u8 bgroup) { enum nl80211_key_type key_type = 0; -- cgit v1.2.3 From c8bdc729c2cdeedb4e899983cd08df95dfd4504c Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:44:43 +0200 Subject: staging: rtl8723au: Remove another unused prototype Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/include/recv_osdep.h | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/rtl8723au/include/recv_osdep.h b/drivers/staging/rtl8723au/include/recv_osdep.h index 3a2cd8a3058d..37a90cafce6a 100644 --- a/drivers/staging/rtl8723au/include/recv_osdep.h +++ b/drivers/staging/rtl8723au/include/recv_osdep.h @@ -23,7 +23,6 @@ void _rtw_free_recv_priv23a (struct recv_priv *precvpriv); int rtw_recv_entry23a(struct recv_frame *precv_frame); int rtw_recv_indicatepkt23a(struct rtw_adapter *adapter, struct recv_frame *precv_frame); -void rtw_recv_returnpacket(struct net_device *cnxt, struct sk_buff *preturnedpkt); void rtw_hostapd_mlme_rx23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame); void rtw_handle_tkip_mic_err23a(struct rtw_adapter *padapter, u8 bgroup); -- cgit v1.2.3 From 684ad6ee72f98ddf541c976653b07c18e3a15bdc Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:44:44 +0200 Subject: staging: rtl8723au: Remove dummy function rtw_hostapd_mlme_rx23a() Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 2 -- drivers/staging/rtl8723au/include/recv_osdep.h | 1 - drivers/staging/rtl8723au/os_dep/recv_linux.c | 5 ----- 3 files changed, 8 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index c2ab4c66607c..31022f2508c3 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -646,8 +646,6 @@ void mgt_dispatcher23a(struct rtw_adapter *padapter, break; default: _mgt_dispatcher23a(padapter, ptable, precv_frame); - if (check_fwstate(pmlmepriv, WIFI_AP_STATE) == true) - rtw_hostapd_mlme_rx23a(padapter, precv_frame); break; } #else diff --git a/drivers/staging/rtl8723au/include/recv_osdep.h b/drivers/staging/rtl8723au/include/recv_osdep.h index 37a90cafce6a..c2d3f1bd5948 100644 --- a/drivers/staging/rtl8723au/include/recv_osdep.h +++ b/drivers/staging/rtl8723au/include/recv_osdep.h @@ -24,7 +24,6 @@ void _rtw_free_recv_priv23a (struct recv_priv *precvpriv); int rtw_recv_entry23a(struct recv_frame *precv_frame); int rtw_recv_indicatepkt23a(struct rtw_adapter *adapter, struct recv_frame *precv_frame); -void rtw_hostapd_mlme_rx23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame); void rtw_handle_tkip_mic_err23a(struct rtw_adapter *padapter, u8 bgroup); int rtw_init_recv_priv(struct recv_priv *precvpriv, struct rtw_adapter *padapter); diff --git a/drivers/staging/rtl8723au/os_dep/recv_linux.c b/drivers/staging/rtl8723au/os_dep/recv_linux.c index 8fecbe38ca27..528ed9253b14 100644 --- a/drivers/staging/rtl8723au/os_dep/recv_linux.c +++ b/drivers/staging/rtl8723au/os_dep/recv_linux.c @@ -69,11 +69,6 @@ void rtw_handle_tkip_mic_err23a(struct rtw_adapter *padapter, u8 bgroup) wrqu.data.length = sizeof(ev); } -void rtw_hostapd_mlme_rx23a(struct rtw_adapter *padapter, - struct recv_frame *precv_frame) -{ -} - int rtw_recv_indicatepkt23a(struct rtw_adapter *padapter, struct recv_frame *precv_frame) { -- cgit v1.2.3 From 480c865ed9e34c2e9362723c094e10b62068b8e4 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:44:45 +0200 Subject: staging: rtl8723au: rtw_mlme.c: Clean up mess Clean up spaghetti formatting and avoid NULL initializing variables where it isn't needed. Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme.c | 1045 ++++++++++++++++------------- 1 file changed, 568 insertions(+), 477 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme.c b/drivers/staging/rtl8723au/core/rtw_mlme.c index 8c11fa18fe89..8bb368499ce2 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme.c @@ -53,8 +53,11 @@ int _rtw_init_mlme_priv23a(struct rtw_adapter *padapter) pmlmepriv->nic_hdl = padapter; pmlmepriv->fw_state = 0; - pmlmepriv->cur_network.network.InfrastructureMode = Ndis802_11AutoUnknown; - pmlmepriv->scan_mode=SCAN_ACTIVE;/* 1: active, 0: pasive. Maybe someday we should rename this varable to "active_mode" (Jeff) */ + pmlmepriv->cur_network.network.InfrastructureMode = + Ndis802_11AutoUnknown; + /* 1: active, 0: pasive. Maybe someday we should rename this + varable to "active_mode" (Jeff) */ + pmlmepriv->scan_mode = SCAN_ACTIVE; spin_lock_init(&pmlmepriv->lock); _rtw_init_queue23a(&pmlmepriv->scanned_queue); @@ -72,11 +75,10 @@ int _rtw_init_mlme_priv23a(struct rtw_adapter *padapter) #ifdef CONFIG_8723AU_AP_MODE static void rtw_free_mlme_ie_data(u8 **ppie, u32 *plen) { - if(*ppie) - { + if (*ppie) { kfree(*ppie); *plen = 0; - *ppie=NULL; + *ppie = NULL; } } #endif @@ -86,30 +88,42 @@ void rtw23a_free_mlme_priv_ie_data(struct mlme_priv *pmlmepriv) #ifdef CONFIG_8723AU_AP_MODE kfree(pmlmepriv->assoc_req); kfree(pmlmepriv->assoc_rsp); - rtw_free_mlme_ie_data(&pmlmepriv->wps_beacon_ie, &pmlmepriv->wps_beacon_ie_len); - rtw_free_mlme_ie_data(&pmlmepriv->wps_probe_req_ie, &pmlmepriv->wps_probe_req_ie_len); - rtw_free_mlme_ie_data(&pmlmepriv->wps_probe_resp_ie, &pmlmepriv->wps_probe_resp_ie_len); - rtw_free_mlme_ie_data(&pmlmepriv->wps_assoc_resp_ie, &pmlmepriv->wps_assoc_resp_ie_len); - - rtw_free_mlme_ie_data(&pmlmepriv->p2p_beacon_ie, &pmlmepriv->p2p_beacon_ie_len); - rtw_free_mlme_ie_data(&pmlmepriv->p2p_probe_req_ie, &pmlmepriv->p2p_probe_req_ie_len); - rtw_free_mlme_ie_data(&pmlmepriv->p2p_probe_resp_ie, &pmlmepriv->p2p_probe_resp_ie_len); - rtw_free_mlme_ie_data(&pmlmepriv->p2p_go_probe_resp_ie, &pmlmepriv->p2p_go_probe_resp_ie_len); - rtw_free_mlme_ie_data(&pmlmepriv->p2p_assoc_req_ie, &pmlmepriv->p2p_assoc_req_ie_len); - - rtw_free_mlme_ie_data(&pmlmepriv->wfd_beacon_ie, &pmlmepriv->wfd_beacon_ie_len); - rtw_free_mlme_ie_data(&pmlmepriv->wfd_probe_req_ie, &pmlmepriv->wfd_probe_req_ie_len); - rtw_free_mlme_ie_data(&pmlmepriv->wfd_probe_resp_ie, &pmlmepriv->wfd_probe_resp_ie_len); - rtw_free_mlme_ie_data(&pmlmepriv->wfd_go_probe_resp_ie, &pmlmepriv->wfd_go_probe_resp_ie_len); - rtw_free_mlme_ie_data(&pmlmepriv->wfd_assoc_req_ie, &pmlmepriv->wfd_assoc_req_ie_len); + rtw_free_mlme_ie_data(&pmlmepriv->wps_beacon_ie, + &pmlmepriv->wps_beacon_ie_len); + rtw_free_mlme_ie_data(&pmlmepriv->wps_probe_req_ie, + &pmlmepriv->wps_probe_req_ie_len); + rtw_free_mlme_ie_data(&pmlmepriv->wps_probe_resp_ie, + &pmlmepriv->wps_probe_resp_ie_len); + rtw_free_mlme_ie_data(&pmlmepriv->wps_assoc_resp_ie, + &pmlmepriv->wps_assoc_resp_ie_len); + + rtw_free_mlme_ie_data(&pmlmepriv->p2p_beacon_ie, + &pmlmepriv->p2p_beacon_ie_len); + rtw_free_mlme_ie_data(&pmlmepriv->p2p_probe_req_ie, + &pmlmepriv->p2p_probe_req_ie_len); + rtw_free_mlme_ie_data(&pmlmepriv->p2p_probe_resp_ie, + &pmlmepriv->p2p_probe_resp_ie_len); + rtw_free_mlme_ie_data(&pmlmepriv->p2p_go_probe_resp_ie, + &pmlmepriv->p2p_go_probe_resp_ie_len); + rtw_free_mlme_ie_data(&pmlmepriv->p2p_assoc_req_ie, + &pmlmepriv->p2p_assoc_req_ie_len); + + rtw_free_mlme_ie_data(&pmlmepriv->wfd_beacon_ie, + &pmlmepriv->wfd_beacon_ie_len); + rtw_free_mlme_ie_data(&pmlmepriv->wfd_probe_req_ie, + &pmlmepriv->wfd_probe_req_ie_len); + rtw_free_mlme_ie_data(&pmlmepriv->wfd_probe_resp_ie, + &pmlmepriv->wfd_probe_resp_ie_len); + rtw_free_mlme_ie_data(&pmlmepriv->wfd_go_probe_resp_ie, + &pmlmepriv->wfd_go_probe_resp_ie_len); + rtw_free_mlme_ie_data(&pmlmepriv->wfd_assoc_req_ie, + &pmlmepriv->wfd_assoc_req_ie_len); #endif } void _rtw_free_mlme_priv23a(struct mlme_priv *pmlmepriv) { - rtw23a_free_mlme_priv_ie_data(pmlmepriv); - } struct wlan_network *rtw_alloc_network(struct mlme_priv *pmlmepriv) @@ -150,10 +164,9 @@ void _rtw_free_network23a(struct mlme_priv *pmlmepriv, } void _rtw_free_network23a_nolock23a(struct mlme_priv *pmlmepriv, - struct wlan_network *pnetwork) + struct wlan_network *pnetwork) { - - if (pnetwork == NULL) + if (!pnetwork) return; if (pnetwork->fixed == true) @@ -165,9 +178,9 @@ void _rtw_free_network23a_nolock23a(struct mlme_priv *pmlmepriv, } /* - return the wlan_network with the matching addr + return the wlan_network with the matching addr - Shall be calle under atomic context... to avoid possible racing condition... + Shall be calle under atomic context... to avoid possible racing condition... */ struct wlan_network * _rtw_find_network23a(struct rtw_queue *scanned_queue, u8 *addr) @@ -194,7 +207,7 @@ _rtw_find_network23a(struct rtw_queue *scanned_queue, u8 *addr) plist = plist->next; } - if(plist == phead) + if (plist == phead) pnetwork = NULL; /* spin_unlock_bh(&scanned_queue->lock); */ @@ -208,7 +221,7 @@ void _rtw_free_network23a_queue23a(struct rtw_adapter *padapter, u8 isfreeall) { struct list_head *phead, *plist, *ptmp; struct wlan_network *pnetwork; - struct mlme_priv* pmlmepriv = &padapter->mlmepriv; + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct rtw_queue *scanned_queue = &pmlmepriv->scanned_queue; spin_lock_bh(&scanned_queue->lock); @@ -222,20 +235,21 @@ void _rtw_free_network23a_queue23a(struct rtw_adapter *padapter, u8 isfreeall) } spin_unlock_bh(&scanned_queue->lock); - } -int rtw_if_up23a(struct rtw_adapter *padapter) { - +int rtw_if_up23a(struct rtw_adapter *padapter) +{ int res; - if(padapter->bDriverStopped || padapter->bSurpriseRemoved || - (check_fwstate(&padapter->mlmepriv, _FW_LINKED)== false)) { - RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("rtw_if_up23a:bDriverStopped(%d) OR bSurpriseRemoved(%d)", padapter->bDriverStopped, padapter->bSurpriseRemoved)); - res=false; - } - else - res= true; + if (padapter->bDriverStopped || padapter->bSurpriseRemoved || + check_fwstate(&padapter->mlmepriv, _FW_LINKED) == false) { + RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, + ("rtw_if_up23a:bDriverStopped(%d) OR " + "bSurpriseRemoved(%d)", padapter->bDriverStopped, + padapter->bSurpriseRemoved)); + res = false; + } else + res = true; return res; } @@ -247,9 +261,9 @@ void rtw_generate_random_ibss23a(u8* pibss) pibss[0] = 0x02; /* in ad-hoc mode bit1 must set to 1 */ pibss[1] = 0x11; pibss[2] = 0x87; - pibss[3] = (u8)(curtime & 0xff) ;/* p[0]; */ - pibss[4] = (u8)((curtime>>8) & 0xff) ;/* p[1]; */ - pibss[5] = (u8)((curtime>>16) & 0xff) ;/* p[2]; */ + pibss[3] = curtime & 0xff;/* p[0]; */ + pibss[4] = (curtime >> 8) & 0xff;/* p[1]; */ + pibss[5] = (curtime >> 16) & 0xff;/* p[2]; */ return; } @@ -261,9 +275,9 @@ u8 *rtw_get_capability23a_from_ie(u8 *ie) u16 rtw_get_capability23a(struct wlan_bssid_ex *bss) { - u16 val; + u16 val; - memcpy((u8 *)&val, rtw_get_capability23a_from_ie(bss->IEs), 2); + memcpy(&val, rtw_get_capability23a_from_ie(bss->IEs), 2); return le16_to_cpu(val); } @@ -278,41 +292,35 @@ u8 *rtw_get_beacon_interval23a_from_ie(u8 *ie) return ie + 8; } -int rtw_init_mlme_priv23a (struct rtw_adapter *padapter)/* struct mlme_priv *pmlmepriv) */ +int rtw_init_mlme_priv23a (struct rtw_adapter *padapter) { int res; - res = _rtw_init_mlme_priv23a(padapter);/* (pmlmepriv); */ + res = _rtw_init_mlme_priv23a(padapter); return res; } void rtw_free_mlme_priv23a (struct mlme_priv *pmlmepriv) { - - RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("rtw_free_mlme_priv23a\n")); + RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, + ("rtw_free_mlme_priv23a\n")); _rtw_free_mlme_priv23a(pmlmepriv); - } -void rtw_free_network(struct mlme_priv *pmlmepriv, struct wlan_network *pnetwork, u8 is_freeall); -void rtw_free_network(struct mlme_priv *pmlmepriv, struct wlan_network *pnetwork, u8 is_freeall)/* struct wlan_network *pnetwork, _queue *free_queue) */ +void rtw_free_network(struct mlme_priv *pmlmepriv, + struct wlan_network *pnetwork, u8 is_freeall) { - RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("rtw_free_network ==> ssid = %s\n\n" , pnetwork->network.Ssid.ssid)); _rtw_free_network23a(pmlmepriv, pnetwork, is_freeall); - } -void rtw_free_network_nolock(struct mlme_priv *pmlmepriv, struct wlan_network *pnetwork); -void rtw_free_network_nolock(struct mlme_priv *pmlmepriv, struct wlan_network *pnetwork) +void rtw_free_network_nolock(struct mlme_priv *pmlmepriv, + struct wlan_network *pnetwork) { - - /* RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("rtw_free_network ==> ssid = %s\n\n" , pnetwork->network.Ssid.ssid)); */ _rtw_free_network23a_nolock23a(pmlmepriv, pnetwork); - } void rtw_free_network_queue23a(struct rtw_adapter* dev, u8 isfreeall) @@ -323,9 +331,9 @@ void rtw_free_network_queue23a(struct rtw_adapter* dev, u8 isfreeall) } /* - return the wlan_network with the matching addr + return the wlan_network with the matching addr - Shall be calle under atomic context... to avoid possible racing condition... + Shall be calle under atomic context... to avoid possible racing condition... */ struct wlan_network * rtw_find_network23a(struct rtw_queue *scanned_queue, u8 *addr) @@ -337,25 +345,20 @@ rtw_find_network23a(struct rtw_queue *scanned_queue, u8 *addr) return pnetwork; } -int rtw_is_same_ibss23a(struct rtw_adapter *adapter, struct wlan_network *pnetwork) +int rtw_is_same_ibss23a(struct rtw_adapter *adapter, + struct wlan_network *pnetwork) { int ret = true; struct security_priv *psecuritypriv = &adapter->securitypriv; - if ((psecuritypriv->dot11PrivacyAlgrthm != _NO_PRIVACY_) && - (pnetwork->network.Privacy == 0)) - { + if (psecuritypriv->dot11PrivacyAlgrthm != _NO_PRIVACY_ && + pnetwork->network.Privacy == 0) ret = false; - } - else if ((psecuritypriv->dot11PrivacyAlgrthm == _NO_PRIVACY_) && - (pnetwork->network.Privacy == 1)) - { + else if (psecuritypriv->dot11PrivacyAlgrthm == _NO_PRIVACY_ && + pnetwork->network.Privacy == 1) ret = false; - } else - { ret = true; - } return ret; } @@ -363,18 +366,16 @@ int rtw_is_same_ibss23a(struct rtw_adapter *adapter, struct wlan_network *pnetwo inline int is_same_ess(struct wlan_bssid_ex *a, struct wlan_bssid_ex *b); inline int is_same_ess(struct wlan_bssid_ex *a, struct wlan_bssid_ex *b) { - /* RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("(%s,%d)(%s,%d)\n", */ - /* a->Ssid.Ssid, a->Ssid.SsidLength, b->Ssid.Ssid, b->Ssid.SsidLength)); */ return (a->Ssid.ssid_len == b->Ssid.ssid_len) && !memcmp(a->Ssid.ssid, b->Ssid.ssid, a->Ssid.ssid_len); } int is_same_network23a(struct wlan_bssid_ex *src, struct wlan_bssid_ex *dst) { - u16 s_cap, d_cap; + u16 s_cap, d_cap; - memcpy((u8 *)&s_cap, rtw_get_capability23a_from_ie(src->IEs), 2); - memcpy((u8 *)&d_cap, rtw_get_capability23a_from_ie(dst->IEs), 2); + memcpy(&s_cap, rtw_get_capability23a_from_ie(src->IEs), 2); + memcpy(&d_cap, rtw_get_capability23a_from_ie(dst->IEs), 2); s_cap = le16_to_cpu(s_cap); d_cap = le16_to_cpu(d_cap); @@ -389,10 +390,10 @@ int is_same_network23a(struct wlan_bssid_ex *src, struct wlan_bssid_ex *dst) (d_cap & WLAN_CAPABILITY_ESS))); } -struct wlan_network *rtw_get_oldest_wlan_network23a(struct rtw_queue *scanned_queue) +struct wlan_network * +rtw_get_oldest_wlan_network23a(struct rtw_queue *scanned_queue) { struct list_head *plist, *phead; - struct wlan_network *pwlan; struct wlan_network *oldest = NULL; @@ -412,7 +413,7 @@ struct wlan_network *rtw_get_oldest_wlan_network23a(struct rtw_queue *scanned_qu } void update_network23a(struct wlan_bssid_ex *dst, struct wlan_bssid_ex *src, - struct rtw_adapter * padapter, bool update_ie) + struct rtw_adapter *padapter, bool update_ie) { u8 ss_ori = dst->PhyInfo.SignalStrength; u8 sq_ori = dst->PhyInfo.SignalQuality; @@ -426,30 +427,35 @@ void update_network23a(struct wlan_bssid_ex *dst, struct wlan_bssid_ex *src, u8 sq_final; long rssi_final; - DBG_8723A("%s %s(%pM, ch%u) ss_ori:%3u, sq_ori:%3u, rssi_ori:%3ld, ss_smp:%3u, sq_smp:%3u, rssi_smp:%3ld\n", + DBG_8723A("%s %s(%pM, ch%u) ss_ori:%3u, sq_ori:%3u, rssi_ori:%3ld, " + "ss_smp:%3u, sq_smp:%3u, rssi_smp:%3ld\n", __func__, src->Ssid.ssid, src->MacAddress, src->Configuration.DSConfig, ss_ori, sq_ori, rssi_ori, ss_smp, sq_smp, rssi_smp ); /* The rule below is 1/5 for sample value, 4/5 for history value */ - if (check_fwstate(&padapter->mlmepriv, _FW_LINKED) && is_same_network23a(&padapter->mlmepriv.cur_network.network, src)) { + if (check_fwstate(&padapter->mlmepriv, _FW_LINKED) && + is_same_network23a(&padapter->mlmepriv.cur_network.network, src)) { /* Take the recvpriv's value for the connected AP*/ ss_final = padapter->recvpriv.signal_strength; sq_final = padapter->recvpriv.signal_qual; - /* the rssi value here is undecorated, and will be used for antenna diversity */ + /* the rssi value here is undecorated, and will be + used for antenna diversity */ if (sq_smp != 101) /* from the right channel */ rssi_final = (src->Rssi+dst->Rssi*4)/5; else rssi_final = rssi_ori; - } - else { + } else { if (sq_smp != 101) { /* from the right channel */ - ss_final = ((u32)(src->PhyInfo.SignalStrength)+(u32)(dst->PhyInfo.SignalStrength)*4)/5; - sq_final = ((u32)(src->PhyInfo.SignalQuality)+(u32)(dst->PhyInfo.SignalQuality)*4)/5; - rssi_final = (src->Rssi+dst->Rssi*4)/5; + ss_final = ((u32)src->PhyInfo.SignalStrength + + (u32)dst->PhyInfo.SignalStrength * 4) / 5; + sq_final = ((u32)src->PhyInfo.SignalQuality + + (u32)dst->PhyInfo.SignalQuality * 4) / 5; + rssi_final = src->Rssi+dst->Rssi * 4 / 5; } else { - /* bss info not receving from the right channel, use the original RX signal infos */ + /* bss info not receving from the right channel, use + the original RX signal infos */ ss_final = dst->PhyInfo.SignalStrength; sq_final = dst->PhyInfo.SignalQuality; rssi_final = dst->Rssi; @@ -458,35 +464,32 @@ void update_network23a(struct wlan_bssid_ex *dst, struct wlan_bssid_ex *src, } if (update_ie) - memcpy((u8 *)dst, (u8 *)src, get_wlan_bssid_ex_sz(src)); + memcpy(dst, src, get_wlan_bssid_ex_sz(src)); dst->PhyInfo.SignalStrength = ss_final; dst->PhyInfo.SignalQuality = sq_final; dst->Rssi = rssi_final; - DBG_8723A("%s %s(%pM), SignalStrength:%u, SignalQuality:%u, RawRSSI:%ld\n", - __func__, dst->Ssid.ssid, dst->MacAddress, + DBG_8723A("%s %s(%pM), SignalStrength:%u, SignalQuality:%u, " + "RawRSSI:%ld\n", __func__, dst->Ssid.ssid, dst->MacAddress, dst->PhyInfo.SignalStrength, dst->PhyInfo.SignalQuality, dst->Rssi); - } -static void update_current_network(struct rtw_adapter *adapter, struct wlan_bssid_ex *pnetwork) +static void update_current_network(struct rtw_adapter *adapter, + struct wlan_bssid_ex *pnetwork) { - struct mlme_priv *pmlmepriv = &adapter->mlmepriv; - - if ((check_fwstate(pmlmepriv, _FW_LINKED)== true) && (is_same_network23a(&pmlmepriv->cur_network.network, pnetwork))) - { - /* RT_TRACE(_module_rtl871x_mlme_c_,_drv_err_,"Same Network\n"); */ + struct mlme_priv *pmlmepriv = &adapter->mlmepriv; - /* if(pmlmepriv->cur_network.network.IELength<= pnetwork->IELength) */ - { - update_network23a(&pmlmepriv->cur_network.network, pnetwork,adapter, true); - rtw_update_protection23a(adapter, (pmlmepriv->cur_network.network.IEs) + sizeof (struct ndis_802_11_fixed_ies), - pmlmepriv->cur_network.network.IELength); - } + if (check_fwstate(pmlmepriv, _FW_LINKED) && + is_same_network23a(&pmlmepriv->cur_network.network, pnetwork)) { + update_network23a(&pmlmepriv->cur_network.network, + pnetwork,adapter, true); + rtw_update_protection23a(adapter, + pmlmepriv->cur_network.network.IEs + + sizeof (struct ndis_802_11_fixed_ies), + pmlmepriv->cur_network.network.IELength); } - } /* @@ -494,7 +497,8 @@ static void update_current_network(struct rtw_adapter *adapter, struct wlan_bssi Caller must hold pmlmepriv->lock first. */ -void rtw_update_scanned_network23a(struct rtw_adapter *adapter, struct wlan_bssid_ex *target) +void rtw_update_scanned_network23a(struct rtw_adapter *adapter, + struct wlan_bssid_ex *target) { struct list_head *plist, *phead; struct mlme_priv *pmlmepriv = &adapter->mlmepriv; @@ -561,19 +565,20 @@ void rtw_update_scanned_network23a(struct rtw_adapter *adapter, struct wlan_bssi /* target.reserved == 1, means that scanned network is * a bcn frame. */ - if ((pnetwork->network.IELength>target->IELength) && - (target->reserved == 1)) + if (pnetwork->network.IELength > target->IELength && + target->reserved == 1) update_ie = false; - update_network23a(&pnetwork->network, target,adapter, update_ie); + update_network23a(&pnetwork->network, target,adapter, + update_ie); } exit: spin_unlock_bh(&queue->lock); - } -void rtw_add_network(struct rtw_adapter *adapter, struct wlan_bssid_ex *pnetwork) +void rtw_add_network(struct rtw_adapter *adapter, + struct wlan_bssid_ex *pnetwork) { update_current_network(adapter, pnetwork); rtw_update_scanned_network23a(adapter, pnetwork); @@ -585,7 +590,8 @@ void rtw_add_network(struct rtw_adapter *adapter, struct wlan_bssid_ex *pnetwork /* (3) WMM */ /* (4) HT */ /* (5) others */ -int rtw_is_desired_network(struct rtw_adapter *adapter, struct wlan_network *pnetwork) +int rtw_is_desired_network(struct rtw_adapter *adapter, + struct wlan_network *pnetwork) { struct security_priv *psecuritypriv = &adapter->securitypriv; struct mlme_priv *pmlmepriv = &adapter->mlmepriv; @@ -600,31 +606,31 @@ int rtw_is_desired_network(struct rtw_adapter *adapter, struct wlan_network *pne desired_encmode = psecuritypriv->ndisencryptstatus; privacy = pnetwork->network.Privacy; - if (check_fwstate(pmlmepriv, WIFI_UNDER_WPS)) - { - if (rtw_get_wps_ie23a(pnetwork->network.IEs+_FIXED_IE_LENGTH_, pnetwork->network.IELength-_FIXED_IE_LENGTH_, NULL, &wps_ielen)!= NULL) - { + if (check_fwstate(pmlmepriv, WIFI_UNDER_WPS)) { + if (rtw_get_wps_ie23a(pnetwork->network.IEs + _FIXED_IE_LENGTH_, + pnetwork->network.IELength - + _FIXED_IE_LENGTH_, NULL, &wps_ielen)) return true; - } else - { return false; - } } - if (adapter->registrypriv.wifi_spec == 1) /* for correct flow of 8021X to do.... */ - { - if ((desired_encmode == Ndis802_11EncryptionDisabled) && (privacy != 0)) + if (adapter->registrypriv.wifi_spec == 1) { + /* for correct flow of 8021X to do.... */ + if (desired_encmode == Ndis802_11EncryptionDisabled && + privacy != 0) bselected = false; } - if ((desired_encmode != Ndis802_11EncryptionDisabled) && (privacy == 0)) { - DBG_8723A("desired_encmode: %d, privacy: %d\n", desired_encmode, privacy); + if (desired_encmode != Ndis802_11EncryptionDisabled && + privacy == 0) { + DBG_8723A("desired_encmode: %d, privacy: %d\n", + desired_encmode, privacy); bselected = false; } - if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) == true) - { - if (pnetwork->network.InfrastructureMode != pmlmepriv->cur_network.network.InfrastructureMode) + if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE)) { + if (pnetwork->network.InfrastructureMode != + pmlmepriv->cur_network.network.InfrastructureMode) bselected = false; } @@ -632,15 +638,14 @@ int rtw_is_desired_network(struct rtw_adapter *adapter, struct wlan_network *pne } /* TODO: Perry : For Power Management */ -void rtw_atimdone_event_callback23a(struct rtw_adapter *adapter , u8 *pbuf) +void rtw_atimdone_event_callback23a(struct rtw_adapter *adapter, u8 *pbuf) { - RT_TRACE(_module_rtl871x_mlme_c_,_drv_err_,("receive atimdone_evet\n")); return; } -void rtw_survey_event_cb23a(struct rtw_adapter *adapter, u8 *pbuf) +void rtw_survey_event_cb23a(struct rtw_adapter *adapter, u8 *pbuf) { u32 len; struct wlan_bssid_ex *pnetwork; @@ -648,31 +653,36 @@ void rtw_survey_event_cb23a(struct rtw_adapter *adapter, u8 *pbuf) pnetwork = (struct wlan_bssid_ex *)pbuf; - RT_TRACE(_module_rtl871x_mlme_c_,_drv_info_,("rtw_survey_event_cb23a, ssid=%s\n", pnetwork->Ssid.ssid)); + RT_TRACE(_module_rtl871x_mlme_c_,_drv_info_, + ("rtw_survey_event_cb23a, ssid=%s\n", pnetwork->Ssid.ssid)); len = get_wlan_bssid_ex_sz(pnetwork); - if(len > (sizeof(struct wlan_bssid_ex))) - { - RT_TRACE(_module_rtl871x_mlme_c_,_drv_err_,("\n ****rtw_survey_event_cb23a: return a wrong bss ***\n")); + if (len > (sizeof(struct wlan_bssid_ex))) { + RT_TRACE(_module_rtl871x_mlme_c_,_drv_err_, + ("\n ****rtw_survey_event_cb23a: return a wrong " + "bss ***\n")); return; } spin_lock_bh(&pmlmepriv->lock); /* update IBSS_network 's timestamp */ - if ((check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)) == true) - { - /* RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_,"rtw_survey_event_cb23a : WIFI_ADHOC_MASTER_STATE\n\n"); */ + if (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)) { + /* RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, + "rtw_survey_event_cb23a : WIFI_ADHOC_MASTER_STATE\n\n"); */ if (ether_addr_equal(pmlmepriv->cur_network.network.MacAddress, pnetwork->MacAddress)) { - struct wlan_network* ibss_wlan = NULL; + struct wlan_network* ibss_wlan; - memcpy(pmlmepriv->cur_network.network.IEs, pnetwork->IEs, 8); + memcpy(pmlmepriv->cur_network.network.IEs, + pnetwork->IEs, 8); spin_lock_bh(&pmlmepriv->scanned_queue.lock); - ibss_wlan = rtw_find_network23a(&pmlmepriv->scanned_queue, pnetwork->MacAddress); - if (ibss_wlan) - { - memcpy(ibss_wlan->network.IEs , pnetwork->IEs, 8); + ibss_wlan = rtw_find_network23a( + &pmlmepriv->scanned_queue, + pnetwork->MacAddress); + if (ibss_wlan) { + memcpy(ibss_wlan->network.IEs, + pnetwork->IEs, 8); spin_unlock_bh(&pmlmepriv->scanned_queue.lock); goto exit; } @@ -681,8 +691,7 @@ void rtw_survey_event_cb23a(struct rtw_adapter *adapter, u8 *pbuf) } /* lock pmlmepriv->lock when you accessing network_q */ - if ((check_fwstate(pmlmepriv, _FW_UNDER_LINKING)) == false) - { + if (check_fwstate(pmlmepriv, _FW_UNDER_LINKING) == false) { if (pnetwork->Ssid.ssid[0] == 0) pnetwork->Ssid.ssid_len = 0; @@ -696,10 +705,12 @@ exit: return; } -void rtw_surveydone_event_callback23a(struct rtw_adapter *adapter, u8 *pbuf) +void rtw_surveydone_event_callback23a(struct rtw_adapter *adapter, u8 *pbuf) { struct mlme_priv *pmlmepriv = &adapter->mlmepriv; struct mlme_ext_priv *pmlmeext = &adapter->mlmeextpriv; + struct wlan_bssid_ex *pdev_network; + u8 *pibss; spin_lock_bh(&pmlmepriv->lock); @@ -709,7 +720,9 @@ void rtw_surveydone_event_callback23a(struct rtw_adapter *adapter, u8 *pbuf) pmlmepriv->wps_probe_req_ie = NULL; } - RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("rtw_surveydone_event_callback23a: fw_state:%x\n\n", get_fwstate(pmlmepriv))); + RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, + ("rtw_surveydone_event_callback23a: fw_state:%x\n\n", + get_fwstate(pmlmepriv))); if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY)) { del_timer_sync(&pmlmepriv->scan_to_timer); @@ -717,39 +730,53 @@ void rtw_surveydone_event_callback23a(struct rtw_adapter *adapter, u8 *pbuf) _clr_fwstate_(pmlmepriv, _FW_UNDER_SURVEY); } else { - RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("nic status =%x, survey done event comes too late!\n", get_fwstate(pmlmepriv))); + RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, + ("nic status =%x, survey done event comes too late!\n", + get_fwstate(pmlmepriv))); } rtw_set_signal_stat_timer(&adapter->recvpriv); if (pmlmepriv->to_join == true) { - if ((check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) == true)) { + if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE)) { if (check_fwstate(pmlmepriv, _FW_LINKED) == false) { set_fwstate(pmlmepriv, _FW_UNDER_LINKING); - if (rtw_select_and_join_from_scanned_queue23a(pmlmepriv) == _SUCCESS) { + if (rtw_select_and_join_from_scanned_queue23a( + pmlmepriv) == _SUCCESS) { mod_timer(&pmlmepriv->assoc_timer, jiffies + msecs_to_jiffies(MAX_JOIN_TIMEOUT)); } else { - struct wlan_bssid_ex *pdev_network = &adapter->registrypriv.dev_network; - u8 *pibss = adapter->registrypriv.dev_network.MacAddress; + pdev_network = &adapter->registrypriv.dev_network; + pibss = adapter->registrypriv.dev_network.MacAddress; - _clr_fwstate_(pmlmepriv, _FW_UNDER_SURVEY); + _clr_fwstate_(pmlmepriv, + _FW_UNDER_SURVEY); - RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("switching to adhoc master\n")); + RT_TRACE(_module_rtl871x_mlme_c_, + _drv_err_, + ("switching to adhoc " + "master\n")); - memset(&pdev_network->Ssid, 0, sizeof(struct cfg80211_ssid)); - memcpy(&pdev_network->Ssid, &pmlmepriv->assoc_ssid, sizeof(struct cfg80211_ssid)); + memset(&pdev_network->Ssid, 0, + sizeof(struct cfg80211_ssid)); + memcpy(&pdev_network->Ssid, + &pmlmepriv->assoc_ssid, + sizeof(struct cfg80211_ssid)); - rtw_update_registrypriv_dev_network23a(adapter); + rtw_update_registrypriv_dev_network23a( + adapter); rtw_generate_random_ibss23a(pibss); - pmlmepriv->fw_state = WIFI_ADHOC_MASTER_STATE; + pmlmepriv->fw_state = + WIFI_ADHOC_MASTER_STATE; - if (rtw_createbss_cmd23a(adapter)!= _SUCCESS) - { - RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("Error =>rtw_createbss_cmd23a status FAIL\n")); - } + if (rtw_createbss_cmd23a(adapter) != + _SUCCESS) + RT_TRACE(_module_rtl871x_mlme_c_, + _drv_err_, + ("Error =>rtw_createbss_cmd23a" + " status FAIL\n")); pmlmepriv->to_join = false; } @@ -758,27 +785,32 @@ void rtw_surveydone_event_callback23a(struct rtw_adapter *adapter, u8 *pbuf) int ret; set_fwstate(pmlmepriv, _FW_UNDER_LINKING); pmlmepriv->to_join = false; - ret = rtw_select_and_join_from_scanned_queue23a(pmlmepriv); + ret = rtw_select_and_join_from_scanned_queue23a( + pmlmepriv); if (ret == _SUCCESS) { unsigned long e; e = msecs_to_jiffies(MAX_JOIN_TIMEOUT); mod_timer(&pmlmepriv->assoc_timer, jiffies + e); - } else if (ret == 2)/* there is no need to wait for join */ - { + } else if (ret == 2) {/* there is no need to wait */ _clr_fwstate_(pmlmepriv, _FW_UNDER_LINKING); rtw_indicate_connect23a(adapter); } else { - DBG_8723A("try_to_join, but select scanning queue fail, to_roaming:%d\n", rtw_to_roaming(adapter)); + DBG_8723A("try_to_join, but select scanning " + "queue fail, to_roaming:%d\n", + rtw_to_roaming(adapter)); if (rtw_to_roaming(adapter) != 0) { - if (--pmlmepriv->to_roaming == 0 - || _SUCCESS != rtw_sitesurvey_cmd23a(adapter, &pmlmepriv->assoc_ssid, 1, NULL, 0) - ) { + if (--pmlmepriv->to_roaming == 0 || + rtw_sitesurvey_cmd23a( + adapter, + &pmlmepriv->assoc_ssid, 1, + NULL, 0) != _SUCCESS) { rtw_set_roaming(adapter, 0); - rtw_free_assoc_resources23a(adapter, 1); - rtw_indicate_disconnect23a(adapter); - } else { + rtw_free_assoc_resources23a( + adapter, 1); + rtw_indicate_disconnect23a( + adapter); + } else pmlmepriv->to_join = true; - } } _clr_fwstate_(pmlmepriv, _FW_UNDER_LINKING); } @@ -789,11 +821,10 @@ void rtw_surveydone_event_callback23a(struct rtw_adapter *adapter, u8 *pbuf) rtw_os_xmit_schedule23a(adapter); - if(pmlmeext->sitesurvey_res.bss_cnt == 0) + if (pmlmeext->sitesurvey_res.bss_cnt == 0) rtw_hal_sreset_reset23a(adapter); rtw_cfg80211_surveydone_event_callback(adapter); - } void rtw_dummy_event_callback23a(struct rtw_adapter *adapter , u8 *pbuf) @@ -804,7 +835,7 @@ void rtw23a_fwdbg_event_callback(struct rtw_adapter *adapter , u8 *pbuf) { } -static void free_scanqueue(struct mlme_priv *pmlmepriv) +static void free_scanqueue(struct mlme_priv *pmlmepriv) { struct wlan_network *pnetwork; struct rtw_queue *scan_queue = &pmlmepriv->scanned_queue; @@ -822,42 +853,38 @@ static void free_scanqueue(struct mlme_priv *pmlmepriv) } spin_unlock_bh(&scan_queue->lock); - } /* -*rtw_free_assoc_resources23a: the caller has to lock pmlmepriv->lock -*/ -void rtw_free_assoc_resources23a(struct rtw_adapter *adapter, int lock_scanned_queue) + *rtw_free_assoc_resources23a: the caller has to lock pmlmepriv->lock + */ +void rtw_free_assoc_resources23a(struct rtw_adapter *adapter, + int lock_scanned_queue) { - struct wlan_network* pwlan = NULL; - struct mlme_priv *pmlmepriv = &adapter->mlmepriv; - struct sta_priv *pstapriv = &adapter->stapriv; + struct wlan_network* pwlan; + struct mlme_priv *pmlmepriv = &adapter->mlmepriv; + struct sta_priv *pstapriv = &adapter->stapriv; struct wlan_network *tgt_network = &pmlmepriv->cur_network; + struct sta_info* psta; - RT_TRACE(_module_rtl871x_mlme_c_, _drv_notice_, ("+rtw_free_assoc_resources23a\n")); - RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("tgt_network->network.MacAddress="MAC_FMT" ssid=%s\n", - MAC_ARG(tgt_network->network.MacAddress), tgt_network->network.Ssid.ssid)); - - if(check_fwstate(pmlmepriv, WIFI_STATION_STATE|WIFI_AP_STATE)) - { - struct sta_info* psta; - - psta = rtw_get_stainfo23a(&adapter->stapriv, tgt_network->network.MacAddress); + RT_TRACE(_module_rtl871x_mlme_c_, _drv_notice_, + ("+rtw_free_assoc_resources23a\n")); + RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, + ("tgt_network->network.MacAddress="MAC_FMT" ssid=%s\n", + MAC_ARG(tgt_network->network.MacAddress), + tgt_network->network.Ssid.ssid)); - { - spin_lock_bh(&pstapriv->sta_hash_lock); - rtw_free_stainfo23a(adapter, psta); - } + if (check_fwstate(pmlmepriv, WIFI_STATION_STATE|WIFI_AP_STATE)) { + psta = rtw_get_stainfo23a(&adapter->stapriv, + tgt_network->network.MacAddress); + spin_lock_bh(&pstapriv->sta_hash_lock); + rtw_free_stainfo23a(adapter, psta); spin_unlock_bh(&pstapriv->sta_hash_lock); - } - if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE|WIFI_ADHOC_MASTER_STATE|WIFI_AP_STATE)) - { - struct sta_info* psta; - + if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE | + WIFI_ADHOC_MASTER_STATE|WIFI_AP_STATE)) { rtw_free_all_stainfo23a(adapter); psta = rtw_get_bcmc_stainfo23a(adapter); @@ -868,23 +895,25 @@ void rtw_free_assoc_resources23a(struct rtw_adapter *adapter, int lock_scanned_q rtw_init_bcmc_stainfo23a(adapter); } - if(lock_scanned_queue) + if (lock_scanned_queue) spin_lock_bh(&pmlmepriv->scanned_queue.lock); - pwlan = rtw_find_network23a(&pmlmepriv->scanned_queue, tgt_network->network.MacAddress); - if(pwlan) + pwlan = rtw_find_network23a(&pmlmepriv->scanned_queue, + tgt_network->network.MacAddress); + if (pwlan) pwlan->fixed = false; else - RT_TRACE(_module_rtl871x_mlme_c_,_drv_err_,("rtw_free_assoc_resources23a : pwlan== NULL\n\n")); + RT_TRACE(_module_rtl871x_mlme_c_,_drv_err_, + ("rtw_free_assoc_resources23a : pwlan== NULL\n")); - if (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) && (adapter->stapriv.asoc_sta_count == 1)) + if (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) && + adapter->stapriv.asoc_sta_count == 1) rtw_free_network_nolock(pmlmepriv, pwlan); - if(lock_scanned_queue) + if (lock_scanned_queue) spin_unlock_bh(&pmlmepriv->scanned_queue.lock); pmlmepriv->key_mask = 0; - } /* @@ -892,13 +921,14 @@ void rtw_free_assoc_resources23a(struct rtw_adapter *adapter, int lock_scanned_q */ void rtw_indicate_connect23a(struct rtw_adapter *padapter) { - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("+rtw_indicate_connect23a\n")); + RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, + ("+rtw_indicate_connect23a\n")); pmlmepriv->to_join = false; - if(!check_fwstate(&padapter->mlmepriv, _FW_LINKED)) { + if (!check_fwstate(&padapter->mlmepriv, _FW_LINKED)) { set_fwstate(pmlmepriv, _FW_LINKED); rtw_led_control(padapter, LED_CTL_LINK); @@ -915,18 +945,20 @@ void rtw_indicate_connect23a(struct rtw_adapter *padapter) rtw_set_scan_deny(padapter, 3000); - RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("-rtw_indicate_connect23a: fw_state=0x%08x\n", get_fwstate(pmlmepriv))); - + RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, + ("-rtw_indicate_connect23a: fw_state=0x%08x\n", + get_fwstate(pmlmepriv))); } /* -*rtw_indicate_disconnect23a: the caller has to lock pmlmepriv->lock -*/ + *rtw_indicate_disconnect23a: the caller has to lock pmlmepriv->lock + */ void rtw_indicate_disconnect23a(struct rtw_adapter *padapter) { struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("+rtw_indicate_disconnect23a\n")); + RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, + ("+rtw_indicate_disconnect23a\n")); _clr_fwstate_(pmlmepriv, _FW_UNDER_LINKING|WIFI_UNDER_WPS); @@ -936,7 +968,7 @@ void rtw_indicate_disconnect23a(struct rtw_adapter *padapter) _clr_fwstate_(pmlmepriv, _FW_LINKED); if (check_fwstate(&padapter->mlmepriv, _FW_LINKED) || - (rtw_to_roaming(padapter) <= 0)) { + rtw_to_roaming(padapter) <= 0) { rtw_os_indicate_disconnect23a(padapter); /* set ips_deny_time to avoid enter IPS before LPS leave */ @@ -952,7 +984,6 @@ void rtw_indicate_disconnect23a(struct rtw_adapter *padapter) } rtw_lps_ctrl_wk_cmd23a(padapter, LPS_CTRL_DISCONNECT, 1); - } void rtw_scan_abort23a(struct rtw_adapter *adapter) @@ -965,37 +996,39 @@ void rtw_scan_abort23a(struct rtw_adapter *adapter) pmlmeext->scan_abort = true; while (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY) && jiffies_to_msecs(jiffies - start) <= 200) { - if (adapter->bDriverStopped || adapter->bSurpriseRemoved) break; - DBG_8723A(FUNC_NDEV_FMT"fw_state = _FW_UNDER_SURVEY!\n", FUNC_NDEV_ARG(adapter->pnetdev)); + DBG_8723A(FUNC_NDEV_FMT "fw_state = _FW_UNDER_SURVEY!\n", + FUNC_NDEV_ARG(adapter->pnetdev)); msleep(20); } if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY)) { if (!adapter->bDriverStopped && !adapter->bSurpriseRemoved) - DBG_8723A(FUNC_NDEV_FMT"waiting for scan_abort time out!\n", FUNC_NDEV_ARG(adapter->pnetdev)); + DBG_8723A(FUNC_NDEV_FMT "waiting for scan_abort time " + "out!\n", FUNC_NDEV_ARG(adapter->pnetdev)); rtw_cfg80211_indicate_scan_done(wdev_to_priv(adapter->rtw_wdev), true); } pmlmeext->scan_abort = false; } -static struct sta_info *rtw_joinbss_update_stainfo(struct rtw_adapter *padapter, struct wlan_network *pnetwork) +static struct sta_info * +rtw_joinbss_update_stainfo(struct rtw_adapter *padapter, + struct wlan_network *pnetwork) { int i; - struct sta_info *bmc_sta, *psta = NULL; + struct sta_info *bmc_sta, *psta; struct recv_reorder_ctrl *preorder_ctrl; struct sta_priv *pstapriv = &padapter->stapriv; psta = rtw_get_stainfo23a(pstapriv, pnetwork->network.MacAddress); - if (psta == NULL) { - psta = rtw_alloc_stainfo23a(pstapriv, pnetwork->network.MacAddress); - } + if (!psta) + psta = rtw_alloc_stainfo23a(pstapriv, + pnetwork->network.MacAddress); - if (psta) /* update ptarget_sta */ - { + if (psta) { /* update ptarget_sta */ DBG_8723A("%s\n", __func__); psta->aid = pnetwork->join_res; @@ -1005,57 +1038,63 @@ static struct sta_info *rtw_joinbss_update_stainfo(struct rtw_adapter *padapter, rtw_hal_set_odm_var23a(padapter, HAL_ODM_STA_INFO, psta, true); /* security related */ - if (padapter->securitypriv.dot11AuthAlgrthm == dot11AuthAlgrthm_8021X) - { + if (padapter->securitypriv.dot11AuthAlgrthm == + dot11AuthAlgrthm_8021X) { padapter->securitypriv.binstallGrpkey = false; padapter->securitypriv.busetkipkey = false; padapter->securitypriv.bgrpkey_handshake = false; psta->ieee8021x_blocked = true; - psta->dot118021XPrivacy = padapter->securitypriv.dot11PrivacyAlgrthm; + psta->dot118021XPrivacy = + padapter->securitypriv.dot11PrivacyAlgrthm; - memset((u8 *)&psta->dot118021x_UncstKey, 0, sizeof (union Keytype)); + memset(&psta->dot118021x_UncstKey, 0, + sizeof (union Keytype)); - memset((u8 *)&psta->dot11tkiprxmickey, 0, sizeof (union Keytype)); - memset((u8 *)&psta->dot11tkiptxmickey, 0, sizeof (union Keytype)); + memset(&psta->dot11tkiprxmickey, 0, + sizeof (union Keytype)); + memset(&psta->dot11tkiptxmickey, 0, + sizeof (union Keytype)); - memset((u8 *)&psta->dot11txpn, 0, sizeof (union pn48)); - memset((u8 *)&psta->dot11rxpn, 0, sizeof (union pn48)); + memset(&psta->dot11txpn, 0, sizeof (union pn48)); + memset(&psta->dot11rxpn, 0, sizeof (union pn48)); } /* Commented by Albert 2012/07/21 */ /* When doing the WPS, the wps_ie_len won't equal to 0 */ - /* And the Wi-Fi driver shouldn't allow the data packet to be tramsmitted. */ - if (padapter->securitypriv.wps_ie_len != 0) - { + /* And the Wi-Fi driver shouldn't allow the data packet + to be tramsmitted. */ + if (padapter->securitypriv.wps_ie_len != 0) { psta->ieee8021x_blocked = true; padapter->securitypriv.wps_ie_len = 0; } - /* for A-MPDU Rx reordering buffer control for bmc_sta & sta_info */ - /* if A-MPDU Rx is enabled, reseting rx_ordering_ctrl wstart_b(indicate_seq) to default value = 0xffff */ + /* for A-MPDU Rx reordering buffer control for bmc_sta & + * sta_info */ + /* if A-MPDU Rx is enabled, reseting + rx_ordering_ctrl wstart_b(indicate_seq) to default + value = 0xffff */ /* todo: check if AP can send A-MPDU packets */ - for (i = 0; i < 16 ; i++) - { + for (i = 0; i < 16 ; i++) { /* preorder_ctrl = &precvpriv->recvreorder_ctrl[i]; */ preorder_ctrl = &psta->recvreorder_ctrl[i]; preorder_ctrl->enable = false; preorder_ctrl->indicate_seq = 0xffff; preorder_ctrl->wend_b = 0xffff; - preorder_ctrl->wsize_b = 64;/* max_ampdu_sz; ex. 32(kbytes) -> wsize_b = 32 */ + /* max_ampdu_sz; ex. 32(kbytes) -> wsize_b = 32 */ + preorder_ctrl->wsize_b = 64; } bmc_sta = rtw_get_bcmc_stainfo23a(padapter); - if (bmc_sta) - { - for (i = 0; i < 16 ; i++) - { - /* preorder_ctrl = &precvpriv->recvreorder_ctrl[i]; */ + if (bmc_sta) { + for (i = 0; i < 16 ; i++) { preorder_ctrl = &bmc_sta->recvreorder_ctrl[i]; preorder_ctrl->enable = false; preorder_ctrl->indicate_seq = 0xffff; preorder_ctrl->wend_b = 0xffff; - preorder_ctrl->wsize_b = 64;/* max_ampdu_sz; ex. 32(kbytes) -> wsize_b = 32 */ + /* max_ampdu_sz; ex. 32(kbytes) -> + wsize_b = 32 */ + preorder_ctrl->wsize_b = 64; } } @@ -1069,29 +1108,41 @@ static struct sta_info *rtw_joinbss_update_stainfo(struct rtw_adapter *padapter, /* pnetwork : returns from rtw23a_joinbss_event_cb */ /* ptarget_wlan: found from scanned_queue */ -static void rtw_joinbss_update_network23a(struct rtw_adapter *padapter, struct wlan_network *ptarget_wlan, struct wlan_network *pnetwork) +static void +rtw_joinbss_update_network23a(struct rtw_adapter *padapter, + struct wlan_network *ptarget_wlan, + struct wlan_network *pnetwork) { struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct wlan_network *cur_network = &pmlmepriv->cur_network; DBG_8723A("%s\n", __func__); - RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("\nfw_state:%x, BSSID:"MAC_FMT"\n" - , get_fwstate(pmlmepriv), MAC_ARG(pnetwork->network.MacAddress))); + RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, + ("\nfw_state:%x, BSSID:"MAC_FMT"\n", get_fwstate(pmlmepriv), + MAC_ARG(pnetwork->network.MacAddress))); /* why not use ptarget_wlan?? */ - memcpy(&cur_network->network, &pnetwork->network, pnetwork->network.Length); + memcpy(&cur_network->network, &pnetwork->network, + pnetwork->network.Length); /* some IEs in pnetwork is wrong, so we should use ptarget_wlan IEs */ cur_network->network.IELength = ptarget_wlan->network.IELength; - memcpy(&cur_network->network.IEs[0], &ptarget_wlan->network.IEs[0], MAX_IE_SZ); + memcpy(&cur_network->network.IEs[0], &ptarget_wlan->network.IEs[0], + MAX_IE_SZ); cur_network->aid = pnetwork->join_res; rtw_set_signal_stat_timer(&padapter->recvpriv); - padapter->recvpriv.signal_strength = ptarget_wlan->network.PhyInfo.SignalStrength; - padapter->recvpriv.signal_qual = ptarget_wlan->network.PhyInfo.SignalQuality; - /* the ptarget_wlan->network.Rssi is raw data, we use ptarget_wlan->network.PhyInfo.SignalStrength instead (has scaled) */ - padapter->recvpriv.rssi = translate_percentage_to_dbm(ptarget_wlan->network.PhyInfo.SignalStrength); + padapter->recvpriv.signal_strength = + ptarget_wlan->network.PhyInfo.SignalStrength; + padapter->recvpriv.signal_qual = + ptarget_wlan->network.PhyInfo.SignalQuality; + /* + * the ptarget_wlan->network.Rssi is raw data, we use + * ptarget_wlan->network.PhyInfo.SignalStrength instead (has scaled) + */ + padapter->recvpriv.rssi = translate_percentage_to_dbm( + ptarget_wlan->network.PhyInfo.SignalStrength); DBG_8723A("%s signal_strength:%3u, rssi:%3d, signal_qual:%3u\n", __func__, padapter->recvpriv.signal_strength, padapter->recvpriv.rssi, padapter->recvpriv.signal_qual); @@ -1110,40 +1161,51 @@ static void rtw_joinbss_update_network23a(struct rtw_adapter *padapter, struct w break; default: pmlmepriv->fw_state = WIFI_NULL_STATE; - RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("Invalid network_mode\n")); + RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, + ("Invalid network_mode\n")); break; } - rtw_update_protection23a(padapter, (cur_network->network.IEs) + sizeof (struct ndis_802_11_fixed_ies), - (cur_network->network.IELength)); + rtw_update_protection23a(padapter, cur_network->network.IEs + + sizeof (struct ndis_802_11_fixed_ies), + cur_network->network.IELength); - rtw_update_ht_cap23a(padapter, cur_network->network.IEs, cur_network->network.IELength); + rtw_update_ht_cap23a(padapter, cur_network->network.IEs, + cur_network->network.IELength); } -/* Notes: the fucntion could be > passive_level (the same context as Rx tasklet) */ -/* pnetwork : returns from rtw23a_joinbss_event_cb */ -/* ptarget_wlan: found from scanned_queue */ -/* if join_res > 0, for (fw_state==WIFI_STATION_STATE), we check if "ptarget_sta" & "ptarget_wlan" exist. */ -/* if join_res > 0, for (fw_state==WIFI_ADHOC_STATE), we only check if "ptarget_wlan" exist. */ -/* if join_res > 0, update "cur_network->network" from "pnetwork->network" if (ptarget_wlan !=NULL). */ +/* + * Notes: + * the fucntion could be > passive_level (the same context as Rx tasklet) + * pnetwork : returns from rtw23a_joinbss_event_cb + * ptarget_wlan: found from scanned_queue + * if join_res > 0, for (fw_state==WIFI_STATION_STATE), + * we check if "ptarget_sta" & "ptarget_wlan" exist. + * if join_res > 0, for (fw_state==WIFI_ADHOC_STATE), + * we only check if "ptarget_wlan" exist. + * if join_res > 0, update "cur_network->network" from "pnetwork->network" + * if (ptarget_wlan !=NULL). + */ void rtw_joinbss_event_prehandle23a(struct rtw_adapter *adapter, u8 *pbuf) { - static u8 retry=0; - struct sta_info *ptarget_sta= NULL, *pcur_sta = NULL; - struct sta_priv *pstapriv = &adapter->stapriv; - struct mlme_priv *pmlmepriv = &adapter->mlmepriv; - struct wlan_network *pnetwork = (struct wlan_network *)pbuf; + struct sta_info *ptarget_sta, *pcur_sta; + struct sta_priv *pstapriv = &adapter->stapriv; + struct mlme_priv *pmlmepriv = &adapter->mlmepriv; + struct wlan_network *pnetwork = (struct wlan_network *)pbuf; struct wlan_network *cur_network = &pmlmepriv->cur_network; - struct wlan_network *pcur_wlan = NULL, *ptarget_wlan = NULL; - unsigned int the_same_macaddr = false; + struct wlan_network *pcur_wlan, *ptarget_wlan = NULL; + bool the_same_macaddr; - RT_TRACE(_module_rtl871x_mlme_c_,_drv_info_,("joinbss event call back received with res=%d\n", pnetwork->join_res)); + RT_TRACE(_module_rtl871x_mlme_c_,_drv_info_, + ("joinbss event call back received with res=%d\n", + pnetwork->join_res)); rtw_get_encrypt_decrypt_from_registrypriv23a(adapter); if (pmlmepriv->assoc_ssid.ssid_len == 0) { - RT_TRACE(_module_rtl871x_mlme_c_,_drv_err_,("@@@@@ joinbss event call back for Any SSid\n")); + RT_TRACE(_module_rtl871x_mlme_c_,_drv_err_, + ("@@@@@ joinbss event call back for Any SSid\n")); } else { RT_TRACE(_module_rtl871x_mlme_c_,_drv_err_, ("@@@@@ rtw23a_joinbss_event_cb for SSid:%s\n", @@ -1157,93 +1219,102 @@ void rtw_joinbss_event_prehandle23a(struct rtw_adapter *adapter, u8 *pbuf) the_same_macaddr = false; pnetwork->network.Length = get_wlan_bssid_ex_sz(&pnetwork->network); - if(pnetwork->network.Length > sizeof(struct wlan_bssid_ex)) - { - RT_TRACE(_module_rtl871x_mlme_c_,_drv_err_,("\n\n ***joinbss_evt_callback return a wrong bss ***\n\n")); + if (pnetwork->network.Length > sizeof(struct wlan_bssid_ex)) { + RT_TRACE(_module_rtl871x_mlme_c_,_drv_err_, + ("\n\n ***joinbss_evt_callback return a wrong bss " + "***\n\n")); return; } spin_lock_bh(&pmlmepriv->lock); - RT_TRACE(_module_rtl871x_mlme_c_,_drv_info_,("\n rtw23a_joinbss_event_cb !! _enter_critical\n")); + RT_TRACE(_module_rtl871x_mlme_c_,_drv_info_, + ("\n rtw23a_joinbss_event_cb !! _enter_critical\n")); - if(pnetwork->join_res > 0) - { + if (pnetwork->join_res > 0) { spin_lock_bh(&pmlmepriv->scanned_queue.lock); - retry = 0; - if (check_fwstate(pmlmepriv,_FW_UNDER_LINKING)) - { + if (check_fwstate(pmlmepriv,_FW_UNDER_LINKING)) { /* s1. find ptarget_wlan */ - if(check_fwstate(pmlmepriv, _FW_LINKED)) - { - if(the_same_macaddr == true) - { + if (check_fwstate(pmlmepriv, _FW_LINKED)) { + if (the_same_macaddr == true) { ptarget_wlan = rtw_find_network23a(&pmlmepriv->scanned_queue, cur_network->network.MacAddress); - } - else - { + } else { pcur_wlan = rtw_find_network23a(&pmlmepriv->scanned_queue, cur_network->network.MacAddress); - if(pcur_wlan) pcur_wlan->fixed = false; + if (pcur_wlan) + pcur_wlan->fixed = false; pcur_sta = rtw_get_stainfo23a(pstapriv, cur_network->network.MacAddress); - if(pcur_sta) { + if (pcur_sta) { spin_lock_bh(&pstapriv->sta_hash_lock); - rtw_free_stainfo23a(adapter, pcur_sta); + rtw_free_stainfo23a(adapter, + pcur_sta); spin_unlock_bh(&pstapriv->sta_hash_lock); } ptarget_wlan = rtw_find_network23a(&pmlmepriv->scanned_queue, pnetwork->network.MacAddress); - if(check_fwstate(pmlmepriv, WIFI_STATION_STATE) == true) { - if(ptarget_wlan) ptarget_wlan->fixed = true; + if (check_fwstate(pmlmepriv, + WIFI_STATION_STATE)) { + if (ptarget_wlan) + ptarget_wlan->fixed = + true; } } - } - else - { - ptarget_wlan = rtw_find_network23a(&pmlmepriv->scanned_queue, pnetwork->network.MacAddress); - if(check_fwstate(pmlmepriv, WIFI_STATION_STATE) == true) { - if(ptarget_wlan) ptarget_wlan->fixed = true; + } else { + ptarget_wlan = rtw_find_network23a( + &pmlmepriv->scanned_queue, + pnetwork->network.MacAddress); + if (check_fwstate(pmlmepriv, + WIFI_STATION_STATE)) { + if (ptarget_wlan) + ptarget_wlan->fixed = true; } } /* s2. update cur_network */ - if(ptarget_wlan) - { - rtw_joinbss_update_network23a(adapter, ptarget_wlan, pnetwork); - } - else - { - RT_TRACE(_module_rtl871x_mlme_c_,_drv_err_,("Can't find ptarget_wlan when joinbss_event callback\n")); + if (ptarget_wlan) + rtw_joinbss_update_network23a(adapter, + ptarget_wlan, + pnetwork); + else { + RT_TRACE(_module_rtl871x_mlme_c_,_drv_err_, + ("Can't find ptarget_wlan when " + "joinbss_event callback\n")); spin_unlock_bh(&pmlmepriv->scanned_queue.lock); goto ignore_joinbss_callback; } - /* s3. find ptarget_sta & update ptarget_sta after update cur_network only for station mode */ - if(check_fwstate(pmlmepriv, WIFI_STATION_STATE) == true) - { - ptarget_sta = rtw_joinbss_update_stainfo(adapter, pnetwork); - if(ptarget_sta==NULL) - { - RT_TRACE(_module_rtl871x_mlme_c_,_drv_err_,("Can't update stainfo when joinbss_event callback\n")); + /* s3. find ptarget_sta & update ptarget_sta after + update cur_network only for station mode */ + if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)) { + ptarget_sta = rtw_joinbss_update_stainfo( + adapter, pnetwork); + if (!ptarget_sta) { + RT_TRACE(_module_rtl871x_mlme_c_, + _drv_err_, + ("Can't update stainfo when " + "joinbss_event callback\n")); spin_unlock_bh(&pmlmepriv->scanned_queue.lock); goto ignore_joinbss_callback; } } /* s4. indicate connect */ - if (check_fwstate(pmlmepriv, WIFI_STATION_STATE) == true) - { + if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)) rtw_indicate_connect23a(adapter); - } else { - /* adhoc mode will rtw_indicate_connect23a when rtw_stassoc_event_callback23a */ - RT_TRACE(_module_rtl871x_mlme_c_,_drv_info_,("adhoc mode, fw_state:%x", get_fwstate(pmlmepriv))); + else { + /* adhoc mode will rtw_indicate_connect23a + when rtw_stassoc_event_callback23a */ + RT_TRACE(_module_rtl871x_mlme_c_,_drv_info_, + ("adhoc mode, fw_state:%x", + get_fwstate(pmlmepriv))); } /* s5. Cancle assoc_timer */ del_timer_sync(&pmlmepriv->assoc_timer); - RT_TRACE(_module_rtl871x_mlme_c_,_drv_info_,("Cancle assoc_timer\n")); + RT_TRACE(_module_rtl871x_mlme_c_,_drv_info_, + ("Cancle assoc_timer\n")); } else { RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("rtw23a_joinbss_event_cb err: fw_state:%x", @@ -1252,20 +1323,19 @@ void rtw_joinbss_event_prehandle23a(struct rtw_adapter *adapter, u8 *pbuf) goto ignore_joinbss_callback; } spin_unlock_bh(&pmlmepriv->scanned_queue.lock); - } else if(pnetwork->join_res == -4) { + } else if (pnetwork->join_res == -4) { rtw_reset_securitypriv23a(adapter); mod_timer(&pmlmepriv->assoc_timer, jiffies + msecs_to_jiffies(1)); /* rtw_free_assoc_resources23a(adapter, 1); */ - if((check_fwstate(pmlmepriv, _FW_UNDER_LINKING))) { + if (check_fwstate(pmlmepriv, _FW_UNDER_LINKING)) { RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, - ("fail! clear _FW_UNDER_LINKING ^^^fw_state=%x\n", - get_fwstate(pmlmepriv))); + ("fail! clear _FW_UNDER_LINKING ^^^fw_state=" + "%x\n", get_fwstate(pmlmepriv))); _clr_fwstate_(pmlmepriv, _FW_UNDER_LINKING); } - } else { /* if join_res < 0 (join fails), then try again */ mod_timer(&pmlmepriv->assoc_timer, @@ -1280,28 +1350,26 @@ ignore_joinbss_callback: void rtw23a_joinbss_event_cb(struct rtw_adapter *adapter, u8 *pbuf) { - struct wlan_network *pnetwork = (struct wlan_network *)pbuf; + struct wlan_network *pnetwork = (struct wlan_network *)pbuf; mlmeext_joinbss_event_callback23a(adapter, pnetwork->join_res); rtw_os_xmit_schedule23a(adapter); - } void rtw_stassoc_event_callback23a(struct rtw_adapter *adapter, u8 *pbuf) { struct sta_info *psta; struct mlme_priv *pmlmepriv = &adapter->mlmepriv; - struct stassoc_event *pstassoc = (struct stassoc_event*)pbuf; + struct stassoc_event *pstassoc = (struct stassoc_event*)pbuf; struct wlan_network *cur_network = &pmlmepriv->cur_network; - struct wlan_network *ptarget_wlan = NULL; + struct wlan_network *ptarget_wlan; - if(rtw_access_ctrl23a(adapter, pstassoc->macaddr) == false) + if (rtw_access_ctrl23a(adapter, pstassoc->macaddr) == false) return; #ifdef CONFIG_8723AU_AP_MODE - if(check_fwstate(pmlmepriv, WIFI_AP_STATE)) - { + if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) { psta = rtw_get_stainfo23a(&adapter->stapriv, pstassoc->macaddr); if (psta) { /* bss_cap_update_on_sta_join23a(adapter, psta); */ @@ -1315,13 +1383,19 @@ void rtw_stassoc_event_callback23a(struct rtw_adapter *adapter, u8 *pbuf) psta = rtw_get_stainfo23a(&adapter->stapriv, pstassoc->macaddr); if (psta != NULL) { /* the sta have been in sta_info_queue => do nothing */ - RT_TRACE(_module_rtl871x_mlme_c_,_drv_err_,("Error: rtw_stassoc_event_callback23a: sta has been in sta_hash_queue\n")); - return; /* between drv has received this event before and fw have not yet to set key to CAM_ENTRY) */ + RT_TRACE(_module_rtl871x_mlme_c_,_drv_err_, + ("Error: rtw_stassoc_event_callback23a: sta has " + "been in sta_hash_queue\n")); + /* between drv has received this event before and + fw have not yet to set key to CAM_ENTRY) */ + return; } psta = rtw_alloc_stainfo23a(&adapter->stapriv, pstassoc->macaddr); - if (psta == NULL) { - RT_TRACE(_module_rtl871x_mlme_c_,_drv_err_,("Can't alloc sta_info when rtw_stassoc_event_callback23a\n")); + if (!psta) { + RT_TRACE(_module_rtl871x_mlme_c_,_drv_err_, + ("Can't alloc sta_info when " + "rtw_stassoc_event_callback23a\n")); return; } @@ -1331,23 +1405,25 @@ void rtw_stassoc_event_callback23a(struct rtw_adapter *adapter, u8 *pbuf) /* psta->aid = (uint)pstassoc->cam_id; */ DBG_8723A("%s\n",__func__); /* for ad-hoc mode */ - rtw_hal_set_odm_var23a(adapter,HAL_ODM_STA_INFO,psta,true); + rtw_hal_set_odm_var23a(adapter, HAL_ODM_STA_INFO, psta, true); - if(adapter->securitypriv.dot11AuthAlgrthm==dot11AuthAlgrthm_8021X) - psta->dot118021XPrivacy = adapter->securitypriv.dot11PrivacyAlgrthm; + if (adapter->securitypriv.dot11AuthAlgrthm == dot11AuthAlgrthm_8021X) + psta->dot118021XPrivacy = + adapter->securitypriv.dot11PrivacyAlgrthm; psta->ieee8021x_blocked = false; spin_lock_bh(&pmlmepriv->lock); - if ( (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)==true ) || - (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE)==true ) ) - { - if(adapter->stapriv.asoc_sta_count== 2) - { + if (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) || + check_fwstate(pmlmepriv, WIFI_ADHOC_STATE)) { + if (adapter->stapriv.asoc_sta_count == 2) { spin_lock_bh(&pmlmepriv->scanned_queue.lock); - ptarget_wlan = rtw_find_network23a(&pmlmepriv->scanned_queue, cur_network->network.MacAddress); - if(ptarget_wlan) ptarget_wlan->fixed = true; + ptarget_wlan = + rtw_find_network23a(&pmlmepriv->scanned_queue, + cur_network->network.MacAddress); + if (ptarget_wlan) + ptarget_wlan->fixed = true; spin_unlock_bh(&pmlmepriv->scanned_queue.lock); /* a sta + bc/mc_stainfo (not Ibss_stainfo) */ rtw_indicate_connect23a(adapter); @@ -1361,40 +1437,40 @@ void rtw_stassoc_event_callback23a(struct rtw_adapter *adapter, u8 *pbuf) void rtw_stadel_event_callback23a(struct rtw_adapter *adapter, u8 *pbuf) { - int mac_id=-1; + int mac_id; struct sta_info *psta; - struct wlan_network* pwlan = NULL; - struct wlan_bssid_ex *pdev_network=NULL; - u8* pibss = NULL; - struct mlme_priv *pmlmepriv = &adapter->mlmepriv; - struct stadel_event *pstadel = (struct stadel_event*)pbuf; - struct sta_priv *pstapriv = &adapter->stapriv; + struct wlan_network* pwlan; + struct wlan_bssid_ex *pdev_network; + u8 *pibss; + struct mlme_priv *pmlmepriv = &adapter->mlmepriv; + struct stadel_event *pstadel = (struct stadel_event *)pbuf; + struct sta_priv *pstapriv = &adapter->stapriv; struct wlan_network *tgt_network = &pmlmepriv->cur_network; psta = rtw_get_stainfo23a(&adapter->stapriv, pstadel->macaddr); - if(psta) + if (psta) mac_id = psta->mac_id; else mac_id = pstadel->mac_id; - DBG_8723A("%s(mac_id=%d)=" MAC_FMT "\n", __func__, mac_id, MAC_ARG(pstadel->macaddr)); + DBG_8723A("%s(mac_id=%d)=" MAC_FMT "\n", __func__, mac_id, + MAC_ARG(pstadel->macaddr)); if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) - { return; - } mlmeext_sta_del_event_callback23a(adapter); spin_lock_bh(&pmlmepriv->lock); - if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)) - { - if (rtw_to_roaming(adapter) > 0) - pmlmepriv->to_roaming--; /* this stadel_event is caused by roaming, decrease to_roaming */ - else if (rtw_to_roaming(adapter) == 0) + if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)) { + if (rtw_to_roaming(adapter) > 0) { + /* this stadel_event is caused by roaming, + decrease to_roaming */ + pmlmepriv->to_roaming--; + } else if (rtw_to_roaming(adapter) == 0) rtw_set_roaming(adapter, adapter->registrypriv.max_roaming_times); - if (*((unsigned short *)(pstadel->rsvd)) != WLAN_REASON_EXPIRATION_CHK) + if (*((u16 *)pstadel->rsvd) != WLAN_REASON_EXPIRATION_CHK) rtw_set_roaming(adapter, 0); /* don't roam */ rtw_free_uc_swdec_pending_queue23a(adapter); @@ -1403,7 +1479,8 @@ void rtw_stadel_event_callback23a(struct rtw_adapter *adapter, u8 *pbuf) rtw_indicate_disconnect23a(adapter); spin_lock_bh(&pmlmepriv->scanned_queue.lock); /* remove the network entry in scanned_queue */ - pwlan = rtw_find_network23a(&pmlmepriv->scanned_queue, tgt_network->network.MacAddress); + pwlan = rtw_find_network23a(&pmlmepriv->scanned_queue, + tgt_network->network.MacAddress); if (pwlan) { pwlan->fixed = false; rtw_free_network_nolock(pmlmepriv, pwlan); @@ -1414,21 +1491,21 @@ void rtw_stadel_event_callback23a(struct rtw_adapter *adapter, u8 *pbuf) } if (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) || - check_fwstate(pmlmepriv, WIFI_ADHOC_STATE)) - { + check_fwstate(pmlmepriv, WIFI_ADHOC_STATE)) { spin_lock_bh(&pstapriv->sta_hash_lock); rtw_free_stainfo23a(adapter, psta); spin_unlock_bh(&pstapriv->sta_hash_lock); - if (adapter->stapriv.asoc_sta_count == 1) /* a sta + bc/mc_stainfo (not Ibss_stainfo) */ - { + /* a sta + bc/mc_stainfo (not Ibss_stainfo) */ + if (adapter->stapriv.asoc_sta_count == 1) { spin_lock_bh(&pmlmepriv->scanned_queue.lock); /* free old ibss network */ - /* pwlan = rtw_find_network23a(&pmlmepriv->scanned_queue, pstadel->macaddr); */ - pwlan = rtw_find_network23a(&pmlmepriv->scanned_queue, tgt_network->network.MacAddress); - if (pwlan) - { + /* pwlan = rtw_find_network23a( + &pmlmepriv->scanned_queue, pstadel->macaddr); */ + pwlan = rtw_find_network23a(&pmlmepriv->scanned_queue, + tgt_network->network.MacAddress); + if (pwlan) { pwlan->fixed = false; rtw_free_network_nolock(pmlmepriv, pwlan); } @@ -1437,7 +1514,8 @@ void rtw_stadel_event_callback23a(struct rtw_adapter *adapter, u8 *pbuf) pdev_network = &adapter->registrypriv.dev_network; pibss = adapter->registrypriv.dev_network.MacAddress; - memcpy(pdev_network, &tgt_network->network, get_wlan_bssid_ex_sz(&tgt_network->network)); + memcpy(pdev_network, &tgt_network->network, + get_wlan_bssid_ex_sz(&tgt_network->network)); memset(&pdev_network->Ssid, 0, sizeof(struct cfg80211_ssid)); @@ -1448,32 +1526,28 @@ void rtw_stadel_event_callback23a(struct rtw_adapter *adapter, u8 *pbuf) rtw_generate_random_ibss23a(pibss); - if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE)) - { + if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE)) { set_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE); _clr_fwstate_(pmlmepriv, WIFI_ADHOC_STATE); } - if (rtw_createbss_cmd23a(adapter)!= _SUCCESS) - { - - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("***Error =>stadel_event_callback: rtw_createbss_cmd23a status FAIL***\n ")); - + if (rtw_createbss_cmd23a(adapter) != _SUCCESS) { + RT_TRACE(_module_rtl871x_ioctl_set_c_, + _drv_err_, + ("***Error =>stadel_event_callback: " + "rtw_createbss_cmd23a status " + "FAIL***\n")); } - } - } spin_unlock_bh(&pmlmepriv->lock); - } void rtw_cpwm_event_callback23a(struct rtw_adapter *padapter, u8 *pbuf) { - - RT_TRACE(_module_rtl871x_mlme_c_,_drv_err_,("+rtw_cpwm_event_callback23a !!!\n")); - + RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, + ("+rtw_cpwm_event_callback23a !!!\n")); } /* @@ -1488,23 +1562,26 @@ void rtw23a_join_to_handler (unsigned long data) DBG_8723A("%s, fw_state=%x\n", __func__, get_fwstate(pmlmepriv)); - if(adapter->bDriverStopped ||adapter->bSurpriseRemoved) + if (adapter->bDriverStopped ||adapter->bSurpriseRemoved) return; spin_lock_bh(&pmlmepriv->lock); if (rtw_to_roaming(adapter) > 0) { /* join timeout caused by roaming */ - while(1) { + while (1) { pmlmepriv->to_roaming--; if (rtw_to_roaming(adapter) != 0) { /* try another */ DBG_8723A("%s try another roaming\n", __func__); - if (_SUCCESS!= (do_join_r = rtw_do_join23a(adapter))) { - DBG_8723A("%s roaming do_join return %d\n", __func__ , do_join_r); + do_join_r = rtw_do_join23a(adapter); + if (do_join_r != _SUCCESS) { + DBG_8723A("%s roaming do_join return " + "%d\n", __func__ , do_join_r); continue; } break; } else { - DBG_8723A("%s We've try roaming but fail\n", __func__); + DBG_8723A("%s We've try roaming but fail\n", + __func__); rtw_indicate_disconnect23a(adapter); break; } @@ -1513,7 +1590,8 @@ void rtw23a_join_to_handler (unsigned long data) rtw_indicate_disconnect23a(adapter); free_scanqueue(pmlmepriv);/* */ - /* indicate disconnect for the case that join_timeout and check_fwstate != FW_LINKED */ + /* indicate disconnect for the case that join_timeout and + check_fwstate != FW_LINKED */ rtw_cfg80211_indicate_disconnect(adapter); } @@ -1530,7 +1608,8 @@ void rtw_scan_timeout_handler23a(unsigned long data) struct rtw_adapter *adapter = (struct rtw_adapter *)data; struct mlme_priv *pmlmepriv = &adapter->mlmepriv; - DBG_8723A(FUNC_ADPT_FMT" fw_state =%x\n", FUNC_ADPT_ARG(adapter), get_fwstate(pmlmepriv)); + DBG_8723A(FUNC_ADPT_FMT" fw_state =%x\n", FUNC_ADPT_ARG(adapter), + get_fwstate(pmlmepriv)); spin_lock_bh(&pmlmepriv->lock); @@ -1551,7 +1630,8 @@ static void rtw_auto_scan_handler(struct rtw_adapter *padapter) if (pmlmepriv->scan_interval == 0) { DBG_8723A("%s\n", __func__); rtw_set_802_11_bssid23a_list_scan(padapter, NULL, 0); - pmlmepriv->scan_interval = SCAN_INTERVAL;/* 30*2 sec = 60sec */ + /* 30*2 sec = 60sec */ + pmlmepriv->scan_interval = SCAN_INTERVAL; } } } @@ -1564,7 +1644,8 @@ void rtw_dynamic_check_timer_handler(unsigned long data) if (adapter->hw_init_completed == false) goto out; - if ((adapter->bDriverStopped == true)||(adapter->bSurpriseRemoved == true)) + if (adapter->bDriverStopped == true || + adapter->bSurpriseRemoved == true) goto out; if (adapter->net_closed == true) @@ -1615,15 +1696,19 @@ void rtw_set_scan_deny(struct rtw_adapter *adapter, u32 ms) #endif /* -* Select a new join candidate from the original @param candidate and @param competitor +* Select a new join candidate from the original @param candidate and +* @param competitor * @return true: candidate is updated * @return false: candidate is not updated */ -static int rtw_check_join_candidate(struct mlme_priv *pmlmepriv - , struct wlan_network **candidate, struct wlan_network *competitor) +static int rtw_check_join_candidate(struct mlme_priv *pmlmepriv, + struct wlan_network **candidate, + struct wlan_network *competitor) { int updated = false; - struct rtw_adapter *adapter = container_of(pmlmepriv, struct rtw_adapter, mlmepriv); + struct rtw_adapter *adapter; + + adapter = container_of(pmlmepriv, struct rtw_adapter, mlmepriv); /* check bssid, if needed */ if (pmlmepriv->assoc_by_bssid == true) { @@ -1642,7 +1727,7 @@ static int rtw_check_join_candidate(struct mlme_priv *pmlmepriv goto exit; } - if (rtw_is_desired_network(adapter, competitor) == false) + if (rtw_is_desired_network(adapter, competitor) == false) goto exit; if (rtw_to_roaming(adapter) > 0) { @@ -1655,19 +1740,21 @@ static int rtw_check_join_candidate(struct mlme_priv *pmlmepriv goto exit; } - if (*candidate == NULL ||(*candidate)->network.Rssinetwork.Rssi) { + if (!*candidate || + (*candidate)->network.Rssinetwork.Rssi) { *candidate = competitor; updated = true; } if (updated) { - DBG_8723A("[by_bssid:%u][assoc_ssid:%s][to_roaming:%u] new candidate: %s("MAC_FMT") rssi:%d\n", - pmlmepriv->assoc_by_bssid, - pmlmepriv->assoc_ssid.ssid, - rtw_to_roaming(adapter), - (*candidate)->network.Ssid.ssid, - MAC_ARG((*candidate)->network.MacAddress), - (int)(*candidate)->network.Rssi); + DBG_8723A("[by_bssid:%u][assoc_ssid:%s][to_roaming:%u] " + "new candidate: %s("MAC_FMT") rssi:%d\n", + pmlmepriv->assoc_by_bssid, + pmlmepriv->assoc_ssid.ssid, + rtw_to_roaming(adapter), + (*candidate)->network.Ssid.ssid, + MAC_ARG((*candidate)->network.MacAddress), + (int)(*candidate)->network.Rssi); } exit: @@ -1690,8 +1777,8 @@ int rtw_select_and_join_from_scanned_queue23a(struct mlme_priv *pmlmepriv) struct list_head *phead, *plist, *ptmp; struct rtw_adapter *adapter; struct rtw_queue *queue = &pmlmepriv->scanned_queue; - struct wlan_network *pnetwork = NULL; - struct wlan_network *candidate = NULL; + struct wlan_network *pnetwork; + struct wlan_network *candidate = NULL; spin_lock_bh(&pmlmepriv->scanned_queue.lock); phead = get_list_head(queue); @@ -1722,7 +1809,7 @@ int rtw_select_and_join_from_scanned_queue23a(struct mlme_priv *pmlmepriv) } /* check for situation of _FW_LINKED */ - if (check_fwstate(pmlmepriv, _FW_LINKED) == true) { + if (check_fwstate(pmlmepriv, _FW_LINKED)) { DBG_8723A("%s: _FW_LINKED while ask_for_joinbss!!!\n", __func__); @@ -1740,7 +1827,7 @@ exit: } int rtw_set_auth23a(struct rtw_adapter * adapter, - struct security_priv *psecuritypriv) + struct security_priv *psecuritypriv) { struct cmd_obj* pcmd; struct setauth_parm *psetauthparm; @@ -1783,7 +1870,7 @@ exit: } int rtw_set_key23a(struct rtw_adapter *adapter, - struct security_priv *psecuritypriv, int keyid, u8 set_tx) + struct security_priv *psecuritypriv, int keyid, u8 set_tx) { u8 keylen; struct cmd_obj *pcmd; @@ -1808,9 +1895,9 @@ int rtw_set_key23a(struct rtw_adapter *adapter, psetkeyparm->algorithm = (unsigned char) psecuritypriv->dot118021XGrpPrivacy; RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, - ("\n rtw_set_key23a: psetkeyparm->algorithm = (unsigned " - "char)psecuritypriv->dot118021XGrpPrivacy =%d\n", - psetkeyparm->algorithm)); + ("\n rtw_set_key23a: psetkeyparm->algorithm = " + "(unsigned char)psecuritypriv->dot118021XGrpPrivacy " + "=%d\n", psetkeyparm->algorithm)); } else { psetkeyparm->algorithm = (u8)psecuritypriv->dot11PrivacyAlgrthm; RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, @@ -1855,8 +1942,8 @@ int rtw_set_key23a(struct rtw_adapter *adapter, break; default: RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, - ("\n rtw_set_key23a:psecuritypriv->dot11PrivacyAlgrthm = " - "%x (must be 1 or 2 or 4 or 5)\n", + ("\n rtw_set_key23a:psecuritypriv->dot11PrivacyAlgrthm" + " = %x (must be 1 or 2 or 4 or 5)\n", psecuritypriv->dot11PrivacyAlgrthm)); res = _FAIL; kfree(pcmd); @@ -1889,7 +1976,7 @@ int rtw_restruct_wmm_ie23a(struct rtw_adapter *adapter, u8 *in_ie, unsigned int i, j; i = 12; /* after the fixed IE */ - while(i < in_len) { + while (i < in_len) { ielength = initial_out_len; /* WMM element ID and OUI */ @@ -1940,11 +2027,11 @@ static int SecIsInPMKIDList(struct rtw_adapter *Adapter, u8 *bssid) i++; /* continue; */ } - } while(i < NUM_PMKID_CACHE); + } while (i < NUM_PMKID_CACHE); - if (i == NUM_PMKID_CACHE) { + if (i == NUM_PMKID_CACHE) i = -1;/* Could not find. */ - } else { + else { /* There is one Pre-Authentication Key for the specific BSSID. */ } @@ -1983,7 +2070,7 @@ static int rtw_append_pmkid(struct rtw_adapter *Adapter, int iEntry, } int rtw_restruct_sec_ie23a(struct rtw_adapter *adapter, u8 *in_ie, u8 *out_ie, - uint in_len) + uint in_len) { u8 authmode; uint ielength; @@ -1994,26 +2081,26 @@ int rtw_restruct_sec_ie23a(struct rtw_adapter *adapter, u8 *in_ie, u8 *out_ie, uint ndissecuritytype = psecuritypriv->ndisencryptstatus; RT_TRACE(_module_rtl871x_mlme_c_, _drv_notice_, - ("+rtw_restruct_sec_ie23a: ndisauthmode=%d ndissecuritytype=%d\n", - ndisauthmode, ndissecuritytype)); + ("+rtw_restruct_sec_ie23a: ndisauthmode=%d " + "ndissecuritytype=%d\n", ndisauthmode, ndissecuritytype)); /* copy fixed ie only */ memcpy(out_ie, in_ie, 12); ielength = 12; - if ((ndisauthmode==Ndis802_11AuthModeWPA) || - (ndisauthmode==Ndis802_11AuthModeWPAPSK)) + if (ndisauthmode == Ndis802_11AuthModeWPA || + ndisauthmode == Ndis802_11AuthModeWPAPSK) authmode = WLAN_EID_VENDOR_SPECIFIC; - if ((ndisauthmode==Ndis802_11AuthModeWPA2) || - (ndisauthmode==Ndis802_11AuthModeWPA2PSK)) - authmode=_WPA2_IE_ID_; + if (ndisauthmode == Ndis802_11AuthModeWPA2 || + ndisauthmode == Ndis802_11AuthModeWPA2PSK) + authmode = _WPA2_IE_ID_; 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 == _WPA2_IE_ID_) { /* copy RSN or SSN */ memcpy(&out_ie[ielength], &psecuritypriv->supplicant_ie[0], psecuritypriv->supplicant_ie[1] + 2); @@ -2021,13 +2108,12 @@ int rtw_restruct_sec_ie23a(struct rtw_adapter *adapter, u8 *in_ie, u8 *out_ie, } iEntry = SecIsInPMKIDList(adapter, pmlmepriv->assoc_bssid); - if (iEntry < 0) { + if (iEntry < 0) return ielength; - } else { - if (authmode == _WPA2_IE_ID_) { - ielength=rtw_append_pmkid(adapter, iEntry, - out_ie, ielength); - } + else { + if (authmode == _WPA2_IE_ID_) + ielength = rtw_append_pmkid(adapter, iEntry, + out_ie, ielength); } return ielength; @@ -2120,7 +2206,6 @@ void rtw_update_registrypriv_dev_network23a(struct rtw_adapter* adapter) /* notes: translate IELength & Length after assign the Length to cmdsz in createbss_cmd(); */ /* pdev_network->IELength = cpu_to_le32(sz); */ - } void rtw_get_encrypt_decrypt_from_registrypriv23a(struct rtw_adapter* adapter) @@ -2285,8 +2370,8 @@ void rtw_update_ht_cap23a(struct rtw_adapter *padapter, u8 *pie, uint ie_len) /* update cur_bwmode & cur_ch_offset */ if (pregistrypriv->cbw40_enable && - (pmlmeinfo->HT_caps.u.HT_cap_element.HT_caps_info & BIT(1)) && - (pmlmeinfo->HT_info.infos[0] & BIT(2))) { + pmlmeinfo->HT_caps.u.HT_cap_element.HT_caps_info & BIT(1) && + pmlmeinfo->HT_info.infos[0] & BIT(2)) { int i; u8 rf_type; @@ -2294,7 +2379,7 @@ void rtw_update_ht_cap23a(struct rtw_adapter *padapter, u8 *pie, uint ie_len) /* update the MCS rates */ for (i = 0; i < 16; i++) { - if ((rf_type == RF_1T1R) || (rf_type == RF_1T2R)) + if (rf_type == RF_1T1R || rf_type == RF_1T2R) pmlmeinfo->HT_caps.u.HT_cap_element.MCS_rate[i] &= MCS_rate_1R23A[i]; else pmlmeinfo->HT_caps.u.HT_cap_element.MCS_rate[i] &= MCS_rate_2R23A[i]; @@ -2332,52 +2417,52 @@ void rtw_update_ht_cap23a(struct rtw_adapter *padapter, u8 *pie, uint ie_len) pmlmeinfo->HT_protection = pmlmeinfo->HT_info.infos[1] & 0x3; } -void rtw_issue_addbareq_cmd23a(struct rtw_adapter *padapter, struct xmit_frame *pxmitframe) +void rtw_issue_addbareq_cmd23a(struct rtw_adapter *padapter, + struct xmit_frame *pxmitframe) { u8 issued; int priority; - struct sta_info *psta = NULL; + struct sta_info *psta; struct ht_priv *phtpriv; struct pkt_attrib *pattrib = &pxmitframe->attrib; s32 bmcst = is_multicast_ether_addr(pattrib->ra); - if (bmcst || (padapter->mlmepriv.LinkDetectInfo.NumTxOkInPeriod<100)) + if (bmcst || padapter->mlmepriv.LinkDetectInfo.NumTxOkInPeriod < 100) return; priority = pattrib->priority; if (pattrib->psta) psta = pattrib->psta; - else - { + else { DBG_8723A("%s, call rtw_get_stainfo23a()\n", __func__); psta = rtw_get_stainfo23a(&padapter->stapriv, pattrib->ra); } - if (psta == NULL) - { + if (!psta) { DBG_8723A("%s, psta == NUL\n", __func__); return; } - if (!(psta->state &_FW_LINKED)) - { - DBG_8723A("%s, psta->state(0x%x) != _FW_LINKED\n", __func__, psta->state); + if (!(psta->state &_FW_LINKED)) { + DBG_8723A("%s, psta->state(0x%x) != _FW_LINKED\n", + __func__, psta->state); return; } phtpriv = &psta->htpriv; - if ((phtpriv->ht_option == true) && (phtpriv->ampdu_enable == true)) - { + if (phtpriv->ht_option == true && phtpriv->ampdu_enable == true) { issued = (phtpriv->agg_enable_bitmap>>priority)&0x1; issued |= (phtpriv->candidate_tid_bitmap>>priority)&0x1; - if (0 == issued) - { - DBG_8723A("rtw_issue_addbareq_cmd23a, p =%d\n", priority); - psta->htpriv.candidate_tid_bitmap |= CHKBIT((u8)priority); - rtw_addbareq_cmd23a(padapter, (u8) priority, pattrib->ra); + if (issued == 0) { + DBG_8723A("rtw_issue_addbareq_cmd23a, p =%d\n", + priority); + psta->htpriv.candidate_tid_bitmap |= + CHKBIT((u8)priority); + rtw_addbareq_cmd23a(padapter, (u8) priority, + pattrib->ra); } } } @@ -2394,21 +2479,23 @@ inline u8 rtw_to_roaming(struct rtw_adapter *adapter) return adapter->mlmepriv.to_roaming; } -void rtw23a_roaming(struct rtw_adapter *padapter, struct wlan_network *tgt_network) +void rtw23a_roaming(struct rtw_adapter *padapter, + struct wlan_network *tgt_network) { - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; spin_lock_bh(&pmlmepriv->lock); _rtw23a_roaming(padapter, tgt_network); spin_unlock_bh(&pmlmepriv->lock); } -void _rtw23a_roaming(struct rtw_adapter *padapter, struct wlan_network *tgt_network) +void _rtw23a_roaming(struct rtw_adapter *padapter, + struct wlan_network *tgt_network) { - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct wlan_network *pnetwork; int do_join_r; - if (tgt_network != NULL) + if (tgt_network) pnetwork = tgt_network; else pnetwork = &pmlmepriv->cur_network; @@ -2423,17 +2510,21 @@ void _rtw23a_roaming(struct rtw_adapter *padapter, struct wlan_network *tgt_netw pmlmepriv->assoc_by_bssid = false; - while(1) { - if (_SUCCESS == (do_join_r = rtw_do_join23a(padapter))) { + while (1) { + do_join_r = rtw_do_join23a(padapter); + if (do_join_r == _SUCCESS) break; - } else { - DBG_8723A("roaming do_join return %d\n", do_join_r); + else { + DBG_8723A("roaming do_join return %d\n", + do_join_r); pmlmepriv->to_roaming--; - if (0 < rtw_to_roaming(padapter)) { + if (0 < rtw_to_roaming(padapter)) continue; - } else { - DBG_8723A("%s(%d) -to roaming fail, indicate_disconnect\n", __func__, __LINE__); + else { + DBG_8723A("%s(%d) -to roaming fail, " + "indicate_disconnect\n", + __func__, __LINE__); rtw_indicate_disconnect23a(padapter); break; } -- cgit v1.2.3 From 56828797acdb99d23b5e5e5c52e7d571d59b783f Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:44:46 +0200 Subject: staging: rtl8723au: Fold rtw_to_roaming() into the code Simple read variable from a struct function, having it as an external function is just silly. Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_ioctl_set.c | 4 +-- drivers/staging/rtl8723au/core/rtw_mlme.c | 41 ++++++++++------------- drivers/staging/rtl8723au/include/rtw_mlme.h | 1 - drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c | 2 +- 4 files changed, 21 insertions(+), 27 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_ioctl_set.c b/drivers/staging/rtl8723au/core/rtw_ioctl_set.c index 619bef3af153..fe4926a4ced6 100644 --- a/drivers/staging/rtl8723au/core/rtw_ioctl_set.c +++ b/drivers/staging/rtl8723au/core/rtw_ioctl_set.c @@ -54,7 +54,7 @@ u8 rtw_do_join23a(struct rtw_adapter *padapter) /* we try to issue sitesurvey firstly */ if (pmlmepriv->LinkDetectInfo.bBusyTraffic == false || - rtw_to_roaming(padapter) > 0) { + padapter->mlmepriv.to_roaming > 0) { RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, ("rtw_do_join23a(): site survey if scanned_queue " "is empty\n.")); @@ -130,7 +130,7 @@ u8 rtw_do_join23a(struct rtw_adapter *padapter) queue */ /* we try to issue sitesurvey firstly */ if (pmlmepriv->LinkDetectInfo.bBusyTraffic == - false || rtw_to_roaming(padapter) > 0) { + false || padapter->mlmepriv.to_roaming > 0){ /* DBG_8723A("rtw_do_join23a() when no " "desired bss in scanning queue\n"); */ diff --git a/drivers/staging/rtl8723au/core/rtw_mlme.c b/drivers/staging/rtl8723au/core/rtw_mlme.c index 8bb368499ce2..34d2164f1dd8 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme.c @@ -325,9 +325,7 @@ void rtw_free_network_nolock(struct mlme_priv *pmlmepriv, void rtw_free_network_queue23a(struct rtw_adapter* dev, u8 isfreeall) { - _rtw_free_network23a_queue23a(dev, isfreeall); - } /* @@ -729,7 +727,6 @@ void rtw_surveydone_event_callback23a(struct rtw_adapter *adapter, u8 *pbuf) _clr_fwstate_(pmlmepriv, _FW_UNDER_SURVEY); } else { - RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("nic status =%x, survey done event comes too late!\n", get_fwstate(pmlmepriv))); @@ -797,8 +794,8 @@ void rtw_surveydone_event_callback23a(struct rtw_adapter *adapter, u8 *pbuf) } else { DBG_8723A("try_to_join, but select scanning " "queue fail, to_roaming:%d\n", - rtw_to_roaming(adapter)); - if (rtw_to_roaming(adapter) != 0) { + adapter->mlmepriv.to_roaming); + if (adapter->mlmepriv.to_roaming) { if (--pmlmepriv->to_roaming == 0 || rtw_sitesurvey_cmd23a( adapter, @@ -964,11 +961,11 @@ void rtw_indicate_disconnect23a(struct rtw_adapter *padapter) /* DBG_8723A("clear wps when %s\n", __func__); */ - if (rtw_to_roaming(padapter) > 0) + if (padapter->mlmepriv.to_roaming > 0) _clr_fwstate_(pmlmepriv, _FW_LINKED); if (check_fwstate(&padapter->mlmepriv, _FW_LINKED) || - rtw_to_roaming(padapter) <= 0) { + padapter->mlmepriv.to_roaming <= 0) { rtw_os_indicate_disconnect23a(padapter); /* set ips_deny_time to avoid enter IPS before LPS leave */ @@ -1464,11 +1461,11 @@ void rtw_stadel_event_callback23a(struct rtw_adapter *adapter, u8 *pbuf) spin_lock_bh(&pmlmepriv->lock); if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)) { - if (rtw_to_roaming(adapter) > 0) { + if (adapter->mlmepriv.to_roaming > 0) { /* this stadel_event is caused by roaming, decrease to_roaming */ pmlmepriv->to_roaming--; - } else if (rtw_to_roaming(adapter) == 0) + } else if (adapter->mlmepriv.to_roaming == 0) rtw_set_roaming(adapter, adapter->registrypriv.max_roaming_times); if (*((u16 *)pstadel->rsvd) != WLAN_REASON_EXPIRATION_CHK) rtw_set_roaming(adapter, 0); /* don't roam */ @@ -1567,10 +1564,12 @@ void rtw23a_join_to_handler (unsigned long data) spin_lock_bh(&pmlmepriv->lock); - if (rtw_to_roaming(adapter) > 0) { /* join timeout caused by roaming */ + if (adapter->mlmepriv.to_roaming > 0) { + /* join timeout caused by roaming */ while (1) { pmlmepriv->to_roaming--; - if (rtw_to_roaming(adapter) != 0) { /* try another */ + if (adapter->mlmepriv.to_roaming != 0) { + /* try another */ DBG_8723A("%s try another roaming\n", __func__); do_join_r = rtw_do_join23a(adapter); if (do_join_r != _SUCCESS) { @@ -1730,7 +1729,7 @@ static int rtw_check_join_candidate(struct mlme_priv *pmlmepriv, if (rtw_is_desired_network(adapter, competitor) == false) goto exit; - if (rtw_to_roaming(adapter) > 0) { + if (adapter->mlmepriv.to_roaming > 0) { unsigned int passed; passed = jiffies_to_msecs(jiffies - competitor->last_scanned); @@ -1751,7 +1750,7 @@ static int rtw_check_join_candidate(struct mlme_priv *pmlmepriv, "new candidate: %s("MAC_FMT") rssi:%d\n", pmlmepriv->assoc_by_bssid, pmlmepriv->assoc_ssid.ssid, - rtw_to_roaming(adapter), + adapter->mlmepriv.to_roaming, (*candidate)->network.Ssid.ssid, MAC_ARG((*candidate)->network.MacAddress), (int)(*candidate)->network.Rssi); @@ -2474,11 +2473,6 @@ inline void rtw_set_roaming(struct rtw_adapter *adapter, u8 to_roaming) adapter->mlmepriv.to_roaming = to_roaming; } -inline u8 rtw_to_roaming(struct rtw_adapter *adapter) -{ - return adapter->mlmepriv.to_roaming; -} - void rtw23a_roaming(struct rtw_adapter *padapter, struct wlan_network *tgt_network) { @@ -2500,7 +2494,7 @@ void _rtw23a_roaming(struct rtw_adapter *padapter, else pnetwork = &pmlmepriv->cur_network; - if (0 < rtw_to_roaming(padapter)) { + if (padapter->mlmepriv.to_roaming > 0) { DBG_8723A("roaming from %s("MAC_FMT"), length:%d\n", pnetwork->network.Ssid.ssid, MAC_ARG(pnetwork->network.MacAddress), @@ -2519,7 +2513,7 @@ void _rtw23a_roaming(struct rtw_adapter *padapter, do_join_r); pmlmepriv->to_roaming--; - if (0 < rtw_to_roaming(padapter)) + if (padapter->mlmepriv.to_roaming > 0) continue; else { DBG_8723A("%s(%d) -to roaming fail, " @@ -2535,12 +2529,13 @@ void _rtw23a_roaming(struct rtw_adapter *padapter, int rtw_linked_check(struct rtw_adapter *padapter) { - if ((check_fwstate(&padapter->mlmepriv, WIFI_AP_STATE)) || - (check_fwstate(&padapter->mlmepriv, WIFI_ADHOC_STATE|WIFI_ADHOC_MASTER_STATE))) { + if (check_fwstate(&padapter->mlmepriv, WIFI_AP_STATE) || + check_fwstate(&padapter->mlmepriv, + WIFI_ADHOC_STATE|WIFI_ADHOC_MASTER_STATE)) { if (padapter->stapriv.asoc_sta_count > 2) return true; } else { /* Station mode */ - if (check_fwstate(&padapter->mlmepriv, _FW_LINKED) == true) + if (check_fwstate(&padapter->mlmepriv, _FW_LINKED)) return true; } return false; diff --git a/drivers/staging/rtl8723au/include/rtw_mlme.h b/drivers/staging/rtl8723au/include/rtw_mlme.h index 0b48b05fc1ad..d4b43bdeeefc 100644 --- a/drivers/staging/rtl8723au/include/rtw_mlme.h +++ b/drivers/staging/rtl8723au/include/rtw_mlme.h @@ -494,6 +494,5 @@ void _rtw23a_roaming(struct rtw_adapter *adapter, void rtw23a_roaming(struct rtw_adapter *adapter, struct wlan_network *tgt_network); void rtw_set_roaming(struct rtw_adapter *adapter, u8 to_roaming); -u8 rtw_to_roaming(struct rtw_adapter *adapter); #endif /* __RTL871X_MLME_H_ */ diff --git a/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c b/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c index cf44d295b66a..4f4d69c742b1 100644 --- a/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c +++ b/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c @@ -366,7 +366,7 @@ void rtw_cfg80211_indicate_connect(struct rtw_adapter *padapter) if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) return; - if (rtw_to_roaming(padapter) > 0) { + if (padapter->mlmepriv.to_roaming > 0) { struct wiphy *wiphy = pwdev->wiphy; struct ieee80211_channel *notify_channel; u32 freq; -- cgit v1.2.3 From e418361c5bdc7e24dffab2460c873c1efd53a5f8 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:44:47 +0200 Subject: staging: rtl8723au: Fold _rtw_free_mlme_priv23a() into rtw_free_mlme_priv23a() Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme.c b/drivers/staging/rtl8723au/core/rtw_mlme.c index 34d2164f1dd8..14c4196e7d1f 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme.c @@ -121,8 +121,11 @@ void rtw23a_free_mlme_priv_ie_data(struct mlme_priv *pmlmepriv) #endif } -void _rtw_free_mlme_priv23a(struct mlme_priv *pmlmepriv) +void rtw_free_mlme_priv23a(struct mlme_priv *pmlmepriv) { + RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, + ("rtw_free_mlme_priv23a\n")); + rtw23a_free_mlme_priv_ie_data(pmlmepriv); } @@ -301,13 +304,6 @@ int rtw_init_mlme_priv23a (struct rtw_adapter *padapter) return res; } -void rtw_free_mlme_priv23a (struct mlme_priv *pmlmepriv) -{ - RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, - ("rtw_free_mlme_priv23a\n")); - _rtw_free_mlme_priv23a(pmlmepriv); -} - void rtw_free_network(struct mlme_priv *pmlmepriv, struct wlan_network *pnetwork, u8 is_freeall) { -- cgit v1.2.3 From 7ca9ed219b48dbeaabf1f8f6092cfc58a259550c Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:44:48 +0200 Subject: staging: rtl8723au: Remove unused function rtw_get_timestampe_from_ie23a() Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme.c | 5 ----- drivers/staging/rtl8723au/include/rtw_mlme.h | 1 - drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c | 1 - 3 files changed, 7 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme.c b/drivers/staging/rtl8723au/core/rtw_mlme.c index 14c4196e7d1f..0a2141bd32d9 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme.c @@ -285,11 +285,6 @@ u16 rtw_get_capability23a(struct wlan_bssid_ex *bss) return le16_to_cpu(val); } -u8 *rtw_get_timestampe_from_ie23a(u8 *ie) -{ - return ie + 0; -} - u8 *rtw_get_beacon_interval23a_from_ie(u8 *ie) { return ie + 8; diff --git a/drivers/staging/rtl8723au/include/rtw_mlme.h b/drivers/staging/rtl8723au/include/rtw_mlme.h index d4b43bdeeefc..0af91d02976f 100644 --- a/drivers/staging/rtl8723au/include/rtw_mlme.h +++ b/drivers/staging/rtl8723au/include/rtw_mlme.h @@ -472,7 +472,6 @@ int rtw_if_up23a(struct rtw_adapter *padapter); int rtw_linked_check(struct rtw_adapter *padapter); u8 *rtw_get_capability23a_from_ie(u8 *ie); -u8 *rtw_get_timestampe_from_ie23a(u8 *ie); u8 *rtw_get_beacon_interval23a_from_ie(u8 *ie); diff --git a/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c b/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c index 4f4d69c742b1..5dbe3f43ab0e 100644 --- a/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c +++ b/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c @@ -288,7 +288,6 @@ static int rtw_cfg80211_inform_bss(struct rtw_adapter *padapter, notify_channel = ieee80211_get_channel(wiphy, freq); - /* rtw_get_timestampe_from_ie23a() */ notify_timestamp = jiffies_to_msecs(jiffies) * 1000; /* uSec */ notify_interval = -- cgit v1.2.3 From d944b7218b1f51ec5ae1a9346dcaa29fe31f31ac Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:44:49 +0200 Subject: staging: rtl8723au: collect_bss_info23a(): Use struct ieee80211_mgmt Somplify code by using struct ieee80211_mgmt to calculate offsets Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 52 +++++++++++++-------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c index 31022f2508c3..68991dca1cbf 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme_ext.c @@ -4471,15 +4471,14 @@ u8 collect_bss_info23a(struct rtw_adapter *padapter, { int i, length; const u8 *p; - u16 val16; struct sk_buff *skb = precv_frame->pkt; - struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; - u8 *pframe = skb->data; + struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *) skb->data; int packet_len = skb->len; u8 ie_offset; struct registry_priv *pregistrypriv = &padapter->registrypriv; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; + u16 capab_info; length = packet_len - sizeof(struct ieee80211_hdr_3addr); @@ -4490,29 +4489,32 @@ u8 collect_bss_info23a(struct rtw_adapter *padapter, memset(bssid, 0, sizeof(struct wlan_bssid_ex)); - if (ieee80211_is_beacon(hdr->frame_control)) { + if (ieee80211_is_beacon(mgmt->frame_control)) { bssid->reserved = 1; - ie_offset = _BEACON_IE_OFFSET_; + ie_offset = offsetof(struct ieee80211_mgmt, u.beacon.variable); + capab_info = mgmt->u.beacon.capab_info; + } else if (ieee80211_is_probe_req(mgmt->frame_control)) { + ie_offset = offsetof(struct ieee80211_mgmt, + u.probe_req.variable); + bssid->reserved = 2; + capab_info = 0; + } else if (ieee80211_is_probe_resp(mgmt->frame_control)) { + ie_offset = offsetof(struct ieee80211_mgmt, + u.probe_resp.variable); + bssid->reserved = 3; + capab_info = mgmt->u.probe_resp.capab_info; } else { - /* FIXME : more type */ - if (ieee80211_is_probe_req(hdr->frame_control)) { - ie_offset = _PROBEREQ_IE_OFFSET_; - bssid->reserved = 2; - } else if (ieee80211_is_probe_resp(hdr->frame_control)) { - ie_offset = _PROBERSP_IE_OFFSET_; - bssid->reserved = 3; - } else { - bssid->reserved = 0; - ie_offset = _FIXED_IE_LENGTH_; - } + bssid->reserved = 0; + ie_offset = offsetof(struct ieee80211_mgmt, u.beacon.variable); + capab_info = mgmt->u.beacon.capab_info; } + ie_offset -= offsetof(struct ieee80211_mgmt, u); bssid->Length = sizeof(struct wlan_bssid_ex) - MAX_IE_SZ + length; /* below is to copy the information element */ bssid->IELength = length; - memcpy(bssid->IEs, pframe + sizeof(struct ieee80211_hdr_3addr), - bssid->IELength); + memcpy(bssid->IEs, &mgmt->u, bssid->IELength); /* get the signal strength */ /* in dBM.raw data */ @@ -4596,10 +4598,10 @@ u8 collect_bss_info23a(struct rtw_adapter *padapter, } } - if (ieee80211_is_probe_req(hdr->frame_control)) { + if (ieee80211_is_probe_req(mgmt->frame_control)) { /* FIXME */ bssid->InfrastructureMode = Ndis802_11Infrastructure; - ether_addr_copy(bssid->MacAddress, hdr->addr2); + ether_addr_copy(bssid->MacAddress, mgmt->sa); bssid->Privacy = 1; return _SUCCESS; } @@ -4609,17 +4611,15 @@ u8 collect_bss_info23a(struct rtw_adapter *padapter, bssid->Configuration.BeaconPeriod = le32_to_cpu(bssid->Configuration.BeaconPeriod); - val16 = rtw_get_capability23a(bssid); - - if (val16 & BIT(0)) { + if (capab_info & BIT(0)) { bssid->InfrastructureMode = Ndis802_11Infrastructure; - ether_addr_copy(bssid->MacAddress, hdr->addr2); + ether_addr_copy(bssid->MacAddress, mgmt->sa); } else { bssid->InfrastructureMode = Ndis802_11IBSS; - ether_addr_copy(bssid->MacAddress, hdr->addr3); + ether_addr_copy(bssid->MacAddress, mgmt->bssid); } - if (val16 & BIT(4)) + if (capab_info & BIT(4)) bssid->Privacy = 1; else bssid->Privacy = 0; -- cgit v1.2.3 From afa7e480a9587b1b7f35cc2d08bae7c441dc8bc8 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:44:50 +0200 Subject: staging: rtl8723au: Move rtw23a_roaming() so we can declare _rtw_roaming() static Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme.c | 111 ++++++++++++++------------- drivers/staging/rtl8723au/include/rtw_mlme.h | 2 - 2 files changed, 56 insertions(+), 57 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme.c b/drivers/staging/rtl8723au/core/rtw_mlme.c index 0a2141bd32d9..fcb1add545bf 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme.c @@ -271,6 +271,61 @@ void rtw_generate_random_ibss23a(u8* pibss) return; } +static void _rtw_roaming(struct rtw_adapter *padapter, + struct wlan_network *tgt_network) +{ + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct wlan_network *pnetwork; + int do_join_r; + + if (tgt_network) + pnetwork = tgt_network; + else + pnetwork = &pmlmepriv->cur_network; + + if (padapter->mlmepriv.to_roaming > 0) { + DBG_8723A("roaming from %s("MAC_FMT"), length:%d\n", + pnetwork->network.Ssid.ssid, + MAC_ARG(pnetwork->network.MacAddress), + pnetwork->network.Ssid.ssid_len); + memcpy(&pmlmepriv->assoc_ssid, &pnetwork->network.Ssid, + sizeof(struct cfg80211_ssid)); + + pmlmepriv->assoc_by_bssid = false; + + while (1) { + do_join_r = rtw_do_join23a(padapter); + if (do_join_r == _SUCCESS) + break; + else { + DBG_8723A("roaming do_join return %d\n", + do_join_r); + pmlmepriv->to_roaming--; + + if (padapter->mlmepriv.to_roaming > 0) + continue; + else { + DBG_8723A("%s(%d) -to roaming fail, " + "indicate_disconnect\n", + __func__, __LINE__); + rtw_indicate_disconnect23a(padapter); + break; + } + } + } + } +} + +void rtw23a_roaming(struct rtw_adapter *padapter, + struct wlan_network *tgt_network) +{ + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + + spin_lock_bh(&pmlmepriv->lock); + _rtw_roaming(padapter, tgt_network); + spin_unlock_bh(&pmlmepriv->lock); +} + u8 *rtw_get_capability23a_from_ie(u8 *ie) { return ie + 8 + 2; @@ -1475,7 +1530,7 @@ void rtw_stadel_event_callback23a(struct rtw_adapter *adapter, u8 *pbuf) } spin_unlock_bh(&pmlmepriv->scanned_queue.lock); - _rtw23a_roaming(adapter, tgt_network); + _rtw_roaming(adapter, tgt_network); } if (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) || @@ -2464,60 +2519,6 @@ inline void rtw_set_roaming(struct rtw_adapter *adapter, u8 to_roaming) adapter->mlmepriv.to_roaming = to_roaming; } -void rtw23a_roaming(struct rtw_adapter *padapter, - struct wlan_network *tgt_network) -{ - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - - spin_lock_bh(&pmlmepriv->lock); - _rtw23a_roaming(padapter, tgt_network); - spin_unlock_bh(&pmlmepriv->lock); -} -void _rtw23a_roaming(struct rtw_adapter *padapter, - struct wlan_network *tgt_network) -{ - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct wlan_network *pnetwork; - int do_join_r; - - if (tgt_network) - pnetwork = tgt_network; - else - pnetwork = &pmlmepriv->cur_network; - - if (padapter->mlmepriv.to_roaming > 0) { - DBG_8723A("roaming from %s("MAC_FMT"), length:%d\n", - pnetwork->network.Ssid.ssid, - MAC_ARG(pnetwork->network.MacAddress), - pnetwork->network.Ssid.ssid_len); - memcpy(&pmlmepriv->assoc_ssid, &pnetwork->network.Ssid, - sizeof(struct cfg80211_ssid)); - - pmlmepriv->assoc_by_bssid = false; - - while (1) { - do_join_r = rtw_do_join23a(padapter); - if (do_join_r == _SUCCESS) - break; - else { - DBG_8723A("roaming do_join return %d\n", - do_join_r); - pmlmepriv->to_roaming--; - - if (padapter->mlmepriv.to_roaming > 0) - continue; - else { - DBG_8723A("%s(%d) -to roaming fail, " - "indicate_disconnect\n", - __func__, __LINE__); - rtw_indicate_disconnect23a(padapter); - break; - } - } - } - } -} - int rtw_linked_check(struct rtw_adapter *padapter) { if (check_fwstate(&padapter->mlmepriv, WIFI_AP_STATE) || diff --git a/drivers/staging/rtl8723au/include/rtw_mlme.h b/drivers/staging/rtl8723au/include/rtw_mlme.h index 0af91d02976f..6036503c00ea 100644 --- a/drivers/staging/rtl8723au/include/rtw_mlme.h +++ b/drivers/staging/rtl8723au/include/rtw_mlme.h @@ -488,8 +488,6 @@ int rtw_is_same_ibss23a(struct rtw_adapter *adapter, struct wlan_network *pnetwork); int is_same_network23a(struct wlan_bssid_ex *src, struct wlan_bssid_ex *dst); -void _rtw23a_roaming(struct rtw_adapter *adapter, - struct wlan_network *tgt_network); void rtw23a_roaming(struct rtw_adapter *adapter, struct wlan_network *tgt_network); void rtw_set_roaming(struct rtw_adapter *adapter, u8 to_roaming); -- cgit v1.2.3 From a9339fdd13d69b782dfaaa26e3122fac23e4fac5 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:44:51 +0200 Subject: staging: rtl8723au: Remove bogus inline from rtw_set_roaming() prototype Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme.c b/drivers/staging/rtl8723au/core/rtw_mlme.c index fcb1add545bf..e207f477b449 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme.c @@ -271,6 +271,13 @@ void rtw_generate_random_ibss23a(u8* pibss) return; } +void rtw_set_roaming(struct rtw_adapter *adapter, u8 to_roaming) +{ + if (to_roaming == 0) + adapter->mlmepriv.to_join = false; + adapter->mlmepriv.to_roaming = to_roaming; +} + static void _rtw_roaming(struct rtw_adapter *padapter, struct wlan_network *tgt_network) { @@ -2512,13 +2519,6 @@ void rtw_issue_addbareq_cmd23a(struct rtw_adapter *padapter, } } -inline void rtw_set_roaming(struct rtw_adapter *adapter, u8 to_roaming) -{ - if (to_roaming == 0) - adapter->mlmepriv.to_join = false; - adapter->mlmepriv.to_roaming = to_roaming; -} - int rtw_linked_check(struct rtw_adapter *padapter) { if (check_fwstate(&padapter->mlmepriv, WIFI_AP_STATE) || -- cgit v1.2.3 From dff222670ebebf1a7f147a23ccb5fc0312f2ae7e Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 15 Apr 2014 19:44:52 +0200 Subject: staging: rtl8723au: Make _rtw_free_network23() static Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723au/core/rtw_mlme.c | 4 ++-- drivers/staging/rtl8723au/include/rtw_mlme.h | 2 -- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_mlme.c b/drivers/staging/rtl8723au/core/rtw_mlme.c index e207f477b449..4d21d623070e 100644 --- a/drivers/staging/rtl8723au/core/rtw_mlme.c +++ b/drivers/staging/rtl8723au/core/rtw_mlme.c @@ -146,8 +146,8 @@ struct wlan_network *rtw_alloc_network(struct mlme_priv *pmlmepriv) return pnetwork; } -void _rtw_free_network23a(struct mlme_priv *pmlmepriv, - struct wlan_network *pnetwork, u8 isfreeall) +static void _rtw_free_network23a(struct mlme_priv *pmlmepriv, + struct wlan_network *pnetwork, u8 isfreeall) { u32 lifetime = SCANQUEUE_LIFETIME; diff --git a/drivers/staging/rtl8723au/include/rtw_mlme.h b/drivers/staging/rtl8723au/include/rtw_mlme.h index 6036503c00ea..3d6f7307e41e 100644 --- a/drivers/staging/rtl8723au/include/rtw_mlme.h +++ b/drivers/staging/rtl8723au/include/rtw_mlme.h @@ -458,8 +458,6 @@ void _rtw_free_mlme_priv23a(struct mlme_priv *pmlmepriv); struct wlan_network *rtw_alloc_network(struct mlme_priv *pmlmepriv); -void _rtw_free_network23a(struct mlme_priv *pmlmepriv, - struct wlan_network *pnetwork, u8 isfreeall); void _rtw_free_network23a_nolock23a(struct mlme_priv *pmlmepriv, struct wlan_network *pnetwork); -- cgit v1.2.3 From b4f42e2831ff9b9fa19252265d7c8985d47eefb9 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Thu, 10 Apr 2014 09:46:28 -0600 Subject: block: remove struct request buffer member This was used in the olden days, back when onions were proper yellow. Basically it mapped to the current buffer to be transferred. With highmem being added more than a decade ago, most drivers map pages out of a bio, and rq->buffer isn't pointing at anything valid. Convert old style drivers to just use bio_data(). For the discard payload use case, just reference the page in the bio. Signed-off-by: Jens Axboe --- block/blk-core.c | 21 ++++++--------------- block/blk-map.c | 3 --- drivers/block/amiflop.c | 2 +- drivers/block/ataflop.c | 2 +- drivers/block/floppy.c | 18 +++++++++--------- drivers/block/hd.c | 10 +++++----- drivers/block/mg_disk.c | 12 ++++++------ drivers/block/paride/pcd.c | 2 +- drivers/block/paride/pd.c | 4 ++-- drivers/block/paride/pf.c | 4 ++-- drivers/block/skd_main.c | 5 ++--- drivers/block/swim.c | 2 +- drivers/block/swim3.c | 6 +++--- drivers/block/xen-blkfront.c | 4 ++-- drivers/block/xsysace.c | 4 ++-- drivers/block/z2ram.c | 6 ++++-- drivers/ide/ide-disk.c | 5 ++--- drivers/md/dm.c | 1 - drivers/mtd/mtd_blkdevs.c | 3 +-- drivers/mtd/ubi/block.c | 2 +- drivers/scsi/scsi_lib.c | 3 --- drivers/scsi/sd.c | 10 ++++------ include/linux/blkdev.h | 1 - 23 files changed, 55 insertions(+), 75 deletions(-) diff --git a/block/blk-core.c b/block/blk-core.c index 1fe9ff6e6802..ae6227fd07aa 100644 --- a/block/blk-core.c +++ b/block/blk-core.c @@ -146,8 +146,8 @@ void blk_dump_rq_flags(struct request *rq, char *msg) printk(KERN_INFO " sector %llu, nr/cnr %u/%u\n", (unsigned long long)blk_rq_pos(rq), blk_rq_sectors(rq), blk_rq_cur_sectors(rq)); - printk(KERN_INFO " bio %p, biotail %p, buffer %p, len %u\n", - rq->bio, rq->biotail, rq->buffer, blk_rq_bytes(rq)); + printk(KERN_INFO " bio %p, biotail %p, len %u\n", + rq->bio, rq->biotail, blk_rq_bytes(rq)); if (rq->cmd_type == REQ_TYPE_BLOCK_PC) { printk(KERN_INFO " cdb: "); @@ -1360,7 +1360,6 @@ void blk_add_request_payload(struct request *rq, struct page *page, rq->__data_len = rq->resid_len = len; rq->nr_phys_segments = 1; - rq->buffer = bio_data(bio); } EXPORT_SYMBOL_GPL(blk_add_request_payload); @@ -1402,12 +1401,6 @@ bool bio_attempt_front_merge(struct request_queue *q, struct request *req, bio->bi_next = req->bio; req->bio = bio; - /* - * may not be valid. if the low level driver said - * it didn't need a bounce buffer then it better - * not touch req->buffer either... - */ - req->buffer = bio_data(bio); req->__sector = bio->bi_iter.bi_sector; req->__data_len += bio->bi_iter.bi_size; req->ioprio = ioprio_best(req->ioprio, bio_prio(bio)); @@ -2434,7 +2427,6 @@ bool blk_update_request(struct request *req, int error, unsigned int nr_bytes) } req->__data_len -= total_bytes; - req->buffer = bio_data(req->bio); /* update sector only for requests with clear definition of sector */ if (req->cmd_type == REQ_TYPE_FS) @@ -2752,10 +2744,9 @@ void blk_rq_bio_prep(struct request_queue *q, struct request *rq, /* Bit 0 (R/W) is identical in rq->cmd_flags and bio->bi_rw */ rq->cmd_flags |= bio->bi_rw & REQ_WRITE; - if (bio_has_data(bio)) { + if (bio_has_data(bio)) rq->nr_phys_segments = bio_phys_segments(q, bio); - rq->buffer = bio_data(bio); - } + rq->__data_len = bio->bi_iter.bi_size; rq->bio = rq->biotail = bio; @@ -2831,7 +2822,7 @@ EXPORT_SYMBOL_GPL(blk_rq_unprep_clone); /* * Copy attributes of the original request to the clone request. - * The actual data parts (e.g. ->cmd, ->buffer, ->sense) are not copied. + * The actual data parts (e.g. ->cmd, ->sense) are not copied. */ static void __blk_rq_prep_clone(struct request *dst, struct request *src) { @@ -2857,7 +2848,7 @@ static void __blk_rq_prep_clone(struct request *dst, struct request *src) * * Description: * Clones bios in @rq_src to @rq, and copies attributes of @rq_src to @rq. - * The actual data parts of @rq_src (e.g. ->cmd, ->buffer, ->sense) + * The actual data parts of @rq_src (e.g. ->cmd, ->sense) * are not copied, and copying such parts is the caller's responsibility. * Also, pages which the original bios are pointing to are not copied * and the cloned bios just point same pages. diff --git a/block/blk-map.c b/block/blk-map.c index f7b22bc21518..f890d4345b0c 100644 --- a/block/blk-map.c +++ b/block/blk-map.c @@ -155,7 +155,6 @@ int blk_rq_map_user(struct request_queue *q, struct request *rq, if (!bio_flagged(bio, BIO_USER_MAPPED)) rq->cmd_flags |= REQ_COPY_USER; - rq->buffer = NULL; return 0; unmap_rq: blk_rq_unmap_user(bio); @@ -238,7 +237,6 @@ int blk_rq_map_user_iov(struct request_queue *q, struct request *rq, blk_queue_bounce(q, &bio); bio_get(bio); blk_rq_bio_prep(q, rq, bio); - rq->buffer = NULL; return 0; } EXPORT_SYMBOL(blk_rq_map_user_iov); @@ -325,7 +323,6 @@ int blk_rq_map_kern(struct request_queue *q, struct request *rq, void *kbuf, } blk_queue_bounce(q, &rq->bio); - rq->buffer = NULL; return 0; } EXPORT_SYMBOL(blk_rq_map_kern); diff --git a/drivers/block/amiflop.c b/drivers/block/amiflop.c index 748dea4f34dc..758da2287d9a 100644 --- a/drivers/block/amiflop.c +++ b/drivers/block/amiflop.c @@ -1406,7 +1406,7 @@ next_segment: track = block / (floppy->dtype->sects * floppy->type->sect_mult); sector = block % (floppy->dtype->sects * floppy->type->sect_mult); - data = rq->buffer + 512 * cnt; + data = bio_data(rq->bio) + 512 * cnt; #ifdef DEBUG printk("access to track %d, sector %d, with buffer at " "0x%08lx\n", track, sector, data); diff --git a/drivers/block/ataflop.c b/drivers/block/ataflop.c index 96b629e1f0c9..7e8a55f8917c 100644 --- a/drivers/block/ataflop.c +++ b/drivers/block/ataflop.c @@ -1484,7 +1484,7 @@ repeat: ReqCnt = 0; ReqCmd = rq_data_dir(fd_request); ReqBlock = blk_rq_pos(fd_request); - ReqBuffer = fd_request->buffer; + ReqBuffer = bio_data(fd_request->bio); setup_req_params( drive ); do_fd_action( drive ); diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c index 8f5565bf34cd..5f69c910c3ac 100644 --- a/drivers/block/floppy.c +++ b/drivers/block/floppy.c @@ -2351,7 +2351,7 @@ static void rw_interrupt(void) } if (CT(COMMAND) != FD_READ || - raw_cmd->kernel_data == current_req->buffer) { + raw_cmd->kernel_data == bio_data(current_req->bio)) { /* transfer directly from buffer */ cont->done(1); } else if (CT(COMMAND) == FD_READ) { @@ -2640,7 +2640,7 @@ static int make_raw_rw_request(void) raw_cmd->flags &= ~FD_RAW_WRITE; raw_cmd->flags |= FD_RAW_READ; COMMAND = FM_MODE(_floppy, FD_READ); - } else if ((unsigned long)current_req->buffer < MAX_DMA_ADDRESS) { + } else if ((unsigned long)bio_data(current_req->bio) < MAX_DMA_ADDRESS) { unsigned long dma_limit; int direct, indirect; @@ -2654,13 +2654,13 @@ static int make_raw_rw_request(void) */ max_size = buffer_chain_size(); dma_limit = (MAX_DMA_ADDRESS - - ((unsigned long)current_req->buffer)) >> 9; + ((unsigned long)bio_data(current_req->bio))) >> 9; if ((unsigned long)max_size > dma_limit) max_size = dma_limit; /* 64 kb boundaries */ - if (CROSS_64KB(current_req->buffer, max_size << 9)) + if (CROSS_64KB(bio_data(current_req->bio), max_size << 9)) max_size = (K_64 - - ((unsigned long)current_req->buffer) % + ((unsigned long)bio_data(current_req->bio)) % K_64) >> 9; direct = transfer_size(ssize, max_sector, max_size) - fsector_t; /* @@ -2677,7 +2677,7 @@ static int make_raw_rw_request(void) (DP->read_track & (1 << DRS->probed_format)))))) { max_size = blk_rq_sectors(current_req); } else { - raw_cmd->kernel_data = current_req->buffer; + raw_cmd->kernel_data = bio_data(current_req->bio); raw_cmd->length = current_count_sectors << 9; if (raw_cmd->length == 0) { DPRINT("%s: zero dma transfer attempted\n", __func__); @@ -2731,7 +2731,7 @@ static int make_raw_rw_request(void) raw_cmd->length = ((raw_cmd->length - 1) | (ssize - 1)) + 1; raw_cmd->length <<= 9; if ((raw_cmd->length < current_count_sectors << 9) || - (raw_cmd->kernel_data != current_req->buffer && + (raw_cmd->kernel_data != bio_data(current_req->bio) && CT(COMMAND) == FD_WRITE && (aligned_sector_t + (raw_cmd->length >> 9) > buffer_max || aligned_sector_t < buffer_min)) || @@ -2739,7 +2739,7 @@ static int make_raw_rw_request(void) raw_cmd->length <= 0 || current_count_sectors <= 0) { DPRINT("fractionary current count b=%lx s=%lx\n", raw_cmd->length, current_count_sectors); - if (raw_cmd->kernel_data != current_req->buffer) + if (raw_cmd->kernel_data != bio_data(current_req->bio)) pr_info("addr=%d, length=%ld\n", (int)((raw_cmd->kernel_data - floppy_track_buffer) >> 9), @@ -2756,7 +2756,7 @@ static int make_raw_rw_request(void) return 0; } - if (raw_cmd->kernel_data != current_req->buffer) { + if (raw_cmd->kernel_data != bio_data(current_req->bio)) { if (raw_cmd->kernel_data < floppy_track_buffer || current_count_sectors < 0 || raw_cmd->length < 0 || diff --git a/drivers/block/hd.c b/drivers/block/hd.c index bf397bf108b7..8a290c08262f 100644 --- a/drivers/block/hd.c +++ b/drivers/block/hd.c @@ -464,11 +464,11 @@ static void read_intr(void) ok_to_read: req = hd_req; - insw(HD_DATA, req->buffer, 256); + insw(HD_DATA, bio_data(req->bio), 256); #ifdef DEBUG printk("%s: read: sector %ld, remaining = %u, buffer=%p\n", req->rq_disk->disk_name, blk_rq_pos(req) + 1, - blk_rq_sectors(req) - 1, req->buffer+512); + blk_rq_sectors(req) - 1, bio_data(req->bio)+512); #endif if (hd_end_request(0, 512)) { SET_HANDLER(&read_intr); @@ -505,7 +505,7 @@ static void write_intr(void) ok_to_write: if (hd_end_request(0, 512)) { SET_HANDLER(&write_intr); - outsw(HD_DATA, req->buffer, 256); + outsw(HD_DATA, bio_data(req->bio), 256); return; } @@ -624,7 +624,7 @@ repeat: printk("%s: %sing: CHS=%d/%d/%d, sectors=%d, buffer=%p\n", req->rq_disk->disk_name, req_data_dir(req) == READ ? "read" : "writ", - cyl, head, sec, nsect, req->buffer); + cyl, head, sec, nsect, bio_data(req->bio)); #endif if (req->cmd_type == REQ_TYPE_FS) { switch (rq_data_dir(req)) { @@ -643,7 +643,7 @@ repeat: bad_rw_intr(); goto repeat; } - outsw(HD_DATA, req->buffer, 256); + outsw(HD_DATA, bio_data(req->bio), 256); break; default: printk("unknown hd-command\n"); diff --git a/drivers/block/mg_disk.c b/drivers/block/mg_disk.c index eb59b1241366..e352cac707e8 100644 --- a/drivers/block/mg_disk.c +++ b/drivers/block/mg_disk.c @@ -479,7 +479,7 @@ static unsigned int mg_out(struct mg_host *host, static void mg_read_one(struct mg_host *host, struct request *req) { - u16 *buff = (u16 *)req->buffer; + u16 *buff = (u16 *)bio_data(req->bio); u32 i; for (i = 0; i < MG_SECTOR_SIZE >> 1; i++) @@ -496,7 +496,7 @@ static void mg_read(struct request *req) mg_bad_rw_intr(host); MG_DBG("requested %d sects (from %ld), buffer=0x%p\n", - blk_rq_sectors(req), blk_rq_pos(req), req->buffer); + blk_rq_sectors(req), blk_rq_pos(req), bio_data(req->bio)); do { if (mg_wait(host, ATA_DRQ, @@ -514,7 +514,7 @@ static void mg_read(struct request *req) static void mg_write_one(struct mg_host *host, struct request *req) { - u16 *buff = (u16 *)req->buffer; + u16 *buff = (u16 *)bio_data(req->bio); u32 i; for (i = 0; i < MG_SECTOR_SIZE >> 1; i++) @@ -534,7 +534,7 @@ static void mg_write(struct request *req) } MG_DBG("requested %d sects (from %ld), buffer=0x%p\n", - rem, blk_rq_pos(req), req->buffer); + rem, blk_rq_pos(req), bio_data(req->bio)); if (mg_wait(host, ATA_DRQ, MG_TMAX_WAIT_WR_DRQ) != MG_ERR_NONE) { @@ -585,7 +585,7 @@ ok_to_read: mg_read_one(host, req); MG_DBG("sector %ld, remaining=%ld, buffer=0x%p\n", - blk_rq_pos(req), blk_rq_sectors(req) - 1, req->buffer); + blk_rq_pos(req), blk_rq_sectors(req) - 1, bio_data(req->bio)); /* send read confirm */ outb(MG_CMD_RD_CONF, (unsigned long)host->dev_base + MG_REG_COMMAND); @@ -624,7 +624,7 @@ ok_to_write: /* write 1 sector and set handler if remains */ mg_write_one(host, req); MG_DBG("sector %ld, remaining=%ld, buffer=0x%p\n", - blk_rq_pos(req), blk_rq_sectors(req), req->buffer); + blk_rq_pos(req), blk_rq_sectors(req), bio_data(req->bio)); host->mg_do_intr = mg_write_intr; mod_timer(&host->timer, jiffies + 3 * HZ); } diff --git a/drivers/block/paride/pcd.c b/drivers/block/paride/pcd.c index e76bdc074dbe..719cb1bc1640 100644 --- a/drivers/block/paride/pcd.c +++ b/drivers/block/paride/pcd.c @@ -747,7 +747,7 @@ static void do_pcd_request(struct request_queue * q) pcd_current = cd; pcd_sector = blk_rq_pos(pcd_req); pcd_count = blk_rq_cur_sectors(pcd_req); - pcd_buf = pcd_req->buffer; + pcd_buf = bio_data(pcd_req->bio); pcd_busy = 1; ps_set_intr(do_pcd_read, NULL, 0, nice); return; diff --git a/drivers/block/paride/pd.c b/drivers/block/paride/pd.c index 19ad8f0c83ef..fea7e76a00de 100644 --- a/drivers/block/paride/pd.c +++ b/drivers/block/paride/pd.c @@ -454,7 +454,7 @@ static enum action do_pd_io_start(void) if (pd_block + pd_count > get_capacity(pd_req->rq_disk)) return Fail; pd_run = blk_rq_sectors(pd_req); - pd_buf = pd_req->buffer; + pd_buf = bio_data(pd_req->bio); pd_retries = 0; if (pd_cmd == READ) return do_pd_read_start(); @@ -485,7 +485,7 @@ static int pd_next_buf(void) spin_lock_irqsave(&pd_lock, saved_flags); __blk_end_request_cur(pd_req, 0); pd_count = blk_rq_cur_sectors(pd_req); - pd_buf = pd_req->buffer; + pd_buf = bio_data(pd_req->bio); spin_unlock_irqrestore(&pd_lock, saved_flags); return 0; } diff --git a/drivers/block/paride/pf.c b/drivers/block/paride/pf.c index f5c86d523ba0..9a15fd3c9349 100644 --- a/drivers/block/paride/pf.c +++ b/drivers/block/paride/pf.c @@ -795,7 +795,7 @@ repeat: } pf_cmd = rq_data_dir(pf_req); - pf_buf = pf_req->buffer; + pf_buf = bio_data(pf_req->bio); pf_retries = 0; pf_busy = 1; @@ -827,7 +827,7 @@ static int pf_next_buf(void) if (!pf_req) return 1; pf_count = blk_rq_cur_sectors(pf_req); - pf_buf = pf_req->buffer; + pf_buf = bio_data(pf_req->bio); } return 0; } diff --git a/drivers/block/skd_main.c b/drivers/block/skd_main.c index a69dd93d1bd5..36bcedfd930c 100644 --- a/drivers/block/skd_main.c +++ b/drivers/block/skd_main.c @@ -563,7 +563,6 @@ skd_prep_discard_cdb(struct skd_scsi_request *scsi_req, req = skreq->req; blk_add_request_payload(req, page, len); - req->buffer = buf; } static void skd_request_fn_not_online(struct request_queue *q); @@ -856,10 +855,10 @@ static void skd_end_request(struct skd_device *skdev, if ((io_flags & REQ_DISCARD) && (skreq->discard_page == 1)) { + struct bio *bio = req->bio; pr_debug("%s:%s:%d, free the page!", skdev->name, __func__, __LINE__); - free_page((unsigned long)req->buffer); - req->buffer = NULL; + __free_page(bio->bi_io_vec->bv_page); } if (unlikely(error)) { diff --git a/drivers/block/swim.c b/drivers/block/swim.c index b02d53a399f3..6b44bbe528b7 100644 --- a/drivers/block/swim.c +++ b/drivers/block/swim.c @@ -549,7 +549,7 @@ static void redo_fd_request(struct request_queue *q) case READ: err = floppy_read_sectors(fs, blk_rq_pos(req), blk_rq_cur_sectors(req), - req->buffer); + bio_data(req->bio)); break; } done: diff --git a/drivers/block/swim3.c b/drivers/block/swim3.c index c74f7b56e7c4..523ee8fd4c15 100644 --- a/drivers/block/swim3.c +++ b/drivers/block/swim3.c @@ -342,7 +342,7 @@ static void start_request(struct floppy_state *fs) swim3_dbg("do_fd_req: dev=%s cmd=%d sec=%ld nr_sec=%u buf=%p\n", req->rq_disk->disk_name, req->cmd, (long)blk_rq_pos(req), blk_rq_sectors(req), - req->buffer); + bio_data(req->bio)); swim3_dbg(" errors=%d current_nr_sectors=%u\n", req->errors, blk_rq_cur_sectors(req)); #endif @@ -479,11 +479,11 @@ static inline void setup_transfer(struct floppy_state *fs) /* Set up 3 dma commands: write preamble, data, postamble */ init_dma(cp, OUTPUT_MORE, write_preamble, sizeof(write_preamble)); ++cp; - init_dma(cp, OUTPUT_MORE, req->buffer, 512); + init_dma(cp, OUTPUT_MORE, bio_data(req->bio), 512); ++cp; init_dma(cp, OUTPUT_LAST, write_postamble, sizeof(write_postamble)); } else { - init_dma(cp, INPUT_LAST, req->buffer, n * 512); + init_dma(cp, INPUT_LAST, bio_data(req->bio), n * 512); } ++cp; out_le16(&cp->command, DBDMA_STOP); diff --git a/drivers/block/xen-blkfront.c b/drivers/block/xen-blkfront.c index efe1b4761735..283a30e88287 100644 --- a/drivers/block/xen-blkfront.c +++ b/drivers/block/xen-blkfront.c @@ -612,10 +612,10 @@ static void do_blkif_request(struct request_queue *rq) } pr_debug("do_blk_req %p: cmd %p, sec %lx, " - "(%u/%u) buffer:%p [%s]\n", + "(%u/%u) [%s]\n", req, req->cmd, (unsigned long)blk_rq_pos(req), blk_rq_cur_sectors(req), blk_rq_sectors(req), - req->buffer, rq_data_dir(req) ? "write" : "read"); + rq_data_dir(req) ? "write" : "read"); if (blkif_queue_request(req)) { blk_requeue_request(rq, req); diff --git a/drivers/block/xsysace.c b/drivers/block/xsysace.c index 1393b8871a28..ab3ea62e5dfc 100644 --- a/drivers/block/xsysace.c +++ b/drivers/block/xsysace.c @@ -661,7 +661,7 @@ static void ace_fsm_dostate(struct ace_device *ace) rq_data_dir(req)); ace->req = req; - ace->data_ptr = req->buffer; + ace->data_ptr = bio_data(req->bio); ace->data_count = blk_rq_cur_sectors(req) * ACE_BUF_PER_SECTOR; ace_out32(ace, ACE_MPULBA, blk_rq_pos(req) & 0x0FFFFFFF); @@ -733,7 +733,7 @@ static void ace_fsm_dostate(struct ace_device *ace) * blk_rq_sectors(ace->req), * blk_rq_cur_sectors(ace->req)); */ - ace->data_ptr = ace->req->buffer; + ace->data_ptr = bio_data(ace->req->bio); ace->data_count = blk_rq_cur_sectors(ace->req) * 16; ace_fsm_yieldirq(ace); break; diff --git a/drivers/block/z2ram.c b/drivers/block/z2ram.c index 27de5046708a..968f9e52effa 100644 --- a/drivers/block/z2ram.c +++ b/drivers/block/z2ram.c @@ -87,13 +87,15 @@ static void do_z2_request(struct request_queue *q) while (len) { unsigned long addr = start & Z2RAM_CHUNKMASK; unsigned long size = Z2RAM_CHUNKSIZE - addr; + void *buffer = bio_data(req->bio); + if (len < size) size = len; addr += z2ram_map[ start >> Z2RAM_CHUNKSHIFT ]; if (rq_data_dir(req) == READ) - memcpy(req->buffer, (char *)addr, size); + memcpy(buffer, (char *)addr, size); else - memcpy((char *)addr, req->buffer, size); + memcpy((char *)addr, buffer, size); start += size; len -= size; } diff --git a/drivers/ide/ide-disk.c b/drivers/ide/ide-disk.c index 16f69be820c7..ee880382e3bc 100644 --- a/drivers/ide/ide-disk.c +++ b/drivers/ide/ide-disk.c @@ -188,10 +188,9 @@ static ide_startstop_t ide_do_rw_disk(ide_drive_t *drive, struct request *rq, ledtrig_ide_activity(); - pr_debug("%s: %sing: block=%llu, sectors=%u, buffer=0x%08lx\n", + pr_debug("%s: %sing: block=%llu, sectors=%u\n", drive->name, rq_data_dir(rq) == READ ? "read" : "writ", - (unsigned long long)block, blk_rq_sectors(rq), - (unsigned long)rq->buffer); + (unsigned long long)block, blk_rq_sectors(rq)); if (hwif->rw_disk) hwif->rw_disk(drive, rq); diff --git a/drivers/md/dm.c b/drivers/md/dm.c index 455e64916498..6a71bc7c9133 100644 --- a/drivers/md/dm.c +++ b/drivers/md/dm.c @@ -1544,7 +1544,6 @@ static int setup_clone(struct request *clone, struct request *rq, clone->cmd = rq->cmd; clone->cmd_len = rq->cmd_len; clone->sense = rq->sense; - clone->buffer = rq->buffer; clone->end_io = end_clone_request; clone->end_io_data = tio; diff --git a/drivers/mtd/mtd_blkdevs.c b/drivers/mtd/mtd_blkdevs.c index 0b2ccb68c0d0..4dbfaee9aa95 100644 --- a/drivers/mtd/mtd_blkdevs.c +++ b/drivers/mtd/mtd_blkdevs.c @@ -82,8 +82,7 @@ static int do_blktrans_request(struct mtd_blktrans_ops *tr, block = blk_rq_pos(req) << 9 >> tr->blkshift; nsect = blk_rq_cur_bytes(req) >> tr->blkshift; - - buf = req->buffer; + buf = bio_data(req->bio); if (req->cmd_type != REQ_TYPE_FS) return -EIO; diff --git a/drivers/mtd/ubi/block.c b/drivers/mtd/ubi/block.c index 7ff473c871a9..ee774ba3728d 100644 --- a/drivers/mtd/ubi/block.c +++ b/drivers/mtd/ubi/block.c @@ -253,7 +253,7 @@ static int do_ubiblock_request(struct ubiblock *dev, struct request *req) * flash access anyway. */ mutex_lock(&dev->dev_mutex); - ret = ubiblock_read(dev, req->buffer, sec, len); + ret = ubiblock_read(dev, bio_data(req->bio), sec, len); mutex_unlock(&dev->dev_mutex); return ret; diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index 0f3bddcb6b1a..3cc82d3dec78 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -1018,8 +1018,6 @@ static int scsi_init_sgtable(struct request *req, struct scsi_data_buffer *sdb, return BLKPREP_DEFER; } - req->buffer = NULL; - /* * Next, walk the list, and fill in the addresses and sizes of * each segment. @@ -1156,7 +1154,6 @@ int scsi_setup_blk_pc_cmnd(struct scsi_device *sdev, struct request *req) BUG_ON(blk_rq_bytes(req)); memset(&cmd->sdb, 0, sizeof(cmd->sdb)); - req->buffer = NULL; } cmd->cmd_len = req->cmd_len; diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index efcbcd182863..06d154d20faa 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -739,14 +739,11 @@ static int sd_setup_discard_cmnd(struct scsi_device *sdp, struct request *rq) blk_add_request_payload(rq, page, len); ret = scsi_setup_blk_pc_cmnd(sdp, rq); - rq->buffer = page_address(page); rq->__data_len = nr_bytes; out: - if (ret != BLKPREP_OK) { + if (ret != BLKPREP_OK) __free_page(page); - rq->buffer = NULL; - } return ret; } @@ -843,8 +840,9 @@ static void sd_unprep_fn(struct request_queue *q, struct request *rq) struct scsi_cmnd *SCpnt = rq->special; if (rq->cmd_flags & REQ_DISCARD) { - free_page((unsigned long)rq->buffer); - rq->buffer = NULL; + struct bio *bio = rq->bio; + + __free_page(bio->bi_io_vec->bv_page); } if (SCpnt->cmnd != rq->cmd) { mempool_free(SCpnt->cmnd, sd_cdb_pool); diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index 86a8df13a5fe..eb5e94803892 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -178,7 +178,6 @@ struct request { unsigned short ioprio; void *special; /* opaque pointer available for LLD use */ - char *buffer; /* kaddr of the current segment if available */ int tag; int errors; -- cgit v1.2.3 From 742ee69b92d9559e968f70cf0a49157866f8fbef Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Mon, 14 Apr 2014 10:30:06 +0200 Subject: blk-mq: initialize resid_len Signed-off-by: Christoph Hellwig Signed-off-by: Jens Axboe --- block/blk-mq.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/block/blk-mq.c b/block/blk-mq.c index 5455ed19de1c..658428a28faf 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -353,6 +353,8 @@ static void blk_mq_start_request(struct request *rq, bool last) trace_block_rq_issue(q, rq); + rq->resid_len = blk_rq_bytes(rq); + /* * Just mark start time and set the started bit. Due to memory * ordering, we know we'll see the correct deadline as long as -- cgit v1.2.3 From 9d74e25737d73e93ccddeb5a61bcd56b7b8eb57b Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Mon, 14 Apr 2014 10:30:07 +0200 Subject: blk-mq: do not initialize req->special Drivers can reach their private data easily using the blk_mq_rq_to_pdu helper and don't need req->special. By not initializing it code can be simplified nicely, and we also shave off a few more instructions from the I/O path. Signed-off-by: Christoph Hellwig Signed-off-by: Jens Axboe --- block/blk-flush.c | 10 ++-------- block/blk-mq.c | 15 ++------------- block/blk-mq.h | 1 - drivers/block/null_blk.c | 4 ++-- drivers/block/virtio_blk.c | 6 +++--- 5 files changed, 9 insertions(+), 27 deletions(-) diff --git a/block/blk-flush.c b/block/blk-flush.c index 77f20458910c..0e42adcfb55e 100644 --- a/block/blk-flush.c +++ b/block/blk-flush.c @@ -306,22 +306,16 @@ static bool blk_kick_flush(struct request_queue *q) */ q->flush_pending_idx ^= 1; + blk_rq_init(q, q->flush_rq); if (q->mq_ops) { - struct blk_mq_ctx *ctx = first_rq->mq_ctx; - struct blk_mq_hw_ctx *hctx = q->mq_ops->map_queue(q, ctx->cpu); - - blk_mq_rq_init(hctx, q->flush_rq); - q->flush_rq->mq_ctx = ctx; - /* * Reuse the tag value from the fist waiting request, * with blk-mq the tag is generated during request * allocation and drivers can rely on it being inside * the range they asked for. */ + q->flush_rq->mq_ctx = first_rq->mq_ctx; q->flush_rq->tag = first_rq->tag; - } else { - blk_rq_init(q, q->flush_rq); } q->flush_rq->cmd_type = REQ_TYPE_FS; diff --git a/block/blk-mq.c b/block/blk-mq.c index 658428a28faf..d9d0984d2f01 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -251,24 +251,13 @@ struct request *blk_mq_alloc_reserved_request(struct request_queue *q, int rw, } EXPORT_SYMBOL(blk_mq_alloc_reserved_request); -/* - * Re-init and set pdu, if we have it - */ -void blk_mq_rq_init(struct blk_mq_hw_ctx *hctx, struct request *rq) -{ - blk_rq_init(hctx->queue, rq); - - if (hctx->cmd_size) - rq->special = blk_mq_rq_to_pdu(rq); -} - static void __blk_mq_free_request(struct blk_mq_hw_ctx *hctx, struct blk_mq_ctx *ctx, struct request *rq) { const int tag = rq->tag; struct request_queue *q = rq->q; - blk_mq_rq_init(hctx, rq); + blk_rq_init(hctx->queue, rq); blk_mq_put_tag(hctx->tags, tag); blk_mq_queue_exit(q); @@ -1165,7 +1154,7 @@ static int blk_mq_init_rq_map(struct blk_mq_hw_ctx *hctx, left -= to_do * rq_size; for (j = 0; j < to_do; j++) { hctx->rqs[i] = p; - blk_mq_rq_init(hctx, hctx->rqs[i]); + blk_rq_init(hctx->queue, hctx->rqs[i]); p += rq_size; i++; } diff --git a/block/blk-mq.h b/block/blk-mq.h index ebbe6bac9d61..238379a612e4 100644 --- a/block/blk-mq.h +++ b/block/blk-mq.h @@ -27,7 +27,6 @@ void blk_mq_run_hw_queue(struct blk_mq_hw_ctx *hctx, bool async); void blk_mq_init_flush(struct request_queue *q); void blk_mq_drain_queue(struct request_queue *q); void blk_mq_free_queue(struct request_queue *q); -void blk_mq_rq_init(struct blk_mq_hw_ctx *hctx, struct request *rq); /* * CPU hotplug helpers diff --git a/drivers/block/null_blk.c b/drivers/block/null_blk.c index 091b9ea14feb..71df69d90900 100644 --- a/drivers/block/null_blk.c +++ b/drivers/block/null_blk.c @@ -226,7 +226,7 @@ static void null_cmd_end_timer(struct nullb_cmd *cmd) static void null_softirq_done_fn(struct request *rq) { - end_cmd(rq->special); + end_cmd(blk_mq_rq_to_pdu(rq)); } static inline void null_handle_cmd(struct nullb_cmd *cmd) @@ -311,7 +311,7 @@ static void null_request_fn(struct request_queue *q) static int null_queue_rq(struct blk_mq_hw_ctx *hctx, struct request *rq) { - struct nullb_cmd *cmd = rq->special; + struct nullb_cmd *cmd = blk_mq_rq_to_pdu(rq); cmd->rq = rq; cmd->nq = hctx->driver_data; diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c index 6d8a87f252de..c7d02bc9d945 100644 --- a/drivers/block/virtio_blk.c +++ b/drivers/block/virtio_blk.c @@ -112,7 +112,7 @@ static int __virtblk_add_req(struct virtqueue *vq, static inline void virtblk_request_done(struct request *req) { - struct virtblk_req *vbr = req->special; + struct virtblk_req *vbr = blk_mq_rq_to_pdu(req); int error = virtblk_result(vbr); if (req->cmd_type == REQ_TYPE_BLOCK_PC) { @@ -154,7 +154,7 @@ static void virtblk_done(struct virtqueue *vq) static int virtio_queue_rq(struct blk_mq_hw_ctx *hctx, struct request *req) { struct virtio_blk *vblk = hctx->queue->queuedata; - struct virtblk_req *vbr = req->special; + struct virtblk_req *vbr = blk_mq_rq_to_pdu(req); unsigned long flags; unsigned int num; const bool last = (req->cmd_flags & REQ_END) != 0; @@ -501,7 +501,7 @@ static int virtblk_init_vbr(void *data, struct blk_mq_hw_ctx *hctx, struct request *rq, unsigned int nr) { struct virtio_blk *vblk = data; - struct virtblk_req *vbr = rq->special; + struct virtblk_req *vbr = blk_mq_rq_to_pdu(rq); sg_init_table(vbr->sg, vblk->sg_elems); return 0; -- cgit v1.2.3 From 8727af4b9d45c7503042e3fbd926c1a173876e9c Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Mon, 14 Apr 2014 10:30:08 +0200 Subject: blk-mq: make ->flush_rq fully transparent to drivers Drivers shouldn't have to care about the block layer setting aside a request to implement the flush state machine. We already override the mq context and tag to make it more transparent, but so far haven't deal with the driver private data in the request. Make sure to override this as well, and while we're at it add a proper helper sitting in blk-mq.c that implements the full impersonation. Signed-off-by: Christoph Hellwig Signed-off-by: Jens Axboe --- block/blk-flush.c | 12 ++---------- block/blk-mq.c | 20 ++++++++++++++++++++ block/blk-mq.h | 2 ++ 3 files changed, 24 insertions(+), 10 deletions(-) diff --git a/block/blk-flush.c b/block/blk-flush.c index 0e42adcfb55e..c41fc19f75d1 100644 --- a/block/blk-flush.c +++ b/block/blk-flush.c @@ -307,16 +307,8 @@ static bool blk_kick_flush(struct request_queue *q) q->flush_pending_idx ^= 1; blk_rq_init(q, q->flush_rq); - if (q->mq_ops) { - /* - * Reuse the tag value from the fist waiting request, - * with blk-mq the tag is generated during request - * allocation and drivers can rely on it being inside - * the range they asked for. - */ - q->flush_rq->mq_ctx = first_rq->mq_ctx; - q->flush_rq->tag = first_rq->tag; - } + if (q->mq_ops) + blk_mq_clone_flush_request(q->flush_rq, first_rq); q->flush_rq->cmd_type = REQ_TYPE_FS; q->flush_rq->cmd_flags = WRITE_FLUSH | REQ_FLUSH_SEQ; diff --git a/block/blk-mq.c b/block/blk-mq.c index d9d0984d2f01..e644feec068c 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -275,6 +275,26 @@ void blk_mq_free_request(struct request *rq) __blk_mq_free_request(hctx, ctx, rq); } +/* + * Clone all relevant state from a request that has been put on hold in + * the flush state machine into the preallocated flush request that hangs + * off the request queue. + * + * For a driver the flush request should be invisible, that's why we are + * impersonating the original request here. + */ +void blk_mq_clone_flush_request(struct request *flush_rq, + struct request *orig_rq) +{ + struct blk_mq_hw_ctx *hctx = + orig_rq->q->mq_ops->map_queue(orig_rq->q, orig_rq->mq_ctx->cpu); + + flush_rq->mq_ctx = orig_rq->mq_ctx; + flush_rq->tag = orig_rq->tag; + memcpy(blk_mq_rq_to_pdu(flush_rq), blk_mq_rq_to_pdu(orig_rq), + hctx->cmd_size); +} + bool blk_mq_end_io_partial(struct request *rq, int error, unsigned int nr_bytes) { if (blk_update_request(rq, error, blk_rq_bytes(rq))) diff --git a/block/blk-mq.h b/block/blk-mq.h index 238379a612e4..7964dadb7d64 100644 --- a/block/blk-mq.h +++ b/block/blk-mq.h @@ -27,6 +27,8 @@ void blk_mq_run_hw_queue(struct blk_mq_hw_ctx *hctx, bool async); void blk_mq_init_flush(struct request_queue *q); void blk_mq_drain_queue(struct request_queue *q); void blk_mq_free_queue(struct request_queue *q); +void blk_mq_clone_flush_request(struct request *flush_rq, + struct request *orig_rq); /* * CPU hotplug helpers -- cgit v1.2.3 From e9b267d91f6ddbc694cb40aa962b0b2cec03971d Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Tue, 15 Apr 2014 13:59:10 -0600 Subject: blk-mq: add ->init_request and ->exit_request methods The current blk_mq_init_commands/blk_mq_free_commands interface has a two problems: 1) Because only the constructor is passed to blk_mq_init_commands there is no easy way to clean up when a comman initialization failed. The current code simply leaks the allocations done in the constructor. 2) There is no good place to call blk_mq_free_commands: before blk_cleanup_queue there is no guarantee that all outstanding commands have completed, so we can't free them yet. After blk_cleanup_queue the queue has usually been freed. This can be worked around by grabbing an unconditional reference before calling blk_cleanup_queue and dropping it after blk_mq_free_commands is done, although that's not exatly pretty and driver writers are guaranteed to get it wrong sooner or later. Both issues are easily fixed by making the request constructor and destructor normal blk_mq_ops methods. Signed-off-by: Christoph Hellwig Signed-off-by: Jens Axboe --- block/blk-mq.c | 105 ++++++++++++++------------------------------- drivers/block/virtio_blk.c | 23 +++++----- include/linux/blk-mq.h | 14 +++++- 3 files changed, 55 insertions(+), 87 deletions(-) diff --git a/block/blk-mq.c b/block/blk-mq.c index e644feec068c..48d2d8495f5e 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -1031,74 +1031,20 @@ static void blk_mq_hctx_notify(void *data, unsigned long action, blk_mq_put_ctx(ctx); } -static int blk_mq_init_hw_commands(struct blk_mq_hw_ctx *hctx, - int (*init)(void *, struct blk_mq_hw_ctx *, - struct request *, unsigned int), - void *data) +static void blk_mq_free_rq_map(struct blk_mq_hw_ctx *hctx, void *driver_data) { - unsigned int i; - int ret = 0; - - for (i = 0; i < hctx->queue_depth; i++) { - struct request *rq = hctx->rqs[i]; - - ret = init(data, hctx, rq, i); - if (ret) - break; - } - - return ret; -} - -int blk_mq_init_commands(struct request_queue *q, - int (*init)(void *, struct blk_mq_hw_ctx *, - struct request *, unsigned int), - void *data) -{ - struct blk_mq_hw_ctx *hctx; - unsigned int i; - int ret = 0; - - queue_for_each_hw_ctx(q, hctx, i) { - ret = blk_mq_init_hw_commands(hctx, init, data); - if (ret) - break; - } - - return ret; -} -EXPORT_SYMBOL(blk_mq_init_commands); - -static void blk_mq_free_hw_commands(struct blk_mq_hw_ctx *hctx, - void (*free)(void *, struct blk_mq_hw_ctx *, - struct request *, unsigned int), - void *data) -{ - unsigned int i; + struct page *page; - for (i = 0; i < hctx->queue_depth; i++) { - struct request *rq = hctx->rqs[i]; + if (hctx->rqs && hctx->queue->mq_ops->exit_request) { + int i; - free(data, hctx, rq, i); + for (i = 0; i < hctx->queue_depth; i++) { + if (!hctx->rqs[i]) + continue; + hctx->queue->mq_ops->exit_request(driver_data, hctx, + hctx->rqs[i], i); + } } -} - -void blk_mq_free_commands(struct request_queue *q, - void (*free)(void *, struct blk_mq_hw_ctx *, - struct request *, unsigned int), - void *data) -{ - struct blk_mq_hw_ctx *hctx; - unsigned int i; - - queue_for_each_hw_ctx(q, hctx, i) - blk_mq_free_hw_commands(hctx, free, data); -} -EXPORT_SYMBOL(blk_mq_free_commands); - -static void blk_mq_free_rq_map(struct blk_mq_hw_ctx *hctx) -{ - struct page *page; while (!list_empty(&hctx->page_list)) { page = list_first_entry(&hctx->page_list, struct page, lru); @@ -1123,10 +1069,12 @@ static size_t order_to_size(unsigned int order) } static int blk_mq_init_rq_map(struct blk_mq_hw_ctx *hctx, - unsigned int reserved_tags, int node) + struct blk_mq_reg *reg, void *driver_data, int node) { + unsigned int reserved_tags = reg->reserved_tags; unsigned int i, j, entries_per_page, max_order = 4; size_t rq_size, left; + int error; INIT_LIST_HEAD(&hctx->page_list); @@ -1175,14 +1123,23 @@ static int blk_mq_init_rq_map(struct blk_mq_hw_ctx *hctx, for (j = 0; j < to_do; j++) { hctx->rqs[i] = p; blk_rq_init(hctx->queue, hctx->rqs[i]); + if (reg->ops->init_request) { + error = reg->ops->init_request(driver_data, + hctx, hctx->rqs[i], i); + if (error) + goto err_rq_map; + } + p += rq_size; i++; } } - if (i < (reserved_tags + BLK_MQ_TAG_MIN)) + if (i < (reserved_tags + BLK_MQ_TAG_MIN)) { + error = -ENOMEM; goto err_rq_map; - else if (i != hctx->queue_depth) { + } + if (i != hctx->queue_depth) { hctx->queue_depth = i; pr_warn("%s: queue depth set to %u because of low memory\n", __func__, i); @@ -1190,12 +1147,14 @@ static int blk_mq_init_rq_map(struct blk_mq_hw_ctx *hctx, hctx->tags = blk_mq_init_tags(hctx->queue_depth, reserved_tags, node); if (!hctx->tags) { -err_rq_map: - blk_mq_free_rq_map(hctx); - return -ENOMEM; + error = -ENOMEM; + goto err_rq_map; } return 0; +err_rq_map: + blk_mq_free_rq_map(hctx, driver_data); + return error; } static int blk_mq_init_hw_queues(struct request_queue *q, @@ -1228,7 +1187,7 @@ static int blk_mq_init_hw_queues(struct request_queue *q, blk_mq_hctx_notify, hctx); blk_mq_register_cpu_notifier(&hctx->cpu_notifier); - if (blk_mq_init_rq_map(hctx, reg->reserved_tags, node)) + if (blk_mq_init_rq_map(hctx, reg, driver_data, node)) break; /* @@ -1268,7 +1227,7 @@ static int blk_mq_init_hw_queues(struct request_queue *q, reg->ops->exit_hctx(hctx, j); blk_mq_unregister_cpu_notifier(&hctx->cpu_notifier); - blk_mq_free_rq_map(hctx); + blk_mq_free_rq_map(hctx, driver_data); kfree(hctx->ctxs); } @@ -1455,7 +1414,7 @@ void blk_mq_free_queue(struct request_queue *q) queue_for_each_hw_ctx(q, hctx, i) { kfree(hctx->ctx_map); kfree(hctx->ctxs); - blk_mq_free_rq_map(hctx); + blk_mq_free_rq_map(hctx, q->queuedata); blk_mq_unregister_cpu_notifier(&hctx->cpu_notifier); if (q->mq_ops->exit_hctx) q->mq_ops->exit_hctx(hctx, i); diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c index c7d02bc9d945..d06206abd340 100644 --- a/drivers/block/virtio_blk.c +++ b/drivers/block/virtio_blk.c @@ -480,11 +480,22 @@ static const struct device_attribute dev_attr_cache_type_rw = __ATTR(cache_type, S_IRUGO|S_IWUSR, virtblk_cache_type_show, virtblk_cache_type_store); +static int virtblk_init_request(void *data, struct blk_mq_hw_ctx *hctx, + struct request *rq, unsigned int nr) +{ + struct virtio_blk *vblk = data; + struct virtblk_req *vbr = blk_mq_rq_to_pdu(rq); + + sg_init_table(vbr->sg, vblk->sg_elems); + return 0; +} + static struct blk_mq_ops virtio_mq_ops = { .queue_rq = virtio_queue_rq, .map_queue = blk_mq_map_queue, .alloc_hctx = blk_mq_alloc_single_hw_queue, .free_hctx = blk_mq_free_single_hw_queue, + .init_request = virtblk_init_request, .complete = virtblk_request_done, }; @@ -497,16 +508,6 @@ static struct blk_mq_reg virtio_mq_reg = { }; module_param_named(queue_depth, virtio_mq_reg.queue_depth, uint, 0444); -static int virtblk_init_vbr(void *data, struct blk_mq_hw_ctx *hctx, - struct request *rq, unsigned int nr) -{ - struct virtio_blk *vblk = data; - struct virtblk_req *vbr = blk_mq_rq_to_pdu(rq); - - sg_init_table(vbr->sg, vblk->sg_elems); - return 0; -} - static int virtblk_probe(struct virtio_device *vdev) { struct virtio_blk *vblk; @@ -577,8 +578,6 @@ static int virtblk_probe(struct virtio_device *vdev) goto out_put_disk; } - blk_mq_init_commands(q, virtblk_init_vbr, vblk); - q->queuedata = vblk; virtblk_name_format("vd", index, vblk->disk->disk_name, DISK_NAME_LEN); diff --git a/include/linux/blk-mq.h b/include/linux/blk-mq.h index b6ee48740458..29c1a6e83814 100644 --- a/include/linux/blk-mq.h +++ b/include/linux/blk-mq.h @@ -67,6 +67,10 @@ typedef struct blk_mq_hw_ctx *(alloc_hctx_fn)(struct blk_mq_reg *,unsigned int); typedef void (free_hctx_fn)(struct blk_mq_hw_ctx *, unsigned int); typedef int (init_hctx_fn)(struct blk_mq_hw_ctx *, void *, unsigned int); typedef void (exit_hctx_fn)(struct blk_mq_hw_ctx *, unsigned int); +typedef int (init_request_fn)(void *, struct blk_mq_hw_ctx *, + struct request *, unsigned int); +typedef void (exit_request_fn)(void *, struct blk_mq_hw_ctx *, + struct request *, unsigned int); struct blk_mq_ops { /* @@ -99,6 +103,14 @@ struct blk_mq_ops { */ init_hctx_fn *init_hctx; exit_hctx_fn *exit_hctx; + + /* + * Called for every command allocated by the block layer to allow + * the driver to set up driver specific data. + * Ditto for exit/teardown. + */ + init_request_fn *init_request; + exit_request_fn *exit_request; }; enum { @@ -118,8 +130,6 @@ enum { struct request_queue *blk_mq_init_queue(struct blk_mq_reg *, void *); int blk_mq_register_disk(struct gendisk *); void blk_mq_unregister_disk(struct gendisk *); -int blk_mq_init_commands(struct request_queue *, int (*init)(void *data, struct blk_mq_hw_ctx *, struct request *, unsigned int), void *data); -void blk_mq_free_commands(struct request_queue *, void (*free)(void *data, struct blk_mq_hw_ctx *, struct request *, unsigned int), void *data); void blk_mq_flush_plug_list(struct blk_plug *plug, bool from_schedule); -- cgit v1.2.3 From ed44832dea8a74f909e0187f350201402927f5e5 Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Mon, 14 Apr 2014 10:30:10 +0200 Subject: blk-mq: initialize request on allocation If we want to share tag and request allocation between queues we cannot initialize the request at init/free time, but need to initialize it at allocation time as it might get used for different queues over its lifetime. Signed-off-by: Christoph Hellwig Signed-off-by: Jens Axboe --- block/blk-mq.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/block/blk-mq.c b/block/blk-mq.c index 48d2d8495f5e..2a5a0fed10a3 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -82,6 +82,7 @@ static struct request *__blk_mq_alloc_request(struct blk_mq_hw_ctx *hctx, tag = blk_mq_get_tag(hctx->tags, gfp, reserved); if (tag != BLK_MQ_TAG_FAIL) { rq = hctx->rqs[tag]; + blk_rq_init(hctx->queue, rq); rq->tag = tag; return rq; @@ -257,9 +258,7 @@ static void __blk_mq_free_request(struct blk_mq_hw_ctx *hctx, const int tag = rq->tag; struct request_queue *q = rq->q; - blk_rq_init(hctx->queue, rq); blk_mq_put_tag(hctx->tags, tag); - blk_mq_queue_exit(q); } @@ -1122,7 +1121,6 @@ static int blk_mq_init_rq_map(struct blk_mq_hw_ctx *hctx, left -= to_do * rq_size; for (j = 0; j < to_do; j++) { hctx->rqs[i] = p; - blk_rq_init(hctx->queue, hctx->rqs[i]); if (reg->ops->init_request) { error = reg->ops->init_request(driver_data, hctx, hctx->rqs[i], i); -- cgit v1.2.3 From 24d2f90309b23f2cfe016b2aebc5f0d6e01c57fd Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Tue, 15 Apr 2014 14:14:00 -0600 Subject: blk-mq: split out tag initialization, support shared tags Add a new blk_mq_tag_set structure that gets set up before we initialize the queue. A single blk_mq_tag_set structure can be shared by multiple queues. Signed-off-by: Christoph Hellwig Modular export of blk_mq_{alloc,free}_tagset added by me. Signed-off-by: Jens Axboe --- block/blk-mq-cpumap.c | 6 +- block/blk-mq-tag.c | 14 --- block/blk-mq-tag.h | 19 +++- block/blk-mq.c | 244 +++++++++++++++++++++++++-------------------- block/blk-mq.h | 5 +- drivers/block/null_blk.c | 92 ++++++++++------- drivers/block/virtio_blk.c | 48 +++++---- include/linux/blk-mq.h | 34 +++---- 8 files changed, 262 insertions(+), 200 deletions(-) diff --git a/block/blk-mq-cpumap.c b/block/blk-mq-cpumap.c index 097921329619..5d0f93cf358c 100644 --- a/block/blk-mq-cpumap.c +++ b/block/blk-mq-cpumap.c @@ -80,17 +80,17 @@ int blk_mq_update_queue_map(unsigned int *map, unsigned int nr_queues) return 0; } -unsigned int *blk_mq_make_queue_map(struct blk_mq_reg *reg) +unsigned int *blk_mq_make_queue_map(struct blk_mq_tag_set *set) { unsigned int *map; /* If cpus are offline, map them to first hctx */ map = kzalloc_node(sizeof(*map) * num_possible_cpus(), GFP_KERNEL, - reg->numa_node); + set->numa_node); if (!map) return NULL; - if (!blk_mq_update_queue_map(map, reg->nr_hw_queues)) + if (!blk_mq_update_queue_map(map, set->nr_hw_queues)) return map; kfree(map); diff --git a/block/blk-mq-tag.c b/block/blk-mq-tag.c index 83ae96c51a27..7a799c46c32d 100644 --- a/block/blk-mq-tag.c +++ b/block/blk-mq-tag.c @@ -1,25 +1,11 @@ #include #include -#include #include #include "blk.h" #include "blk-mq.h" #include "blk-mq-tag.h" -/* - * Per tagged queue (tag address space) map - */ -struct blk_mq_tags { - unsigned int nr_tags; - unsigned int nr_reserved_tags; - unsigned int nr_batch_move; - unsigned int nr_max_cache; - - struct percpu_ida free_tags; - struct percpu_ida reserved_tags; -}; - void blk_mq_wait_for_tags(struct blk_mq_tags *tags) { int tag = blk_mq_get_tag(tags, __GFP_WAIT, false); diff --git a/block/blk-mq-tag.h b/block/blk-mq-tag.h index 947ba2c6148e..b602e3fa66ea 100644 --- a/block/blk-mq-tag.h +++ b/block/blk-mq-tag.h @@ -1,7 +1,24 @@ #ifndef INT_BLK_MQ_TAG_H #define INT_BLK_MQ_TAG_H -struct blk_mq_tags; +#include + +/* + * Tag address space map. + */ +struct blk_mq_tags { + unsigned int nr_tags; + unsigned int nr_reserved_tags; + unsigned int nr_batch_move; + unsigned int nr_max_cache; + + struct percpu_ida free_tags; + struct percpu_ida reserved_tags; + + struct request **rqs; + struct list_head page_list; +}; + extern struct blk_mq_tags *blk_mq_init_tags(unsigned int nr_tags, unsigned int reserved_tags, int node); extern void blk_mq_free_tags(struct blk_mq_tags *tags); diff --git a/block/blk-mq.c b/block/blk-mq.c index 2a5a0fed10a3..9180052d42cc 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -81,7 +81,7 @@ static struct request *__blk_mq_alloc_request(struct blk_mq_hw_ctx *hctx, tag = blk_mq_get_tag(hctx->tags, gfp, reserved); if (tag != BLK_MQ_TAG_FAIL) { - rq = hctx->rqs[tag]; + rq = hctx->tags->rqs[tag]; blk_rq_init(hctx->queue, rq); rq->tag = tag; @@ -404,6 +404,12 @@ static void blk_mq_requeue_request(struct request *rq) rq->nr_phys_segments--; } +struct request *blk_mq_tag_to_rq(struct blk_mq_tags *tags, unsigned int tag) +{ + return tags->rqs[tag]; +} +EXPORT_SYMBOL(blk_mq_tag_to_rq); + struct blk_mq_timeout_data { struct blk_mq_hw_ctx *hctx; unsigned long *next; @@ -425,12 +431,13 @@ static void blk_mq_timeout_check(void *__data, unsigned long *free_tags) do { struct request *rq; - tag = find_next_zero_bit(free_tags, hctx->queue_depth, tag); - if (tag >= hctx->queue_depth) + tag = find_next_zero_bit(free_tags, hctx->tags->nr_tags, tag); + if (tag >= hctx->tags->nr_tags) break; - rq = hctx->rqs[tag++]; - + rq = blk_mq_tag_to_rq(hctx->tags, tag++); + if (rq->q != hctx->queue) + continue; if (!test_bit(REQ_ATOM_STARTED, &rq->atomic_flags)) continue; @@ -969,11 +976,11 @@ struct blk_mq_hw_ctx *blk_mq_map_queue(struct request_queue *q, const int cpu) } EXPORT_SYMBOL(blk_mq_map_queue); -struct blk_mq_hw_ctx *blk_mq_alloc_single_hw_queue(struct blk_mq_reg *reg, +struct blk_mq_hw_ctx *blk_mq_alloc_single_hw_queue(struct blk_mq_tag_set *set, unsigned int hctx_index) { return kmalloc_node(sizeof(struct blk_mq_hw_ctx), - GFP_KERNEL | __GFP_ZERO, reg->numa_node); + GFP_KERNEL | __GFP_ZERO, set->numa_node); } EXPORT_SYMBOL(blk_mq_alloc_single_hw_queue); @@ -1030,31 +1037,31 @@ static void blk_mq_hctx_notify(void *data, unsigned long action, blk_mq_put_ctx(ctx); } -static void blk_mq_free_rq_map(struct blk_mq_hw_ctx *hctx, void *driver_data) +static void blk_mq_free_rq_map(struct blk_mq_tag_set *set, + struct blk_mq_tags *tags, unsigned int hctx_idx) { struct page *page; - if (hctx->rqs && hctx->queue->mq_ops->exit_request) { + if (tags->rqs && set->ops->exit_request) { int i; - for (i = 0; i < hctx->queue_depth; i++) { - if (!hctx->rqs[i]) + for (i = 0; i < tags->nr_tags; i++) { + if (!tags->rqs[i]) continue; - hctx->queue->mq_ops->exit_request(driver_data, hctx, - hctx->rqs[i], i); + set->ops->exit_request(set->driver_data, tags->rqs[i], + hctx_idx, i); } } - while (!list_empty(&hctx->page_list)) { - page = list_first_entry(&hctx->page_list, struct page, lru); + while (!list_empty(&tags->page_list)) { + page = list_first_entry(&tags->page_list, struct page, lru); list_del_init(&page->lru); __free_pages(page, page->private); } - kfree(hctx->rqs); + kfree(tags->rqs); - if (hctx->tags) - blk_mq_free_tags(hctx->tags); + blk_mq_free_tags(tags); } static size_t order_to_size(unsigned int order) @@ -1067,30 +1074,36 @@ static size_t order_to_size(unsigned int order) return ret; } -static int blk_mq_init_rq_map(struct blk_mq_hw_ctx *hctx, - struct blk_mq_reg *reg, void *driver_data, int node) +static struct blk_mq_tags *blk_mq_init_rq_map(struct blk_mq_tag_set *set, + unsigned int hctx_idx) { - unsigned int reserved_tags = reg->reserved_tags; + struct blk_mq_tags *tags; unsigned int i, j, entries_per_page, max_order = 4; size_t rq_size, left; - int error; - INIT_LIST_HEAD(&hctx->page_list); + tags = blk_mq_init_tags(set->queue_depth, set->reserved_tags, + set->numa_node); + if (!tags) + return NULL; - hctx->rqs = kmalloc_node(hctx->queue_depth * sizeof(struct request *), - GFP_KERNEL, node); - if (!hctx->rqs) - return -ENOMEM; + INIT_LIST_HEAD(&tags->page_list); + + tags->rqs = kmalloc_node(set->queue_depth * sizeof(struct request *), + GFP_KERNEL, set->numa_node); + if (!tags->rqs) { + blk_mq_free_tags(tags); + return NULL; + } /* * rq_size is the size of the request plus driver payload, rounded * to the cacheline size */ - rq_size = round_up(sizeof(struct request) + hctx->cmd_size, + rq_size = round_up(sizeof(struct request) + set->cmd_size, cache_line_size()); - left = rq_size * hctx->queue_depth; + left = rq_size * set->queue_depth; - for (i = 0; i < hctx->queue_depth;) { + for (i = 0; i < set->queue_depth; ) { int this_order = max_order; struct page *page; int to_do; @@ -1100,7 +1113,8 @@ static int blk_mq_init_rq_map(struct blk_mq_hw_ctx *hctx, this_order--; do { - page = alloc_pages_node(node, GFP_KERNEL, this_order); + page = alloc_pages_node(set->numa_node, GFP_KERNEL, + this_order); if (page) break; if (!this_order--) @@ -1110,22 +1124,22 @@ static int blk_mq_init_rq_map(struct blk_mq_hw_ctx *hctx, } while (1); if (!page) - break; + goto fail; page->private = this_order; - list_add_tail(&page->lru, &hctx->page_list); + list_add_tail(&page->lru, &tags->page_list); p = page_address(page); entries_per_page = order_to_size(this_order) / rq_size; - to_do = min(entries_per_page, hctx->queue_depth - i); + to_do = min(entries_per_page, set->queue_depth - i); left -= to_do * rq_size; for (j = 0; j < to_do; j++) { - hctx->rqs[i] = p; - if (reg->ops->init_request) { - error = reg->ops->init_request(driver_data, - hctx, hctx->rqs[i], i); - if (error) - goto err_rq_map; + tags->rqs[i] = p; + if (set->ops->init_request) { + if (set->ops->init_request(set->driver_data, + tags->rqs[i], hctx_idx, i, + set->numa_node)) + goto fail; } p += rq_size; @@ -1133,30 +1147,16 @@ static int blk_mq_init_rq_map(struct blk_mq_hw_ctx *hctx, } } - if (i < (reserved_tags + BLK_MQ_TAG_MIN)) { - error = -ENOMEM; - goto err_rq_map; - } - if (i != hctx->queue_depth) { - hctx->queue_depth = i; - pr_warn("%s: queue depth set to %u because of low memory\n", - __func__, i); - } + return tags; - hctx->tags = blk_mq_init_tags(hctx->queue_depth, reserved_tags, node); - if (!hctx->tags) { - error = -ENOMEM; - goto err_rq_map; - } - - return 0; -err_rq_map: - blk_mq_free_rq_map(hctx, driver_data); - return error; +fail: + pr_warn("%s: failed to allocate requests\n", __func__); + blk_mq_free_rq_map(set, tags, hctx_idx); + return NULL; } static int blk_mq_init_hw_queues(struct request_queue *q, - struct blk_mq_reg *reg, void *driver_data) + struct blk_mq_tag_set *set) { struct blk_mq_hw_ctx *hctx; unsigned int i, j; @@ -1170,23 +1170,21 @@ static int blk_mq_init_hw_queues(struct request_queue *q, node = hctx->numa_node; if (node == NUMA_NO_NODE) - node = hctx->numa_node = reg->numa_node; + node = hctx->numa_node = set->numa_node; INIT_DELAYED_WORK(&hctx->delayed_work, blk_mq_work_fn); spin_lock_init(&hctx->lock); INIT_LIST_HEAD(&hctx->dispatch); hctx->queue = q; hctx->queue_num = i; - hctx->flags = reg->flags; - hctx->queue_depth = reg->queue_depth; - hctx->cmd_size = reg->cmd_size; + hctx->flags = set->flags; + hctx->cmd_size = set->cmd_size; blk_mq_init_cpu_notifier(&hctx->cpu_notifier, blk_mq_hctx_notify, hctx); blk_mq_register_cpu_notifier(&hctx->cpu_notifier); - if (blk_mq_init_rq_map(hctx, reg, driver_data, node)) - break; + hctx->tags = set->tags[i]; /* * Allocate space for all possible cpus to avoid allocation in @@ -1206,8 +1204,8 @@ static int blk_mq_init_hw_queues(struct request_queue *q, hctx->nr_ctx_map = num_maps; hctx->nr_ctx = 0; - if (reg->ops->init_hctx && - reg->ops->init_hctx(hctx, driver_data, i)) + if (set->ops->init_hctx && + set->ops->init_hctx(hctx, set->driver_data, i)) break; } @@ -1221,11 +1219,10 @@ static int blk_mq_init_hw_queues(struct request_queue *q, if (i == j) break; - if (reg->ops->exit_hctx) - reg->ops->exit_hctx(hctx, j); + if (set->ops->exit_hctx) + set->ops->exit_hctx(hctx, j); blk_mq_unregister_cpu_notifier(&hctx->cpu_notifier); - blk_mq_free_rq_map(hctx, driver_data); kfree(hctx->ctxs); } @@ -1290,41 +1287,25 @@ static void blk_mq_map_swqueue(struct request_queue *q) } } -struct request_queue *blk_mq_init_queue(struct blk_mq_reg *reg, - void *driver_data) +struct request_queue *blk_mq_init_queue(struct blk_mq_tag_set *set) { struct blk_mq_hw_ctx **hctxs; struct blk_mq_ctx *ctx; struct request_queue *q; int i; - if (!reg->nr_hw_queues || - !reg->ops->queue_rq || !reg->ops->map_queue || - !reg->ops->alloc_hctx || !reg->ops->free_hctx) - return ERR_PTR(-EINVAL); - - if (!reg->queue_depth) - reg->queue_depth = BLK_MQ_MAX_DEPTH; - else if (reg->queue_depth > BLK_MQ_MAX_DEPTH) { - pr_err("blk-mq: queuedepth too large (%u)\n", reg->queue_depth); - reg->queue_depth = BLK_MQ_MAX_DEPTH; - } - - if (reg->queue_depth < (reg->reserved_tags + BLK_MQ_TAG_MIN)) - return ERR_PTR(-EINVAL); - ctx = alloc_percpu(struct blk_mq_ctx); if (!ctx) return ERR_PTR(-ENOMEM); - hctxs = kmalloc_node(reg->nr_hw_queues * sizeof(*hctxs), GFP_KERNEL, - reg->numa_node); + hctxs = kmalloc_node(set->nr_hw_queues * sizeof(*hctxs), GFP_KERNEL, + set->numa_node); if (!hctxs) goto err_percpu; - for (i = 0; i < reg->nr_hw_queues; i++) { - hctxs[i] = reg->ops->alloc_hctx(reg, i); + for (i = 0; i < set->nr_hw_queues; i++) { + hctxs[i] = set->ops->alloc_hctx(set, i); if (!hctxs[i]) goto err_hctxs; @@ -1335,11 +1316,11 @@ struct request_queue *blk_mq_init_queue(struct blk_mq_reg *reg, hctxs[i]->queue_num = i; } - q = blk_alloc_queue_node(GFP_KERNEL, reg->numa_node); + q = blk_alloc_queue_node(GFP_KERNEL, set->numa_node); if (!q) goto err_hctxs; - q->mq_map = blk_mq_make_queue_map(reg); + q->mq_map = blk_mq_make_queue_map(set); if (!q->mq_map) goto err_map; @@ -1347,33 +1328,34 @@ struct request_queue *blk_mq_init_queue(struct blk_mq_reg *reg, blk_queue_rq_timeout(q, 30000); q->nr_queues = nr_cpu_ids; - q->nr_hw_queues = reg->nr_hw_queues; + q->nr_hw_queues = set->nr_hw_queues; q->queue_ctx = ctx; q->queue_hw_ctx = hctxs; - q->mq_ops = reg->ops; + q->mq_ops = set->ops; q->queue_flags |= QUEUE_FLAG_MQ_DEFAULT; q->sg_reserved_size = INT_MAX; blk_queue_make_request(q, blk_mq_make_request); - blk_queue_rq_timed_out(q, reg->ops->timeout); - if (reg->timeout) - blk_queue_rq_timeout(q, reg->timeout); + blk_queue_rq_timed_out(q, set->ops->timeout); + if (set->timeout) + blk_queue_rq_timeout(q, set->timeout); - if (reg->ops->complete) - blk_queue_softirq_done(q, reg->ops->complete); + if (set->ops->complete) + blk_queue_softirq_done(q, set->ops->complete); blk_mq_init_flush(q); - blk_mq_init_cpu_queues(q, reg->nr_hw_queues); + blk_mq_init_cpu_queues(q, set->nr_hw_queues); - q->flush_rq = kzalloc(round_up(sizeof(struct request) + reg->cmd_size, - cache_line_size()), GFP_KERNEL); + q->flush_rq = kzalloc(round_up(sizeof(struct request) + + set->cmd_size, cache_line_size()), + GFP_KERNEL); if (!q->flush_rq) goto err_hw; - if (blk_mq_init_hw_queues(q, reg, driver_data)) + if (blk_mq_init_hw_queues(q, set)) goto err_flush_rq; blk_mq_map_swqueue(q); @@ -1391,11 +1373,11 @@ err_hw: err_map: blk_cleanup_queue(q); err_hctxs: - for (i = 0; i < reg->nr_hw_queues; i++) { + for (i = 0; i < set->nr_hw_queues; i++) { if (!hctxs[i]) break; free_cpumask_var(hctxs[i]->cpumask); - reg->ops->free_hctx(hctxs[i], i); + set->ops->free_hctx(hctxs[i], i); } kfree(hctxs); err_percpu: @@ -1412,7 +1394,6 @@ void blk_mq_free_queue(struct request_queue *q) queue_for_each_hw_ctx(q, hctx, i) { kfree(hctx->ctx_map); kfree(hctx->ctxs); - blk_mq_free_rq_map(hctx, q->queuedata); blk_mq_unregister_cpu_notifier(&hctx->cpu_notifier); if (q->mq_ops->exit_hctx) q->mq_ops->exit_hctx(hctx, i); @@ -1473,6 +1454,53 @@ static int blk_mq_queue_reinit_notify(struct notifier_block *nb, return NOTIFY_OK; } +int blk_mq_alloc_tag_set(struct blk_mq_tag_set *set) +{ + int i; + + if (!set->nr_hw_queues) + return -EINVAL; + if (!set->queue_depth || set->queue_depth > BLK_MQ_MAX_DEPTH) + return -EINVAL; + if (set->queue_depth < set->reserved_tags + BLK_MQ_TAG_MIN) + return -EINVAL; + + if (!set->nr_hw_queues || + !set->ops->queue_rq || !set->ops->map_queue || + !set->ops->alloc_hctx || !set->ops->free_hctx) + return -EINVAL; + + + set->tags = kmalloc_node(set->nr_hw_queues * sizeof(struct blk_mq_tags), + GFP_KERNEL, set->numa_node); + if (!set->tags) + goto out; + + for (i = 0; i < set->nr_hw_queues; i++) { + set->tags[i] = blk_mq_init_rq_map(set, i); + if (!set->tags[i]) + goto out_unwind; + } + + return 0; + +out_unwind: + while (--i >= 0) + blk_mq_free_rq_map(set, set->tags[i], i); +out: + return -ENOMEM; +} +EXPORT_SYMBOL(blk_mq_alloc_tag_set); + +void blk_mq_free_tag_set(struct blk_mq_tag_set *set) +{ + int i; + + for (i = 0; i < set->nr_hw_queues; i++) + blk_mq_free_rq_map(set, set->tags[i], i); +} +EXPORT_SYMBOL(blk_mq_free_tag_set); + void blk_mq_disable_hotplug(void) { mutex_lock(&all_q_mutex); diff --git a/block/blk-mq.h b/block/blk-mq.h index 7964dadb7d64..5fa14f19f752 100644 --- a/block/blk-mq.h +++ b/block/blk-mq.h @@ -1,6 +1,8 @@ #ifndef INT_BLK_MQ_H #define INT_BLK_MQ_H +struct blk_mq_tag_set; + struct blk_mq_ctx { struct { spinlock_t lock; @@ -46,8 +48,7 @@ void blk_mq_disable_hotplug(void); /* * CPU -> queue mappings */ -struct blk_mq_reg; -extern unsigned int *blk_mq_make_queue_map(struct blk_mq_reg *reg); +extern unsigned int *blk_mq_make_queue_map(struct blk_mq_tag_set *set); extern int blk_mq_update_queue_map(unsigned int *map, unsigned int nr_queues); void blk_mq_add_timer(struct request *rq); diff --git a/drivers/block/null_blk.c b/drivers/block/null_blk.c index 71df69d90900..8e7e3a0b0d24 100644 --- a/drivers/block/null_blk.c +++ b/drivers/block/null_blk.c @@ -32,6 +32,7 @@ struct nullb { unsigned int index; struct request_queue *q; struct gendisk *disk; + struct blk_mq_tag_set tag_set; struct hrtimer timer; unsigned int queue_depth; spinlock_t lock; @@ -320,10 +321,11 @@ static int null_queue_rq(struct blk_mq_hw_ctx *hctx, struct request *rq) return BLK_MQ_RQ_QUEUE_OK; } -static struct blk_mq_hw_ctx *null_alloc_hctx(struct blk_mq_reg *reg, unsigned int hctx_index) +static struct blk_mq_hw_ctx *null_alloc_hctx(struct blk_mq_tag_set *set, + unsigned int hctx_index) { - int b_size = DIV_ROUND_UP(reg->nr_hw_queues, nr_online_nodes); - int tip = (reg->nr_hw_queues % nr_online_nodes); + int b_size = DIV_ROUND_UP(set->nr_hw_queues, nr_online_nodes); + int tip = (set->nr_hw_queues % nr_online_nodes); int node = 0, i, n; /* @@ -338,7 +340,7 @@ static struct blk_mq_hw_ctx *null_alloc_hctx(struct blk_mq_reg *reg, unsigned in tip--; if (!tip) - b_size = reg->nr_hw_queues / nr_online_nodes; + b_size = set->nr_hw_queues / nr_online_nodes; } } @@ -387,13 +389,17 @@ static struct blk_mq_ops null_mq_ops = { .map_queue = blk_mq_map_queue, .init_hctx = null_init_hctx, .complete = null_softirq_done_fn, + .alloc_hctx = blk_mq_alloc_single_hw_queue, + .free_hctx = blk_mq_free_single_hw_queue, }; -static struct blk_mq_reg null_mq_reg = { - .ops = &null_mq_ops, - .queue_depth = 64, - .cmd_size = sizeof(struct nullb_cmd), - .flags = BLK_MQ_F_SHOULD_MERGE, +static struct blk_mq_ops null_mq_ops_pernode = { + .queue_rq = null_queue_rq, + .map_queue = blk_mq_map_queue, + .init_hctx = null_init_hctx, + .complete = null_softirq_done_fn, + .alloc_hctx = null_alloc_hctx, + .free_hctx = null_free_hctx, }; static void null_del_dev(struct nullb *nullb) @@ -402,6 +408,8 @@ static void null_del_dev(struct nullb *nullb) del_gendisk(nullb->disk); blk_cleanup_queue(nullb->q); + if (queue_mode == NULL_Q_MQ) + blk_mq_free_tag_set(&nullb->tag_set); put_disk(nullb->disk); kfree(nullb); } @@ -506,7 +514,7 @@ static int null_add_dev(void) nullb = kzalloc_node(sizeof(*nullb), GFP_KERNEL, home_node); if (!nullb) - return -ENOMEM; + goto out; spin_lock_init(&nullb->lock); @@ -514,49 +522,47 @@ static int null_add_dev(void) submit_queues = nr_online_nodes; if (setup_queues(nullb)) - goto err; + goto out_free_nullb; if (queue_mode == NULL_Q_MQ) { - null_mq_reg.numa_node = home_node; - null_mq_reg.queue_depth = hw_queue_depth; - null_mq_reg.nr_hw_queues = submit_queues; - - if (use_per_node_hctx) { - null_mq_reg.ops->alloc_hctx = null_alloc_hctx; - null_mq_reg.ops->free_hctx = null_free_hctx; - } else { - null_mq_reg.ops->alloc_hctx = blk_mq_alloc_single_hw_queue; - null_mq_reg.ops->free_hctx = blk_mq_free_single_hw_queue; - } - - nullb->q = blk_mq_init_queue(&null_mq_reg, nullb); + if (use_per_node_hctx) + nullb->tag_set.ops = &null_mq_ops_pernode; + else + nullb->tag_set.ops = &null_mq_ops; + nullb->tag_set.nr_hw_queues = submit_queues; + nullb->tag_set.queue_depth = hw_queue_depth; + nullb->tag_set.numa_node = home_node; + nullb->tag_set.cmd_size = sizeof(struct nullb_cmd); + nullb->tag_set.flags = BLK_MQ_F_SHOULD_MERGE; + nullb->tag_set.driver_data = nullb; + + if (blk_mq_alloc_tag_set(&nullb->tag_set)) + goto out_cleanup_queues; + + nullb->q = blk_mq_init_queue(&nullb->tag_set); + if (!nullb->q) + goto out_cleanup_tags; } else if (queue_mode == NULL_Q_BIO) { nullb->q = blk_alloc_queue_node(GFP_KERNEL, home_node); + if (!nullb->q) + goto out_cleanup_queues; blk_queue_make_request(nullb->q, null_queue_bio); init_driver_queues(nullb); } else { nullb->q = blk_init_queue_node(null_request_fn, &nullb->lock, home_node); + if (!nullb->q) + goto out_cleanup_queues; blk_queue_prep_rq(nullb->q, null_rq_prep_fn); - if (nullb->q) - blk_queue_softirq_done(nullb->q, null_softirq_done_fn); + blk_queue_softirq_done(nullb->q, null_softirq_done_fn); init_driver_queues(nullb); } - if (!nullb->q) - goto queue_fail; - nullb->q->queuedata = nullb; queue_flag_set_unlocked(QUEUE_FLAG_NONROT, nullb->q); disk = nullb->disk = alloc_disk_node(1, home_node); - if (!disk) { -queue_fail: - blk_cleanup_queue(nullb->q); - cleanup_queues(nullb); -err: - kfree(nullb); - return -ENOMEM; - } + if (!disk) + goto out_cleanup_blk_queue; mutex_lock(&lock); list_add_tail(&nullb->list, &nullb_list); @@ -579,6 +585,18 @@ err: sprintf(disk->disk_name, "nullb%d", nullb->index); add_disk(disk); return 0; + +out_cleanup_blk_queue: + blk_cleanup_queue(nullb->q); +out_cleanup_tags: + if (queue_mode == NULL_Q_MQ) + blk_mq_free_tag_set(&nullb->tag_set); +out_cleanup_queues: + cleanup_queues(nullb); +out_free_nullb: + kfree(nullb); +out: + return -ENOMEM; } static int __init null_init(void) diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c index d06206abd340..f909a8821e65 100644 --- a/drivers/block/virtio_blk.c +++ b/drivers/block/virtio_blk.c @@ -30,6 +30,9 @@ struct virtio_blk /* The disk structure for the kernel. */ struct gendisk *disk; + /* Block layer tags. */ + struct blk_mq_tag_set tag_set; + /* Process context for config space updates */ struct work_struct config_work; @@ -480,8 +483,9 @@ static const struct device_attribute dev_attr_cache_type_rw = __ATTR(cache_type, S_IRUGO|S_IWUSR, virtblk_cache_type_show, virtblk_cache_type_store); -static int virtblk_init_request(void *data, struct blk_mq_hw_ctx *hctx, - struct request *rq, unsigned int nr) +static int virtblk_init_request(void *data, struct request *rq, + unsigned int hctx_idx, unsigned int request_idx, + unsigned int numa_node) { struct virtio_blk *vblk = data; struct virtblk_req *vbr = blk_mq_rq_to_pdu(rq); @@ -495,18 +499,12 @@ static struct blk_mq_ops virtio_mq_ops = { .map_queue = blk_mq_map_queue, .alloc_hctx = blk_mq_alloc_single_hw_queue, .free_hctx = blk_mq_free_single_hw_queue, - .init_request = virtblk_init_request, .complete = virtblk_request_done, + .init_request = virtblk_init_request, }; -static struct blk_mq_reg virtio_mq_reg = { - .ops = &virtio_mq_ops, - .nr_hw_queues = 1, - .queue_depth = 0, /* Set in virtblk_probe */ - .numa_node = NUMA_NO_NODE, - .flags = BLK_MQ_F_SHOULD_MERGE, -}; -module_param_named(queue_depth, virtio_mq_reg.queue_depth, uint, 0444); +static unsigned int virtblk_queue_depth; +module_param_named(queue_depth, virtblk_queue_depth, uint, 0444); static int virtblk_probe(struct virtio_device *vdev) { @@ -562,20 +560,32 @@ static int virtblk_probe(struct virtio_device *vdev) } /* Default queue sizing is to fill the ring. */ - if (!virtio_mq_reg.queue_depth) { - virtio_mq_reg.queue_depth = vblk->vq->num_free; + if (!virtblk_queue_depth) { + virtblk_queue_depth = vblk->vq->num_free; /* ... but without indirect descs, we use 2 descs per req */ if (!virtio_has_feature(vdev, VIRTIO_RING_F_INDIRECT_DESC)) - virtio_mq_reg.queue_depth /= 2; + virtblk_queue_depth /= 2; } - virtio_mq_reg.cmd_size = + + memset(&vblk->tag_set, 0, sizeof(vblk->tag_set)); + vblk->tag_set.ops = &virtio_mq_ops; + vblk->tag_set.nr_hw_queues = 1; + vblk->tag_set.queue_depth = virtblk_queue_depth; + vblk->tag_set.numa_node = NUMA_NO_NODE; + vblk->tag_set.flags = BLK_MQ_F_SHOULD_MERGE; + vblk->tag_set.cmd_size = sizeof(struct virtblk_req) + sizeof(struct scatterlist) * sg_elems; + vblk->tag_set.driver_data = vblk; - q = vblk->disk->queue = blk_mq_init_queue(&virtio_mq_reg, vblk); + err = blk_mq_alloc_tag_set(&vblk->tag_set); + if (err) + goto out_put_disk; + + q = vblk->disk->queue = blk_mq_init_queue(&vblk->tag_set); if (!q) { err = -ENOMEM; - goto out_put_disk; + goto out_free_tags; } q->queuedata = vblk; @@ -678,6 +688,8 @@ static int virtblk_probe(struct virtio_device *vdev) out_del_disk: del_gendisk(vblk->disk); blk_cleanup_queue(vblk->disk->queue); +out_free_tags: + blk_mq_free_tag_set(&vblk->tag_set); out_put_disk: put_disk(vblk->disk); out_free_vq: @@ -704,6 +716,8 @@ static void virtblk_remove(struct virtio_device *vdev) del_gendisk(vblk->disk); blk_cleanup_queue(vblk->disk->queue); + blk_mq_free_tag_set(&vblk->tag_set); + /* Stop all the virtqueues. */ vdev->config->reset(vdev); diff --git a/include/linux/blk-mq.h b/include/linux/blk-mq.h index 29c1a6e83814..a4ea0ce83b07 100644 --- a/include/linux/blk-mq.h +++ b/include/linux/blk-mq.h @@ -33,8 +33,6 @@ struct blk_mq_hw_ctx { unsigned int nr_ctx_map; unsigned long *ctx_map; - struct request **rqs; - struct list_head page_list; struct blk_mq_tags *tags; unsigned long queued; @@ -42,7 +40,6 @@ struct blk_mq_hw_ctx { #define BLK_MQ_MAX_DISPATCH_ORDER 10 unsigned long dispatched[BLK_MQ_MAX_DISPATCH_ORDER]; - unsigned int queue_depth; unsigned int numa_node; unsigned int cmd_size; /* per-request extra data */ @@ -50,7 +47,7 @@ struct blk_mq_hw_ctx { struct kobject kobj; }; -struct blk_mq_reg { +struct blk_mq_tag_set { struct blk_mq_ops *ops; unsigned int nr_hw_queues; unsigned int queue_depth; @@ -59,18 +56,22 @@ struct blk_mq_reg { int numa_node; unsigned int timeout; unsigned int flags; /* BLK_MQ_F_* */ + void *driver_data; + + struct blk_mq_tags **tags; }; typedef int (queue_rq_fn)(struct blk_mq_hw_ctx *, struct request *); typedef struct blk_mq_hw_ctx *(map_queue_fn)(struct request_queue *, const int); -typedef struct blk_mq_hw_ctx *(alloc_hctx_fn)(struct blk_mq_reg *,unsigned int); +typedef struct blk_mq_hw_ctx *(alloc_hctx_fn)(struct blk_mq_tag_set *, + unsigned int); typedef void (free_hctx_fn)(struct blk_mq_hw_ctx *, unsigned int); typedef int (init_hctx_fn)(struct blk_mq_hw_ctx *, void *, unsigned int); typedef void (exit_hctx_fn)(struct blk_mq_hw_ctx *, unsigned int); -typedef int (init_request_fn)(void *, struct blk_mq_hw_ctx *, - struct request *, unsigned int); -typedef void (exit_request_fn)(void *, struct blk_mq_hw_ctx *, - struct request *, unsigned int); +typedef int (init_request_fn)(void *, struct request *, unsigned int, + unsigned int, unsigned int); +typedef void (exit_request_fn)(void *, struct request *, unsigned int, + unsigned int); struct blk_mq_ops { /* @@ -127,10 +128,13 @@ enum { BLK_MQ_MAX_DEPTH = 2048, }; -struct request_queue *blk_mq_init_queue(struct blk_mq_reg *, void *); +struct request_queue *blk_mq_init_queue(struct blk_mq_tag_set *); int blk_mq_register_disk(struct gendisk *); void blk_mq_unregister_disk(struct gendisk *); +int blk_mq_alloc_tag_set(struct blk_mq_tag_set *set); +void blk_mq_free_tag_set(struct blk_mq_tag_set *set); + void blk_mq_flush_plug_list(struct blk_plug *plug, bool from_schedule); void blk_mq_insert_request(struct request *, bool, bool, bool); @@ -139,10 +143,10 @@ void blk_mq_free_request(struct request *rq); bool blk_mq_can_queue(struct blk_mq_hw_ctx *); struct request *blk_mq_alloc_request(struct request_queue *q, int rw, gfp_t gfp); struct request *blk_mq_alloc_reserved_request(struct request_queue *q, int rw, gfp_t gfp); -struct request *blk_mq_rq_from_tag(struct request_queue *q, unsigned int tag); +struct request *blk_mq_tag_to_rq(struct blk_mq_tags *tags, unsigned int tag); struct blk_mq_hw_ctx *blk_mq_map_queue(struct request_queue *, const int ctx_index); -struct blk_mq_hw_ctx *blk_mq_alloc_single_hw_queue(struct blk_mq_reg *, unsigned int); +struct blk_mq_hw_ctx *blk_mq_alloc_single_hw_queue(struct blk_mq_tag_set *, unsigned int); void blk_mq_free_single_hw_queue(struct blk_mq_hw_ctx *, unsigned int); bool blk_mq_end_io_partial(struct request *rq, int error, @@ -173,12 +177,6 @@ static inline void *blk_mq_rq_to_pdu(struct request *rq) return (void *) rq + sizeof(*rq); } -static inline struct request *blk_mq_tag_to_rq(struct blk_mq_hw_ctx *hctx, - unsigned int tag) -{ - return hctx->rqs[tag]; -} - #define queue_for_each_hw_ctx(q, hctx, i) \ for ((i) = 0; (i) < (q)->nr_hw_queues && \ ({ hctx = (q)->queue_hw_ctx[i]; 1; }); (i)++) -- cgit v1.2.3 From fb3ccb5da71273e7f0d50b50bc879e50cedd60e7 Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Mon, 14 Apr 2014 10:30:12 +0200 Subject: block: all blk-mq requests are tagged Instead of setting the REQ_QUEUED flag on each of them just take it into account in the only macro checking it. Signed-off-by: Christoph Hellwig Signed-off-by: Jens Axboe --- include/linux/blkdev.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index eb5e94803892..95bb551273ab 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -1101,7 +1101,8 @@ static inline bool blk_needs_flush_plug(struct task_struct *tsk) /* * tag stuff */ -#define blk_rq_tagged(rq) ((rq)->cmd_flags & REQ_QUEUED) +#define blk_rq_tagged(rq) \ + ((rq)->mq_ctx || ((rq)->cmd_flags & REQ_QUEUED)) extern int blk_queue_start_tag(struct request_queue *, struct request *); extern struct request *blk_queue_find_tag(struct request_queue *, int); extern void blk_queue_end_tag(struct request_queue *, struct request *); -- cgit v1.2.3 From 15e524a4ea23015aa3df37bfc37bf8be8eae8ead Mon Sep 17 00:00:00 2001 From: Stephen Warren Date: Wed, 19 Mar 2014 15:47:53 -0600 Subject: ARM: tegra: add Jetson TK1 device tree Jetson TK1 is an NVIDIA Tegra124 development board, containing Tegra124, 2GB RAM, eMMC, SD card, SPI flash, serial port, PCIe Ethernet, HDMI, audio, mini PCIe, JTAG, SATA, and an expansion IO connector containing GPIOs, I2C, SPI, CSI, eDP, etc. The following features work with this device tree: UART, SD card, eMMC, SPI flash, USB (full-size jack, and mini-PCIe), audio, AS3722 RTC, system power-off, suspend/resume (LP1) with wake via RTC alarm. The following features should work with this device tree, but are not validated: Expansion I2C, expansion SPI, expansion GPIO, gpio-key for the power button. The following features are not yet implemented in this device tree: Most voltage regulators, expansion UART, HDMI, eDP, PCIe (Ethernet, and mini- PCIe connector), CSI, SATA. Signed-off-by: Stephen Warren --- arch/arm/boot/dts/Makefile | 1 + arch/arm/boot/dts/tegra124-jetson-tk1.dts | 1561 +++++++++++++++++++++++++++++ 2 files changed, 1562 insertions(+) create mode 100644 arch/arm/boot/dts/tegra124-jetson-tk1.dts diff --git a/arch/arm/boot/dts/Makefile b/arch/arm/boot/dts/Makefile index 35c146f31e46..d96b2c2ec429 100644 --- a/arch/arm/boot/dts/Makefile +++ b/arch/arm/boot/dts/Makefile @@ -368,6 +368,7 @@ dtb-$(CONFIG_ARCH_TEGRA) += tegra20-harmony.dtb \ tegra30-cardhu-a02.dtb \ tegra30-cardhu-a04.dtb \ tegra114-dalmore.dtb \ + tegra124-jetson-tk1.dtb \ tegra124-venice2.dtb dtb-$(CONFIG_ARCH_VERSATILE) += versatile-ab.dtb \ versatile-pb.dtb diff --git a/arch/arm/boot/dts/tegra124-jetson-tk1.dts b/arch/arm/boot/dts/tegra124-jetson-tk1.dts new file mode 100644 index 000000000000..dedcb0c165c5 --- /dev/null +++ b/arch/arm/boot/dts/tegra124-jetson-tk1.dts @@ -0,0 +1,1561 @@ +/dts-v1/; + +#include +#include "tegra124.dtsi" + +/ { + model = "NVIDIA Tegra124 Jetson TK1"; + compatible = "nvidia,jetson-tk1", "nvidia,tegra124"; + + aliases { + rtc0 = "/i2c@0,7000d000/pmic@40"; + rtc1 = "/rtc@0,7000e000"; + }; + + memory { + reg = <0x0 0x80000000 0x0 0x80000000>; + }; + + pinmux: pinmux@0,70000868 { + pinctrl-names = "default"; + pinctrl-0 = <&state_default>; + + state_default: pinmux { + clk_32k_out_pa0 { + nvidia,pins = "clk_32k_out_pa0"; + nvidia,function = "soc"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + uart3_cts_n_pa1 { + nvidia,pins = "uart3_cts_n_pa1"; + nvidia,function = "uartc"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + dap2_fs_pa2 { + nvidia,pins = "dap2_fs_pa2"; + nvidia,function = "i2s1"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + dap2_sclk_pa3 { + nvidia,pins = "dap2_sclk_pa3"; + nvidia,function = "i2s1"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + dap2_din_pa4 { + nvidia,pins = "dap2_din_pa4"; + nvidia,function = "i2s1"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + dap2_dout_pa5 { + nvidia,pins = "dap2_dout_pa5"; + nvidia,function = "i2s1"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + sdmmc3_clk_pa6 { + nvidia,pins = "sdmmc3_clk_pa6"; + nvidia,function = "sdmmc3"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + sdmmc3_cmd_pa7 { + nvidia,pins = "sdmmc3_cmd_pa7"; + nvidia,function = "sdmmc3"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + pb0 { + nvidia,pins = "pb0"; + nvidia,function = "uartd"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + pb1 { + nvidia,pins = "pb1"; + nvidia,function = "uartd"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + sdmmc3_dat3_pb4 { + nvidia,pins = "sdmmc3_dat3_pb4"; + nvidia,function = "sdmmc3"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + sdmmc3_dat2_pb5 { + nvidia,pins = "sdmmc3_dat2_pb5"; + nvidia,function = "sdmmc3"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + sdmmc3_dat1_pb6 { + nvidia,pins = "sdmmc3_dat1_pb6"; + nvidia,function = "sdmmc3"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + sdmmc3_dat0_pb7 { + nvidia,pins = "sdmmc3_dat0_pb7"; + nvidia,function = "sdmmc3"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + uart3_rts_n_pc0 { + nvidia,pins = "uart3_rts_n_pc0"; + nvidia,function = "uartc"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + uart2_txd_pc2 { + nvidia,pins = "uart2_txd_pc2"; + nvidia,function = "irda"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + uart2_rxd_pc3 { + nvidia,pins = "uart2_rxd_pc3"; + nvidia,function = "irda"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + gen1_i2c_scl_pc4 { + nvidia,pins = "gen1_i2c_scl_pc4"; + nvidia,function = "i2c1"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + nvidia,open-drain = ; + }; + gen1_i2c_sda_pc5 { + nvidia,pins = "gen1_i2c_sda_pc5"; + nvidia,function = "i2c1"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + nvidia,open-drain = ; + }; + pc7 { + nvidia,pins = "pc7"; + nvidia,function = "rsvd1"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + pg0 { + nvidia,pins = "pg0"; + nvidia,function = "rsvd1"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + pg1 { + nvidia,pins = "pg1"; + nvidia,function = "rsvd1"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + pg2 { + nvidia,pins = "pg2"; + nvidia,function = "rsvd1"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + pg3 { + nvidia,pins = "pg3"; + nvidia,function = "rsvd1"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + pg4 { + nvidia,pins = "pg4"; + nvidia,function = "spi4"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + pg5 { + nvidia,pins = "pg5"; + nvidia,function = "spi4"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + pg6 { + nvidia,pins = "pg6"; + nvidia,function = "spi4"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + pg7 { + nvidia,pins = "pg7"; + nvidia,function = "spi4"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + ph0 { + nvidia,pins = "ph0"; + nvidia,function = "gmi"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + ph1 { + nvidia,pins = "ph1"; + nvidia,function = "pwm1"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + ph2 { + nvidia,pins = "ph2"; + nvidia,function = "gmi"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + ph3 { + nvidia,pins = "ph3"; + nvidia,function = "gmi"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + ph4 { + nvidia,pins = "ph4"; + nvidia,function = "rsvd2"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + ph5 { + nvidia,pins = "ph5"; + nvidia,function = "rsvd2"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + ph6 { + nvidia,pins = "ph6"; + nvidia,function = "gmi"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + ph7 { + nvidia,pins = "ph7"; + nvidia,function = "gmi"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + pi0 { + nvidia,pins = "pi0"; + nvidia,function = "rsvd1"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + pi1 { + nvidia,pins = "pi1"; + nvidia,function = "rsvd1"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + pi2 { + nvidia,pins = "pi2"; + nvidia,function = "rsvd4"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + pi3 { + nvidia,pins = "pi3"; + nvidia,function = "spi4"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + pi4 { + nvidia,pins = "pi4"; + nvidia,function = "gmi"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + pi5 { + nvidia,pins = "pi5"; + nvidia,function = "rsvd2"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + pi6 { + nvidia,pins = "pi6"; + nvidia,function = "rsvd1"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + pi7 { + nvidia,pins = "pi7"; + nvidia,function = "rsvd1"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + pj0 { + nvidia,pins = "pj0"; + nvidia,function = "rsvd1"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + pj2 { + nvidia,pins = "pj2"; + nvidia,function = "rsvd1"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + uart2_cts_n_pj5 { + nvidia,pins = "uart2_cts_n_pj5"; + nvidia,function = "uartb"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + uart2_rts_n_pj6 { + nvidia,pins = "uart2_rts_n_pj6"; + nvidia,function = "uartb"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + pj7 { + nvidia,pins = "pj7"; + nvidia,function = "uartd"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + pk0 { + nvidia,pins = "pk0"; + nvidia,function = "soc"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + pk1 { + nvidia,pins = "pk1"; + nvidia,function = "rsvd4"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + pk2 { + nvidia,pins = "pk2"; + nvidia,function = "rsvd1"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + pk3 { + nvidia,pins = "pk3"; + nvidia,function = "gmi"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + pk4 { + nvidia,pins = "pk4"; + nvidia,function = "rsvd2"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + spdif_out_pk5 { + nvidia,pins = "spdif_out_pk5"; + nvidia,function = "rsvd2"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + spdif_in_pk6 { + nvidia,pins = "spdif_in_pk6"; + nvidia,function = "rsvd2"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + pk7 { + nvidia,pins = "pk7"; + nvidia,function = "uartd"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + dap1_fs_pn0 { + nvidia,pins = "dap1_fs_pn0"; + nvidia,function = "i2s0"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + dap1_din_pn1 { + nvidia,pins = "dap1_din_pn1"; + nvidia,function = "i2s0"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + dap1_dout_pn2 { + nvidia,pins = "dap1_dout_pn2"; + nvidia,function = "sata"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + dap1_sclk_pn3 { + nvidia,pins = "dap1_sclk_pn3"; + nvidia,function = "i2s0"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + usb_vbus_en0_pn4 { + nvidia,pins = "usb_vbus_en0_pn4"; + nvidia,function = "usb"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + nvidia,open-drain = ; + }; + usb_vbus_en1_pn5 { + nvidia,pins = "usb_vbus_en1_pn5"; + nvidia,function = "usb"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + nvidia,open-drain = ; + }; + hdmi_int_pn7 { + nvidia,pins = "hdmi_int_pn7"; + nvidia,function = "rsvd1"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + nvidia,rcv-sel = ; + }; + ulpi_data7_po0 { + nvidia,pins = "ulpi_data7_po0"; + nvidia,function = "ulpi"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + ulpi_data0_po1 { + nvidia,pins = "ulpi_data0_po1"; + nvidia,function = "ulpi"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + ulpi_data1_po2 { + nvidia,pins = "ulpi_data1_po2"; + nvidia,function = "ulpi"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + ulpi_data2_po3 { + nvidia,pins = "ulpi_data2_po3"; + nvidia,function = "ulpi"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + ulpi_data3_po4 { + nvidia,pins = "ulpi_data3_po4"; + nvidia,function = "ulpi"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + ulpi_data4_po5 { + nvidia,pins = "ulpi_data4_po5"; + nvidia,function = "ulpi"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + ulpi_data5_po6 { + nvidia,pins = "ulpi_data5_po6"; + nvidia,function = "ulpi"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + ulpi_data6_po7 { + nvidia,pins = "ulpi_data6_po7"; + nvidia,function = "ulpi"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + dap3_fs_pp0 { + nvidia,pins = "dap3_fs_pp0"; + nvidia,function = "i2s2"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + dap3_din_pp1 { + nvidia,pins = "dap3_din_pp1"; + nvidia,function = "i2s2"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + dap3_dout_pp2 { + nvidia,pins = "dap3_dout_pp2"; + nvidia,function = "rsvd4"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + dap3_sclk_pp3 { + nvidia,pins = "dap3_sclk_pp3"; + nvidia,function = "rsvd3"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + dap4_fs_pp4 { + nvidia,pins = "dap4_fs_pp4"; + nvidia,function = "i2s3"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + dap4_din_pp5 { + nvidia,pins = "dap4_din_pp5"; + nvidia,function = "i2s3"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + dap4_dout_pp6 { + nvidia,pins = "dap4_dout_pp6"; + nvidia,function = "i2s3"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + dap4_sclk_pp7 { + nvidia,pins = "dap4_sclk_pp7"; + nvidia,function = "i2s3"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + kb_col0_pq0 { + nvidia,pins = "kb_col0_pq0"; + nvidia,function = "rsvd2"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + kb_col1_pq1 { + nvidia,pins = "kb_col1_pq1"; + nvidia,function = "rsvd2"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + kb_col2_pq2 { + nvidia,pins = "kb_col2_pq2"; + nvidia,function = "rsvd2"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + kb_col3_pq3 { + nvidia,pins = "kb_col3_pq3"; + nvidia,function = "kbc"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + kb_col4_pq4 { + nvidia,pins = "kb_col4_pq4"; + nvidia,function = "sdmmc3"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + kb_col5_pq5 { + nvidia,pins = "kb_col5_pq5"; + nvidia,function = "rsvd2"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + kb_col6_pq6 { + nvidia,pins = "kb_col6_pq6"; + nvidia,function = "rsvd2"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + kb_col7_pq7 { + nvidia,pins = "kb_col7_pq7"; + nvidia,function = "rsvd2"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + kb_row0_pr0 { + nvidia,pins = "kb_row0_pr0"; + nvidia,function = "rsvd2"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + kb_row1_pr1 { + nvidia,pins = "kb_row1_pr1"; + nvidia,function = "rsvd2"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + kb_row2_pr2 { + nvidia,pins = "kb_row2_pr2"; + nvidia,function = "rsvd2"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + kb_row3_pr3 { + nvidia,pins = "kb_row3_pr3"; + nvidia,function = "sys"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + kb_row4_pr4 { + nvidia,pins = "kb_row4_pr4"; + nvidia,function = "rsvd3"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + kb_row5_pr5 { + nvidia,pins = "kb_row5_pr5"; + nvidia,function = "rsvd3"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + kb_row6_pr6 { + nvidia,pins = "kb_row6_pr6"; + nvidia,function = "displaya_alt"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + kb_row7_pr7 { + nvidia,pins = "kb_row7_pr7"; + nvidia,function = "rsvd2"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + kb_row8_ps0 { + nvidia,pins = "kb_row8_ps0"; + nvidia,function = "rsvd2"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + kb_row9_ps1 { + nvidia,pins = "kb_row9_ps1"; + nvidia,function = "rsvd2"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + kb_row10_ps2 { + nvidia,pins = "kb_row10_ps2"; + nvidia,function = "rsvd2"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + kb_row11_ps3 { + nvidia,pins = "kb_row11_ps3"; + nvidia,function = "rsvd2"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + kb_row12_ps4 { + nvidia,pins = "kb_row12_ps4"; + nvidia,function = "rsvd2"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + kb_row13_ps5 { + nvidia,pins = "kb_row13_ps5"; + nvidia,function = "rsvd2"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + kb_row14_ps6 { + nvidia,pins = "kb_row14_ps6"; + nvidia,function = "rsvd2"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + kb_row15_ps7 { + nvidia,pins = "kb_row15_ps7"; + nvidia,function = "soc"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + kb_row16_pt0 { + nvidia,pins = "kb_row16_pt0"; + nvidia,function = "rsvd2"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + kb_row17_pt1 { + nvidia,pins = "kb_row17_pt1"; + nvidia,function = "rsvd2"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + gen2_i2c_scl_pt5 { + nvidia,pins = "gen2_i2c_scl_pt5"; + nvidia,function = "i2c2"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + nvidia,open-drain = ; + }; + gen2_i2c_sda_pt6 { + nvidia,pins = "gen2_i2c_sda_pt6"; + nvidia,function = "i2c2"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + nvidia,open-drain = ; + }; + sdmmc4_cmd_pt7 { + nvidia,pins = "sdmmc4_cmd_pt7"; + nvidia,function = "sdmmc4"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + pu0 { + nvidia,pins = "pu0"; + nvidia,function = "rsvd4"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + pu1 { + nvidia,pins = "pu1"; + nvidia,function = "rsvd1"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + pu2 { + nvidia,pins = "pu2"; + nvidia,function = "rsvd1"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + pu3 { + nvidia,pins = "pu3"; + nvidia,function = "gmi"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + pu4 { + nvidia,pins = "pu4"; + nvidia,function = "gmi"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + pu5 { + nvidia,pins = "pu5"; + nvidia,function = "gmi"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + pu6 { + nvidia,pins = "pu6"; + nvidia,function = "rsvd3"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + pv0 { + nvidia,pins = "pv0"; + nvidia,function = "rsvd1"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + pv1 { + nvidia,pins = "pv1"; + nvidia,function = "rsvd1"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + sdmmc3_cd_n_pv2 { + nvidia,pins = "sdmmc3_cd_n_pv2"; + nvidia,function = "sdmmc3"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + sdmmc1_wp_n_pv3 { + nvidia,pins = "sdmmc1_wp_n_pv3"; + nvidia,function = "sdmmc1"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + ddc_scl_pv4 { + nvidia,pins = "ddc_scl_pv4"; + nvidia,function = "i2c4"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + nvidia,rcv-sel = ; + }; + ddc_sda_pv5 { + nvidia,pins = "ddc_sda_pv5"; + nvidia,function = "i2c4"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + nvidia,rcv-sel = ; + }; + gpio_w2_aud_pw2 { + nvidia,pins = "gpio_w2_aud_pw2"; + nvidia,function = "rsvd2"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + gpio_w3_aud_pw3 { + nvidia,pins = "gpio_w3_aud_pw3"; + nvidia,function = "spi6"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + dap_mclk1_pw4 { + nvidia,pins = "dap_mclk1_pw4"; + nvidia,function = "extperiph1"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + clk2_out_pw5 { + nvidia,pins = "clk2_out_pw5"; + nvidia,function = "extperiph2"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + uart3_txd_pw6 { + nvidia,pins = "uart3_txd_pw6"; + nvidia,function = "uartc"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + uart3_rxd_pw7 { + nvidia,pins = "uart3_rxd_pw7"; + nvidia,function = "uartc"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + dvfs_pwm_px0 { + nvidia,pins = "dvfs_pwm_px0"; + nvidia,function = "cldvfs"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + gpio_x1_aud_px1 { + nvidia,pins = "gpio_x1_aud_px1"; + nvidia,function = "rsvd2"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + dvfs_clk_px2 { + nvidia,pins = "dvfs_clk_px2"; + nvidia,function = "cldvfs"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + gpio_x3_aud_px3 { + nvidia,pins = "gpio_x3_aud_px3"; + nvidia,function = "rsvd4"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + gpio_x4_aud_px4 { + nvidia,pins = "gpio_x4_aud_px4"; + nvidia,function = "gmi"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + gpio_x5_aud_px5 { + nvidia,pins = "gpio_x5_aud_px5"; + nvidia,function = "rsvd4"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + gpio_x6_aud_px6 { + nvidia,pins = "gpio_x6_aud_px6"; + nvidia,function = "gmi"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + gpio_x7_aud_px7 { + nvidia,pins = "gpio_x7_aud_px7"; + nvidia,function = "rsvd1"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + ulpi_clk_py0 { + nvidia,pins = "ulpi_clk_py0"; + nvidia,function = "spi1"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + ulpi_dir_py1 { + nvidia,pins = "ulpi_dir_py1"; + nvidia,function = "spi1"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + ulpi_nxt_py2 { + nvidia,pins = "ulpi_nxt_py2"; + nvidia,function = "spi1"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + ulpi_stp_py3 { + nvidia,pins = "ulpi_stp_py3"; + nvidia,function = "spi1"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + sdmmc1_dat3_py4 { + nvidia,pins = "sdmmc1_dat3_py4"; + nvidia,function = "sdmmc1"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + sdmmc1_dat2_py5 { + nvidia,pins = "sdmmc1_dat2_py5"; + nvidia,function = "sdmmc1"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + sdmmc1_dat1_py6 { + nvidia,pins = "sdmmc1_dat1_py6"; + nvidia,function = "sdmmc1"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + sdmmc1_dat0_py7 { + nvidia,pins = "sdmmc1_dat0_py7"; + nvidia,function = "sdmmc1"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + sdmmc1_clk_pz0 { + nvidia,pins = "sdmmc1_clk_pz0"; + nvidia,function = "sdmmc1"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + sdmmc1_cmd_pz1 { + nvidia,pins = "sdmmc1_cmd_pz1"; + nvidia,function = "sdmmc1"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + pwr_i2c_scl_pz6 { + nvidia,pins = "pwr_i2c_scl_pz6"; + nvidia,function = "i2cpwr"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + nvidia,open-drain = ; + }; + pwr_i2c_sda_pz7 { + nvidia,pins = "pwr_i2c_sda_pz7"; + nvidia,function = "i2cpwr"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + nvidia,open-drain = ; + }; + sdmmc4_dat0_paa0 { + nvidia,pins = "sdmmc4_dat0_paa0"; + nvidia,function = "sdmmc4"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + sdmmc4_dat1_paa1 { + nvidia,pins = "sdmmc4_dat1_paa1"; + nvidia,function = "sdmmc4"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + sdmmc4_dat2_paa2 { + nvidia,pins = "sdmmc4_dat2_paa2"; + nvidia,function = "sdmmc4"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + sdmmc4_dat3_paa3 { + nvidia,pins = "sdmmc4_dat3_paa3"; + nvidia,function = "sdmmc4"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + sdmmc4_dat4_paa4 { + nvidia,pins = "sdmmc4_dat4_paa4"; + nvidia,function = "sdmmc4"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + sdmmc4_dat5_paa5 { + nvidia,pins = "sdmmc4_dat5_paa5"; + nvidia,function = "sdmmc4"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + sdmmc4_dat6_paa6 { + nvidia,pins = "sdmmc4_dat6_paa6"; + nvidia,function = "sdmmc4"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + sdmmc4_dat7_paa7 { + nvidia,pins = "sdmmc4_dat7_paa7"; + nvidia,function = "sdmmc4"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + pbb0 { + nvidia,pins = "pbb0"; + nvidia,function = "vimclk2_alt"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + cam_i2c_scl_pbb1 { + nvidia,pins = "cam_i2c_scl_pbb1"; + nvidia,function = "i2c3"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + nvidia,open-drain = ; + }; + cam_i2c_sda_pbb2 { + nvidia,pins = "cam_i2c_sda_pbb2"; + nvidia,function = "i2c3"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + nvidia,open-drain = ; + }; + pbb3 { + nvidia,pins = "pbb3"; + nvidia,function = "vgp3"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + pbb4 { + nvidia,pins = "pbb4"; + nvidia,function = "vgp4"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + pbb5 { + nvidia,pins = "pbb5"; + nvidia,function = "rsvd3"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + pbb6 { + nvidia,pins = "pbb6"; + nvidia,function = "rsvd2"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + pbb7 { + nvidia,pins = "pbb7"; + nvidia,function = "rsvd2"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + cam_mclk_pcc0 { + nvidia,pins = "cam_mclk_pcc0"; + nvidia,function = "vi_alt3"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + pcc1 { + nvidia,pins = "pcc1"; + nvidia,function = "rsvd2"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + pcc2 { + nvidia,pins = "pcc2"; + nvidia,function = "rsvd2"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + sdmmc4_clk_pcc4 { + nvidia,pins = "sdmmc4_clk_pcc4"; + nvidia,function = "sdmmc4"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + clk2_req_pcc5 { + nvidia,pins = "clk2_req_pcc5"; + nvidia,function = "rsvd2"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + clk3_out_pee0 { + nvidia,pins = "clk3_out_pee0"; + nvidia,function = "extperiph3"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + clk3_req_pee1 { + nvidia,pins = "clk3_req_pee1"; + nvidia,function = "rsvd2"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + dap_mclk1_req_pee2 { + nvidia,pins = "dap_mclk1_req_pee2"; + nvidia,function = "sata"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + hdmi_cec_pee3 { + nvidia,pins = "hdmi_cec_pee3"; + nvidia,function = "cec"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + nvidia,open-drain = ; + }; + sdmmc3_clk_lb_out_pee4 { + nvidia,pins = "sdmmc3_clk_lb_out_pee4"; + nvidia,function = "sdmmc3"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + sdmmc3_clk_lb_in_pee5 { + nvidia,pins = "sdmmc3_clk_lb_in_pee5"; + nvidia,function = "sdmmc3"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + dp_hpd_pff0 { + nvidia,pins = "dp_hpd_pff0"; + nvidia,function = "dp"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + usb_vbus_en2_pff1 { + nvidia,pins = "usb_vbus_en2_pff1"; + nvidia,function = "rsvd2"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + nvidia,open-drain = ; + }; + pff2 { + nvidia,pins = "pff2"; + nvidia,function = "rsvd2"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + nvidia,open-drain = ; + }; + core_pwr_req { + nvidia,pins = "core_pwr_req"; + nvidia,function = "pwron"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + cpu_pwr_req { + nvidia,pins = "cpu_pwr_req"; + nvidia,function = "rsvd2"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + pwr_int_n { + nvidia,pins = "pwr_int_n"; + nvidia,function = "pmi"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + reset_out_n { + nvidia,pins = "reset_out_n"; + nvidia,function = "reset_out_n"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + owr { + nvidia,pins = "owr"; + nvidia,function = "rsvd2"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + nvidia,rcv-sel = ; + }; + clk_32k_in { + nvidia,pins = "clk_32k_in"; + nvidia,function = "rsvd2"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + jtag_rtck { + nvidia,pins = "jtag_rtck"; + nvidia,function = "rtck"; + nvidia,pull = ; + nvidia,tristate = ; + nvidia,enable-input = ; + }; + }; + }; + + /* DB9 serial port */ + serial@0,70006300 { + status = "okay"; + }; + + /* Expansion GEN1_I2C_*, mini-PCIe I2C, on-board components */ + i2c@0,7000c000 { + status = "okay"; + clock-frequency = <100000>; + + rt5640: audio-codec@1c { + compatible = "realtek,rt5640"; + reg = <0x1c>; + interrupt-parent = <&gpio>; + interrupts = ; + realtek,ldo1-en-gpios = + <&gpio TEGRA_GPIO(R, 2) GPIO_ACTIVE_HIGH>; + }; + + temperature-sensor@4c { + compatible = "ti,tmp451"; + reg = <0x4c>; + interrupt-parent = <&gpio>; + interrupts = ; + }; + + eeprom@56 { + compatible = "atmel,24c02"; + reg = <0x56>; + pagesize = <8>; + }; + }; + + /* Expansion GEN2_I2C_* */ + i2c@0,7000c400 { + status = "okay"; + clock-frequency = <100000>; + }; + + /* Expansion CAM_I2C_* */ + i2c@0,7000c500 { + status = "okay"; + clock-frequency = <100000>; + }; + + /* HDMI DDC */ + i2c@0,7000c700 { + status = "okay"; + clock-frequency = <100000>; + }; + + /* Expansion PWR_I2C_*, on-board components */ + i2c@0,7000d000 { + status = "okay"; + clock-frequency = <400000>; + + pmic: pmic@40 { + compatible = "ams,as3722"; + reg = <0x40>; + interrupts = <0 86 IRQ_TYPE_LEVEL_HIGH>; + + ams,system-power-controller; + + #interrupt-cells = <2>; + interrupt-controller; + + gpio-controller; + #gpio-cells = <2>; + + pinctrl-names = "default"; + pinctrl-0 = <&as3722_default>; + + as3722_default: pinmux { + gpio0 { + pins = "gpio0"; + function = "gpio"; + bias-pull-down; + }; + + gpio1_2_4_7 { + pins = "gpio1", "gpio2", "gpio4", "gpio7"; + function = "gpio"; + bias-pull-up; + }; + + gpio3_5_6 { + pins = "gpio3", "gpio5", "gpio6"; + bias-high-impedance; + }; + }; + }; + }; + + /* Expansion TS_SPI_* */ + spi@0,7000d400 { + status = "okay"; + }; + + /* Internal SPI */ + spi@0,7000da00 { + status = "okay"; + spi-max-frequency = <25000000>; + spi-flash@0 { + compatible = "winbond,w25q32dw"; + reg = <0>; + spi-max-frequency = <20000000>; + }; + }; + + pmc@0,7000e400 { + nvidia,invert-interrupt; + nvidia,suspend-mode = <1>; + nvidia,cpu-pwr-good-time = <500>; + nvidia,cpu-pwr-off-time = <300>; + nvidia,core-pwr-good-time = <641 3845>; + nvidia,core-pwr-off-time = <61036>; + nvidia,core-power-req-active-high; + nvidia,sys-clock-req-active-high; + }; + + /* SD card */ + sdhci@0,700b0400 { + status = "okay"; + cd-gpios = <&gpio TEGRA_GPIO(V, 2) GPIO_ACTIVE_LOW>; + power-gpios = <&gpio TEGRA_GPIO(R, 0) GPIO_ACTIVE_HIGH>; + bus-width = <4>; + }; + + /* eMMC */ + sdhci@0,700b0600 { + status = "okay"; + bus-width = <8>; + }; + + ahub@0,70300000 { + i2s@0,70301100 { + status = "okay"; + }; + }; + + /* mini-PCIe USB */ + usb@0,7d004000 { + status = "okay"; + }; + + usb-phy@0,7d004000 { + status = "okay"; + }; + + /* USB A connector */ + usb@0,7d008000 { + status = "okay"; + }; + + usb-phy@0,7d008000 { + status = "okay"; + vbus-supply = <&vdd_usb3_vbus>; + }; + + clocks { + compatible = "simple-bus"; + #address-cells = <1>; + #size-cells = <0>; + + clk32k_in: clock@0 { + compatible = "fixed-clock"; + reg = <0>; + #clock-cells = <0>; + clock-frequency = <32768>; + }; + }; + + gpio-keys { + compatible = "gpio-keys"; + + power { + label = "Power"; + gpios = <&gpio TEGRA_GPIO(Q, 0) GPIO_ACTIVE_LOW>; + linux,code = ; + debounce-interval = <10>; + gpio-key,wakeup; + }; + }; + + regulators { + compatible = "simple-bus"; + #address-cells = <1>; + #size-cells = <0>; + + vdd_usb3_vbus: regulator@8 { + compatible = "regulator-fixed"; + reg = <8>; + regulator-name = "+5V_USB_HS"; + regulator-min-microvolt = <5000000>; + regulator-max-microvolt = <5000000>; + gpio = <&gpio TEGRA_GPIO(N, 5) GPIO_ACTIVE_HIGH>; + enable-active-high; + gpio-open-drain; + }; + }; + + sound { + compatible = "nvidia,tegra-audio-rt5640-jetson-tk1", + "nvidia,tegra-audio-rt5640"; + nvidia,model = "NVIDIA Tegra Jetson TK1"; + + nvidia,audio-routing = + "Headphones", "HPOR", + "Headphones", "HPOL", + "Mic Jack", "MICBIAS1", + "IN2P", "Mic Jack"; + + nvidia,i2s-controller = <&tegra_i2s1>; + nvidia,audio-codec = <&rt5640>; + + nvidia,hp-det-gpios = <&gpio TEGRA_GPIO(R, 7) GPIO_ACTIVE_LOW>; + + clocks = <&tegra_car TEGRA124_CLK_PLL_A>, + <&tegra_car TEGRA124_CLK_PLL_A_OUT0>, + <&tegra_car TEGRA124_CLK_EXTERN1>; + clock-names = "pll_a", "pll_a_out0", "mclk"; + }; +}; -- cgit v1.2.3 From 22b3577659fd2d001ef9455a2856321a99229747 Mon Sep 17 00:00:00 2001 From: Stephen Warren Date: Mon, 24 Mar 2014 18:04:43 -0600 Subject: ARM: tegra: define Jetson TK1 regulators These are mostly identical to the Venice2 regulator definitions, since the board designs are very similar. Differences are: - Jetson TK1 doesn't have a built-in LCD panel, so on-board regulators are not present for the backlight, touchscreen, or panel. - +3.3V_RUN needs to be boot-on/always-on, since it's widely used. This change should likely be propagated to Venice2 for completeness, although it will have no practical effect there since various other regulators use +3.3V_RUN as their supply and are always-on. - +3.3V_LP0 needs to be boot-on as well as always-on. One reason is because it's used to driver the UART level-shifter; without this, I see a brief period of UART corruption during cold boots.I suspect this change needs to be propagated to Venice2, and we simply haven't noticed the need since there's no UART level-shifter on Venice2. - A few rails have different names in the schematics. Signed-off-by: Stephen Warren --- arch/arm/boot/dts/tegra124-jetson-tk1.dts | 230 ++++++++++++++++++++++++++++++ 1 file changed, 230 insertions(+) diff --git a/arch/arm/boot/dts/tegra124-jetson-tk1.dts b/arch/arm/boot/dts/tegra124-jetson-tk1.dts index dedcb0c165c5..ae5c750dc515 100644 --- a/arch/arm/boot/dts/tegra124-jetson-tk1.dts +++ b/arch/arm/boot/dts/tegra124-jetson-tk1.dts @@ -1426,6 +1426,155 @@ bias-high-impedance; }; }; + + regulators { + vsup-sd2-supply = <&vdd_5v0_sys>; + vsup-sd3-supply = <&vdd_5v0_sys>; + vsup-sd4-supply = <&vdd_5v0_sys>; + vsup-sd5-supply = <&vdd_5v0_sys>; + vin-ldo0-supply = <&vdd_1v35_lp0>; + vin-ldo1-6-supply = <&vdd_3v3_run>; + vin-ldo2-5-7-supply = <&vddio_1v8>; + vin-ldo3-4-supply = <&vdd_3v3_sys>; + vin-ldo9-10-supply = <&vdd_5v0_sys>; + vin-ldo11-supply = <&vdd_3v3_run>; + + sd0 { + regulator-name = "+VDD_CPU_AP"; + regulator-min-microvolt = <700000>; + regulator-max-microvolt = <1400000>; + regulator-min-microamp = <3500000>; + regulator-max-microamp = <3500000>; + regulator-always-on; + regulator-boot-on; + ams,external-control = <2>; + }; + + sd1 { + regulator-name = "+VDD_CORE"; + regulator-min-microvolt = <700000>; + regulator-max-microvolt = <1350000>; + regulator-min-microamp = <2500000>; + regulator-max-microamp = <2500000>; + regulator-always-on; + regulator-boot-on; + ams,external-control = <1>; + }; + + vdd_1v35_lp0: sd2 { + regulator-name = "+1.35V_LP0(sd2)"; + regulator-min-microvolt = <1350000>; + regulator-max-microvolt = <1350000>; + regulator-always-on; + regulator-boot-on; + }; + + sd3 { + regulator-name = "+1.35V_LP0(sd3)"; + regulator-min-microvolt = <1350000>; + regulator-max-microvolt = <1350000>; + regulator-always-on; + regulator-boot-on; + }; + + sd4 { + regulator-name = "+1.05V_RUN"; + regulator-min-microvolt = <1050000>; + regulator-max-microvolt = <1050000>; + }; + + vddio_1v8: sd5 { + regulator-name = "+1.8V_VDDIO"; + regulator-min-microvolt = <1800000>; + regulator-max-microvolt = <1800000>; + regulator-boot-on; + regulator-always-on; + }; + + sd6 { + regulator-name = "+VDD_GPU_AP"; + regulator-min-microvolt = <650000>; + regulator-max-microvolt = <1200000>; + regulator-min-microamp = <3500000>; + regulator-max-microamp = <3500000>; + regulator-boot-on; + regulator-always-on; + }; + + ldo0 { + regulator-name = "+1.05V_RUN_AVDD"; + regulator-min-microvolt = <1050000>; + regulator-max-microvolt = <1050000>; + regulator-boot-on; + regulator-always-on; + ams,external-control = <1>; + }; + + ldo1 { + regulator-name = "+1.8V_RUN_CAM"; + regulator-min-microvolt = <1800000>; + regulator-max-microvolt = <1800000>; + }; + + ldo2 { + regulator-name = "+1.2V_GEN_AVDD"; + regulator-min-microvolt = <1200000>; + regulator-max-microvolt = <1200000>; + regulator-boot-on; + regulator-always-on; + }; + + ldo3 { + regulator-name = "+1.05V_LP0_VDD_RTC"; + regulator-min-microvolt = <1000000>; + regulator-max-microvolt = <1000000>; + regulator-boot-on; + regulator-always-on; + ams,enable-tracking; + }; + + ldo4 { + regulator-name = "+2.8V_RUN_CAM"; + regulator-min-microvolt = <2800000>; + regulator-max-microvolt = <2800000>; + }; + + ldo5 { + regulator-name = "+1.2V_RUN_CAM_FRONT"; + regulator-min-microvolt = <1200000>; + regulator-max-microvolt = <1200000>; + }; + + vddio_sdmmc3: ldo6 { + regulator-name = "+VDDIO_SDMMC3"; + regulator-min-microvolt = <1800000>; + regulator-max-microvolt = <3300000>; + }; + + ldo7 { + regulator-name = "+1.05V_RUN_CAM_REAR"; + regulator-min-microvolt = <1050000>; + regulator-max-microvolt = <1050000>; + }; + + ldo9 { + regulator-name = "+3.3V_RUN_TOUCH"; + regulator-min-microvolt = <2800000>; + regulator-max-microvolt = <2800000>; + }; + + ldo10 { + regulator-name = "+2.8V_RUN_CAM_AF"; + regulator-min-microvolt = <2800000>; + regulator-max-microvolt = <2800000>; + }; + + ldo11 { + regulator-name = "+1.8V_RUN_VPP_FUSE"; + regulator-min-microvolt = <1800000>; + regulator-max-microvolt = <1800000>; + }; + }; }; }; @@ -1462,6 +1611,7 @@ cd-gpios = <&gpio TEGRA_GPIO(V, 2) GPIO_ACTIVE_LOW>; power-gpios = <&gpio TEGRA_GPIO(R, 0) GPIO_ACTIVE_HIGH>; bus-width = <4>; + vmmc-supply = <&vddio_sdmmc3>; }; /* eMMC */ @@ -1525,6 +1675,72 @@ #address-cells = <1>; #size-cells = <0>; + vdd_mux: regulator@0 { + compatible = "regulator-fixed"; + reg = <0>; + regulator-name = "+VDD_MUX"; + regulator-min-microvolt = <12000000>; + regulator-max-microvolt = <12000000>; + regulator-always-on; + regulator-boot-on; + }; + + vdd_5v0_sys: regulator@1 { + compatible = "regulator-fixed"; + reg = <1>; + regulator-name = "+5V_SYS"; + regulator-min-microvolt = <5000000>; + regulator-max-microvolt = <5000000>; + regulator-always-on; + regulator-boot-on; + vin-supply = <&vdd_mux>; + }; + + vdd_3v3_sys: regulator@2 { + compatible = "regulator-fixed"; + reg = <2>; + regulator-name = "+3.3V_SYS"; + regulator-min-microvolt = <3300000>; + regulator-max-microvolt = <3300000>; + regulator-always-on; + regulator-boot-on; + vin-supply = <&vdd_mux>; + }; + + vdd_3v3_run: regulator@3 { + compatible = "regulator-fixed"; + reg = <3>; + regulator-name = "+3.3V_RUN"; + regulator-min-microvolt = <3300000>; + regulator-max-microvolt = <3300000>; + regulator-always-on; + regulator-boot-on; + gpio = <&pmic 1 GPIO_ACTIVE_HIGH>; + enable-active-high; + vin-supply = <&vdd_3v3_sys>; + }; + + vdd_3v3_hdmi: regulator@4 { + compatible = "regulator-fixed"; + reg = <4>; + regulator-name = "+3.3V_AVDD_HDMI_AP_GATED"; + regulator-min-microvolt = <3300000>; + regulator-max-microvolt = <3300000>; + vin-supply = <&vdd_3v3_run>; + }; + + vdd_usb1_vbus: regulator@7 { + compatible = "regulator-fixed"; + reg = <7>; + regulator-name = "+USB0_VBUS_SW"; + regulator-min-microvolt = <5000000>; + regulator-max-microvolt = <5000000>; + gpio = <&gpio TEGRA_GPIO(N, 4) GPIO_ACTIVE_HIGH>; + enable-active-high; + gpio-open-drain; + vin-supply = <&vdd_5v0_sys>; + }; + vdd_usb3_vbus: regulator@8 { compatible = "regulator-fixed"; reg = <8>; @@ -1534,6 +1750,20 @@ gpio = <&gpio TEGRA_GPIO(N, 5) GPIO_ACTIVE_HIGH>; enable-active-high; gpio-open-drain; + vin-supply = <&vdd_5v0_sys>; + }; + + vdd_3v3_lp0: regulator@10 { + compatible = "regulator-fixed"; + reg = <10>; + regulator-name = "+3.3V_LP0"; + regulator-min-microvolt = <3300000>; + regulator-max-microvolt = <3300000>; + regulator-always-on; + regulator-boot-on; + gpio = <&pmic 2 GPIO_ACTIVE_HIGH>; + enable-active-high; + vin-supply = <&vdd_3v3_sys>; }; }; -- cgit v1.2.3 From 66097ca7889965e1b85de5cf699d7d728d84f47a Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Tue, 15 Apr 2014 22:24:21 +0200 Subject: ASoC: Fix snd_soc_kcontrol_platform() return type This should obviously be snd_soc_platform * and not snd_soc_codec * Fixes: f6272ff8a5f4 ("ASoC: Add snd_soc_kcontrol_platform() helper function") Reported-by: kbuild test robot Reported-by: Stephen Rothwell Signed-off-by: Lars-Peter Clausen Signed-off-by: Mark Brown --- include/sound/soc.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/sound/soc.h b/include/sound/soc.h index 94a2dc20ad6e..81454b0dd624 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h @@ -1253,7 +1253,7 @@ static inline struct snd_soc_codec *snd_soc_kcontrol_codec( * registered with snd_soc_add_platform_controls() or via table based setup of * a snd_soc_platform_driver. Otherwise the behavior is undefined. */ -static inline struct snd_soc_codec *snd_soc_kcontrol_platform( +static inline struct snd_soc_platform *snd_soc_kcontrol_platform( struct snd_kcontrol *kcontrol) { return snd_kcontrol_chip(kcontrol); -- cgit v1.2.3 From 72dc392ae5bbad3477053ac4c5708dba6706ffa0 Mon Sep 17 00:00:00 2001 From: Geert Uytterhoeven Date: Tue, 15 Apr 2014 14:33:57 +0200 Subject: ARM: shmobile: r8a7740: Remove unused r8a7740_add_early_devices_dt() It was removed in commit 744fdc8dc0e22cc5b61ee1bcde9375f188daa330 ("ARM: shmobile: r8a7740: Prepare for reference DT setup"), but accidentally resurrected in commit 88378837780166d67a11142cd6f76596c0a2d8c3 ("ARM: shmobile: Remove unused r8a7740 auxdata table"). Signed-off-by: Geert Uytterhoeven Reviewed-by: Laurent Pinchart Signed-off-by: Simon Horman --- arch/arm/mach-shmobile/setup-r8a7740.c | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/arch/arm/mach-shmobile/setup-r8a7740.c b/arch/arm/mach-shmobile/setup-r8a7740.c index 8f3c68101d59..cba3a07a97c2 100644 --- a/arch/arm/mach-shmobile/setup-r8a7740.c +++ b/arch/arm/mach-shmobile/setup-r8a7740.c @@ -869,17 +869,6 @@ void __init r8a7740_add_early_devices(void) #ifdef CONFIG_USE_OF -void __init r8a7740_add_early_devices_dt(void) -{ - shmobile_setup_delay(800, 1, 3); /* Cortex-A9 @ 800MHz */ - - early_platform_add_devices(r8a7740_early_devices, - ARRAY_SIZE(r8a7740_early_devices)); - - /* setup early console here as well */ - shmobile_setup_console(); -} - void __init r8a7740_add_standard_devices_dt(void) { platform_add_devices(r8a7740_devices_dt, -- cgit v1.2.3 From 1fba31f047639a6c7accf4f6d075a6cf9eacecc0 Mon Sep 17 00:00:00 2001 From: Geert Uytterhoeven Date: Tue, 15 Apr 2014 14:33:59 +0200 Subject: ARM: shmobile: sh7372: Call sh7372_add_early_devices() instead of open coding Signed-off-by: Geert Uytterhoeven Reviewed-by: Laurent Pinchart Signed-off-by: Simon Horman --- arch/arm/mach-shmobile/setup-sh7372.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/arch/arm/mach-shmobile/setup-sh7372.c b/arch/arm/mach-shmobile/setup-sh7372.c index 27301278c208..f8176b051be4 100644 --- a/arch/arm/mach-shmobile/setup-sh7372.c +++ b/arch/arm/mach-shmobile/setup-sh7372.c @@ -1037,11 +1037,7 @@ void __init sh7372_add_early_devices_dt(void) { shmobile_setup_delay(800, 1, 3); /* Cortex-A8 @ 800MHz */ - early_platform_add_devices(sh7372_early_devices, - ARRAY_SIZE(sh7372_early_devices)); - - /* setup early console here as well */ - shmobile_setup_console(); + sh7372_add_early_devices(); } void __init sh7372_add_standard_devices_dt(void) -- cgit v1.2.3 From bb6c3d58c36adb205b4bf233fd1c4079e02a6811 Mon Sep 17 00:00:00 2001 From: Geert Uytterhoeven Date: Tue, 15 Apr 2014 14:33:58 +0200 Subject: ARM: shmobile: r8a7740: Make r8a7740_meram_workaround() __init It's called from eva_init() only, which is __init Signed-off-by: Geert Uytterhoeven Reviewed-by: Laurent Pinchart Signed-off-by: Simon Horman --- arch/arm/mach-shmobile/setup-r8a7740.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm/mach-shmobile/setup-r8a7740.c b/arch/arm/mach-shmobile/setup-r8a7740.c index cba3a07a97c2..a177a7b3bdbd 100644 --- a/arch/arm/mach-shmobile/setup-r8a7740.c +++ b/arch/arm/mach-shmobile/setup-r8a7740.c @@ -765,7 +765,7 @@ static struct platform_device *r8a7740_late_devices[] __initdata = { * "Media RAM (MERAM)" on r8a7740 documentation */ #define MEBUFCNTR 0xFE950098 -void r8a7740_meram_workaround(void) +void __init r8a7740_meram_workaround(void) { void __iomem *reg; -- cgit v1.2.3 From dd485ab9a88267f4db0d58ace23b19e876ebf8ac Mon Sep 17 00:00:00 2001 From: Geert Uytterhoeven Date: Tue, 15 Apr 2014 14:51:50 +0200 Subject: ARM: shmobile: armadillo-reference dts: Seiko Instruments, Inc is "sii" Use "sii,s35390a" instead of "seiko,s35390a", cfr. Documentation/devicetree/bindings/i2c/trivial-devices.txt and Documentation/devicetree/bindings/vendor-prefixes.txt. Signed-off-by: Geert Uytterhoeven Acked-by: Ulrich Hecht Signed-off-by: Simon Horman --- arch/arm/boot/dts/r8a7740-armadillo800eva-reference.dts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm/boot/dts/r8a7740-armadillo800eva-reference.dts b/arch/arm/boot/dts/r8a7740-armadillo800eva-reference.dts index 0cb235a450b9..10344e6edd20 100644 --- a/arch/arm/boot/dts/r8a7740-armadillo800eva-reference.dts +++ b/arch/arm/boot/dts/r8a7740-armadillo800eva-reference.dts @@ -180,7 +180,7 @@ &i2c2 { status = "okay"; rtc@30 { - compatible = "seiko,s35390a"; + compatible = "sii,s35390a"; reg = <0x30>; }; }; -- cgit v1.2.3 From b13b1d2d8692b437203de7a404c6b809d2cc4d99 Mon Sep 17 00:00:00 2001 From: Shaohua Li Date: Tue, 8 Apr 2014 15:58:09 +0800 Subject: x86/mm: In the PTE swapout page reclaim case clear the accessed bit instead of flushing the TLB We use the accessed bit to age a page at page reclaim time, and currently we also flush the TLB when doing so. But in some workloads TLB flush overhead is very heavy. In my simple multithreaded app with a lot of swap to several pcie SSDs, removing the tlb flush gives about 20% ~ 30% swapout speedup. Fortunately just removing the TLB flush is a valid optimization: on x86 CPUs, clearing the accessed bit without a TLB flush doesn't cause data corruption. It could cause incorrect page aging and the (mistaken) reclaim of hot pages, but the chance of that should be relatively low. So as a performance optimization don't flush the TLB when clearing the accessed bit, it will eventually be flushed by a context switch or a VM operation anyway. [ In the rare event of it not getting flushed for a long time the delay shouldn't really matter because there's no real memory pressure for swapout to react to. ] Suggested-by: Linus Torvalds Signed-off-by: Shaohua Li Acked-by: Rik van Riel Acked-by: Mel Gorman Acked-by: Hugh Dickins Acked-by: Johannes Weiner Cc: linux-mm@kvack.org Cc: Peter Zijlstra Link: http://lkml.kernel.org/r/20140408075809.GA1764@kernel.org [ Rewrote the changelog and the code comments. ] Signed-off-by: Ingo Molnar --- arch/x86/mm/pgtable.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/arch/x86/mm/pgtable.c b/arch/x86/mm/pgtable.c index c96314abd144..0004ac72dbdd 100644 --- a/arch/x86/mm/pgtable.c +++ b/arch/x86/mm/pgtable.c @@ -399,13 +399,20 @@ int pmdp_test_and_clear_young(struct vm_area_struct *vma, int ptep_clear_flush_young(struct vm_area_struct *vma, unsigned long address, pte_t *ptep) { - int young; - - young = ptep_test_and_clear_young(vma, address, ptep); - if (young) - flush_tlb_page(vma, address); - - return young; + /* + * On x86 CPUs, clearing the accessed bit without a TLB flush + * doesn't cause data corruption. [ It could cause incorrect + * page aging and the (mistaken) reclaim of hot pages, but the + * chance of that should be relatively low. ] + * + * So as a performance optimization don't flush the TLB when + * clearing the accessed bit, it will eventually be flushed by + * a context switch or a VM operation anyway. [ In the rare + * event of it not getting flushed for a long time the delay + * shouldn't really matter because there's no real memory + * pressure for swapout to react to. ] + */ + return ptep_test_and_clear_young(vma, address, ptep); } #ifdef CONFIG_TRANSPARENT_HUGEPAGE -- cgit v1.2.3 From 4b973ee05673497de678338c00ade803e45f9bfa Mon Sep 17 00:00:00 2001 From: Alexander Stein Date: Tue, 15 Apr 2014 19:38:56 +0200 Subject: ALSA: sound/atmel/ac97c.c: Convert to module_platform_driver This reduces some boilerplate code. Signed-off-by: Alexander Stein Acked-by: Alexandre Belloni Acked-by: Nicolas Ferre Signed-off-by: Takashi Iwai --- sound/atmel/ac97c.c | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/sound/atmel/ac97c.c b/sound/atmel/ac97c.c index 05ec049c9faf..a04d23174dc2 100644 --- a/sound/atmel/ac97c.c +++ b/sound/atmel/ac97c.c @@ -1198,6 +1198,7 @@ static int atmel_ac97c_remove(struct platform_device *pdev) } static struct platform_driver atmel_ac97c_driver = { + .probe = atmel_ac97c_probe, .remove = atmel_ac97c_remove, .driver = { .name = "atmel_ac97c", @@ -1205,19 +1206,7 @@ static struct platform_driver atmel_ac97c_driver = { .pm = ATMEL_AC97C_PM_OPS, }, }; - -static int __init atmel_ac97c_init(void) -{ - return platform_driver_probe(&atmel_ac97c_driver, - atmel_ac97c_probe); -} -module_init(atmel_ac97c_init); - -static void __exit atmel_ac97c_exit(void) -{ - platform_driver_unregister(&atmel_ac97c_driver); -} -module_exit(atmel_ac97c_exit); +module_platform_driver(atmel_ac97c_driver); MODULE_LICENSE("GPL"); MODULE_DESCRIPTION("Driver for Atmel AC97 controller"); -- cgit v1.2.3 From 5c7ab1574987f131f983b15ecfd717faf114f4df Mon Sep 17 00:00:00 2001 From: Alexander Stein Date: Tue, 15 Apr 2014 19:38:57 +0200 Subject: ALSA: sound/atmel-ac97c.h: Remove unused flags from platform data This platform data member is unused, so remove it. Signed-off-by: Alexander Stein Acked-by: Alexandre Belloni Acked-by: Nicolas Ferre Signed-off-by: Takashi Iwai --- include/sound/atmel-ac97c.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/include/sound/atmel-ac97c.h b/include/sound/atmel-ac97c.h index e6aabdb45865..00e6c289a936 100644 --- a/include/sound/atmel-ac97c.h +++ b/include/sound/atmel-ac97c.h @@ -23,7 +23,6 @@ * @reset_pin: GPIO pin wired to the reset input on the external AC97 codec, * optional to use, set to -ENODEV if not in use. AC97 layer will * try to do a software reset of the external codec anyway. - * @flags: Flags for which directions should be enabled. * * If the user do not want to use a DMA channel for playback or capture, i.e. * only one feature is required on the board. The slave for playback or capture @@ -33,7 +32,6 @@ struct ac97c_platform_data { struct dw_dma_slave rx_dws; struct dw_dma_slave tx_dws; - unsigned int flags; int reset_pin; }; -- cgit v1.2.3 From dc2eadece70089430f12e4ed6bb1a4421cf3d6f4 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Mon, 17 Feb 2014 11:27:49 +0100 Subject: clocksource: sh_cmt: Use request_irq() instead of setup_irq() The driver claims it needs to register an interrupt handler too early for request_irq(). This might have been true in the past, but the only meaningful difference between request_irq() and setup_irq() today is an additional kzalloc() call in request_irq(). As the driver calls kmalloc() itself we know that the slab allocator is available, we can thus switch to request_irq(). Signed-off-by: Laurent Pinchart --- drivers/clocksource/sh_cmt.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/drivers/clocksource/sh_cmt.c b/drivers/clocksource/sh_cmt.c index 0b1836a6c539..a3103b871260 100644 --- a/drivers/clocksource/sh_cmt.c +++ b/drivers/clocksource/sh_cmt.c @@ -728,12 +728,6 @@ static int sh_cmt_setup(struct sh_cmt_priv *p, struct platform_device *pdev) goto err1; } - /* request irq using setup_irq() (too early for request_irq()) */ - p->irqaction.name = dev_name(&p->pdev->dev); - p->irqaction.handler = sh_cmt_interrupt; - p->irqaction.dev_id = p; - p->irqaction.flags = IRQF_TIMER | IRQF_IRQPOLL | IRQF_NOBALANCING; - /* get hold of clock */ p->clk = clk_get(&p->pdev->dev, "cmt_fck"); if (IS_ERR(p->clk)) { @@ -786,7 +780,9 @@ static int sh_cmt_setup(struct sh_cmt_priv *p, struct platform_device *pdev) } p->cs_enabled = false; - ret = setup_irq(irq, &p->irqaction); + ret = request_irq(irq, sh_cmt_interrupt, + IRQF_TIMER | IRQF_IRQPOLL | IRQF_NOBALANCING, + dev_name(&p->pdev->dev), p); if (ret) { dev_err(&p->pdev->dev, "failed to request irq %d\n", irq); goto err4; -- cgit v1.2.3 From 7269f9333292586f2378c5321b40a8d3779c4653 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Mon, 27 Jan 2014 15:29:19 +0100 Subject: clocksource: sh_cmt: Split channel fields from sh_cmt_priv Create a new sh_cmt_channel structure to hold the channel-specific field in preparation for multiple channels per device support. Signed-off-by: Laurent Pinchart --- drivers/clocksource/sh_cmt.c | 385 ++++++++++++++++++++++--------------------- 1 file changed, 199 insertions(+), 186 deletions(-) diff --git a/drivers/clocksource/sh_cmt.c b/drivers/clocksource/sh_cmt.c index a3103b871260..351b3ca3ccc4 100644 --- a/drivers/clocksource/sh_cmt.c +++ b/drivers/clocksource/sh_cmt.c @@ -35,15 +35,10 @@ #include #include -struct sh_cmt_priv { - void __iomem *mapbase; - void __iomem *mapbase_str; - struct clk *clk; - unsigned long width; /* 16 or 32 bit version of hardware block */ - unsigned long overflow_bit; - unsigned long clear_bits; - struct irqaction irqaction; - struct platform_device *pdev; +struct sh_cmt_priv; + +struct sh_cmt_channel { + struct sh_cmt_priv *cmt; unsigned long flags; unsigned long match_value; @@ -55,6 +50,20 @@ struct sh_cmt_priv { struct clocksource cs; unsigned long total_cycles; bool cs_enabled; +}; + +struct sh_cmt_priv { + struct platform_device *pdev; + + void __iomem *mapbase; + void __iomem *mapbase_str; + struct clk *clk; + + struct sh_cmt_channel channel; + + unsigned long width; /* 16 or 32 bit version of hardware block */ + unsigned long overflow_bit; + unsigned long clear_bits; /* callbacks for CMSTR and CMCSR access */ unsigned long (*read_control)(void __iomem *base, unsigned long offs); @@ -114,60 +123,60 @@ static void sh_cmt_write32(void __iomem *base, unsigned long offs, #define CMCNT 1 /* channel register */ #define CMCOR 2 /* channel register */ -static inline unsigned long sh_cmt_read_cmstr(struct sh_cmt_priv *p) +static inline unsigned long sh_cmt_read_cmstr(struct sh_cmt_channel *ch) { - return p->read_control(p->mapbase_str, 0); + return ch->cmt->read_control(ch->cmt->mapbase_str, 0); } -static inline unsigned long sh_cmt_read_cmcsr(struct sh_cmt_priv *p) +static inline unsigned long sh_cmt_read_cmcsr(struct sh_cmt_channel *ch) { - return p->read_control(p->mapbase, CMCSR); + return ch->cmt->read_control(ch->cmt->mapbase, CMCSR); } -static inline unsigned long sh_cmt_read_cmcnt(struct sh_cmt_priv *p) +static inline unsigned long sh_cmt_read_cmcnt(struct sh_cmt_channel *ch) { - return p->read_count(p->mapbase, CMCNT); + return ch->cmt->read_count(ch->cmt->mapbase, CMCNT); } -static inline void sh_cmt_write_cmstr(struct sh_cmt_priv *p, +static inline void sh_cmt_write_cmstr(struct sh_cmt_channel *ch, unsigned long value) { - p->write_control(p->mapbase_str, 0, value); + ch->cmt->write_control(ch->cmt->mapbase_str, 0, value); } -static inline void sh_cmt_write_cmcsr(struct sh_cmt_priv *p, +static inline void sh_cmt_write_cmcsr(struct sh_cmt_channel *ch, unsigned long value) { - p->write_control(p->mapbase, CMCSR, value); + ch->cmt->write_control(ch->cmt->mapbase, CMCSR, value); } -static inline void sh_cmt_write_cmcnt(struct sh_cmt_priv *p, +static inline void sh_cmt_write_cmcnt(struct sh_cmt_channel *ch, unsigned long value) { - p->write_count(p->mapbase, CMCNT, value); + ch->cmt->write_count(ch->cmt->mapbase, CMCNT, value); } -static inline void sh_cmt_write_cmcor(struct sh_cmt_priv *p, +static inline void sh_cmt_write_cmcor(struct sh_cmt_channel *ch, unsigned long value) { - p->write_count(p->mapbase, CMCOR, value); + ch->cmt->write_count(ch->cmt->mapbase, CMCOR, value); } -static unsigned long sh_cmt_get_counter(struct sh_cmt_priv *p, +static unsigned long sh_cmt_get_counter(struct sh_cmt_channel *ch, int *has_wrapped) { unsigned long v1, v2, v3; int o1, o2; - o1 = sh_cmt_read_cmcsr(p) & p->overflow_bit; + o1 = sh_cmt_read_cmcsr(ch) & ch->cmt->overflow_bit; /* Make sure the timer value is stable. Stolen from acpi_pm.c */ do { o2 = o1; - v1 = sh_cmt_read_cmcnt(p); - v2 = sh_cmt_read_cmcnt(p); - v3 = sh_cmt_read_cmcnt(p); - o1 = sh_cmt_read_cmcsr(p) & p->overflow_bit; + v1 = sh_cmt_read_cmcnt(ch); + v2 = sh_cmt_read_cmcnt(ch); + v3 = sh_cmt_read_cmcnt(ch); + o1 = sh_cmt_read_cmcsr(ch) & ch->cmt->overflow_bit; } while (unlikely((o1 != o2) || (v1 > v2 && v1 < v3) || (v2 > v3 && v2 < v1) || (v3 > v1 && v3 < v2))); @@ -177,52 +186,52 @@ static unsigned long sh_cmt_get_counter(struct sh_cmt_priv *p, static DEFINE_RAW_SPINLOCK(sh_cmt_lock); -static void sh_cmt_start_stop_ch(struct sh_cmt_priv *p, int start) +static void sh_cmt_start_stop_ch(struct sh_cmt_channel *ch, int start) { - struct sh_timer_config *cfg = p->pdev->dev.platform_data; + struct sh_timer_config *cfg = ch->cmt->pdev->dev.platform_data; unsigned long flags, value; /* start stop register shared by multiple timer channels */ raw_spin_lock_irqsave(&sh_cmt_lock, flags); - value = sh_cmt_read_cmstr(p); + value = sh_cmt_read_cmstr(ch); if (start) value |= 1 << cfg->timer_bit; else value &= ~(1 << cfg->timer_bit); - sh_cmt_write_cmstr(p, value); + sh_cmt_write_cmstr(ch, value); raw_spin_unlock_irqrestore(&sh_cmt_lock, flags); } -static int sh_cmt_enable(struct sh_cmt_priv *p, unsigned long *rate) +static int sh_cmt_enable(struct sh_cmt_channel *ch, unsigned long *rate) { int k, ret; - pm_runtime_get_sync(&p->pdev->dev); - dev_pm_syscore_device(&p->pdev->dev, true); + pm_runtime_get_sync(&ch->cmt->pdev->dev); + dev_pm_syscore_device(&ch->cmt->pdev->dev, true); /* enable clock */ - ret = clk_enable(p->clk); + ret = clk_enable(ch->cmt->clk); if (ret) { - dev_err(&p->pdev->dev, "cannot enable clock\n"); + dev_err(&ch->cmt->pdev->dev, "cannot enable clock\n"); goto err0; } /* make sure channel is disabled */ - sh_cmt_start_stop_ch(p, 0); + sh_cmt_start_stop_ch(ch, 0); /* configure channel, periodic mode and maximum timeout */ - if (p->width == 16) { - *rate = clk_get_rate(p->clk) / 512; - sh_cmt_write_cmcsr(p, 0x43); + if (ch->cmt->width == 16) { + *rate = clk_get_rate(ch->cmt->clk) / 512; + sh_cmt_write_cmcsr(ch, 0x43); } else { - *rate = clk_get_rate(p->clk) / 8; - sh_cmt_write_cmcsr(p, 0x01a4); + *rate = clk_get_rate(ch->cmt->clk) / 8; + sh_cmt_write_cmcsr(ch, 0x01a4); } - sh_cmt_write_cmcor(p, 0xffffffff); - sh_cmt_write_cmcnt(p, 0); + sh_cmt_write_cmcor(ch, 0xffffffff); + sh_cmt_write_cmcnt(ch, 0); /* * According to the sh73a0 user's manual, as CMCNT can be operated @@ -236,41 +245,41 @@ static int sh_cmt_enable(struct sh_cmt_priv *p, unsigned long *rate) * take RCLKx2 at maximum. */ for (k = 0; k < 100; k++) { - if (!sh_cmt_read_cmcnt(p)) + if (!sh_cmt_read_cmcnt(ch)) break; udelay(1); } - if (sh_cmt_read_cmcnt(p)) { - dev_err(&p->pdev->dev, "cannot clear CMCNT\n"); + if (sh_cmt_read_cmcnt(ch)) { + dev_err(&ch->cmt->pdev->dev, "cannot clear CMCNT\n"); ret = -ETIMEDOUT; goto err1; } /* enable channel */ - sh_cmt_start_stop_ch(p, 1); + sh_cmt_start_stop_ch(ch, 1); return 0; err1: /* stop clock */ - clk_disable(p->clk); + clk_disable(ch->cmt->clk); err0: return ret; } -static void sh_cmt_disable(struct sh_cmt_priv *p) +static void sh_cmt_disable(struct sh_cmt_channel *ch) { /* disable channel */ - sh_cmt_start_stop_ch(p, 0); + sh_cmt_start_stop_ch(ch, 0); /* disable interrupts in CMT block */ - sh_cmt_write_cmcsr(p, 0); + sh_cmt_write_cmcsr(ch, 0); /* stop clock */ - clk_disable(p->clk); + clk_disable(ch->cmt->clk); - dev_pm_syscore_device(&p->pdev->dev, false); - pm_runtime_put(&p->pdev->dev); + dev_pm_syscore_device(&ch->cmt->pdev->dev, false); + pm_runtime_put(&ch->cmt->pdev->dev); } /* private flags */ @@ -280,24 +289,24 @@ static void sh_cmt_disable(struct sh_cmt_priv *p) #define FLAG_SKIPEVENT (1 << 3) #define FLAG_IRQCONTEXT (1 << 4) -static void sh_cmt_clock_event_program_verify(struct sh_cmt_priv *p, +static void sh_cmt_clock_event_program_verify(struct sh_cmt_channel *ch, int absolute) { unsigned long new_match; - unsigned long value = p->next_match_value; + unsigned long value = ch->next_match_value; unsigned long delay = 0; unsigned long now = 0; int has_wrapped; - now = sh_cmt_get_counter(p, &has_wrapped); - p->flags |= FLAG_REPROGRAM; /* force reprogram */ + now = sh_cmt_get_counter(ch, &has_wrapped); + ch->flags |= FLAG_REPROGRAM; /* force reprogram */ if (has_wrapped) { /* we're competing with the interrupt handler. * -> let the interrupt handler reprogram the timer. * -> interrupt number two handles the event. */ - p->flags |= FLAG_SKIPEVENT; + ch->flags |= FLAG_SKIPEVENT; return; } @@ -309,20 +318,20 @@ static void sh_cmt_clock_event_program_verify(struct sh_cmt_priv *p, * but don't save the new match value yet. */ new_match = now + value + delay; - if (new_match > p->max_match_value) - new_match = p->max_match_value; + if (new_match > ch->max_match_value) + new_match = ch->max_match_value; - sh_cmt_write_cmcor(p, new_match); + sh_cmt_write_cmcor(ch, new_match); - now = sh_cmt_get_counter(p, &has_wrapped); - if (has_wrapped && (new_match > p->match_value)) { + now = sh_cmt_get_counter(ch, &has_wrapped); + if (has_wrapped && (new_match > ch->match_value)) { /* we are changing to a greater match value, * so this wrap must be caused by the counter * matching the old value. * -> first interrupt reprograms the timer. * -> interrupt number two handles the event. */ - p->flags |= FLAG_SKIPEVENT; + ch->flags |= FLAG_SKIPEVENT; break; } @@ -333,7 +342,7 @@ static void sh_cmt_clock_event_program_verify(struct sh_cmt_priv *p, * -> save programmed match value. * -> let isr handle the event. */ - p->match_value = new_match; + ch->match_value = new_match; break; } @@ -344,7 +353,7 @@ static void sh_cmt_clock_event_program_verify(struct sh_cmt_priv *p, * -> save programmed match value. * -> let isr handle the event. */ - p->match_value = new_match; + ch->match_value = new_match; break; } @@ -360,138 +369,138 @@ static void sh_cmt_clock_event_program_verify(struct sh_cmt_priv *p, delay = 1; if (!delay) - dev_warn(&p->pdev->dev, "too long delay\n"); + dev_warn(&ch->cmt->pdev->dev, "too long delay\n"); } while (delay); } -static void __sh_cmt_set_next(struct sh_cmt_priv *p, unsigned long delta) +static void __sh_cmt_set_next(struct sh_cmt_channel *ch, unsigned long delta) { - if (delta > p->max_match_value) - dev_warn(&p->pdev->dev, "delta out of range\n"); + if (delta > ch->max_match_value) + dev_warn(&ch->cmt->pdev->dev, "delta out of range\n"); - p->next_match_value = delta; - sh_cmt_clock_event_program_verify(p, 0); + ch->next_match_value = delta; + sh_cmt_clock_event_program_verify(ch, 0); } -static void sh_cmt_set_next(struct sh_cmt_priv *p, unsigned long delta) +static void sh_cmt_set_next(struct sh_cmt_channel *ch, unsigned long delta) { unsigned long flags; - raw_spin_lock_irqsave(&p->lock, flags); - __sh_cmt_set_next(p, delta); - raw_spin_unlock_irqrestore(&p->lock, flags); + raw_spin_lock_irqsave(&ch->lock, flags); + __sh_cmt_set_next(ch, delta); + raw_spin_unlock_irqrestore(&ch->lock, flags); } static irqreturn_t sh_cmt_interrupt(int irq, void *dev_id) { - struct sh_cmt_priv *p = dev_id; + struct sh_cmt_channel *ch = dev_id; /* clear flags */ - sh_cmt_write_cmcsr(p, sh_cmt_read_cmcsr(p) & p->clear_bits); + sh_cmt_write_cmcsr(ch, sh_cmt_read_cmcsr(ch) & ch->cmt->clear_bits); /* update clock source counter to begin with if enabled * the wrap flag should be cleared by the timer specific * isr before we end up here. */ - if (p->flags & FLAG_CLOCKSOURCE) - p->total_cycles += p->match_value + 1; + if (ch->flags & FLAG_CLOCKSOURCE) + ch->total_cycles += ch->match_value + 1; - if (!(p->flags & FLAG_REPROGRAM)) - p->next_match_value = p->max_match_value; + if (!(ch->flags & FLAG_REPROGRAM)) + ch->next_match_value = ch->max_match_value; - p->flags |= FLAG_IRQCONTEXT; + ch->flags |= FLAG_IRQCONTEXT; - if (p->flags & FLAG_CLOCKEVENT) { - if (!(p->flags & FLAG_SKIPEVENT)) { - if (p->ced.mode == CLOCK_EVT_MODE_ONESHOT) { - p->next_match_value = p->max_match_value; - p->flags |= FLAG_REPROGRAM; + if (ch->flags & FLAG_CLOCKEVENT) { + if (!(ch->flags & FLAG_SKIPEVENT)) { + if (ch->ced.mode == CLOCK_EVT_MODE_ONESHOT) { + ch->next_match_value = ch->max_match_value; + ch->flags |= FLAG_REPROGRAM; } - p->ced.event_handler(&p->ced); + ch->ced.event_handler(&ch->ced); } } - p->flags &= ~FLAG_SKIPEVENT; + ch->flags &= ~FLAG_SKIPEVENT; - if (p->flags & FLAG_REPROGRAM) { - p->flags &= ~FLAG_REPROGRAM; - sh_cmt_clock_event_program_verify(p, 1); + if (ch->flags & FLAG_REPROGRAM) { + ch->flags &= ~FLAG_REPROGRAM; + sh_cmt_clock_event_program_verify(ch, 1); - if (p->flags & FLAG_CLOCKEVENT) - if ((p->ced.mode == CLOCK_EVT_MODE_SHUTDOWN) - || (p->match_value == p->next_match_value)) - p->flags &= ~FLAG_REPROGRAM; + if (ch->flags & FLAG_CLOCKEVENT) + if ((ch->ced.mode == CLOCK_EVT_MODE_SHUTDOWN) + || (ch->match_value == ch->next_match_value)) + ch->flags &= ~FLAG_REPROGRAM; } - p->flags &= ~FLAG_IRQCONTEXT; + ch->flags &= ~FLAG_IRQCONTEXT; return IRQ_HANDLED; } -static int sh_cmt_start(struct sh_cmt_priv *p, unsigned long flag) +static int sh_cmt_start(struct sh_cmt_channel *ch, unsigned long flag) { int ret = 0; unsigned long flags; - raw_spin_lock_irqsave(&p->lock, flags); + raw_spin_lock_irqsave(&ch->lock, flags); - if (!(p->flags & (FLAG_CLOCKEVENT | FLAG_CLOCKSOURCE))) - ret = sh_cmt_enable(p, &p->rate); + if (!(ch->flags & (FLAG_CLOCKEVENT | FLAG_CLOCKSOURCE))) + ret = sh_cmt_enable(ch, &ch->rate); if (ret) goto out; - p->flags |= flag; + ch->flags |= flag; /* setup timeout if no clockevent */ - if ((flag == FLAG_CLOCKSOURCE) && (!(p->flags & FLAG_CLOCKEVENT))) - __sh_cmt_set_next(p, p->max_match_value); + if ((flag == FLAG_CLOCKSOURCE) && (!(ch->flags & FLAG_CLOCKEVENT))) + __sh_cmt_set_next(ch, ch->max_match_value); out: - raw_spin_unlock_irqrestore(&p->lock, flags); + raw_spin_unlock_irqrestore(&ch->lock, flags); return ret; } -static void sh_cmt_stop(struct sh_cmt_priv *p, unsigned long flag) +static void sh_cmt_stop(struct sh_cmt_channel *ch, unsigned long flag) { unsigned long flags; unsigned long f; - raw_spin_lock_irqsave(&p->lock, flags); + raw_spin_lock_irqsave(&ch->lock, flags); - f = p->flags & (FLAG_CLOCKEVENT | FLAG_CLOCKSOURCE); - p->flags &= ~flag; + f = ch->flags & (FLAG_CLOCKEVENT | FLAG_CLOCKSOURCE); + ch->flags &= ~flag; - if (f && !(p->flags & (FLAG_CLOCKEVENT | FLAG_CLOCKSOURCE))) - sh_cmt_disable(p); + if (f && !(ch->flags & (FLAG_CLOCKEVENT | FLAG_CLOCKSOURCE))) + sh_cmt_disable(ch); /* adjust the timeout to maximum if only clocksource left */ - if ((flag == FLAG_CLOCKEVENT) && (p->flags & FLAG_CLOCKSOURCE)) - __sh_cmt_set_next(p, p->max_match_value); + if ((flag == FLAG_CLOCKEVENT) && (ch->flags & FLAG_CLOCKSOURCE)) + __sh_cmt_set_next(ch, ch->max_match_value); - raw_spin_unlock_irqrestore(&p->lock, flags); + raw_spin_unlock_irqrestore(&ch->lock, flags); } -static struct sh_cmt_priv *cs_to_sh_cmt(struct clocksource *cs) +static struct sh_cmt_channel *cs_to_sh_cmt(struct clocksource *cs) { - return container_of(cs, struct sh_cmt_priv, cs); + return container_of(cs, struct sh_cmt_channel, cs); } static cycle_t sh_cmt_clocksource_read(struct clocksource *cs) { - struct sh_cmt_priv *p = cs_to_sh_cmt(cs); + struct sh_cmt_channel *ch = cs_to_sh_cmt(cs); unsigned long flags, raw; unsigned long value; int has_wrapped; - raw_spin_lock_irqsave(&p->lock, flags); - value = p->total_cycles; - raw = sh_cmt_get_counter(p, &has_wrapped); + raw_spin_lock_irqsave(&ch->lock, flags); + value = ch->total_cycles; + raw = sh_cmt_get_counter(ch, &has_wrapped); if (unlikely(has_wrapped)) - raw += p->match_value + 1; - raw_spin_unlock_irqrestore(&p->lock, flags); + raw += ch->match_value + 1; + raw_spin_unlock_irqrestore(&ch->lock, flags); return value + raw; } @@ -499,50 +508,50 @@ static cycle_t sh_cmt_clocksource_read(struct clocksource *cs) static int sh_cmt_clocksource_enable(struct clocksource *cs) { int ret; - struct sh_cmt_priv *p = cs_to_sh_cmt(cs); + struct sh_cmt_channel *ch = cs_to_sh_cmt(cs); - WARN_ON(p->cs_enabled); + WARN_ON(ch->cs_enabled); - p->total_cycles = 0; + ch->total_cycles = 0; - ret = sh_cmt_start(p, FLAG_CLOCKSOURCE); + ret = sh_cmt_start(ch, FLAG_CLOCKSOURCE); if (!ret) { - __clocksource_updatefreq_hz(cs, p->rate); - p->cs_enabled = true; + __clocksource_updatefreq_hz(cs, ch->rate); + ch->cs_enabled = true; } return ret; } static void sh_cmt_clocksource_disable(struct clocksource *cs) { - struct sh_cmt_priv *p = cs_to_sh_cmt(cs); + struct sh_cmt_channel *ch = cs_to_sh_cmt(cs); - WARN_ON(!p->cs_enabled); + WARN_ON(!ch->cs_enabled); - sh_cmt_stop(p, FLAG_CLOCKSOURCE); - p->cs_enabled = false; + sh_cmt_stop(ch, FLAG_CLOCKSOURCE); + ch->cs_enabled = false; } static void sh_cmt_clocksource_suspend(struct clocksource *cs) { - struct sh_cmt_priv *p = cs_to_sh_cmt(cs); + struct sh_cmt_channel *ch = cs_to_sh_cmt(cs); - sh_cmt_stop(p, FLAG_CLOCKSOURCE); - pm_genpd_syscore_poweroff(&p->pdev->dev); + sh_cmt_stop(ch, FLAG_CLOCKSOURCE); + pm_genpd_syscore_poweroff(&ch->cmt->pdev->dev); } static void sh_cmt_clocksource_resume(struct clocksource *cs) { - struct sh_cmt_priv *p = cs_to_sh_cmt(cs); + struct sh_cmt_channel *ch = cs_to_sh_cmt(cs); - pm_genpd_syscore_poweron(&p->pdev->dev); - sh_cmt_start(p, FLAG_CLOCKSOURCE); + pm_genpd_syscore_poweron(&ch->cmt->pdev->dev); + sh_cmt_start(ch, FLAG_CLOCKSOURCE); } -static int sh_cmt_register_clocksource(struct sh_cmt_priv *p, +static int sh_cmt_register_clocksource(struct sh_cmt_channel *ch, char *name, unsigned long rating) { - struct clocksource *cs = &p->cs; + struct clocksource *cs = &ch->cs; cs->name = name; cs->rating = rating; @@ -554,47 +563,47 @@ static int sh_cmt_register_clocksource(struct sh_cmt_priv *p, cs->mask = CLOCKSOURCE_MASK(sizeof(unsigned long) * 8); cs->flags = CLOCK_SOURCE_IS_CONTINUOUS; - dev_info(&p->pdev->dev, "used as clock source\n"); + dev_info(&ch->cmt->pdev->dev, "used as clock source\n"); /* Register with dummy 1 Hz value, gets updated in ->enable() */ clocksource_register_hz(cs, 1); return 0; } -static struct sh_cmt_priv *ced_to_sh_cmt(struct clock_event_device *ced) +static struct sh_cmt_channel *ced_to_sh_cmt(struct clock_event_device *ced) { - return container_of(ced, struct sh_cmt_priv, ced); + return container_of(ced, struct sh_cmt_channel, ced); } -static void sh_cmt_clock_event_start(struct sh_cmt_priv *p, int periodic) +static void sh_cmt_clock_event_start(struct sh_cmt_channel *ch, int periodic) { - struct clock_event_device *ced = &p->ced; + struct clock_event_device *ced = &ch->ced; - sh_cmt_start(p, FLAG_CLOCKEVENT); + sh_cmt_start(ch, FLAG_CLOCKEVENT); /* TODO: calculate good shift from rate and counter bit width */ ced->shift = 32; - ced->mult = div_sc(p->rate, NSEC_PER_SEC, ced->shift); - ced->max_delta_ns = clockevent_delta2ns(p->max_match_value, ced); + ced->mult = div_sc(ch->rate, NSEC_PER_SEC, ced->shift); + ced->max_delta_ns = clockevent_delta2ns(ch->max_match_value, ced); ced->min_delta_ns = clockevent_delta2ns(0x1f, ced); if (periodic) - sh_cmt_set_next(p, ((p->rate + HZ/2) / HZ) - 1); + sh_cmt_set_next(ch, ((ch->rate + HZ/2) / HZ) - 1); else - sh_cmt_set_next(p, p->max_match_value); + sh_cmt_set_next(ch, ch->max_match_value); } static void sh_cmt_clock_event_mode(enum clock_event_mode mode, struct clock_event_device *ced) { - struct sh_cmt_priv *p = ced_to_sh_cmt(ced); + struct sh_cmt_channel *ch = ced_to_sh_cmt(ced); /* deal with old setting first */ switch (ced->mode) { case CLOCK_EVT_MODE_PERIODIC: case CLOCK_EVT_MODE_ONESHOT: - sh_cmt_stop(p, FLAG_CLOCKEVENT); + sh_cmt_stop(ch, FLAG_CLOCKEVENT); break; default: break; @@ -602,16 +611,18 @@ static void sh_cmt_clock_event_mode(enum clock_event_mode mode, switch (mode) { case CLOCK_EVT_MODE_PERIODIC: - dev_info(&p->pdev->dev, "used for periodic clock events\n"); - sh_cmt_clock_event_start(p, 1); + dev_info(&ch->cmt->pdev->dev, + "used for periodic clock events\n"); + sh_cmt_clock_event_start(ch, 1); break; case CLOCK_EVT_MODE_ONESHOT: - dev_info(&p->pdev->dev, "used for oneshot clock events\n"); - sh_cmt_clock_event_start(p, 0); + dev_info(&ch->cmt->pdev->dev, + "used for oneshot clock events\n"); + sh_cmt_clock_event_start(ch, 0); break; case CLOCK_EVT_MODE_SHUTDOWN: case CLOCK_EVT_MODE_UNUSED: - sh_cmt_stop(p, FLAG_CLOCKEVENT); + sh_cmt_stop(ch, FLAG_CLOCKEVENT); break; default: break; @@ -621,37 +632,37 @@ static void sh_cmt_clock_event_mode(enum clock_event_mode mode, static int sh_cmt_clock_event_next(unsigned long delta, struct clock_event_device *ced) { - struct sh_cmt_priv *p = ced_to_sh_cmt(ced); + struct sh_cmt_channel *ch = ced_to_sh_cmt(ced); BUG_ON(ced->mode != CLOCK_EVT_MODE_ONESHOT); - if (likely(p->flags & FLAG_IRQCONTEXT)) - p->next_match_value = delta - 1; + if (likely(ch->flags & FLAG_IRQCONTEXT)) + ch->next_match_value = delta - 1; else - sh_cmt_set_next(p, delta - 1); + sh_cmt_set_next(ch, delta - 1); return 0; } static void sh_cmt_clock_event_suspend(struct clock_event_device *ced) { - struct sh_cmt_priv *p = ced_to_sh_cmt(ced); + struct sh_cmt_channel *ch = ced_to_sh_cmt(ced); - pm_genpd_syscore_poweroff(&p->pdev->dev); - clk_unprepare(p->clk); + pm_genpd_syscore_poweroff(&ch->cmt->pdev->dev); + clk_unprepare(ch->cmt->clk); } static void sh_cmt_clock_event_resume(struct clock_event_device *ced) { - struct sh_cmt_priv *p = ced_to_sh_cmt(ced); + struct sh_cmt_channel *ch = ced_to_sh_cmt(ced); - clk_prepare(p->clk); - pm_genpd_syscore_poweron(&p->pdev->dev); + clk_prepare(ch->cmt->clk); + pm_genpd_syscore_poweron(&ch->cmt->pdev->dev); } -static void sh_cmt_register_clockevent(struct sh_cmt_priv *p, +static void sh_cmt_register_clockevent(struct sh_cmt_channel *ch, char *name, unsigned long rating) { - struct clock_event_device *ced = &p->ced; + struct clock_event_device *ced = &ch->ced; memset(ced, 0, sizeof(*ced)); @@ -665,19 +676,19 @@ static void sh_cmt_register_clockevent(struct sh_cmt_priv *p, ced->suspend = sh_cmt_clock_event_suspend; ced->resume = sh_cmt_clock_event_resume; - dev_info(&p->pdev->dev, "used for clock events\n"); + dev_info(&ch->cmt->pdev->dev, "used for clock events\n"); clockevents_register_device(ced); } -static int sh_cmt_register(struct sh_cmt_priv *p, char *name, +static int sh_cmt_register(struct sh_cmt_channel *ch, char *name, unsigned long clockevent_rating, unsigned long clocksource_rating) { if (clockevent_rating) - sh_cmt_register_clockevent(p, name, clockevent_rating); + sh_cmt_register_clockevent(ch, name, clockevent_rating); if (clocksource_rating) - sh_cmt_register_clocksource(p, name, clocksource_rating); + sh_cmt_register_clocksource(ch, name, clocksource_rating); return 0; } @@ -685,6 +696,7 @@ static int sh_cmt_register(struct sh_cmt_priv *p, char *name, static int sh_cmt_setup(struct sh_cmt_priv *p, struct platform_device *pdev) { struct sh_timer_config *cfg = pdev->dev.platform_data; + struct sh_cmt_channel *ch = &p->channel; struct resource *res, *res2; int irq, ret; ret = -ENXIO; @@ -763,26 +775,27 @@ static int sh_cmt_setup(struct sh_cmt_priv *p, struct platform_device *pdev) p->clear_bits = ~0xc000; } - if (p->width == (sizeof(p->max_match_value) * 8)) - p->max_match_value = ~0; + if (p->width == (sizeof(ch->max_match_value) * 8)) + ch->max_match_value = ~0; else - p->max_match_value = (1 << p->width) - 1; + ch->max_match_value = (1 << p->width) - 1; - p->match_value = p->max_match_value; - raw_spin_lock_init(&p->lock); + ch->cmt = p; + ch->match_value = ch->max_match_value; + raw_spin_lock_init(&ch->lock); - ret = sh_cmt_register(p, (char *)dev_name(&p->pdev->dev), + ret = sh_cmt_register(ch, (char *)dev_name(&p->pdev->dev), cfg->clockevent_rating, cfg->clocksource_rating); if (ret) { dev_err(&p->pdev->dev, "registration failed\n"); goto err4; } - p->cs_enabled = false; + ch->cs_enabled = false; ret = request_irq(irq, sh_cmt_interrupt, IRQF_TIMER | IRQF_IRQPOLL | IRQF_NOBALANCING, - dev_name(&p->pdev->dev), p); + dev_name(&p->pdev->dev), ch); if (ret) { dev_err(&p->pdev->dev, "failed to request irq %d\n", irq); goto err4; -- cgit v1.2.3 From 2653caf4381f9adeec8c18dfec21ec3c855d801c Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Mon, 27 Jan 2014 22:04:17 +0100 Subject: clocksource: sh_cmt: Rename struct sh_cmt_priv to sh_cmt_device Channel data is private as well, rename priv to device to make the distrinction between the core device and the channels clearer. Signed-off-by: Laurent Pinchart --- drivers/clocksource/sh_cmt.c | 116 +++++++++++++++++++++---------------------- 1 file changed, 58 insertions(+), 58 deletions(-) diff --git a/drivers/clocksource/sh_cmt.c b/drivers/clocksource/sh_cmt.c index 351b3ca3ccc4..604199a22265 100644 --- a/drivers/clocksource/sh_cmt.c +++ b/drivers/clocksource/sh_cmt.c @@ -35,10 +35,10 @@ #include #include -struct sh_cmt_priv; +struct sh_cmt_device; struct sh_cmt_channel { - struct sh_cmt_priv *cmt; + struct sh_cmt_device *cmt; unsigned long flags; unsigned long match_value; @@ -52,7 +52,7 @@ struct sh_cmt_channel { bool cs_enabled; }; -struct sh_cmt_priv { +struct sh_cmt_device { struct platform_device *pdev; void __iomem *mapbase; @@ -693,132 +693,132 @@ static int sh_cmt_register(struct sh_cmt_channel *ch, char *name, return 0; } -static int sh_cmt_setup(struct sh_cmt_priv *p, struct platform_device *pdev) +static int sh_cmt_setup(struct sh_cmt_device *cmt, struct platform_device *pdev) { struct sh_timer_config *cfg = pdev->dev.platform_data; - struct sh_cmt_channel *ch = &p->channel; + struct sh_cmt_channel *ch = &cmt->channel; struct resource *res, *res2; int irq, ret; ret = -ENXIO; - memset(p, 0, sizeof(*p)); - p->pdev = pdev; + memset(cmt, 0, sizeof(*cmt)); + cmt->pdev = pdev; if (!cfg) { - dev_err(&p->pdev->dev, "missing platform data\n"); + dev_err(&cmt->pdev->dev, "missing platform data\n"); goto err0; } - res = platform_get_resource(p->pdev, IORESOURCE_MEM, 0); + res = platform_get_resource(cmt->pdev, IORESOURCE_MEM, 0); if (!res) { - dev_err(&p->pdev->dev, "failed to get I/O memory\n"); + dev_err(&cmt->pdev->dev, "failed to get I/O memory\n"); goto err0; } /* optional resource for the shared timer start/stop register */ - res2 = platform_get_resource(p->pdev, IORESOURCE_MEM, 1); + res2 = platform_get_resource(cmt->pdev, IORESOURCE_MEM, 1); - irq = platform_get_irq(p->pdev, 0); + irq = platform_get_irq(cmt->pdev, 0); if (irq < 0) { - dev_err(&p->pdev->dev, "failed to get irq\n"); + dev_err(&cmt->pdev->dev, "failed to get irq\n"); goto err0; } /* map memory, let mapbase point to our channel */ - p->mapbase = ioremap_nocache(res->start, resource_size(res)); - if (p->mapbase == NULL) { - dev_err(&p->pdev->dev, "failed to remap I/O memory\n"); + cmt->mapbase = ioremap_nocache(res->start, resource_size(res)); + if (cmt->mapbase == NULL) { + dev_err(&cmt->pdev->dev, "failed to remap I/O memory\n"); goto err0; } /* map second resource for CMSTR */ - p->mapbase_str = ioremap_nocache(res2 ? res2->start : - res->start - cfg->channel_offset, - res2 ? resource_size(res2) : 2); - if (p->mapbase_str == NULL) { - dev_err(&p->pdev->dev, "failed to remap I/O second memory\n"); + cmt->mapbase_str = ioremap_nocache(res2 ? res2->start : + res->start - cfg->channel_offset, + res2 ? resource_size(res2) : 2); + if (cmt->mapbase_str == NULL) { + dev_err(&cmt->pdev->dev, "failed to remap I/O second memory\n"); goto err1; } /* get hold of clock */ - p->clk = clk_get(&p->pdev->dev, "cmt_fck"); - if (IS_ERR(p->clk)) { - dev_err(&p->pdev->dev, "cannot get clock\n"); - ret = PTR_ERR(p->clk); + cmt->clk = clk_get(&cmt->pdev->dev, "cmt_fck"); + if (IS_ERR(cmt->clk)) { + dev_err(&cmt->pdev->dev, "cannot get clock\n"); + ret = PTR_ERR(cmt->clk); goto err2; } - ret = clk_prepare(p->clk); + ret = clk_prepare(cmt->clk); if (ret < 0) goto err3; if (res2 && (resource_size(res2) == 4)) { /* assume both CMSTR and CMCSR to be 32-bit */ - p->read_control = sh_cmt_read32; - p->write_control = sh_cmt_write32; + cmt->read_control = sh_cmt_read32; + cmt->write_control = sh_cmt_write32; } else { - p->read_control = sh_cmt_read16; - p->write_control = sh_cmt_write16; + cmt->read_control = sh_cmt_read16; + cmt->write_control = sh_cmt_write16; } if (resource_size(res) == 6) { - p->width = 16; - p->read_count = sh_cmt_read16; - p->write_count = sh_cmt_write16; - p->overflow_bit = 0x80; - p->clear_bits = ~0x80; + cmt->width = 16; + cmt->read_count = sh_cmt_read16; + cmt->write_count = sh_cmt_write16; + cmt->overflow_bit = 0x80; + cmt->clear_bits = ~0x80; } else { - p->width = 32; - p->read_count = sh_cmt_read32; - p->write_count = sh_cmt_write32; - p->overflow_bit = 0x8000; - p->clear_bits = ~0xc000; + cmt->width = 32; + cmt->read_count = sh_cmt_read32; + cmt->write_count = sh_cmt_write32; + cmt->overflow_bit = 0x8000; + cmt->clear_bits = ~0xc000; } - if (p->width == (sizeof(ch->max_match_value) * 8)) + if (cmt->width == (sizeof(ch->max_match_value) * 8)) ch->max_match_value = ~0; else - ch->max_match_value = (1 << p->width) - 1; + ch->max_match_value = (1 << cmt->width) - 1; - ch->cmt = p; + ch->cmt = cmt; ch->match_value = ch->max_match_value; raw_spin_lock_init(&ch->lock); - ret = sh_cmt_register(ch, (char *)dev_name(&p->pdev->dev), + ret = sh_cmt_register(ch, (char *)dev_name(&cmt->pdev->dev), cfg->clockevent_rating, cfg->clocksource_rating); if (ret) { - dev_err(&p->pdev->dev, "registration failed\n"); + dev_err(&cmt->pdev->dev, "registration failed\n"); goto err4; } ch->cs_enabled = false; ret = request_irq(irq, sh_cmt_interrupt, IRQF_TIMER | IRQF_IRQPOLL | IRQF_NOBALANCING, - dev_name(&p->pdev->dev), ch); + dev_name(&cmt->pdev->dev), ch); if (ret) { - dev_err(&p->pdev->dev, "failed to request irq %d\n", irq); + dev_err(&cmt->pdev->dev, "failed to request irq %d\n", irq); goto err4; } - platform_set_drvdata(pdev, p); + platform_set_drvdata(pdev, cmt); return 0; err4: - clk_unprepare(p->clk); + clk_unprepare(cmt->clk); err3: - clk_put(p->clk); + clk_put(cmt->clk); err2: - iounmap(p->mapbase_str); + iounmap(cmt->mapbase_str); err1: - iounmap(p->mapbase); + iounmap(cmt->mapbase); err0: return ret; } static int sh_cmt_probe(struct platform_device *pdev) { - struct sh_cmt_priv *p = platform_get_drvdata(pdev); + struct sh_cmt_device *cmt = platform_get_drvdata(pdev); struct sh_timer_config *cfg = pdev->dev.platform_data; int ret; @@ -827,20 +827,20 @@ static int sh_cmt_probe(struct platform_device *pdev) pm_runtime_enable(&pdev->dev); } - if (p) { + if (cmt) { dev_info(&pdev->dev, "kept as earlytimer\n"); goto out; } - p = kmalloc(sizeof(*p), GFP_KERNEL); - if (p == NULL) { + cmt = kmalloc(sizeof(*cmt), GFP_KERNEL); + if (cmt == NULL) { dev_err(&pdev->dev, "failed to allocate driver data\n"); return -ENOMEM; } - ret = sh_cmt_setup(p, pdev); + ret = sh_cmt_setup(cmt, pdev); if (ret) { - kfree(p); + kfree(cmt); pm_runtime_idle(&pdev->dev); return ret; } -- cgit v1.2.3 From b882e7b13bc12b3d6b00e4ea2fe374413ddcdd2d Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Mon, 27 Jan 2014 22:04:17 +0100 Subject: clocksource: sh_cmt: Split channel setup to separate function Move the channel setup code from sh_cmt_setup to a new sh_cmt_setup_channel function and call it from sh_cmt_setup. Signed-off-by: Laurent Pinchart --- drivers/clocksource/sh_cmt.c | 79 ++++++++++++++++++++++++++------------------ 1 file changed, 47 insertions(+), 32 deletions(-) diff --git a/drivers/clocksource/sh_cmt.c b/drivers/clocksource/sh_cmt.c index 604199a22265..26f73cf609ba 100644 --- a/drivers/clocksource/sh_cmt.c +++ b/drivers/clocksource/sh_cmt.c @@ -693,12 +693,55 @@ static int sh_cmt_register(struct sh_cmt_channel *ch, char *name, return 0; } +static int sh_cmt_setup_channel(struct sh_cmt_channel *ch, + struct sh_cmt_device *cmt) +{ + struct sh_timer_config *cfg = cmt->pdev->dev.platform_data; + int irq; + int ret; + + memset(ch, 0, sizeof(*ch)); + ch->cmt = cmt; + + irq = platform_get_irq(cmt->pdev, 0); + if (irq < 0) { + dev_err(&cmt->pdev->dev, "failed to get irq\n"); + return irq; + } + + if (cmt->width == (sizeof(ch->max_match_value) * 8)) + ch->max_match_value = ~0; + else + ch->max_match_value = (1 << cmt->width) - 1; + + ch->match_value = ch->max_match_value; + raw_spin_lock_init(&ch->lock); + + ret = sh_cmt_register(ch, (char *)dev_name(&cmt->pdev->dev), + cfg->clockevent_rating, + cfg->clocksource_rating); + if (ret) { + dev_err(&cmt->pdev->dev, "registration failed\n"); + return ret; + } + ch->cs_enabled = false; + + ret = request_irq(irq, sh_cmt_interrupt, + IRQF_TIMER | IRQF_IRQPOLL | IRQF_NOBALANCING, + dev_name(&cmt->pdev->dev), ch); + if (ret) { + dev_err(&cmt->pdev->dev, "failed to request irq %d\n", irq); + return ret; + } + + return 0; +} + static int sh_cmt_setup(struct sh_cmt_device *cmt, struct platform_device *pdev) { struct sh_timer_config *cfg = pdev->dev.platform_data; - struct sh_cmt_channel *ch = &cmt->channel; struct resource *res, *res2; - int irq, ret; + int ret; ret = -ENXIO; memset(cmt, 0, sizeof(*cmt)); @@ -718,12 +761,6 @@ static int sh_cmt_setup(struct sh_cmt_device *cmt, struct platform_device *pdev) /* optional resource for the shared timer start/stop register */ res2 = platform_get_resource(cmt->pdev, IORESOURCE_MEM, 1); - irq = platform_get_irq(cmt->pdev, 0); - if (irq < 0) { - dev_err(&cmt->pdev->dev, "failed to get irq\n"); - goto err0; - } - /* map memory, let mapbase point to our channel */ cmt->mapbase = ioremap_nocache(res->start, resource_size(res)); if (cmt->mapbase == NULL) { @@ -775,31 +812,9 @@ static int sh_cmt_setup(struct sh_cmt_device *cmt, struct platform_device *pdev) cmt->clear_bits = ~0xc000; } - if (cmt->width == (sizeof(ch->max_match_value) * 8)) - ch->max_match_value = ~0; - else - ch->max_match_value = (1 << cmt->width) - 1; - - ch->cmt = cmt; - ch->match_value = ch->max_match_value; - raw_spin_lock_init(&ch->lock); - - ret = sh_cmt_register(ch, (char *)dev_name(&cmt->pdev->dev), - cfg->clockevent_rating, - cfg->clocksource_rating); - if (ret) { - dev_err(&cmt->pdev->dev, "registration failed\n"); - goto err4; - } - ch->cs_enabled = false; - - ret = request_irq(irq, sh_cmt_interrupt, - IRQF_TIMER | IRQF_IRQPOLL | IRQF_NOBALANCING, - dev_name(&cmt->pdev->dev), ch); - if (ret) { - dev_err(&cmt->pdev->dev, "failed to request irq %d\n", irq); + ret = sh_cmt_setup_channel(&cmt->channel, cmt); + if (ret < 0) goto err4; - } platform_set_drvdata(pdev, cmt); -- cgit v1.2.3 From 1d053e1d8eb28f42b7ec57d1c11ce70b8fba45ff Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Mon, 17 Feb 2014 16:04:16 +0100 Subject: clocksource: sh_cmt: Constify name argument to sh_cmt_register() The name argument is assigned to const structure fields only, constify it. Signed-off-by: Laurent Pinchart --- drivers/clocksource/sh_cmt.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/clocksource/sh_cmt.c b/drivers/clocksource/sh_cmt.c index 26f73cf609ba..febd6bf7a37d 100644 --- a/drivers/clocksource/sh_cmt.c +++ b/drivers/clocksource/sh_cmt.c @@ -549,7 +549,7 @@ static void sh_cmt_clocksource_resume(struct clocksource *cs) } static int sh_cmt_register_clocksource(struct sh_cmt_channel *ch, - char *name, unsigned long rating) + const char *name, unsigned long rating) { struct clocksource *cs = &ch->cs; @@ -660,7 +660,7 @@ static void sh_cmt_clock_event_resume(struct clock_event_device *ced) } static void sh_cmt_register_clockevent(struct sh_cmt_channel *ch, - char *name, unsigned long rating) + const char *name, unsigned long rating) { struct clock_event_device *ced = &ch->ced; @@ -680,7 +680,7 @@ static void sh_cmt_register_clockevent(struct sh_cmt_channel *ch, clockevents_register_device(ced); } -static int sh_cmt_register(struct sh_cmt_channel *ch, char *name, +static int sh_cmt_register(struct sh_cmt_channel *ch, const char *name, unsigned long clockevent_rating, unsigned long clocksource_rating) { @@ -717,7 +717,7 @@ static int sh_cmt_setup_channel(struct sh_cmt_channel *ch, ch->match_value = ch->max_match_value; raw_spin_lock_init(&ch->lock); - ret = sh_cmt_register(ch, (char *)dev_name(&cmt->pdev->dev), + ret = sh_cmt_register(ch, dev_name(&cmt->pdev->dev), cfg->clockevent_rating, cfg->clocksource_rating); if (ret) { -- cgit v1.2.3 From 36f1ac982d94cd3cce8ae24abd0676b79dec6126 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Mon, 27 Jan 2014 22:04:17 +0100 Subject: clocksource: sh_cmt: Rename mapbase/mapbase_str to mapbase_ch/mapbase The mapbase variable points to the mapped base address of the channel, rename it to mapbase_sh. mapbase_str points to the mapped base address of the CMT device, rename it to mapbase. Signed-off-by: Laurent Pinchart --- drivers/clocksource/sh_cmt.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/drivers/clocksource/sh_cmt.c b/drivers/clocksource/sh_cmt.c index febd6bf7a37d..eb93b889e189 100644 --- a/drivers/clocksource/sh_cmt.c +++ b/drivers/clocksource/sh_cmt.c @@ -55,8 +55,8 @@ struct sh_cmt_channel { struct sh_cmt_device { struct platform_device *pdev; + void __iomem *mapbase_ch; void __iomem *mapbase; - void __iomem *mapbase_str; struct clk *clk; struct sh_cmt_channel channel; @@ -125,41 +125,41 @@ static void sh_cmt_write32(void __iomem *base, unsigned long offs, static inline unsigned long sh_cmt_read_cmstr(struct sh_cmt_channel *ch) { - return ch->cmt->read_control(ch->cmt->mapbase_str, 0); + return ch->cmt->read_control(ch->cmt->mapbase, 0); } static inline unsigned long sh_cmt_read_cmcsr(struct sh_cmt_channel *ch) { - return ch->cmt->read_control(ch->cmt->mapbase, CMCSR); + return ch->cmt->read_control(ch->cmt->mapbase_ch, CMCSR); } static inline unsigned long sh_cmt_read_cmcnt(struct sh_cmt_channel *ch) { - return ch->cmt->read_count(ch->cmt->mapbase, CMCNT); + return ch->cmt->read_count(ch->cmt->mapbase_ch, CMCNT); } static inline void sh_cmt_write_cmstr(struct sh_cmt_channel *ch, unsigned long value) { - ch->cmt->write_control(ch->cmt->mapbase_str, 0, value); + ch->cmt->write_control(ch->cmt->mapbase, 0, value); } static inline void sh_cmt_write_cmcsr(struct sh_cmt_channel *ch, unsigned long value) { - ch->cmt->write_control(ch->cmt->mapbase, CMCSR, value); + ch->cmt->write_control(ch->cmt->mapbase_ch, CMCSR, value); } static inline void sh_cmt_write_cmcnt(struct sh_cmt_channel *ch, unsigned long value) { - ch->cmt->write_count(ch->cmt->mapbase, CMCNT, value); + ch->cmt->write_count(ch->cmt->mapbase_ch, CMCNT, value); } static inline void sh_cmt_write_cmcor(struct sh_cmt_channel *ch, unsigned long value) { - ch->cmt->write_count(ch->cmt->mapbase, CMCOR, value); + ch->cmt->write_count(ch->cmt->mapbase_ch, CMCOR, value); } static unsigned long sh_cmt_get_counter(struct sh_cmt_channel *ch, @@ -761,18 +761,18 @@ static int sh_cmt_setup(struct sh_cmt_device *cmt, struct platform_device *pdev) /* optional resource for the shared timer start/stop register */ res2 = platform_get_resource(cmt->pdev, IORESOURCE_MEM, 1); - /* map memory, let mapbase point to our channel */ - cmt->mapbase = ioremap_nocache(res->start, resource_size(res)); - if (cmt->mapbase == NULL) { + /* map memory, let mapbase_ch point to our channel */ + cmt->mapbase_ch = ioremap_nocache(res->start, resource_size(res)); + if (cmt->mapbase_ch == NULL) { dev_err(&cmt->pdev->dev, "failed to remap I/O memory\n"); goto err0; } /* map second resource for CMSTR */ - cmt->mapbase_str = ioremap_nocache(res2 ? res2->start : - res->start - cfg->channel_offset, - res2 ? resource_size(res2) : 2); - if (cmt->mapbase_str == NULL) { + cmt->mapbase = ioremap_nocache(res2 ? res2->start : + res->start - cfg->channel_offset, + res2 ? resource_size(res2) : 2); + if (cmt->mapbase == NULL) { dev_err(&cmt->pdev->dev, "failed to remap I/O second memory\n"); goto err1; } @@ -824,9 +824,9 @@ err4: err3: clk_put(cmt->clk); err2: - iounmap(cmt->mapbase_str); -err1: iounmap(cmt->mapbase); +err1: + iounmap(cmt->mapbase_ch); err0: return ret; } -- cgit v1.2.3 From c924d2d2a964715b55b6601be338b3bd05a1ced5 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Mon, 27 Jan 2014 22:04:17 +0100 Subject: clocksource: sh_cmt: Add memory base to sh_cmt_channel structure The channel memory base is channel-specific, add it to the channel structure in preparation for support of multiple channels per device. Signed-off-by: Laurent Pinchart --- drivers/clocksource/sh_cmt.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/drivers/clocksource/sh_cmt.c b/drivers/clocksource/sh_cmt.c index eb93b889e189..4fcb05dc9ea4 100644 --- a/drivers/clocksource/sh_cmt.c +++ b/drivers/clocksource/sh_cmt.c @@ -40,6 +40,8 @@ struct sh_cmt_device; struct sh_cmt_channel { struct sh_cmt_device *cmt; + void __iomem *base; + unsigned long flags; unsigned long match_value; unsigned long next_match_value; @@ -130,12 +132,12 @@ static inline unsigned long sh_cmt_read_cmstr(struct sh_cmt_channel *ch) static inline unsigned long sh_cmt_read_cmcsr(struct sh_cmt_channel *ch) { - return ch->cmt->read_control(ch->cmt->mapbase_ch, CMCSR); + return ch->cmt->read_control(ch->base, CMCSR); } static inline unsigned long sh_cmt_read_cmcnt(struct sh_cmt_channel *ch) { - return ch->cmt->read_count(ch->cmt->mapbase_ch, CMCNT); + return ch->cmt->read_count(ch->base, CMCNT); } static inline void sh_cmt_write_cmstr(struct sh_cmt_channel *ch, @@ -147,19 +149,19 @@ static inline void sh_cmt_write_cmstr(struct sh_cmt_channel *ch, static inline void sh_cmt_write_cmcsr(struct sh_cmt_channel *ch, unsigned long value) { - ch->cmt->write_control(ch->cmt->mapbase_ch, CMCSR, value); + ch->cmt->write_control(ch->base, CMCSR, value); } static inline void sh_cmt_write_cmcnt(struct sh_cmt_channel *ch, unsigned long value) { - ch->cmt->write_count(ch->cmt->mapbase_ch, CMCNT, value); + ch->cmt->write_count(ch->base, CMCNT, value); } static inline void sh_cmt_write_cmcor(struct sh_cmt_channel *ch, unsigned long value) { - ch->cmt->write_count(ch->cmt->mapbase_ch, CMCOR, value); + ch->cmt->write_count(ch->base, CMCOR, value); } static unsigned long sh_cmt_get_counter(struct sh_cmt_channel *ch, @@ -702,6 +704,7 @@ static int sh_cmt_setup_channel(struct sh_cmt_channel *ch, memset(ch, 0, sizeof(*ch)); ch->cmt = cmt; + ch->base = cmt->mapbase_ch; irq = platform_get_irq(cmt->pdev, 0); if (irq < 0) { -- cgit v1.2.3 From 740a95184dd61eb0481f75ced05ea5e01b7ce6ac Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Mon, 27 Jan 2014 22:04:17 +0100 Subject: clocksource: sh_cmt: Add index to struct sh_cmt_channel Use the index when printing messages to identify the channel. Signed-off-by: Laurent Pinchart --- drivers/clocksource/sh_cmt.c | 37 ++++++++++++++++++++++++------------- 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/drivers/clocksource/sh_cmt.c b/drivers/clocksource/sh_cmt.c index 4fcb05dc9ea4..6b65621a9733 100644 --- a/drivers/clocksource/sh_cmt.c +++ b/drivers/clocksource/sh_cmt.c @@ -39,6 +39,7 @@ struct sh_cmt_device; struct sh_cmt_channel { struct sh_cmt_device *cmt; + unsigned int index; void __iomem *base; @@ -216,7 +217,8 @@ static int sh_cmt_enable(struct sh_cmt_channel *ch, unsigned long *rate) /* enable clock */ ret = clk_enable(ch->cmt->clk); if (ret) { - dev_err(&ch->cmt->pdev->dev, "cannot enable clock\n"); + dev_err(&ch->cmt->pdev->dev, "ch%u: cannot enable clock\n", + ch->index); goto err0; } @@ -253,7 +255,8 @@ static int sh_cmt_enable(struct sh_cmt_channel *ch, unsigned long *rate) } if (sh_cmt_read_cmcnt(ch)) { - dev_err(&ch->cmt->pdev->dev, "cannot clear CMCNT\n"); + dev_err(&ch->cmt->pdev->dev, "ch%u: cannot clear CMCNT\n", + ch->index); ret = -ETIMEDOUT; goto err1; } @@ -371,7 +374,8 @@ static void sh_cmt_clock_event_program_verify(struct sh_cmt_channel *ch, delay = 1; if (!delay) - dev_warn(&ch->cmt->pdev->dev, "too long delay\n"); + dev_warn(&ch->cmt->pdev->dev, "ch%u: too long delay\n", + ch->index); } while (delay); } @@ -379,7 +383,8 @@ static void sh_cmt_clock_event_program_verify(struct sh_cmt_channel *ch, static void __sh_cmt_set_next(struct sh_cmt_channel *ch, unsigned long delta) { if (delta > ch->max_match_value) - dev_warn(&ch->cmt->pdev->dev, "delta out of range\n"); + dev_warn(&ch->cmt->pdev->dev, "ch%u: delta out of range\n", + ch->index); ch->next_match_value = delta; sh_cmt_clock_event_program_verify(ch, 0); @@ -565,7 +570,8 @@ static int sh_cmt_register_clocksource(struct sh_cmt_channel *ch, cs->mask = CLOCKSOURCE_MASK(sizeof(unsigned long) * 8); cs->flags = CLOCK_SOURCE_IS_CONTINUOUS; - dev_info(&ch->cmt->pdev->dev, "used as clock source\n"); + dev_info(&ch->cmt->pdev->dev, "ch%u: used as clock source\n", + ch->index); /* Register with dummy 1 Hz value, gets updated in ->enable() */ clocksource_register_hz(cs, 1); @@ -614,12 +620,12 @@ static void sh_cmt_clock_event_mode(enum clock_event_mode mode, switch (mode) { case CLOCK_EVT_MODE_PERIODIC: dev_info(&ch->cmt->pdev->dev, - "used for periodic clock events\n"); + "ch%u: used for periodic clock events\n", ch->index); sh_cmt_clock_event_start(ch, 1); break; case CLOCK_EVT_MODE_ONESHOT: dev_info(&ch->cmt->pdev->dev, - "used for oneshot clock events\n"); + "ch%u: used for oneshot clock events\n", ch->index); sh_cmt_clock_event_start(ch, 0); break; case CLOCK_EVT_MODE_SHUTDOWN: @@ -678,7 +684,8 @@ static void sh_cmt_register_clockevent(struct sh_cmt_channel *ch, ced->suspend = sh_cmt_clock_event_suspend; ced->resume = sh_cmt_clock_event_resume; - dev_info(&ch->cmt->pdev->dev, "used for clock events\n"); + dev_info(&ch->cmt->pdev->dev, "ch%u: used for clock events\n", + ch->index); clockevents_register_device(ced); } @@ -695,7 +702,7 @@ static int sh_cmt_register(struct sh_cmt_channel *ch, const char *name, return 0; } -static int sh_cmt_setup_channel(struct sh_cmt_channel *ch, +static int sh_cmt_setup_channel(struct sh_cmt_channel *ch, unsigned int index, struct sh_cmt_device *cmt) { struct sh_timer_config *cfg = cmt->pdev->dev.platform_data; @@ -705,10 +712,12 @@ static int sh_cmt_setup_channel(struct sh_cmt_channel *ch, memset(ch, 0, sizeof(*ch)); ch->cmt = cmt; ch->base = cmt->mapbase_ch; + ch->index = index; irq = platform_get_irq(cmt->pdev, 0); if (irq < 0) { - dev_err(&cmt->pdev->dev, "failed to get irq\n"); + dev_err(&cmt->pdev->dev, "ch%u: failed to get irq\n", + ch->index); return irq; } @@ -724,7 +733,8 @@ static int sh_cmt_setup_channel(struct sh_cmt_channel *ch, cfg->clockevent_rating, cfg->clocksource_rating); if (ret) { - dev_err(&cmt->pdev->dev, "registration failed\n"); + dev_err(&cmt->pdev->dev, "ch%u: registration failed\n", + ch->index); return ret; } ch->cs_enabled = false; @@ -733,7 +743,8 @@ static int sh_cmt_setup_channel(struct sh_cmt_channel *ch, IRQF_TIMER | IRQF_IRQPOLL | IRQF_NOBALANCING, dev_name(&cmt->pdev->dev), ch); if (ret) { - dev_err(&cmt->pdev->dev, "failed to request irq %d\n", irq); + dev_err(&cmt->pdev->dev, "ch%u: failed to request irq %d\n", + ch->index, irq); return ret; } @@ -815,7 +826,7 @@ static int sh_cmt_setup(struct sh_cmt_device *cmt, struct platform_device *pdev) cmt->clear_bits = ~0xc000; } - ret = sh_cmt_setup_channel(&cmt->channel, cmt); + ret = sh_cmt_setup_channel(&cmt->channel, cfg->timer_bit, cmt); if (ret < 0) goto err4; -- cgit v1.2.3 From b262bc74dcfd77355720342cbcf89cc8ec12e86b Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Mon, 27 Jan 2014 22:04:17 +0100 Subject: clocksource: sh_cmt: Replace kmalloc + memset with kzalloc One kzalloc a day keeps the bugs away. Signed-off-by: Laurent Pinchart --- drivers/clocksource/sh_cmt.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/drivers/clocksource/sh_cmt.c b/drivers/clocksource/sh_cmt.c index 6b65621a9733..0779bf194aea 100644 --- a/drivers/clocksource/sh_cmt.c +++ b/drivers/clocksource/sh_cmt.c @@ -672,8 +672,6 @@ static void sh_cmt_register_clockevent(struct sh_cmt_channel *ch, { struct clock_event_device *ced = &ch->ced; - memset(ced, 0, sizeof(*ced)); - ced->name = name; ced->features = CLOCK_EVT_FEAT_PERIODIC; ced->features |= CLOCK_EVT_FEAT_ONESHOT; @@ -709,7 +707,6 @@ static int sh_cmt_setup_channel(struct sh_cmt_channel *ch, unsigned int index, int irq; int ret; - memset(ch, 0, sizeof(*ch)); ch->cmt = cmt; ch->base = cmt->mapbase_ch; ch->index = index; @@ -758,7 +755,6 @@ static int sh_cmt_setup(struct sh_cmt_device *cmt, struct platform_device *pdev) int ret; ret = -ENXIO; - memset(cmt, 0, sizeof(*cmt)); cmt->pdev = pdev; if (!cfg) { @@ -861,7 +857,7 @@ static int sh_cmt_probe(struct platform_device *pdev) goto out; } - cmt = kmalloc(sizeof(*cmt), GFP_KERNEL); + cmt = kzalloc(sizeof(*cmt), GFP_KERNEL); if (cmt == NULL) { dev_err(&pdev->dev, "failed to allocate driver data\n"); return -ENOMEM; -- cgit v1.2.3 From f5ec9b194a93c05e2ccdb3e90d9061cfedc806d9 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Mon, 27 Jan 2014 22:04:17 +0100 Subject: clocksource: sh_cmt: Allocate channels dynamically This prepares the driver for multi-channel support. Signed-off-by: Laurent Pinchart --- drivers/clocksource/sh_cmt.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/drivers/clocksource/sh_cmt.c b/drivers/clocksource/sh_cmt.c index 0779bf194aea..f94db327ac7c 100644 --- a/drivers/clocksource/sh_cmt.c +++ b/drivers/clocksource/sh_cmt.c @@ -62,7 +62,8 @@ struct sh_cmt_device { void __iomem *mapbase; struct clk *clk; - struct sh_cmt_channel channel; + struct sh_cmt_channel *channels; + unsigned int num_channels; unsigned long width; /* 16 or 32 bit version of hardware block */ unsigned long overflow_bit; @@ -822,7 +823,15 @@ static int sh_cmt_setup(struct sh_cmt_device *cmt, struct platform_device *pdev) cmt->clear_bits = ~0xc000; } - ret = sh_cmt_setup_channel(&cmt->channel, cfg->timer_bit, cmt); + cmt->channels = kzalloc(sizeof(*cmt->channels), GFP_KERNEL); + if (cmt->channels == NULL) { + ret = -ENOMEM; + goto err4; + } + + cmt->num_channels = 1; + + ret = sh_cmt_setup_channel(&cmt->channels[0], cfg->timer_bit, cmt); if (ret < 0) goto err4; @@ -830,6 +839,7 @@ static int sh_cmt_setup(struct sh_cmt_device *cmt, struct platform_device *pdev) return 0; err4: + kfree(cmt->channels); clk_unprepare(cmt->clk); err3: clk_put(cmt->clk); -- cgit v1.2.3 From 2cda3ac49d5744432e9ebffb8ba47bef6eca053d Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Tue, 11 Feb 2014 23:46:48 +0100 Subject: clocksource: sh_cmt: Split static information from sh_cmt_device Create a new sh_cmt_info structure to hold static information about the device model and reference that structure from the sh_cmt_device structure. Signed-off-by: Laurent Pinchart --- drivers/clocksource/sh_cmt.c | 192 +++++++++++++++++++++++++++---------------- 1 file changed, 122 insertions(+), 70 deletions(-) diff --git a/drivers/clocksource/sh_cmt.c b/drivers/clocksource/sh_cmt.c index f94db327ac7c..879b8c2ae556 100644 --- a/drivers/clocksource/sh_cmt.c +++ b/drivers/clocksource/sh_cmt.c @@ -37,6 +37,52 @@ struct sh_cmt_device; +/* + * The CMT comes in 5 different identified flavours, depending not only on the + * SoC but also on the particular instance. The following table lists the main + * characteristics of those flavours. + * + * 16B 32B 32B-F 48B 48B-2 + * ----------------------------------------------------------------------------- + * Channels 2 1/4 1 6 2/8 + * Control Width 16 16 16 16 32 + * Counter Width 16 32 32 32/48 32/48 + * Shared Start/Stop Y Y Y Y N + * + * The 48-bit gen2 version has a per-channel start/stop register located in the + * channel registers block. All other versions have a shared start/stop register + * located in the global space. + * + * Note that CMT0 on r8a73a4, r8a7790 and r8a7791, while implementing 32-bit + * channels only, is a 48-bit gen2 CMT with the 48-bit channels unavailable. + */ + +enum sh_cmt_model { + SH_CMT_16BIT, + SH_CMT_32BIT, + SH_CMT_32BIT_FAST, + SH_CMT_48BIT, + SH_CMT_48BIT_GEN2, +}; + +struct sh_cmt_info { + enum sh_cmt_model model; + + unsigned long width; /* 16 or 32 bit version of hardware block */ + unsigned long overflow_bit; + unsigned long clear_bits; + + /* callbacks for CMSTR and CMCSR access */ + unsigned long (*read_control)(void __iomem *base, unsigned long offs); + void (*write_control)(void __iomem *base, unsigned long offs, + unsigned long value); + + /* callbacks for CMCNT and CMCOR access */ + unsigned long (*read_count)(void __iomem *base, unsigned long offs); + void (*write_count)(void __iomem *base, unsigned long offs, + unsigned long value); +}; + struct sh_cmt_channel { struct sh_cmt_device *cmt; unsigned int index; @@ -58,49 +104,16 @@ struct sh_cmt_channel { struct sh_cmt_device { struct platform_device *pdev; + const struct sh_cmt_info *info; + void __iomem *mapbase_ch; void __iomem *mapbase; struct clk *clk; struct sh_cmt_channel *channels; unsigned int num_channels; - - unsigned long width; /* 16 or 32 bit version of hardware block */ - unsigned long overflow_bit; - unsigned long clear_bits; - - /* callbacks for CMSTR and CMCSR access */ - unsigned long (*read_control)(void __iomem *base, unsigned long offs); - void (*write_control)(void __iomem *base, unsigned long offs, - unsigned long value); - - /* callbacks for CMCNT and CMCOR access */ - unsigned long (*read_count)(void __iomem *base, unsigned long offs); - void (*write_count)(void __iomem *base, unsigned long offs, - unsigned long value); }; -/* Examples of supported CMT timer register layouts and I/O access widths: - * - * "16-bit counter and 16-bit control" as found on sh7263: - * CMSTR 0xfffec000 16-bit - * CMCSR 0xfffec002 16-bit - * CMCNT 0xfffec004 16-bit - * CMCOR 0xfffec006 16-bit - * - * "32-bit counter and 16-bit control" as found on sh7372, sh73a0, r8a7740: - * CMSTR 0xffca0000 16-bit - * CMCSR 0xffca0060 16-bit - * CMCNT 0xffca0064 32-bit - * CMCOR 0xffca0068 32-bit - * - * "32-bit counter and 32-bit control" as found on r8a73a4 and r8a7790: - * CMSTR 0xffca0500 32-bit - * CMCSR 0xffca0510 32-bit - * CMCNT 0xffca0514 32-bit - * CMCOR 0xffca0518 32-bit - */ - static unsigned long sh_cmt_read16(void __iomem *base, unsigned long offs) { return ioread16(base + (offs << 1)); @@ -123,47 +136,100 @@ static void sh_cmt_write32(void __iomem *base, unsigned long offs, iowrite32(value, base + (offs << 2)); } +static const struct sh_cmt_info sh_cmt_info[] = { + [SH_CMT_16BIT] = { + .model = SH_CMT_16BIT, + .width = 16, + .overflow_bit = 0x80, + .clear_bits = ~0x80, + .read_control = sh_cmt_read16, + .write_control = sh_cmt_write16, + .read_count = sh_cmt_read16, + .write_count = sh_cmt_write16, + }, + [SH_CMT_32BIT] = { + .model = SH_CMT_32BIT, + .width = 32, + .overflow_bit = 0x8000, + .clear_bits = ~0xc000, + .read_control = sh_cmt_read16, + .write_control = sh_cmt_write16, + .read_count = sh_cmt_read32, + .write_count = sh_cmt_write32, + }, + [SH_CMT_32BIT_FAST] = { + .model = SH_CMT_32BIT_FAST, + .width = 32, + .overflow_bit = 0x8000, + .clear_bits = ~0xc000, + .read_control = sh_cmt_read16, + .write_control = sh_cmt_write16, + .read_count = sh_cmt_read32, + .write_count = sh_cmt_write32, + }, + [SH_CMT_48BIT] = { + .model = SH_CMT_48BIT, + .width = 32, + .overflow_bit = 0x8000, + .clear_bits = ~0xc000, + .read_control = sh_cmt_read32, + .write_control = sh_cmt_write32, + .read_count = sh_cmt_read32, + .write_count = sh_cmt_write32, + }, + [SH_CMT_48BIT_GEN2] = { + .model = SH_CMT_48BIT_GEN2, + .width = 32, + .overflow_bit = 0x8000, + .clear_bits = ~0xc000, + .read_control = sh_cmt_read32, + .write_control = sh_cmt_write32, + .read_count = sh_cmt_read32, + .write_count = sh_cmt_write32, + }, +}; + #define CMCSR 0 /* channel register */ #define CMCNT 1 /* channel register */ #define CMCOR 2 /* channel register */ static inline unsigned long sh_cmt_read_cmstr(struct sh_cmt_channel *ch) { - return ch->cmt->read_control(ch->cmt->mapbase, 0); + return ch->cmt->info->read_control(ch->cmt->mapbase, 0); } static inline unsigned long sh_cmt_read_cmcsr(struct sh_cmt_channel *ch) { - return ch->cmt->read_control(ch->base, CMCSR); + return ch->cmt->info->read_control(ch->base, CMCSR); } static inline unsigned long sh_cmt_read_cmcnt(struct sh_cmt_channel *ch) { - return ch->cmt->read_count(ch->base, CMCNT); + return ch->cmt->info->read_count(ch->base, CMCNT); } static inline void sh_cmt_write_cmstr(struct sh_cmt_channel *ch, unsigned long value) { - ch->cmt->write_control(ch->cmt->mapbase, 0, value); + ch->cmt->info->write_control(ch->cmt->mapbase, 0, value); } static inline void sh_cmt_write_cmcsr(struct sh_cmt_channel *ch, unsigned long value) { - ch->cmt->write_control(ch->base, CMCSR, value); + ch->cmt->info->write_control(ch->base, CMCSR, value); } static inline void sh_cmt_write_cmcnt(struct sh_cmt_channel *ch, unsigned long value) { - ch->cmt->write_count(ch->base, CMCNT, value); + ch->cmt->info->write_count(ch->base, CMCNT, value); } static inline void sh_cmt_write_cmcor(struct sh_cmt_channel *ch, unsigned long value) { - ch->cmt->write_count(ch->base, CMCOR, value); + ch->cmt->info->write_count(ch->base, CMCOR, value); } static unsigned long sh_cmt_get_counter(struct sh_cmt_channel *ch, @@ -172,7 +238,7 @@ static unsigned long sh_cmt_get_counter(struct sh_cmt_channel *ch, unsigned long v1, v2, v3; int o1, o2; - o1 = sh_cmt_read_cmcsr(ch) & ch->cmt->overflow_bit; + o1 = sh_cmt_read_cmcsr(ch) & ch->cmt->info->overflow_bit; /* Make sure the timer value is stable. Stolen from acpi_pm.c */ do { @@ -180,7 +246,7 @@ static unsigned long sh_cmt_get_counter(struct sh_cmt_channel *ch, v1 = sh_cmt_read_cmcnt(ch); v2 = sh_cmt_read_cmcnt(ch); v3 = sh_cmt_read_cmcnt(ch); - o1 = sh_cmt_read_cmcsr(ch) & ch->cmt->overflow_bit; + o1 = sh_cmt_read_cmcsr(ch) & ch->cmt->info->overflow_bit; } while (unlikely((o1 != o2) || (v1 > v2 && v1 < v3) || (v2 > v3 && v2 < v1) || (v3 > v1 && v3 < v2))); @@ -227,7 +293,7 @@ static int sh_cmt_enable(struct sh_cmt_channel *ch, unsigned long *rate) sh_cmt_start_stop_ch(ch, 0); /* configure channel, periodic mode and maximum timeout */ - if (ch->cmt->width == 16) { + if (ch->cmt->info->width == 16) { *rate = clk_get_rate(ch->cmt->clk) / 512; sh_cmt_write_cmcsr(ch, 0x43); } else { @@ -405,7 +471,8 @@ static irqreturn_t sh_cmt_interrupt(int irq, void *dev_id) struct sh_cmt_channel *ch = dev_id; /* clear flags */ - sh_cmt_write_cmcsr(ch, sh_cmt_read_cmcsr(ch) & ch->cmt->clear_bits); + sh_cmt_write_cmcsr(ch, sh_cmt_read_cmcsr(ch) & + ch->cmt->info->clear_bits); /* update clock source counter to begin with if enabled * the wrap flag should be cleared by the timer specific @@ -719,10 +786,10 @@ static int sh_cmt_setup_channel(struct sh_cmt_channel *ch, unsigned int index, return irq; } - if (cmt->width == (sizeof(ch->max_match_value) * 8)) + if (cmt->info->width == (sizeof(ch->max_match_value) * 8)) ch->max_match_value = ~0; else - ch->max_match_value = (1 << cmt->width) - 1; + ch->max_match_value = (1 << cmt->info->width) - 1; ch->match_value = ch->max_match_value; raw_spin_lock_init(&ch->lock); @@ -800,28 +867,13 @@ static int sh_cmt_setup(struct sh_cmt_device *cmt, struct platform_device *pdev) if (ret < 0) goto err3; - if (res2 && (resource_size(res2) == 4)) { - /* assume both CMSTR and CMCSR to be 32-bit */ - cmt->read_control = sh_cmt_read32; - cmt->write_control = sh_cmt_write32; - } else { - cmt->read_control = sh_cmt_read16; - cmt->write_control = sh_cmt_write16; - } - - if (resource_size(res) == 6) { - cmt->width = 16; - cmt->read_count = sh_cmt_read16; - cmt->write_count = sh_cmt_write16; - cmt->overflow_bit = 0x80; - cmt->clear_bits = ~0x80; - } else { - cmt->width = 32; - cmt->read_count = sh_cmt_read32; - cmt->write_count = sh_cmt_write32; - cmt->overflow_bit = 0x8000; - cmt->clear_bits = ~0xc000; - } + /* identify the model based on the resources */ + if (resource_size(res) == 6) + cmt->info = &sh_cmt_info[SH_CMT_16BIT]; + else if (res2 && (resource_size(res2) == 4)) + cmt->info = &sh_cmt_info[SH_CMT_48BIT_GEN2]; + else + cmt->info = &sh_cmt_info[SH_CMT_32BIT]; cmt->channels = kzalloc(sizeof(*cmt->channels), GFP_KERNEL); if (cmt->channels == NULL) { -- cgit v1.2.3 From d14be99b7e3fe52bc9921caa30953d49f499f121 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Wed, 29 Jan 2014 00:33:08 +0100 Subject: clocksource: sh_cmt: Replace hardcoded register values with macros Define symbolic macros for all used registers bits. Signed-off-by: Laurent Pinchart --- drivers/clocksource/sh_cmt.c | 56 ++++++++++++++++++++++++++++++++++---------- 1 file changed, 44 insertions(+), 12 deletions(-) diff --git a/drivers/clocksource/sh_cmt.c b/drivers/clocksource/sh_cmt.c index 879b8c2ae556..ce00baaf8bd2 100644 --- a/drivers/clocksource/sh_cmt.c +++ b/drivers/clocksource/sh_cmt.c @@ -114,6 +114,34 @@ struct sh_cmt_device { unsigned int num_channels; }; +#define SH_CMT16_CMCSR_CMF (1 << 7) +#define SH_CMT16_CMCSR_CMIE (1 << 6) +#define SH_CMT16_CMCSR_CKS8 (0 << 0) +#define SH_CMT16_CMCSR_CKS32 (1 << 0) +#define SH_CMT16_CMCSR_CKS128 (2 << 0) +#define SH_CMT16_CMCSR_CKS512 (3 << 0) +#define SH_CMT16_CMCSR_CKS_MASK (3 << 0) + +#define SH_CMT32_CMCSR_CMF (1 << 15) +#define SH_CMT32_CMCSR_OVF (1 << 14) +#define SH_CMT32_CMCSR_WRFLG (1 << 13) +#define SH_CMT32_CMCSR_STTF (1 << 12) +#define SH_CMT32_CMCSR_STPF (1 << 11) +#define SH_CMT32_CMCSR_SSIE (1 << 10) +#define SH_CMT32_CMCSR_CMS (1 << 9) +#define SH_CMT32_CMCSR_CMM (1 << 8) +#define SH_CMT32_CMCSR_CMTOUT_IE (1 << 7) +#define SH_CMT32_CMCSR_CMR_NONE (0 << 4) +#define SH_CMT32_CMCSR_CMR_DMA (1 << 4) +#define SH_CMT32_CMCSR_CMR_IRQ (2 << 4) +#define SH_CMT32_CMCSR_CMR_MASK (3 << 4) +#define SH_CMT32_CMCSR_DBGIVD (1 << 3) +#define SH_CMT32_CMCSR_CKS_RCLK8 (4 << 0) +#define SH_CMT32_CMCSR_CKS_RCLK32 (5 << 0) +#define SH_CMT32_CMCSR_CKS_RCLK128 (6 << 0) +#define SH_CMT32_CMCSR_CKS_RCLK1 (7 << 0) +#define SH_CMT32_CMCSR_CKS_MASK (7 << 0) + static unsigned long sh_cmt_read16(void __iomem *base, unsigned long offs) { return ioread16(base + (offs << 1)); @@ -140,8 +168,8 @@ static const struct sh_cmt_info sh_cmt_info[] = { [SH_CMT_16BIT] = { .model = SH_CMT_16BIT, .width = 16, - .overflow_bit = 0x80, - .clear_bits = ~0x80, + .overflow_bit = SH_CMT16_CMCSR_CMF, + .clear_bits = ~SH_CMT16_CMCSR_CMF, .read_control = sh_cmt_read16, .write_control = sh_cmt_write16, .read_count = sh_cmt_read16, @@ -150,8 +178,8 @@ static const struct sh_cmt_info sh_cmt_info[] = { [SH_CMT_32BIT] = { .model = SH_CMT_32BIT, .width = 32, - .overflow_bit = 0x8000, - .clear_bits = ~0xc000, + .overflow_bit = SH_CMT32_CMCSR_CMF, + .clear_bits = ~(SH_CMT32_CMCSR_CMF | SH_CMT32_CMCSR_OVF), .read_control = sh_cmt_read16, .write_control = sh_cmt_write16, .read_count = sh_cmt_read32, @@ -160,8 +188,8 @@ static const struct sh_cmt_info sh_cmt_info[] = { [SH_CMT_32BIT_FAST] = { .model = SH_CMT_32BIT_FAST, .width = 32, - .overflow_bit = 0x8000, - .clear_bits = ~0xc000, + .overflow_bit = SH_CMT32_CMCSR_CMF, + .clear_bits = ~(SH_CMT32_CMCSR_CMF | SH_CMT32_CMCSR_OVF), .read_control = sh_cmt_read16, .write_control = sh_cmt_write16, .read_count = sh_cmt_read32, @@ -170,8 +198,8 @@ static const struct sh_cmt_info sh_cmt_info[] = { [SH_CMT_48BIT] = { .model = SH_CMT_48BIT, .width = 32, - .overflow_bit = 0x8000, - .clear_bits = ~0xc000, + .overflow_bit = SH_CMT32_CMCSR_CMF, + .clear_bits = ~(SH_CMT32_CMCSR_CMF | SH_CMT32_CMCSR_OVF), .read_control = sh_cmt_read32, .write_control = sh_cmt_write32, .read_count = sh_cmt_read32, @@ -180,8 +208,8 @@ static const struct sh_cmt_info sh_cmt_info[] = { [SH_CMT_48BIT_GEN2] = { .model = SH_CMT_48BIT_GEN2, .width = 32, - .overflow_bit = 0x8000, - .clear_bits = ~0xc000, + .overflow_bit = SH_CMT32_CMCSR_CMF, + .clear_bits = ~(SH_CMT32_CMCSR_CMF | SH_CMT32_CMCSR_OVF), .read_control = sh_cmt_read32, .write_control = sh_cmt_write32, .read_count = sh_cmt_read32, @@ -295,10 +323,14 @@ static int sh_cmt_enable(struct sh_cmt_channel *ch, unsigned long *rate) /* configure channel, periodic mode and maximum timeout */ if (ch->cmt->info->width == 16) { *rate = clk_get_rate(ch->cmt->clk) / 512; - sh_cmt_write_cmcsr(ch, 0x43); + sh_cmt_write_cmcsr(ch, SH_CMT16_CMCSR_CMIE | + SH_CMT16_CMCSR_CKS512); } else { *rate = clk_get_rate(ch->cmt->clk) / 8; - sh_cmt_write_cmcsr(ch, 0x01a4); + sh_cmt_write_cmcsr(ch, SH_CMT32_CMCSR_CMM | + SH_CMT32_CMCSR_CMTOUT_IE | + SH_CMT32_CMCSR_CMR_IRQ | + SH_CMT32_CMCSR_CKS_RCLK8); } sh_cmt_write_cmcor(ch, 0xffffffff); -- cgit v1.2.3 From f1ebe1e47e1979393a8492bfe751176908a830ae Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Wed, 19 Feb 2014 16:19:44 +0100 Subject: clocksource: sh_cmt: Set cpumask to cpu_possible_mask The CMT is a global timer not restricted to a single CPU. It has a lower rating than the TMU or ARM architected timer, but is still useful on systems where the other timers are stopped during CPU sleep. When multiple timers are available the timers core selects which timer to use based on timer ratings. On SMP systems where timer broadcasting is required, one dummy timer is instantiated per CPU with a rating of 100. On those systems the CMT timer has a rating of 80, which makes the dummy timer selected by default on all CPUs. The CMT is then available, and will be used as a broadcast timer. On UP systems no dummy timer is instantiated. The CMT timer has a rating of 125 on those systems and is used directly as a clock event device for CPU0 without broadcasting. The CMT rating shouldn't depend on whether we boot a UP or SMP system. We can't raise the CMT rating to 125 on SMP systems. This would select CMT as the clock event device for CPU0 as its rating is higher than the dummy timer rating, and would leave the system without a broadcast timer. We could instead lower the rating to 80 on all systems, but that wouldn't reflect reality as ratings between 1 and 99 are documented as "unfit for real use". We should raise the rating above 99 and still have the CMT selected as a broadcast timer. This can be done by changing the cpumask from cpumask_of(0) to cpu_possible_mask. In that case the timer selection logic will prefer the previously probed and already selected dummy timer for all CPUs based on the fact that already selected per-cpu timers are preferred over new global timers, regardless of their respective ratings. This also better reflects reality, as the CMT is not tied to the boot CPU. Ideally the timer selection logic should realize that the CMT needs to be used as a broadcast timer on SMP systems as no other broadcast timer is available, regardless of the cpumask and rating. Signed-off-by: Laurent Pinchart --- drivers/clocksource/sh_cmt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/clocksource/sh_cmt.c b/drivers/clocksource/sh_cmt.c index ce00baaf8bd2..926abe288126 100644 --- a/drivers/clocksource/sh_cmt.c +++ b/drivers/clocksource/sh_cmt.c @@ -776,7 +776,7 @@ static void sh_cmt_register_clockevent(struct sh_cmt_channel *ch, ced->features = CLOCK_EVT_FEAT_PERIODIC; ced->features |= CLOCK_EVT_FEAT_ONESHOT; ced->rating = rating; - ced->cpumask = cpumask_of(0); + ced->cpumask = cpu_possible_mask; ced->set_next_event = sh_cmt_clock_event_next; ced->set_mode = sh_cmt_clock_event_mode; ced->suspend = sh_cmt_clock_event_suspend; -- cgit v1.2.3 From b7fcbb0f830e6cccc9d358c24f8463e5d8018649 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Wed, 19 Feb 2014 17:00:31 +0100 Subject: clocksource: sh_cmt: Hardcode CMT clock event rating to 125 All boards use or should use a clock event rating of 125 for the CMT, hardcode it in the driver. Signed-off-by: Laurent Pinchart --- drivers/clocksource/sh_cmt.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/drivers/clocksource/sh_cmt.c b/drivers/clocksource/sh_cmt.c index 926abe288126..75b1f83a60a8 100644 --- a/drivers/clocksource/sh_cmt.c +++ b/drivers/clocksource/sh_cmt.c @@ -768,14 +768,14 @@ static void sh_cmt_clock_event_resume(struct clock_event_device *ced) } static void sh_cmt_register_clockevent(struct sh_cmt_channel *ch, - const char *name, unsigned long rating) + const char *name) { struct clock_event_device *ced = &ch->ced; ced->name = name; ced->features = CLOCK_EVT_FEAT_PERIODIC; ced->features |= CLOCK_EVT_FEAT_ONESHOT; - ced->rating = rating; + ced->rating = 125; ced->cpumask = cpu_possible_mask; ced->set_next_event = sh_cmt_clock_event_next; ced->set_mode = sh_cmt_clock_event_mode; @@ -788,11 +788,10 @@ static void sh_cmt_register_clockevent(struct sh_cmt_channel *ch, } static int sh_cmt_register(struct sh_cmt_channel *ch, const char *name, - unsigned long clockevent_rating, - unsigned long clocksource_rating) + bool clockevent, unsigned long clocksource_rating) { - if (clockevent_rating) - sh_cmt_register_clockevent(ch, name, clockevent_rating); + if (clockevent) + sh_cmt_register_clockevent(ch, name); if (clocksource_rating) sh_cmt_register_clocksource(ch, name, clocksource_rating); @@ -827,7 +826,7 @@ static int sh_cmt_setup_channel(struct sh_cmt_channel *ch, unsigned int index, raw_spin_lock_init(&ch->lock); ret = sh_cmt_register(ch, dev_name(&cmt->pdev->dev), - cfg->clockevent_rating, + cfg->clockevent_rating != 0, cfg->clocksource_rating); if (ret) { dev_err(&cmt->pdev->dev, "ch%u: registration failed\n", -- cgit v1.2.3 From fb28a659813084365eced5c2876c6383da52e634 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Wed, 19 Feb 2014 17:00:31 +0100 Subject: clocksource: sh_cmt: Hardcode CMT clock source rating to 125 All boards use or should use a clock source rating of 125 for the CMT, hardcode it in the driver. Signed-off-by: Laurent Pinchart --- drivers/clocksource/sh_cmt.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/clocksource/sh_cmt.c b/drivers/clocksource/sh_cmt.c index 75b1f83a60a8..c753efcfe9f5 100644 --- a/drivers/clocksource/sh_cmt.c +++ b/drivers/clocksource/sh_cmt.c @@ -656,12 +656,12 @@ static void sh_cmt_clocksource_resume(struct clocksource *cs) } static int sh_cmt_register_clocksource(struct sh_cmt_channel *ch, - const char *name, unsigned long rating) + const char *name) { struct clocksource *cs = &ch->cs; cs->name = name; - cs->rating = rating; + cs->rating = 125; cs->read = sh_cmt_clocksource_read; cs->enable = sh_cmt_clocksource_enable; cs->disable = sh_cmt_clocksource_disable; @@ -788,13 +788,13 @@ static void sh_cmt_register_clockevent(struct sh_cmt_channel *ch, } static int sh_cmt_register(struct sh_cmt_channel *ch, const char *name, - bool clockevent, unsigned long clocksource_rating) + bool clockevent, bool clocksource) { if (clockevent) sh_cmt_register_clockevent(ch, name); - if (clocksource_rating) - sh_cmt_register_clocksource(ch, name, clocksource_rating); + if (clocksource) + sh_cmt_register_clocksource(ch, name); return 0; } @@ -827,7 +827,7 @@ static int sh_cmt_setup_channel(struct sh_cmt_channel *ch, unsigned int index, ret = sh_cmt_register(ch, dev_name(&cmt->pdev->dev), cfg->clockevent_rating != 0, - cfg->clocksource_rating); + cfg->clocksource_rating != 0); if (ret) { dev_err(&cmt->pdev->dev, "ch%u: registration failed\n", ch->index); -- cgit v1.2.3 From 81b3b2711072b6047d5f332cd8751a1c5c9a3fb2 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Tue, 28 Jan 2014 12:36:48 +0100 Subject: clocksource: sh_cmt: Add support for multiple channels per device CMT hardware devices can support multiple channels, with global registers and per-channel registers. The sh_cmt driver currently models the hardware with one Linux device per channel. This model makes it difficult to handle global registers in a clean way. Add support for a new model that uses one Linux device per timer with multiple channels per device. This requires changes to platform data, add new channel configuration fields. Support for the legacy model is kept and will be removed after all platforms switch to the new model. Signed-off-by: Laurent Pinchart --- drivers/clocksource/sh_cmt.c | 304 +++++++++++++++++++++++++++++++++---------- include/linux/sh_timer.h | 1 + 2 files changed, 237 insertions(+), 68 deletions(-) diff --git a/drivers/clocksource/sh_cmt.c b/drivers/clocksource/sh_cmt.c index c753efcfe9f5..1efe7d64efca 100644 --- a/drivers/clocksource/sh_cmt.c +++ b/drivers/clocksource/sh_cmt.c @@ -53,7 +53,16 @@ struct sh_cmt_device; * channel registers block. All other versions have a shared start/stop register * located in the global space. * - * Note that CMT0 on r8a73a4, r8a7790 and r8a7791, while implementing 32-bit + * Channels are indexed from 0 to N-1 in the documentation. The channel index + * infers the start/stop bit position in the control register and the channel + * registers block address. Some CMT instances have a subset of channels + * available, in which case the index in the documentation doesn't match the + * "real" index as implemented in hardware. This is for instance the case with + * CMT0 on r8a7740, which is a 32-bit variant with a single channel numbered 0 + * in the documentation but using start/stop bit 5 and having its registers + * block at 0x60. + * + * Similarly CMT0 on r8a73a4, r8a7790 and r8a7791, while implementing 32-bit * channels only, is a 48-bit gen2 CMT with the 48-bit channels unavailable. */ @@ -85,10 +94,14 @@ struct sh_cmt_info { struct sh_cmt_channel { struct sh_cmt_device *cmt; - unsigned int index; - void __iomem *base; + unsigned int index; /* Index in the documentation */ + unsigned int hwidx; /* Real hardware index */ + + void __iomem *iostart; + void __iomem *ioctrl; + unsigned int timer_bit; unsigned long flags; unsigned long match_value; unsigned long next_match_value; @@ -105,6 +118,7 @@ struct sh_cmt_device { struct platform_device *pdev; const struct sh_cmt_info *info; + bool legacy; void __iomem *mapbase_ch; void __iomem *mapbase; @@ -112,6 +126,9 @@ struct sh_cmt_device { struct sh_cmt_channel *channels; unsigned int num_channels; + + bool has_clockevent; + bool has_clocksource; }; #define SH_CMT16_CMCSR_CMF (1 << 7) @@ -223,41 +240,47 @@ static const struct sh_cmt_info sh_cmt_info[] = { static inline unsigned long sh_cmt_read_cmstr(struct sh_cmt_channel *ch) { - return ch->cmt->info->read_control(ch->cmt->mapbase, 0); + if (ch->iostart) + return ch->cmt->info->read_control(ch->iostart, 0); + else + return ch->cmt->info->read_control(ch->cmt->mapbase, 0); } -static inline unsigned long sh_cmt_read_cmcsr(struct sh_cmt_channel *ch) +static inline void sh_cmt_write_cmstr(struct sh_cmt_channel *ch, + unsigned long value) { - return ch->cmt->info->read_control(ch->base, CMCSR); + if (ch->iostart) + ch->cmt->info->write_control(ch->iostart, 0, value); + else + ch->cmt->info->write_control(ch->cmt->mapbase, 0, value); } -static inline unsigned long sh_cmt_read_cmcnt(struct sh_cmt_channel *ch) +static inline unsigned long sh_cmt_read_cmcsr(struct sh_cmt_channel *ch) { - return ch->cmt->info->read_count(ch->base, CMCNT); + return ch->cmt->info->read_control(ch->ioctrl, CMCSR); } -static inline void sh_cmt_write_cmstr(struct sh_cmt_channel *ch, +static inline void sh_cmt_write_cmcsr(struct sh_cmt_channel *ch, unsigned long value) { - ch->cmt->info->write_control(ch->cmt->mapbase, 0, value); + ch->cmt->info->write_control(ch->ioctrl, CMCSR, value); } -static inline void sh_cmt_write_cmcsr(struct sh_cmt_channel *ch, - unsigned long value) +static inline unsigned long sh_cmt_read_cmcnt(struct sh_cmt_channel *ch) { - ch->cmt->info->write_control(ch->base, CMCSR, value); + return ch->cmt->info->read_count(ch->ioctrl, CMCNT); } static inline void sh_cmt_write_cmcnt(struct sh_cmt_channel *ch, unsigned long value) { - ch->cmt->info->write_count(ch->base, CMCNT, value); + ch->cmt->info->write_count(ch->ioctrl, CMCNT, value); } static inline void sh_cmt_write_cmcor(struct sh_cmt_channel *ch, unsigned long value) { - ch->cmt->info->write_count(ch->base, CMCOR, value); + ch->cmt->info->write_count(ch->ioctrl, CMCOR, value); } static unsigned long sh_cmt_get_counter(struct sh_cmt_channel *ch, @@ -286,7 +309,6 @@ static DEFINE_RAW_SPINLOCK(sh_cmt_lock); static void sh_cmt_start_stop_ch(struct sh_cmt_channel *ch, int start) { - struct sh_timer_config *cfg = ch->cmt->pdev->dev.platform_data; unsigned long flags, value; /* start stop register shared by multiple timer channels */ @@ -294,9 +316,9 @@ static void sh_cmt_start_stop_ch(struct sh_cmt_channel *ch, int start) value = sh_cmt_read_cmstr(ch); if (start) - value |= 1 << cfg->timer_bit; + value |= 1 << ch->timer_bit; else - value &= ~(1 << cfg->timer_bit); + value &= ~(1 << ch->timer_bit); sh_cmt_write_cmstr(ch, value); raw_spin_unlock_irqrestore(&sh_cmt_lock, flags); @@ -790,27 +812,72 @@ static void sh_cmt_register_clockevent(struct sh_cmt_channel *ch, static int sh_cmt_register(struct sh_cmt_channel *ch, const char *name, bool clockevent, bool clocksource) { - if (clockevent) + if (clockevent) { + ch->cmt->has_clockevent = true; sh_cmt_register_clockevent(ch, name); + } - if (clocksource) + if (clocksource) { + ch->cmt->has_clocksource = true; sh_cmt_register_clocksource(ch, name); + } return 0; } static int sh_cmt_setup_channel(struct sh_cmt_channel *ch, unsigned int index, - struct sh_cmt_device *cmt) + unsigned int hwidx, bool clockevent, + bool clocksource, struct sh_cmt_device *cmt) { - struct sh_timer_config *cfg = cmt->pdev->dev.platform_data; int irq; int ret; + /* Skip unused channels. */ + if (!clockevent && !clocksource) + return 0; + ch->cmt = cmt; - ch->base = cmt->mapbase_ch; ch->index = index; + ch->hwidx = hwidx; + + /* + * Compute the address of the channel control register block. For the + * timers with a per-channel start/stop register, compute its address + * as well. + * + * For legacy configuration the address has been mapped explicitly. + */ + if (cmt->legacy) { + ch->ioctrl = cmt->mapbase_ch; + } else { + switch (cmt->info->model) { + case SH_CMT_16BIT: + ch->ioctrl = cmt->mapbase + 2 + ch->hwidx * 6; + break; + case SH_CMT_32BIT: + case SH_CMT_48BIT: + ch->ioctrl = cmt->mapbase + 0x10 + ch->hwidx * 0x10; + break; + case SH_CMT_32BIT_FAST: + /* + * The 32-bit "fast" timer has a single channel at hwidx + * 5 but is located at offset 0x40 instead of 0x60 for + * some reason. + */ + ch->ioctrl = cmt->mapbase + 0x40; + break; + case SH_CMT_48BIT_GEN2: + ch->iostart = cmt->mapbase + ch->hwidx * 0x100; + ch->ioctrl = ch->iostart + 0x10; + break; + } + } + + if (cmt->legacy) + irq = platform_get_irq(cmt->pdev, 0); + else + irq = platform_get_irq(cmt->pdev, ch->index); - irq = platform_get_irq(cmt->pdev, 0); if (irq < 0) { dev_err(&cmt->pdev->dev, "ch%u: failed to get irq\n", ch->index); @@ -825,9 +892,15 @@ static int sh_cmt_setup_channel(struct sh_cmt_channel *ch, unsigned int index, ch->match_value = ch->max_match_value; raw_spin_lock_init(&ch->lock); + if (cmt->legacy) { + ch->timer_bit = ch->hwidx; + } else { + ch->timer_bit = cmt->info->model == SH_CMT_48BIT_GEN2 + ? 0 : ch->hwidx; + } + ret = sh_cmt_register(ch, dev_name(&cmt->pdev->dev), - cfg->clockevent_rating != 0, - cfg->clocksource_rating != 0); + clockevent, clocksource); if (ret) { dev_err(&cmt->pdev->dev, "ch%u: registration failed\n", ch->index); @@ -847,97 +920,180 @@ static int sh_cmt_setup_channel(struct sh_cmt_channel *ch, unsigned int index, return 0; } -static int sh_cmt_setup(struct sh_cmt_device *cmt, struct platform_device *pdev) +static int sh_cmt_map_memory(struct sh_cmt_device *cmt) { - struct sh_timer_config *cfg = pdev->dev.platform_data; - struct resource *res, *res2; - int ret; - ret = -ENXIO; + struct resource *mem; - cmt->pdev = pdev; + mem = platform_get_resource(cmt->pdev, IORESOURCE_MEM, 0); + if (!mem) { + dev_err(&cmt->pdev->dev, "failed to get I/O memory\n"); + return -ENXIO; + } - if (!cfg) { - dev_err(&cmt->pdev->dev, "missing platform data\n"); - goto err0; + cmt->mapbase = ioremap_nocache(mem->start, resource_size(mem)); + if (cmt->mapbase == NULL) { + dev_err(&cmt->pdev->dev, "failed to remap I/O memory\n"); + return -ENXIO; } + return 0; +} + +static int sh_cmt_map_memory_legacy(struct sh_cmt_device *cmt) +{ + struct sh_timer_config *cfg = cmt->pdev->dev.platform_data; + struct resource *res, *res2; + + /* map memory, let mapbase_ch point to our channel */ res = platform_get_resource(cmt->pdev, IORESOURCE_MEM, 0); if (!res) { dev_err(&cmt->pdev->dev, "failed to get I/O memory\n"); - goto err0; + return -ENXIO; } - /* optional resource for the shared timer start/stop register */ - res2 = platform_get_resource(cmt->pdev, IORESOURCE_MEM, 1); - - /* map memory, let mapbase_ch point to our channel */ cmt->mapbase_ch = ioremap_nocache(res->start, resource_size(res)); if (cmt->mapbase_ch == NULL) { dev_err(&cmt->pdev->dev, "failed to remap I/O memory\n"); - goto err0; + return -ENXIO; } + /* optional resource for the shared timer start/stop register */ + res2 = platform_get_resource(cmt->pdev, IORESOURCE_MEM, 1); + /* map second resource for CMSTR */ cmt->mapbase = ioremap_nocache(res2 ? res2->start : res->start - cfg->channel_offset, res2 ? resource_size(res2) : 2); if (cmt->mapbase == NULL) { dev_err(&cmt->pdev->dev, "failed to remap I/O second memory\n"); - goto err1; + iounmap(cmt->mapbase_ch); + return -ENXIO; } - /* get hold of clock */ + /* identify the model based on the resources */ + if (resource_size(res) == 6) + cmt->info = &sh_cmt_info[SH_CMT_16BIT]; + else if (res2 && (resource_size(res2) == 4)) + cmt->info = &sh_cmt_info[SH_CMT_48BIT_GEN2]; + else + cmt->info = &sh_cmt_info[SH_CMT_32BIT]; + + return 0; +} + +static void sh_cmt_unmap_memory(struct sh_cmt_device *cmt) +{ + iounmap(cmt->mapbase); + if (cmt->mapbase_ch) + iounmap(cmt->mapbase_ch); +} + +static int sh_cmt_setup(struct sh_cmt_device *cmt, struct platform_device *pdev) +{ + struct sh_timer_config *cfg = pdev->dev.platform_data; + const struct platform_device_id *id = pdev->id_entry; + unsigned int hw_channels; + int ret; + + memset(cmt, 0, sizeof(*cmt)); + cmt->pdev = pdev; + + if (!cfg) { + dev_err(&cmt->pdev->dev, "missing platform data\n"); + return -ENXIO; + } + + cmt->info = (const struct sh_cmt_info *)id->driver_data; + cmt->legacy = cmt->info ? false : true; + + /* Get hold of clock. */ cmt->clk = clk_get(&cmt->pdev->dev, "cmt_fck"); if (IS_ERR(cmt->clk)) { dev_err(&cmt->pdev->dev, "cannot get clock\n"); - ret = PTR_ERR(cmt->clk); - goto err2; + return PTR_ERR(cmt->clk); } ret = clk_prepare(cmt->clk); if (ret < 0) - goto err3; + goto err_clk_put; - /* identify the model based on the resources */ - if (resource_size(res) == 6) - cmt->info = &sh_cmt_info[SH_CMT_16BIT]; - else if (res2 && (resource_size(res2) == 4)) - cmt->info = &sh_cmt_info[SH_CMT_48BIT_GEN2]; + /* + * Map the memory resource(s). We need to support both the legacy + * platform device configuration (with one device per channel) and the + * new version (with multiple channels per device). + */ + if (cmt->legacy) + ret = sh_cmt_map_memory_legacy(cmt); else - cmt->info = &sh_cmt_info[SH_CMT_32BIT]; + ret = sh_cmt_map_memory(cmt); - cmt->channels = kzalloc(sizeof(*cmt->channels), GFP_KERNEL); + if (ret < 0) + goto err_clk_unprepare; + + /* Allocate and setup the channels. */ + if (cmt->legacy) { + cmt->num_channels = 1; + hw_channels = 0; + } else { + cmt->num_channels = hweight8(cfg->channels_mask); + hw_channels = cfg->channels_mask; + } + + cmt->channels = kzalloc(cmt->num_channels * sizeof(*cmt->channels), + GFP_KERNEL); if (cmt->channels == NULL) { ret = -ENOMEM; - goto err4; + goto err_unmap; } - cmt->num_channels = 1; + if (cmt->legacy) { + ret = sh_cmt_setup_channel(&cmt->channels[0], + cfg->timer_bit, cfg->timer_bit, + cfg->clockevent_rating != 0, + cfg->clocksource_rating != 0, cmt); + if (ret < 0) + goto err_unmap; + } else { + unsigned int mask = hw_channels; + unsigned int i; - ret = sh_cmt_setup_channel(&cmt->channels[0], cfg->timer_bit, cmt); - if (ret < 0) - goto err4; + /* + * Use the first channel as a clock event device and the second + * channel as a clock source. If only one channel is available + * use it for both. + */ + for (i = 0; i < cmt->num_channels; ++i) { + unsigned int hwidx = ffs(mask) - 1; + bool clocksource = i == 1 || cmt->num_channels == 1; + bool clockevent = i == 0; + + ret = sh_cmt_setup_channel(&cmt->channels[i], i, hwidx, + clockevent, clocksource, + cmt); + if (ret < 0) + goto err_unmap; + + mask &= ~(1 << hwidx); + } + } platform_set_drvdata(pdev, cmt); return 0; -err4: + +err_unmap: kfree(cmt->channels); + sh_cmt_unmap_memory(cmt); +err_clk_unprepare: clk_unprepare(cmt->clk); -err3: +err_clk_put: clk_put(cmt->clk); -err2: - iounmap(cmt->mapbase); -err1: - iounmap(cmt->mapbase_ch); -err0: return ret; } static int sh_cmt_probe(struct platform_device *pdev) { struct sh_cmt_device *cmt = platform_get_drvdata(pdev); - struct sh_timer_config *cfg = pdev->dev.platform_data; int ret; if (!is_early_platform_device(pdev)) { @@ -966,7 +1122,7 @@ static int sh_cmt_probe(struct platform_device *pdev) return 0; out: - if (cfg->clockevent_rating || cfg->clocksource_rating) + if (cmt->has_clockevent || cmt->has_clocksource) pm_runtime_irq_safe(&pdev->dev); else pm_runtime_idle(&pdev->dev); @@ -979,12 +1135,24 @@ static int sh_cmt_remove(struct platform_device *pdev) return -EBUSY; /* cannot unregister clockevent and clocksource */ } +static const struct platform_device_id sh_cmt_id_table[] = { + { "sh_cmt", 0 }, + { "sh-cmt-16", (kernel_ulong_t)&sh_cmt_info[SH_CMT_16BIT] }, + { "sh-cmt-32", (kernel_ulong_t)&sh_cmt_info[SH_CMT_32BIT] }, + { "sh-cmt-32-fast", (kernel_ulong_t)&sh_cmt_info[SH_CMT_32BIT_FAST] }, + { "sh-cmt-48", (kernel_ulong_t)&sh_cmt_info[SH_CMT_48BIT] }, + { "sh-cmt-48-gen2", (kernel_ulong_t)&sh_cmt_info[SH_CMT_48BIT_GEN2] }, + { } +}; +MODULE_DEVICE_TABLE(platform, sh_cmt_id_table); + static struct platform_driver sh_cmt_device_driver = { .probe = sh_cmt_probe, .remove = sh_cmt_remove, .driver = { .name = "sh_cmt", - } + }, + .id_table = sh_cmt_id_table, }; static int __init sh_cmt_init(void) diff --git a/include/linux/sh_timer.h b/include/linux/sh_timer.h index 4d9dcd138315..8e1e036d6d45 100644 --- a/include/linux/sh_timer.h +++ b/include/linux/sh_timer.h @@ -7,6 +7,7 @@ struct sh_timer_config { int timer_bit; unsigned long clockevent_rating; unsigned long clocksource_rating; + unsigned int channels_mask; }; #endif /* __SH_TIMER_H__ */ -- cgit v1.2.3 From 24b4e07df54b7bf7739fb3dd193f639a8f274ad6 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Fri, 14 Feb 2014 00:35:18 +0100 Subject: clocksource: sh_cmt: Rename clock to "fck" in the non-legacy case The sh_cmt driver gets the CMT functional clock using a connection ID of "cmt_fck". While all SH SoCs create clock lookup entries with a NULL device ID and a "cmt_fck" connection ID, the ARM SoCs use the device ID only with a NULL connection ID. This works on legacy platforms but will break on ARM with DT boot. Fix the situation by using a connection ID of "fck" in the non-legacy platform data case. Clock lookup entries will be renamed to use the device ID as well as the connection ID as platforms get moved to new platform data. The legacy code will eventually be dropped, leaving us with device ID based clock lookup, compatible with DT boot. Signed-off-by: Laurent Pinchart --- drivers/clocksource/sh_cmt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/clocksource/sh_cmt.c b/drivers/clocksource/sh_cmt.c index 1efe7d64efca..a5ea9aedbd50 100644 --- a/drivers/clocksource/sh_cmt.c +++ b/drivers/clocksource/sh_cmt.c @@ -1007,7 +1007,7 @@ static int sh_cmt_setup(struct sh_cmt_device *cmt, struct platform_device *pdev) cmt->legacy = cmt->info ? false : true; /* Get hold of clock. */ - cmt->clk = clk_get(&cmt->pdev->dev, "cmt_fck"); + cmt->clk = clk_get(&cmt->pdev->dev, cmt->legacy ? "cmt_fck" : "fck"); if (IS_ERR(cmt->clk)) { dev_err(&cmt->pdev->dev, "cannot get clock\n"); return PTR_ERR(cmt->clk); -- cgit v1.2.3 From 1cd89c568c057a13ca11acf0eb3a78121513e2b6 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Fri, 14 Feb 2014 01:25:50 +0100 Subject: clocksource: sh_cmt: Remove FSF mail address from GPL notice Do not include the paragraph about writing to the Free Software Foundation's mailing address from the sample GPL notice. The FSF has changed addresses in the past, and may do so again. Linux already includes a copy of the GPL. Signed-off-by: Laurent Pinchart --- drivers/clocksource/sh_cmt.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/drivers/clocksource/sh_cmt.c b/drivers/clocksource/sh_cmt.c index a5ea9aedbd50..399e9525e226 100644 --- a/drivers/clocksource/sh_cmt.c +++ b/drivers/clocksource/sh_cmt.c @@ -11,10 +11,6 @@ * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include -- cgit v1.2.3 From e7a9bcc2372b0e62443569c63a369cfd528db4f4 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Wed, 12 Feb 2014 16:56:44 +0100 Subject: clocksource: sh_cmt: Sort headers alphabetically This helps locating duplicates and inserting new headers. Signed-off-by: Laurent Pinchart --- drivers/clocksource/sh_cmt.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/clocksource/sh_cmt.c b/drivers/clocksource/sh_cmt.c index 399e9525e226..9f215e74751c 100644 --- a/drivers/clocksource/sh_cmt.c +++ b/drivers/clocksource/sh_cmt.c @@ -13,23 +13,23 @@ * GNU General Public License for more details. */ +#include +#include +#include +#include +#include #include -#include -#include #include -#include #include -#include +#include #include -#include -#include -#include -#include -#include -#include #include +#include #include #include +#include +#include +#include struct sh_cmt_device; -- cgit v1.2.3 From bfa76bb12f23ecf0c6d07c302f4571a6fe9bc3e3 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Fri, 21 Feb 2014 01:24:47 +0100 Subject: clocksource: sh_cmt: Request IRQ for clock event device only Clock sources don't need an IRQ, request the IRQ only for channels used as clock event devices. Signed-off-by: Laurent Pinchart --- drivers/clocksource/sh_cmt.c | 51 +++++++++++++++++++++++--------------------- 1 file changed, 27 insertions(+), 24 deletions(-) diff --git a/drivers/clocksource/sh_cmt.c b/drivers/clocksource/sh_cmt.c index 9f215e74751c..bc8d025ce861 100644 --- a/drivers/clocksource/sh_cmt.c +++ b/drivers/clocksource/sh_cmt.c @@ -785,10 +785,28 @@ static void sh_cmt_clock_event_resume(struct clock_event_device *ced) pm_genpd_syscore_poweron(&ch->cmt->pdev->dev); } -static void sh_cmt_register_clockevent(struct sh_cmt_channel *ch, - const char *name) +static int sh_cmt_register_clockevent(struct sh_cmt_channel *ch, + const char *name) { struct clock_event_device *ced = &ch->ced; + int irq; + int ret; + + irq = platform_get_irq(ch->cmt->pdev, ch->cmt->legacy ? 0 : ch->index); + if (irq < 0) { + dev_err(&ch->cmt->pdev->dev, "ch%u: failed to get irq\n", + ch->index); + return irq; + } + + ret = request_irq(irq, sh_cmt_interrupt, + IRQF_TIMER | IRQF_IRQPOLL | IRQF_NOBALANCING, + dev_name(&ch->cmt->pdev->dev), ch); + if (ret) { + dev_err(&ch->cmt->pdev->dev, "ch%u: failed to request irq %d\n", + ch->index, irq); + return ret; + } ced->name = name; ced->features = CLOCK_EVT_FEAT_PERIODIC; @@ -803,14 +821,20 @@ static void sh_cmt_register_clockevent(struct sh_cmt_channel *ch, dev_info(&ch->cmt->pdev->dev, "ch%u: used for clock events\n", ch->index); clockevents_register_device(ced); + + return 0; } static int sh_cmt_register(struct sh_cmt_channel *ch, const char *name, bool clockevent, bool clocksource) { + int ret; + if (clockevent) { ch->cmt->has_clockevent = true; - sh_cmt_register_clockevent(ch, name); + ret = sh_cmt_register_clockevent(ch, name); + if (ret < 0) + return ret; } if (clocksource) { @@ -825,7 +849,6 @@ static int sh_cmt_setup_channel(struct sh_cmt_channel *ch, unsigned int index, unsigned int hwidx, bool clockevent, bool clocksource, struct sh_cmt_device *cmt) { - int irq; int ret; /* Skip unused channels. */ @@ -869,17 +892,6 @@ static int sh_cmt_setup_channel(struct sh_cmt_channel *ch, unsigned int index, } } - if (cmt->legacy) - irq = platform_get_irq(cmt->pdev, 0); - else - irq = platform_get_irq(cmt->pdev, ch->index); - - if (irq < 0) { - dev_err(&cmt->pdev->dev, "ch%u: failed to get irq\n", - ch->index); - return irq; - } - if (cmt->info->width == (sizeof(ch->max_match_value) * 8)) ch->max_match_value = ~0; else @@ -904,15 +916,6 @@ static int sh_cmt_setup_channel(struct sh_cmt_channel *ch, unsigned int index, } ch->cs_enabled = false; - ret = request_irq(irq, sh_cmt_interrupt, - IRQF_TIMER | IRQF_IRQPOLL | IRQF_NOBALANCING, - dev_name(&cmt->pdev->dev), ch); - if (ret) { - dev_err(&cmt->pdev->dev, "ch%u: failed to request irq %d\n", - ch->index, irq); - return ret; - } - return 0; } -- cgit v1.2.3 From 1c56cf6b048e1e1bbe08faf38b5592b373905ac5 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Mon, 17 Feb 2014 11:27:49 +0100 Subject: clocksource: sh_tmu: Use request_irq() instead of setup_irq() The driver claims it needs to register an interrupt handler too early for request_irq(). This might have been true in the past, but the only meaningful difference between request_irq() and setup_irq() today is an additional kzalloc() call in request_irq(). As the driver calls kmalloc() itself we know that the slab allocator is available, we can thus switch to request_irq(). Signed-off-by: Laurent Pinchart --- drivers/clocksource/sh_tmu.c | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/drivers/clocksource/sh_tmu.c b/drivers/clocksource/sh_tmu.c index ecd7b60bfdfa..8613cc90bb74 100644 --- a/drivers/clocksource/sh_tmu.c +++ b/drivers/clocksource/sh_tmu.c @@ -38,7 +38,7 @@ struct sh_tmu_priv { void __iomem *mapbase; struct clk *clk; - struct irqaction irqaction; + int irq; struct platform_device *pdev; unsigned long rate; unsigned long periodic; @@ -401,10 +401,11 @@ static void sh_tmu_register_clockevent(struct sh_tmu_priv *p, clockevents_config_and_register(ced, 1, 0x300, 0xffffffff); - ret = setup_irq(p->irqaction.irq, &p->irqaction); + ret = request_irq(p->irq, sh_tmu_interrupt, + IRQF_TIMER | IRQF_IRQPOLL | IRQF_NOBALANCING, + dev_name(&p->pdev->dev), p); if (ret) { - dev_err(&p->pdev->dev, "failed to request irq %d\n", - p->irqaction.irq); + dev_err(&p->pdev->dev, "failed to request irq %d\n", p->irq); return; } } @@ -425,7 +426,7 @@ static int sh_tmu_setup(struct sh_tmu_priv *p, struct platform_device *pdev) { struct sh_timer_config *cfg = pdev->dev.platform_data; struct resource *res; - int irq, ret; + int ret; ret = -ENXIO; memset(p, 0, sizeof(*p)); @@ -444,8 +445,8 @@ static int sh_tmu_setup(struct sh_tmu_priv *p, struct platform_device *pdev) goto err0; } - irq = platform_get_irq(p->pdev, 0); - if (irq < 0) { + p->irq = platform_get_irq(p->pdev, 0); + if (p->irq < 0) { dev_err(&p->pdev->dev, "failed to get irq\n"); goto err0; } @@ -457,13 +458,6 @@ static int sh_tmu_setup(struct sh_tmu_priv *p, struct platform_device *pdev) goto err0; } - /* setup data for setup_irq() (too early for request_irq()) */ - p->irqaction.name = dev_name(&p->pdev->dev); - p->irqaction.handler = sh_tmu_interrupt; - p->irqaction.dev_id = p; - p->irqaction.irq = irq; - p->irqaction.flags = IRQF_TIMER | IRQF_IRQPOLL | IRQF_NOBALANCING; - /* get hold of clock */ p->clk = clk_get(&p->pdev->dev, "tmu_fck"); if (IS_ERR(p->clk)) { -- cgit v1.2.3 From de2d12c7e856f0fa59ea83275410a364d2b182c0 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Mon, 27 Jan 2014 15:29:19 +0100 Subject: clocksource: sh_tmu: Split channel fields from sh_tmu_priv Create a new sh_tmu_channel structure to hold the channel-specific field in preparation for multiple channels per device support. Signed-off-by: Laurent Pinchart --- drivers/clocksource/sh_tmu.c | 235 +++++++++++++++++++++++-------------------- 1 file changed, 125 insertions(+), 110 deletions(-) diff --git a/drivers/clocksource/sh_tmu.c b/drivers/clocksource/sh_tmu.c index 8613cc90bb74..26457e1fccbb 100644 --- a/drivers/clocksource/sh_tmu.c +++ b/drivers/clocksource/sh_tmu.c @@ -35,11 +35,13 @@ #include #include -struct sh_tmu_priv { - void __iomem *mapbase; - struct clk *clk; +struct sh_tmu_priv; + +struct sh_tmu_channel { + struct sh_tmu_priv *tmu; + int irq; - struct platform_device *pdev; + unsigned long rate; unsigned long periodic; struct clock_event_device ced; @@ -48,6 +50,15 @@ struct sh_tmu_priv { unsigned int enable_count; }; +struct sh_tmu_priv { + struct platform_device *pdev; + + void __iomem *mapbase; + struct clk *clk; + + struct sh_tmu_channel channel; +}; + static DEFINE_RAW_SPINLOCK(sh_tmu_lock); #define TSTR -1 /* shared register */ @@ -55,10 +66,10 @@ static DEFINE_RAW_SPINLOCK(sh_tmu_lock); #define TCNT 1 /* channel register */ #define TCR 2 /* channel register */ -static inline unsigned long sh_tmu_read(struct sh_tmu_priv *p, int reg_nr) +static inline unsigned long sh_tmu_read(struct sh_tmu_channel *ch, int reg_nr) { - struct sh_timer_config *cfg = p->pdev->dev.platform_data; - void __iomem *base = p->mapbase; + struct sh_timer_config *cfg = ch->tmu->pdev->dev.platform_data; + void __iomem *base = ch->tmu->mapbase; unsigned long offs; if (reg_nr == TSTR) @@ -72,11 +83,11 @@ static inline unsigned long sh_tmu_read(struct sh_tmu_priv *p, int reg_nr) return ioread32(base + offs); } -static inline void sh_tmu_write(struct sh_tmu_priv *p, int reg_nr, +static inline void sh_tmu_write(struct sh_tmu_channel *ch, int reg_nr, unsigned long value) { - struct sh_timer_config *cfg = p->pdev->dev.platform_data; - void __iomem *base = p->mapbase; + struct sh_timer_config *cfg = ch->tmu->pdev->dev.platform_data; + void __iomem *base = ch->tmu->mapbase; unsigned long offs; if (reg_nr == TSTR) { @@ -92,152 +103,152 @@ static inline void sh_tmu_write(struct sh_tmu_priv *p, int reg_nr, iowrite32(value, base + offs); } -static void sh_tmu_start_stop_ch(struct sh_tmu_priv *p, int start) +static void sh_tmu_start_stop_ch(struct sh_tmu_channel *ch, int start) { - struct sh_timer_config *cfg = p->pdev->dev.platform_data; + struct sh_timer_config *cfg = ch->tmu->pdev->dev.platform_data; unsigned long flags, value; /* start stop register shared by multiple timer channels */ raw_spin_lock_irqsave(&sh_tmu_lock, flags); - value = sh_tmu_read(p, TSTR); + value = sh_tmu_read(ch, TSTR); if (start) value |= 1 << cfg->timer_bit; else value &= ~(1 << cfg->timer_bit); - sh_tmu_write(p, TSTR, value); + sh_tmu_write(ch, TSTR, value); raw_spin_unlock_irqrestore(&sh_tmu_lock, flags); } -static int __sh_tmu_enable(struct sh_tmu_priv *p) +static int __sh_tmu_enable(struct sh_tmu_channel *ch) { int ret; /* enable clock */ - ret = clk_enable(p->clk); + ret = clk_enable(ch->tmu->clk); if (ret) { - dev_err(&p->pdev->dev, "cannot enable clock\n"); + dev_err(&ch->tmu->pdev->dev, "cannot enable clock\n"); return ret; } /* make sure channel is disabled */ - sh_tmu_start_stop_ch(p, 0); + sh_tmu_start_stop_ch(ch, 0); /* maximum timeout */ - sh_tmu_write(p, TCOR, 0xffffffff); - sh_tmu_write(p, TCNT, 0xffffffff); + sh_tmu_write(ch, TCOR, 0xffffffff); + sh_tmu_write(ch, TCNT, 0xffffffff); /* configure channel to parent clock / 4, irq off */ - p->rate = clk_get_rate(p->clk) / 4; - sh_tmu_write(p, TCR, 0x0000); + ch->rate = clk_get_rate(ch->tmu->clk) / 4; + sh_tmu_write(ch, TCR, 0x0000); /* enable channel */ - sh_tmu_start_stop_ch(p, 1); + sh_tmu_start_stop_ch(ch, 1); return 0; } -static int sh_tmu_enable(struct sh_tmu_priv *p) +static int sh_tmu_enable(struct sh_tmu_channel *ch) { - if (p->enable_count++ > 0) + if (ch->enable_count++ > 0) return 0; - pm_runtime_get_sync(&p->pdev->dev); - dev_pm_syscore_device(&p->pdev->dev, true); + pm_runtime_get_sync(&ch->tmu->pdev->dev); + dev_pm_syscore_device(&ch->tmu->pdev->dev, true); - return __sh_tmu_enable(p); + return __sh_tmu_enable(ch); } -static void __sh_tmu_disable(struct sh_tmu_priv *p) +static void __sh_tmu_disable(struct sh_tmu_channel *ch) { /* disable channel */ - sh_tmu_start_stop_ch(p, 0); + sh_tmu_start_stop_ch(ch, 0); /* disable interrupts in TMU block */ - sh_tmu_write(p, TCR, 0x0000); + sh_tmu_write(ch, TCR, 0x0000); /* stop clock */ - clk_disable(p->clk); + clk_disable(ch->tmu->clk); } -static void sh_tmu_disable(struct sh_tmu_priv *p) +static void sh_tmu_disable(struct sh_tmu_channel *ch) { - if (WARN_ON(p->enable_count == 0)) + if (WARN_ON(ch->enable_count == 0)) return; - if (--p->enable_count > 0) + if (--ch->enable_count > 0) return; - __sh_tmu_disable(p); + __sh_tmu_disable(ch); - dev_pm_syscore_device(&p->pdev->dev, false); - pm_runtime_put(&p->pdev->dev); + dev_pm_syscore_device(&ch->tmu->pdev->dev, false); + pm_runtime_put(&ch->tmu->pdev->dev); } -static void sh_tmu_set_next(struct sh_tmu_priv *p, unsigned long delta, +static void sh_tmu_set_next(struct sh_tmu_channel *ch, unsigned long delta, int periodic) { /* stop timer */ - sh_tmu_start_stop_ch(p, 0); + sh_tmu_start_stop_ch(ch, 0); /* acknowledge interrupt */ - sh_tmu_read(p, TCR); + sh_tmu_read(ch, TCR); /* enable interrupt */ - sh_tmu_write(p, TCR, 0x0020); + sh_tmu_write(ch, TCR, 0x0020); /* reload delta value in case of periodic timer */ if (periodic) - sh_tmu_write(p, TCOR, delta); + sh_tmu_write(ch, TCOR, delta); else - sh_tmu_write(p, TCOR, 0xffffffff); + sh_tmu_write(ch, TCOR, 0xffffffff); - sh_tmu_write(p, TCNT, delta); + sh_tmu_write(ch, TCNT, delta); /* start timer */ - sh_tmu_start_stop_ch(p, 1); + sh_tmu_start_stop_ch(ch, 1); } static irqreturn_t sh_tmu_interrupt(int irq, void *dev_id) { - struct sh_tmu_priv *p = dev_id; + struct sh_tmu_channel *ch = dev_id; /* disable or acknowledge interrupt */ - if (p->ced.mode == CLOCK_EVT_MODE_ONESHOT) - sh_tmu_write(p, TCR, 0x0000); + if (ch->ced.mode == CLOCK_EVT_MODE_ONESHOT) + sh_tmu_write(ch, TCR, 0x0000); else - sh_tmu_write(p, TCR, 0x0020); + sh_tmu_write(ch, TCR, 0x0020); /* notify clockevent layer */ - p->ced.event_handler(&p->ced); + ch->ced.event_handler(&ch->ced); return IRQ_HANDLED; } -static struct sh_tmu_priv *cs_to_sh_tmu(struct clocksource *cs) +static struct sh_tmu_channel *cs_to_sh_tmu(struct clocksource *cs) { - return container_of(cs, struct sh_tmu_priv, cs); + return container_of(cs, struct sh_tmu_channel, cs); } static cycle_t sh_tmu_clocksource_read(struct clocksource *cs) { - struct sh_tmu_priv *p = cs_to_sh_tmu(cs); + struct sh_tmu_channel *ch = cs_to_sh_tmu(cs); - return sh_tmu_read(p, TCNT) ^ 0xffffffff; + return sh_tmu_read(ch, TCNT) ^ 0xffffffff; } static int sh_tmu_clocksource_enable(struct clocksource *cs) { - struct sh_tmu_priv *p = cs_to_sh_tmu(cs); + struct sh_tmu_channel *ch = cs_to_sh_tmu(cs); int ret; - if (WARN_ON(p->cs_enabled)) + if (WARN_ON(ch->cs_enabled)) return 0; - ret = sh_tmu_enable(p); + ret = sh_tmu_enable(ch); if (!ret) { - __clocksource_updatefreq_hz(cs, p->rate); - p->cs_enabled = true; + __clocksource_updatefreq_hz(cs, ch->rate); + ch->cs_enabled = true; } return ret; @@ -245,45 +256,45 @@ static int sh_tmu_clocksource_enable(struct clocksource *cs) static void sh_tmu_clocksource_disable(struct clocksource *cs) { - struct sh_tmu_priv *p = cs_to_sh_tmu(cs); + struct sh_tmu_channel *ch = cs_to_sh_tmu(cs); - if (WARN_ON(!p->cs_enabled)) + if (WARN_ON(!ch->cs_enabled)) return; - sh_tmu_disable(p); - p->cs_enabled = false; + sh_tmu_disable(ch); + ch->cs_enabled = false; } static void sh_tmu_clocksource_suspend(struct clocksource *cs) { - struct sh_tmu_priv *p = cs_to_sh_tmu(cs); + struct sh_tmu_channel *ch = cs_to_sh_tmu(cs); - if (!p->cs_enabled) + if (!ch->cs_enabled) return; - if (--p->enable_count == 0) { - __sh_tmu_disable(p); - pm_genpd_syscore_poweroff(&p->pdev->dev); + if (--ch->enable_count == 0) { + __sh_tmu_disable(ch); + pm_genpd_syscore_poweroff(&ch->tmu->pdev->dev); } } static void sh_tmu_clocksource_resume(struct clocksource *cs) { - struct sh_tmu_priv *p = cs_to_sh_tmu(cs); + struct sh_tmu_channel *ch = cs_to_sh_tmu(cs); - if (!p->cs_enabled) + if (!ch->cs_enabled) return; - if (p->enable_count++ == 0) { - pm_genpd_syscore_poweron(&p->pdev->dev); - __sh_tmu_enable(p); + if (ch->enable_count++ == 0) { + pm_genpd_syscore_poweron(&ch->tmu->pdev->dev); + __sh_tmu_enable(ch); } } -static int sh_tmu_register_clocksource(struct sh_tmu_priv *p, +static int sh_tmu_register_clocksource(struct sh_tmu_channel *ch, char *name, unsigned long rating) { - struct clocksource *cs = &p->cs; + struct clocksource *cs = &ch->cs; cs->name = name; cs->rating = rating; @@ -295,43 +306,43 @@ static int sh_tmu_register_clocksource(struct sh_tmu_priv *p, cs->mask = CLOCKSOURCE_MASK(32); cs->flags = CLOCK_SOURCE_IS_CONTINUOUS; - dev_info(&p->pdev->dev, "used as clock source\n"); + dev_info(&ch->tmu->pdev->dev, "used as clock source\n"); /* Register with dummy 1 Hz value, gets updated in ->enable() */ clocksource_register_hz(cs, 1); return 0; } -static struct sh_tmu_priv *ced_to_sh_tmu(struct clock_event_device *ced) +static struct sh_tmu_channel *ced_to_sh_tmu(struct clock_event_device *ced) { - return container_of(ced, struct sh_tmu_priv, ced); + return container_of(ced, struct sh_tmu_channel, ced); } -static void sh_tmu_clock_event_start(struct sh_tmu_priv *p, int periodic) +static void sh_tmu_clock_event_start(struct sh_tmu_channel *ch, int periodic) { - struct clock_event_device *ced = &p->ced; + struct clock_event_device *ced = &ch->ced; - sh_tmu_enable(p); + sh_tmu_enable(ch); - clockevents_config(ced, p->rate); + clockevents_config(ced, ch->rate); if (periodic) { - p->periodic = (p->rate + HZ/2) / HZ; - sh_tmu_set_next(p, p->periodic, 1); + ch->periodic = (ch->rate + HZ/2) / HZ; + sh_tmu_set_next(ch, ch->periodic, 1); } } static void sh_tmu_clock_event_mode(enum clock_event_mode mode, struct clock_event_device *ced) { - struct sh_tmu_priv *p = ced_to_sh_tmu(ced); + struct sh_tmu_channel *ch = ced_to_sh_tmu(ced); int disabled = 0; /* deal with old setting first */ switch (ced->mode) { case CLOCK_EVT_MODE_PERIODIC: case CLOCK_EVT_MODE_ONESHOT: - sh_tmu_disable(p); + sh_tmu_disable(ch); disabled = 1; break; default: @@ -340,16 +351,18 @@ static void sh_tmu_clock_event_mode(enum clock_event_mode mode, switch (mode) { case CLOCK_EVT_MODE_PERIODIC: - dev_info(&p->pdev->dev, "used for periodic clock events\n"); - sh_tmu_clock_event_start(p, 1); + dev_info(&ch->tmu->pdev->dev, + "used for periodic clock events\n"); + sh_tmu_clock_event_start(ch, 1); break; case CLOCK_EVT_MODE_ONESHOT: - dev_info(&p->pdev->dev, "used for oneshot clock events\n"); - sh_tmu_clock_event_start(p, 0); + dev_info(&ch->tmu->pdev->dev, + "used for oneshot clock events\n"); + sh_tmu_clock_event_start(ch, 0); break; case CLOCK_EVT_MODE_UNUSED: if (!disabled) - sh_tmu_disable(p); + sh_tmu_disable(ch); break; case CLOCK_EVT_MODE_SHUTDOWN: default: @@ -360,29 +373,29 @@ static void sh_tmu_clock_event_mode(enum clock_event_mode mode, static int sh_tmu_clock_event_next(unsigned long delta, struct clock_event_device *ced) { - struct sh_tmu_priv *p = ced_to_sh_tmu(ced); + struct sh_tmu_channel *ch = ced_to_sh_tmu(ced); BUG_ON(ced->mode != CLOCK_EVT_MODE_ONESHOT); /* program new delta value */ - sh_tmu_set_next(p, delta, 0); + sh_tmu_set_next(ch, delta, 0); return 0; } static void sh_tmu_clock_event_suspend(struct clock_event_device *ced) { - pm_genpd_syscore_poweroff(&ced_to_sh_tmu(ced)->pdev->dev); + pm_genpd_syscore_poweroff(&ced_to_sh_tmu(ced)->tmu->pdev->dev); } static void sh_tmu_clock_event_resume(struct clock_event_device *ced) { - pm_genpd_syscore_poweron(&ced_to_sh_tmu(ced)->pdev->dev); + pm_genpd_syscore_poweron(&ced_to_sh_tmu(ced)->tmu->pdev->dev); } -static void sh_tmu_register_clockevent(struct sh_tmu_priv *p, +static void sh_tmu_register_clockevent(struct sh_tmu_channel *ch, char *name, unsigned long rating) { - struct clock_event_device *ced = &p->ced; + struct clock_event_device *ced = &ch->ced; int ret; memset(ced, 0, sizeof(*ced)); @@ -397,27 +410,28 @@ static void sh_tmu_register_clockevent(struct sh_tmu_priv *p, ced->suspend = sh_tmu_clock_event_suspend; ced->resume = sh_tmu_clock_event_resume; - dev_info(&p->pdev->dev, "used for clock events\n"); + dev_info(&ch->tmu->pdev->dev, "used for clock events\n"); clockevents_config_and_register(ced, 1, 0x300, 0xffffffff); - ret = request_irq(p->irq, sh_tmu_interrupt, + ret = request_irq(ch->irq, sh_tmu_interrupt, IRQF_TIMER | IRQF_IRQPOLL | IRQF_NOBALANCING, - dev_name(&p->pdev->dev), p); + dev_name(&ch->tmu->pdev->dev), ch); if (ret) { - dev_err(&p->pdev->dev, "failed to request irq %d\n", p->irq); + dev_err(&ch->tmu->pdev->dev, "failed to request irq %d\n", + ch->irq); return; } } -static int sh_tmu_register(struct sh_tmu_priv *p, char *name, +static int sh_tmu_register(struct sh_tmu_channel *ch, char *name, unsigned long clockevent_rating, unsigned long clocksource_rating) { if (clockevent_rating) - sh_tmu_register_clockevent(p, name, clockevent_rating); + sh_tmu_register_clockevent(ch, name, clockevent_rating); else if (clocksource_rating) - sh_tmu_register_clocksource(p, name, clocksource_rating); + sh_tmu_register_clocksource(ch, name, clocksource_rating); return 0; } @@ -445,8 +459,8 @@ static int sh_tmu_setup(struct sh_tmu_priv *p, struct platform_device *pdev) goto err0; } - p->irq = platform_get_irq(p->pdev, 0); - if (p->irq < 0) { + p->channel.irq = platform_get_irq(p->pdev, 0); + if (p->channel.irq < 0) { dev_err(&p->pdev->dev, "failed to get irq\n"); goto err0; } @@ -470,10 +484,11 @@ static int sh_tmu_setup(struct sh_tmu_priv *p, struct platform_device *pdev) if (ret < 0) goto err2; - p->cs_enabled = false; - p->enable_count = 0; + p->channel.cs_enabled = false; + p->channel.enable_count = 0; + p->channel.tmu = p; - ret = sh_tmu_register(p, (char *)dev_name(&p->pdev->dev), + ret = sh_tmu_register(&p->channel, (char *)dev_name(&p->pdev->dev), cfg->clockevent_rating, cfg->clocksource_rating); if (ret < 0) -- cgit v1.2.3 From 0a72aa39cc105fbf6971feb8928a63530a4a446b Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Mon, 27 Jan 2014 22:04:17 +0100 Subject: clocksource: sh_tmu: Rename struct sh_tmu_priv to sh_tmu_device Channel data is private as well, rename priv to device to make the distrinction between the core device and the channels clearer. Signed-off-by: Laurent Pinchart --- drivers/clocksource/sh_tmu.c | 68 ++++++++++++++++++++++---------------------- 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/drivers/clocksource/sh_tmu.c b/drivers/clocksource/sh_tmu.c index 26457e1fccbb..70137906b8c0 100644 --- a/drivers/clocksource/sh_tmu.c +++ b/drivers/clocksource/sh_tmu.c @@ -35,10 +35,10 @@ #include #include -struct sh_tmu_priv; +struct sh_tmu_device; struct sh_tmu_channel { - struct sh_tmu_priv *tmu; + struct sh_tmu_device *tmu; int irq; @@ -50,7 +50,7 @@ struct sh_tmu_channel { unsigned int enable_count; }; -struct sh_tmu_priv { +struct sh_tmu_device { struct platform_device *pdev; void __iomem *mapbase; @@ -436,59 +436,59 @@ static int sh_tmu_register(struct sh_tmu_channel *ch, char *name, return 0; } -static int sh_tmu_setup(struct sh_tmu_priv *p, struct platform_device *pdev) +static int sh_tmu_setup(struct sh_tmu_device *tmu, struct platform_device *pdev) { struct sh_timer_config *cfg = pdev->dev.platform_data; struct resource *res; int ret; ret = -ENXIO; - memset(p, 0, sizeof(*p)); - p->pdev = pdev; + memset(tmu, 0, sizeof(*tmu)); + tmu->pdev = pdev; if (!cfg) { - dev_err(&p->pdev->dev, "missing platform data\n"); + dev_err(&tmu->pdev->dev, "missing platform data\n"); goto err0; } - platform_set_drvdata(pdev, p); + platform_set_drvdata(pdev, tmu); - res = platform_get_resource(p->pdev, IORESOURCE_MEM, 0); + res = platform_get_resource(tmu->pdev, IORESOURCE_MEM, 0); if (!res) { - dev_err(&p->pdev->dev, "failed to get I/O memory\n"); + dev_err(&tmu->pdev->dev, "failed to get I/O memory\n"); goto err0; } - p->channel.irq = platform_get_irq(p->pdev, 0); - if (p->channel.irq < 0) { - dev_err(&p->pdev->dev, "failed to get irq\n"); + tmu->channel.irq = platform_get_irq(tmu->pdev, 0); + if (tmu->channel.irq < 0) { + dev_err(&tmu->pdev->dev, "failed to get irq\n"); goto err0; } /* map memory, let mapbase point to our channel */ - p->mapbase = ioremap_nocache(res->start, resource_size(res)); - if (p->mapbase == NULL) { - dev_err(&p->pdev->dev, "failed to remap I/O memory\n"); + tmu->mapbase = ioremap_nocache(res->start, resource_size(res)); + if (tmu->mapbase == NULL) { + dev_err(&tmu->pdev->dev, "failed to remap I/O memory\n"); goto err0; } /* get hold of clock */ - p->clk = clk_get(&p->pdev->dev, "tmu_fck"); - if (IS_ERR(p->clk)) { - dev_err(&p->pdev->dev, "cannot get clock\n"); - ret = PTR_ERR(p->clk); + tmu->clk = clk_get(&tmu->pdev->dev, "tmu_fck"); + if (IS_ERR(tmu->clk)) { + dev_err(&tmu->pdev->dev, "cannot get clock\n"); + ret = PTR_ERR(tmu->clk); goto err1; } - ret = clk_prepare(p->clk); + ret = clk_prepare(tmu->clk); if (ret < 0) goto err2; - p->channel.cs_enabled = false; - p->channel.enable_count = 0; - p->channel.tmu = p; + tmu->channel.cs_enabled = false; + tmu->channel.enable_count = 0; + tmu->channel.tmu = tmu; - ret = sh_tmu_register(&p->channel, (char *)dev_name(&p->pdev->dev), + ret = sh_tmu_register(&tmu->channel, (char *)dev_name(&tmu->pdev->dev), cfg->clockevent_rating, cfg->clocksource_rating); if (ret < 0) @@ -497,18 +497,18 @@ static int sh_tmu_setup(struct sh_tmu_priv *p, struct platform_device *pdev) return 0; err3: - clk_unprepare(p->clk); + clk_unprepare(tmu->clk); err2: - clk_put(p->clk); + clk_put(tmu->clk); err1: - iounmap(p->mapbase); + iounmap(tmu->mapbase); err0: return ret; } static int sh_tmu_probe(struct platform_device *pdev) { - struct sh_tmu_priv *p = platform_get_drvdata(pdev); + struct sh_tmu_device *tmu = platform_get_drvdata(pdev); struct sh_timer_config *cfg = pdev->dev.platform_data; int ret; @@ -517,20 +517,20 @@ static int sh_tmu_probe(struct platform_device *pdev) pm_runtime_enable(&pdev->dev); } - if (p) { + if (tmu) { dev_info(&pdev->dev, "kept as earlytimer\n"); goto out; } - p = kmalloc(sizeof(*p), GFP_KERNEL); - if (p == NULL) { + tmu = kmalloc(sizeof(*tmu), GFP_KERNEL); + if (tmu == NULL) { dev_err(&pdev->dev, "failed to allocate driver data\n"); return -ENOMEM; } - ret = sh_tmu_setup(p, pdev); + ret = sh_tmu_setup(tmu, pdev); if (ret) { - kfree(p); + kfree(tmu); pm_runtime_idle(&pdev->dev); return ret; } -- cgit v1.2.3 From a94ddaa6fcd46e168736027535b2d81b6a18883f Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Mon, 27 Jan 2014 22:04:17 +0100 Subject: clocksource: sh_tmu: Split channel setup to separate function Move the channel setup code from sh_tmu_setup to a new sh_tmu_setup_channel function and call it from sh_tmu_setup. Signed-off-by: Laurent Pinchart --- drivers/clocksource/sh_tmu.c | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/drivers/clocksource/sh_tmu.c b/drivers/clocksource/sh_tmu.c index 70137906b8c0..4779c97bb2ee 100644 --- a/drivers/clocksource/sh_tmu.c +++ b/drivers/clocksource/sh_tmu.c @@ -436,6 +436,28 @@ static int sh_tmu_register(struct sh_tmu_channel *ch, char *name, return 0; } +static int sh_tmu_channel_setup(struct sh_tmu_channel *ch, + struct sh_tmu_device *tmu) +{ + struct sh_timer_config *cfg = tmu->pdev->dev.platform_data; + + memset(ch, 0, sizeof(*ch)); + ch->tmu = tmu; + + ch->irq = platform_get_irq(tmu->pdev, 0); + if (ch->irq < 0) { + dev_err(&tmu->pdev->dev, "failed to get irq\n"); + return ch->irq; + } + + ch->cs_enabled = false; + ch->enable_count = 0; + + return sh_tmu_register(ch, (char *)dev_name(&tmu->pdev->dev), + cfg->clockevent_rating, + cfg->clocksource_rating); +} + static int sh_tmu_setup(struct sh_tmu_device *tmu, struct platform_device *pdev) { struct sh_timer_config *cfg = pdev->dev.platform_data; @@ -459,12 +481,6 @@ static int sh_tmu_setup(struct sh_tmu_device *tmu, struct platform_device *pdev) goto err0; } - tmu->channel.irq = platform_get_irq(tmu->pdev, 0); - if (tmu->channel.irq < 0) { - dev_err(&tmu->pdev->dev, "failed to get irq\n"); - goto err0; - } - /* map memory, let mapbase point to our channel */ tmu->mapbase = ioremap_nocache(res->start, resource_size(res)); if (tmu->mapbase == NULL) { @@ -484,13 +500,7 @@ static int sh_tmu_setup(struct sh_tmu_device *tmu, struct platform_device *pdev) if (ret < 0) goto err2; - tmu->channel.cs_enabled = false; - tmu->channel.enable_count = 0; - tmu->channel.tmu = tmu; - - ret = sh_tmu_register(&tmu->channel, (char *)dev_name(&tmu->pdev->dev), - cfg->clockevent_rating, - cfg->clocksource_rating); + ret = sh_tmu_channel_setup(&tmu->channel, tmu); if (ret < 0) goto err3; -- cgit v1.2.3 From 84876d0505b15a2907696566a80a365993feab44 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Mon, 17 Feb 2014 16:04:16 +0100 Subject: clocksource: sh_tmu: Constify name argument to sh_tmu_register() The name argument is assigned to const structure fields only, constify it. Signed-off-by: Laurent Pinchart --- drivers/clocksource/sh_tmu.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/clocksource/sh_tmu.c b/drivers/clocksource/sh_tmu.c index 4779c97bb2ee..2c64e3f93f16 100644 --- a/drivers/clocksource/sh_tmu.c +++ b/drivers/clocksource/sh_tmu.c @@ -292,7 +292,7 @@ static void sh_tmu_clocksource_resume(struct clocksource *cs) } static int sh_tmu_register_clocksource(struct sh_tmu_channel *ch, - char *name, unsigned long rating) + const char *name, unsigned long rating) { struct clocksource *cs = &ch->cs; @@ -393,7 +393,7 @@ static void sh_tmu_clock_event_resume(struct clock_event_device *ced) } static void sh_tmu_register_clockevent(struct sh_tmu_channel *ch, - char *name, unsigned long rating) + const char *name, unsigned long rating) { struct clock_event_device *ced = &ch->ced; int ret; @@ -424,7 +424,7 @@ static void sh_tmu_register_clockevent(struct sh_tmu_channel *ch, } } -static int sh_tmu_register(struct sh_tmu_channel *ch, char *name, +static int sh_tmu_register(struct sh_tmu_channel *ch, const char *name, unsigned long clockevent_rating, unsigned long clocksource_rating) { @@ -453,7 +453,7 @@ static int sh_tmu_channel_setup(struct sh_tmu_channel *ch, ch->cs_enabled = false; ch->enable_count = 0; - return sh_tmu_register(ch, (char *)dev_name(&tmu->pdev->dev), + return sh_tmu_register(ch, dev_name(&tmu->pdev->dev), cfg->clockevent_rating, cfg->clocksource_rating); } -- cgit v1.2.3 From de693461bf9624ec12808f8c5524510364cc2a43 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Mon, 27 Jan 2014 22:04:17 +0100 Subject: clocksource: sh_tmu: Add memory base to sh_tmu_channel structure The channel memory base is channel-specific, add it to the channel structure in preparation for support of multiple channels per device. Signed-off-by: Laurent Pinchart --- drivers/clocksource/sh_tmu.c | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/drivers/clocksource/sh_tmu.c b/drivers/clocksource/sh_tmu.c index 2c64e3f93f16..a464ed868a68 100644 --- a/drivers/clocksource/sh_tmu.c +++ b/drivers/clocksource/sh_tmu.c @@ -40,6 +40,7 @@ struct sh_tmu_device; struct sh_tmu_channel { struct sh_tmu_device *tmu; + void __iomem *base; int irq; unsigned long rate; @@ -68,39 +69,35 @@ static DEFINE_RAW_SPINLOCK(sh_tmu_lock); static inline unsigned long sh_tmu_read(struct sh_tmu_channel *ch, int reg_nr) { - struct sh_timer_config *cfg = ch->tmu->pdev->dev.platform_data; - void __iomem *base = ch->tmu->mapbase; unsigned long offs; if (reg_nr == TSTR) - return ioread8(base - cfg->channel_offset); + return ioread8(ch->tmu->mapbase); offs = reg_nr << 2; if (reg_nr == TCR) - return ioread16(base + offs); + return ioread16(ch->base + offs); else - return ioread32(base + offs); + return ioread32(ch->base + offs); } static inline void sh_tmu_write(struct sh_tmu_channel *ch, int reg_nr, unsigned long value) { - struct sh_timer_config *cfg = ch->tmu->pdev->dev.platform_data; - void __iomem *base = ch->tmu->mapbase; unsigned long offs; if (reg_nr == TSTR) { - iowrite8(value, base - cfg->channel_offset); + iowrite8(value, ch->tmu->mapbase); return; } offs = reg_nr << 2; if (reg_nr == TCR) - iowrite16(value, base + offs); + iowrite16(value, ch->base + offs); else - iowrite32(value, base + offs); + iowrite32(value, ch->base + offs); } static void sh_tmu_start_stop_ch(struct sh_tmu_channel *ch, int start) @@ -481,13 +478,18 @@ static int sh_tmu_setup(struct sh_tmu_device *tmu, struct platform_device *pdev) goto err0; } - /* map memory, let mapbase point to our channel */ - tmu->mapbase = ioremap_nocache(res->start, resource_size(res)); - if (tmu->mapbase == NULL) { + /* + * Map memory, let channel.base point to our channel and mapbase to the + * start/stop shared register. + */ + tmu->channel.base = ioremap_nocache(res->start, resource_size(res)); + if (tmu->channel.base == NULL) { dev_err(&tmu->pdev->dev, "failed to remap I/O memory\n"); goto err0; } + tmu->mapbase = tmu->channel.base - cfg->channel_offset; + /* get hold of clock */ tmu->clk = clk_get(&tmu->pdev->dev, "tmu_fck"); if (IS_ERR(tmu->clk)) { @@ -511,7 +513,7 @@ static int sh_tmu_setup(struct sh_tmu_device *tmu, struct platform_device *pdev) err2: clk_put(tmu->clk); err1: - iounmap(tmu->mapbase); + iounmap(tmu->channel.base); err0: return ret; } -- cgit v1.2.3 From fe68eb802ef8bf034735f37cb561ab814fb3b0d6 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Mon, 27 Jan 2014 22:04:17 +0100 Subject: clocksource: sh_tmu: Add index to struct sh_tmu_channel Use the index as the timer start/stop bit and when printing messages to identify the channel. Signed-off-by: Laurent Pinchart --- drivers/clocksource/sh_tmu.c | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/drivers/clocksource/sh_tmu.c b/drivers/clocksource/sh_tmu.c index a464ed868a68..e30430439bb1 100644 --- a/drivers/clocksource/sh_tmu.c +++ b/drivers/clocksource/sh_tmu.c @@ -39,6 +39,7 @@ struct sh_tmu_device; struct sh_tmu_channel { struct sh_tmu_device *tmu; + unsigned int index; void __iomem *base; int irq; @@ -102,7 +103,6 @@ static inline void sh_tmu_write(struct sh_tmu_channel *ch, int reg_nr, static void sh_tmu_start_stop_ch(struct sh_tmu_channel *ch, int start) { - struct sh_timer_config *cfg = ch->tmu->pdev->dev.platform_data; unsigned long flags, value; /* start stop register shared by multiple timer channels */ @@ -110,9 +110,9 @@ static void sh_tmu_start_stop_ch(struct sh_tmu_channel *ch, int start) value = sh_tmu_read(ch, TSTR); if (start) - value |= 1 << cfg->timer_bit; + value |= 1 << ch->index; else - value &= ~(1 << cfg->timer_bit); + value &= ~(1 << ch->index); sh_tmu_write(ch, TSTR, value); raw_spin_unlock_irqrestore(&sh_tmu_lock, flags); @@ -125,7 +125,8 @@ static int __sh_tmu_enable(struct sh_tmu_channel *ch) /* enable clock */ ret = clk_enable(ch->tmu->clk); if (ret) { - dev_err(&ch->tmu->pdev->dev, "cannot enable clock\n"); + dev_err(&ch->tmu->pdev->dev, "ch%u: cannot enable clock\n", + ch->index); return ret; } @@ -303,7 +304,8 @@ static int sh_tmu_register_clocksource(struct sh_tmu_channel *ch, cs->mask = CLOCKSOURCE_MASK(32); cs->flags = CLOCK_SOURCE_IS_CONTINUOUS; - dev_info(&ch->tmu->pdev->dev, "used as clock source\n"); + dev_info(&ch->tmu->pdev->dev, "ch%u: used as clock source\n", + ch->index); /* Register with dummy 1 Hz value, gets updated in ->enable() */ clocksource_register_hz(cs, 1); @@ -349,12 +351,12 @@ static void sh_tmu_clock_event_mode(enum clock_event_mode mode, switch (mode) { case CLOCK_EVT_MODE_PERIODIC: dev_info(&ch->tmu->pdev->dev, - "used for periodic clock events\n"); + "ch%u: used for periodic clock events\n", ch->index); sh_tmu_clock_event_start(ch, 1); break; case CLOCK_EVT_MODE_ONESHOT: dev_info(&ch->tmu->pdev->dev, - "used for oneshot clock events\n"); + "ch%u: used for oneshot clock events\n", ch->index); sh_tmu_clock_event_start(ch, 0); break; case CLOCK_EVT_MODE_UNUSED: @@ -407,7 +409,8 @@ static void sh_tmu_register_clockevent(struct sh_tmu_channel *ch, ced->suspend = sh_tmu_clock_event_suspend; ced->resume = sh_tmu_clock_event_resume; - dev_info(&ch->tmu->pdev->dev, "used for clock events\n"); + dev_info(&ch->tmu->pdev->dev, "ch%u: used for clock events\n", + ch->index); clockevents_config_and_register(ced, 1, 0x300, 0xffffffff); @@ -415,8 +418,8 @@ static void sh_tmu_register_clockevent(struct sh_tmu_channel *ch, IRQF_TIMER | IRQF_IRQPOLL | IRQF_NOBALANCING, dev_name(&ch->tmu->pdev->dev), ch); if (ret) { - dev_err(&ch->tmu->pdev->dev, "failed to request irq %d\n", - ch->irq); + dev_err(&ch->tmu->pdev->dev, "ch%u: failed to request irq %d\n", + ch->index, ch->irq); return; } } @@ -441,9 +444,19 @@ static int sh_tmu_channel_setup(struct sh_tmu_channel *ch, memset(ch, 0, sizeof(*ch)); ch->tmu = tmu; + /* + * The SH3 variant (SH770x, SH7705, SH7710 and SH7720) maps channel + * registers blocks at base + 2 + 12 * index, while all other variants + * map them at base + 4 + 12 * index. We can compute the index by just + * dividing by 12, the 2 bytes or 4 bytes offset being hidden by the + * integer division. + */ + ch->index = cfg->channel_offset / 12; + ch->irq = platform_get_irq(tmu->pdev, 0); if (ch->irq < 0) { - dev_err(&tmu->pdev->dev, "failed to get irq\n"); + dev_err(&tmu->pdev->dev, "ch%u: failed to get irq\n", + ch->index); return ch->irq; } -- cgit v1.2.3 From 3b77a83eeabb885c5fff02756eba50f446a2d83c Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Mon, 27 Jan 2014 22:04:17 +0100 Subject: clocksource: sh_tmu: Replace kmalloc + memset with kzalloc One kzalloc a day keeps the bugs away. Signed-off-by: Laurent Pinchart --- drivers/clocksource/sh_tmu.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/drivers/clocksource/sh_tmu.c b/drivers/clocksource/sh_tmu.c index e30430439bb1..26a9f7dadfbc 100644 --- a/drivers/clocksource/sh_tmu.c +++ b/drivers/clocksource/sh_tmu.c @@ -397,8 +397,6 @@ static void sh_tmu_register_clockevent(struct sh_tmu_channel *ch, struct clock_event_device *ced = &ch->ced; int ret; - memset(ced, 0, sizeof(*ced)); - ced->name = name; ced->features = CLOCK_EVT_FEAT_PERIODIC; ced->features |= CLOCK_EVT_FEAT_ONESHOT; @@ -441,7 +439,6 @@ static int sh_tmu_channel_setup(struct sh_tmu_channel *ch, { struct sh_timer_config *cfg = tmu->pdev->dev.platform_data; - memset(ch, 0, sizeof(*ch)); ch->tmu = tmu; /* @@ -475,7 +472,6 @@ static int sh_tmu_setup(struct sh_tmu_device *tmu, struct platform_device *pdev) int ret; ret = -ENXIO; - memset(tmu, 0, sizeof(*tmu)); tmu->pdev = pdev; if (!cfg) { @@ -547,7 +543,7 @@ static int sh_tmu_probe(struct platform_device *pdev) goto out; } - tmu = kmalloc(sizeof(*tmu), GFP_KERNEL); + tmu = kzalloc(sizeof(*tmu), GFP_KERNEL); if (tmu == NULL) { dev_err(&pdev->dev, "failed to allocate driver data\n"); return -ENOMEM; -- cgit v1.2.3 From a5de49f436e2bc498c1d13f6f8a9afaf19cb5f95 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Mon, 27 Jan 2014 22:04:17 +0100 Subject: clocksource: sh_tmu: Allocate channels dynamically This prepares the driver for multi-channel support. Signed-off-by: Laurent Pinchart --- drivers/clocksource/sh_tmu.c | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/drivers/clocksource/sh_tmu.c b/drivers/clocksource/sh_tmu.c index 26a9f7dadfbc..55b7a37f0c9b 100644 --- a/drivers/clocksource/sh_tmu.c +++ b/drivers/clocksource/sh_tmu.c @@ -58,7 +58,8 @@ struct sh_tmu_device { void __iomem *mapbase; struct clk *clk; - struct sh_tmu_channel channel; + struct sh_tmu_channel *channels; + unsigned int num_channels; }; static DEFINE_RAW_SPINLOCK(sh_tmu_lock); @@ -469,6 +470,7 @@ static int sh_tmu_setup(struct sh_tmu_device *tmu, struct platform_device *pdev) { struct sh_timer_config *cfg = pdev->dev.platform_data; struct resource *res; + void __iomem *base; int ret; ret = -ENXIO; @@ -488,16 +490,16 @@ static int sh_tmu_setup(struct sh_tmu_device *tmu, struct platform_device *pdev) } /* - * Map memory, let channel.base point to our channel and mapbase to the + * Map memory, let base point to our channel and mapbase to the * start/stop shared register. */ - tmu->channel.base = ioremap_nocache(res->start, resource_size(res)); - if (tmu->channel.base == NULL) { + base = ioremap_nocache(res->start, resource_size(res)); + if (base == NULL) { dev_err(&tmu->pdev->dev, "failed to remap I/O memory\n"); goto err0; } - tmu->mapbase = tmu->channel.base - cfg->channel_offset; + tmu->mapbase = base - cfg->channel_offset; /* get hold of clock */ tmu->clk = clk_get(&tmu->pdev->dev, "tmu_fck"); @@ -511,18 +513,29 @@ static int sh_tmu_setup(struct sh_tmu_device *tmu, struct platform_device *pdev) if (ret < 0) goto err2; - ret = sh_tmu_channel_setup(&tmu->channel, tmu); + tmu->channels = kzalloc(sizeof(*tmu->channels), GFP_KERNEL); + if (tmu->channels == NULL) { + ret = -ENOMEM; + goto err3; + } + + tmu->num_channels = 1; + + tmu->channels[0].base = base; + + ret = sh_tmu_channel_setup(&tmu->channels[0], tmu); if (ret < 0) goto err3; return 0; err3: + kfree(tmu->channels); clk_unprepare(tmu->clk); err2: clk_put(tmu->clk); err1: - iounmap(tmu->channel.base); + iounmap(base); err0: return ret; } -- cgit v1.2.3 From 5cfe2d151f8f55052f5463e725d3d3a4aa51335d Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Wed, 29 Jan 2014 00:33:08 +0100 Subject: clocksource: sh_tmu: Replace hardcoded register values with macros Define symbolic macros for all used registers bits. Signed-off-by: Laurent Pinchart --- drivers/clocksource/sh_tmu.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/drivers/clocksource/sh_tmu.c b/drivers/clocksource/sh_tmu.c index 55b7a37f0c9b..63ed92d56c8f 100644 --- a/drivers/clocksource/sh_tmu.c +++ b/drivers/clocksource/sh_tmu.c @@ -69,6 +69,15 @@ static DEFINE_RAW_SPINLOCK(sh_tmu_lock); #define TCNT 1 /* channel register */ #define TCR 2 /* channel register */ +#define TCR_UNF (1 << 8) +#define TCR_UNIE (1 << 5) +#define TCR_TPSC_CLK4 (0 << 0) +#define TCR_TPSC_CLK16 (1 << 0) +#define TCR_TPSC_CLK64 (2 << 0) +#define TCR_TPSC_CLK256 (3 << 0) +#define TCR_TPSC_CLK1024 (4 << 0) +#define TCR_TPSC_MASK (7 << 0) + static inline unsigned long sh_tmu_read(struct sh_tmu_channel *ch, int reg_nr) { unsigned long offs; @@ -140,7 +149,7 @@ static int __sh_tmu_enable(struct sh_tmu_channel *ch) /* configure channel to parent clock / 4, irq off */ ch->rate = clk_get_rate(ch->tmu->clk) / 4; - sh_tmu_write(ch, TCR, 0x0000); + sh_tmu_write(ch, TCR, TCR_TPSC_CLK4); /* enable channel */ sh_tmu_start_stop_ch(ch, 1); @@ -165,7 +174,7 @@ static void __sh_tmu_disable(struct sh_tmu_channel *ch) sh_tmu_start_stop_ch(ch, 0); /* disable interrupts in TMU block */ - sh_tmu_write(ch, TCR, 0x0000); + sh_tmu_write(ch, TCR, TCR_TPSC_CLK4); /* stop clock */ clk_disable(ch->tmu->clk); @@ -195,7 +204,7 @@ static void sh_tmu_set_next(struct sh_tmu_channel *ch, unsigned long delta, sh_tmu_read(ch, TCR); /* enable interrupt */ - sh_tmu_write(ch, TCR, 0x0020); + sh_tmu_write(ch, TCR, TCR_UNIE | TCR_TPSC_CLK4); /* reload delta value in case of periodic timer */ if (periodic) @@ -215,9 +224,9 @@ static irqreturn_t sh_tmu_interrupt(int irq, void *dev_id) /* disable or acknowledge interrupt */ if (ch->ced.mode == CLOCK_EVT_MODE_ONESHOT) - sh_tmu_write(ch, TCR, 0x0000); + sh_tmu_write(ch, TCR, TCR_TPSC_CLK4); else - sh_tmu_write(ch, TCR, 0x0020); + sh_tmu_write(ch, TCR, TCR_UNIE | TCR_TPSC_CLK4); /* notify clockevent layer */ ch->ced.event_handler(&ch->ced); -- cgit v1.2.3 From f1010ed1a13ea38f495ebfa2fdb1f38b7f87301f Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Wed, 19 Feb 2014 17:00:31 +0100 Subject: clocksource: sh_tmu: Hardcode TMU clock event and source ratings to 200 All boards use clock event and clock source ratings of 200 for the TMU, hardcode it in the driver. Signed-off-by: Laurent Pinchart --- drivers/clocksource/sh_tmu.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/drivers/clocksource/sh_tmu.c b/drivers/clocksource/sh_tmu.c index 63ed92d56c8f..fec9bedb8f45 100644 --- a/drivers/clocksource/sh_tmu.c +++ b/drivers/clocksource/sh_tmu.c @@ -300,12 +300,12 @@ static void sh_tmu_clocksource_resume(struct clocksource *cs) } static int sh_tmu_register_clocksource(struct sh_tmu_channel *ch, - const char *name, unsigned long rating) + const char *name) { struct clocksource *cs = &ch->cs; cs->name = name; - cs->rating = rating; + cs->rating = 200; cs->read = sh_tmu_clocksource_read; cs->enable = sh_tmu_clocksource_enable; cs->disable = sh_tmu_clocksource_disable; @@ -402,7 +402,7 @@ static void sh_tmu_clock_event_resume(struct clock_event_device *ced) } static void sh_tmu_register_clockevent(struct sh_tmu_channel *ch, - const char *name, unsigned long rating) + const char *name) { struct clock_event_device *ced = &ch->ced; int ret; @@ -410,7 +410,7 @@ static void sh_tmu_register_clockevent(struct sh_tmu_channel *ch, ced->name = name; ced->features = CLOCK_EVT_FEAT_PERIODIC; ced->features |= CLOCK_EVT_FEAT_ONESHOT; - ced->rating = rating; + ced->rating = 200; ced->cpumask = cpumask_of(0); ced->set_next_event = sh_tmu_clock_event_next; ced->set_mode = sh_tmu_clock_event_mode; @@ -433,13 +433,12 @@ static void sh_tmu_register_clockevent(struct sh_tmu_channel *ch, } static int sh_tmu_register(struct sh_tmu_channel *ch, const char *name, - unsigned long clockevent_rating, - unsigned long clocksource_rating) + bool clockevent, bool clocksource) { - if (clockevent_rating) - sh_tmu_register_clockevent(ch, name, clockevent_rating); - else if (clocksource_rating) - sh_tmu_register_clocksource(ch, name, clocksource_rating); + if (clockevent) + sh_tmu_register_clockevent(ch, name); + else if (clocksource) + sh_tmu_register_clocksource(ch, name); return 0; } @@ -471,8 +470,8 @@ static int sh_tmu_channel_setup(struct sh_tmu_channel *ch, ch->enable_count = 0; return sh_tmu_register(ch, dev_name(&tmu->pdev->dev), - cfg->clockevent_rating, - cfg->clocksource_rating); + cfg->clockevent_rating != 0, + cfg->clocksource_rating != 0); } static int sh_tmu_setup(struct sh_tmu_device *tmu, struct platform_device *pdev) -- cgit v1.2.3 From 8c7f21e6739ad836f30561d641393a8417abdad3 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Tue, 28 Jan 2014 12:36:48 +0100 Subject: clocksource: sh_tmu: Add support for multiple channels per device TMU hardware devices can support multiple channels, with global registers and per-channel registers. The sh_tmu driver currently models the hardware with one Linux device per channel. This model makes it difficult to handle global registers in a clean way. Add support for a new model that uses one Linux device per timer with multiple channels per device. This requires changes to platform data, add new channel configuration fields. Support for the legacy model is kept and will be removed after all platforms switch to the new model. Signed-off-by: Laurent Pinchart --- drivers/clocksource/sh_tmu.c | 213 ++++++++++++++++++++++++++++++------------- 1 file changed, 152 insertions(+), 61 deletions(-) diff --git a/drivers/clocksource/sh_tmu.c b/drivers/clocksource/sh_tmu.c index fec9bedb8f45..0306d31e9f1d 100644 --- a/drivers/clocksource/sh_tmu.c +++ b/drivers/clocksource/sh_tmu.c @@ -35,6 +35,12 @@ #include #include +enum sh_tmu_model { + SH_TMU_LEGACY, + SH_TMU, + SH_TMU_SH3, +}; + struct sh_tmu_device; struct sh_tmu_channel { @@ -58,8 +64,13 @@ struct sh_tmu_device { void __iomem *mapbase; struct clk *clk; + enum sh_tmu_model model; + struct sh_tmu_channel *channels; unsigned int num_channels; + + bool has_clockevent; + bool has_clocksource; }; static DEFINE_RAW_SPINLOCK(sh_tmu_lock); @@ -82,8 +93,16 @@ static inline unsigned long sh_tmu_read(struct sh_tmu_channel *ch, int reg_nr) { unsigned long offs; - if (reg_nr == TSTR) - return ioread8(ch->tmu->mapbase); + if (reg_nr == TSTR) { + switch (ch->tmu->model) { + case SH_TMU_LEGACY: + return ioread8(ch->tmu->mapbase); + case SH_TMU_SH3: + return ioread8(ch->tmu->mapbase + 2); + case SH_TMU: + return ioread8(ch->tmu->mapbase + 4); + } + } offs = reg_nr << 2; @@ -99,8 +118,14 @@ static inline void sh_tmu_write(struct sh_tmu_channel *ch, int reg_nr, unsigned long offs; if (reg_nr == TSTR) { - iowrite8(value, ch->tmu->mapbase); - return; + switch (ch->tmu->model) { + case SH_TMU_LEGACY: + return iowrite8(value, ch->tmu->mapbase); + case SH_TMU_SH3: + return iowrite8(value, ch->tmu->mapbase + 2); + case SH_TMU: + return iowrite8(value, ch->tmu->mapbase + 4); + } } offs = reg_nr << 2; @@ -435,31 +460,49 @@ static void sh_tmu_register_clockevent(struct sh_tmu_channel *ch, static int sh_tmu_register(struct sh_tmu_channel *ch, const char *name, bool clockevent, bool clocksource) { - if (clockevent) + if (clockevent) { + ch->tmu->has_clockevent = true; sh_tmu_register_clockevent(ch, name); - else if (clocksource) + } else if (clocksource) { + ch->tmu->has_clocksource = true; sh_tmu_register_clocksource(ch, name); + } return 0; } -static int sh_tmu_channel_setup(struct sh_tmu_channel *ch, +static int sh_tmu_channel_setup(struct sh_tmu_channel *ch, unsigned int index, + bool clockevent, bool clocksource, struct sh_tmu_device *tmu) { - struct sh_timer_config *cfg = tmu->pdev->dev.platform_data; + /* Skip unused channels. */ + if (!clockevent && !clocksource) + return 0; ch->tmu = tmu; - /* - * The SH3 variant (SH770x, SH7705, SH7710 and SH7720) maps channel - * registers blocks at base + 2 + 12 * index, while all other variants - * map them at base + 4 + 12 * index. We can compute the index by just - * dividing by 12, the 2 bytes or 4 bytes offset being hidden by the - * integer division. - */ - ch->index = cfg->channel_offset / 12; + if (tmu->model == SH_TMU_LEGACY) { + struct sh_timer_config *cfg = tmu->pdev->dev.platform_data; + + /* + * The SH3 variant (SH770x, SH7705, SH7710 and SH7720) maps + * channel registers blocks at base + 2 + 12 * index, while all + * other variants map them at base + 4 + 12 * index. We can + * compute the index by just dividing by 12, the 2 bytes or 4 + * bytes offset being hidden by the integer division. + */ + ch->index = cfg->channel_offset / 12; + ch->base = tmu->mapbase + cfg->channel_offset; + } else { + ch->index = index; + + if (tmu->model == SH_TMU_SH3) + ch->base = tmu->mapbase + 4 + ch->index * 12; + else + ch->base = tmu->mapbase + 8 + ch->index * 12; + } - ch->irq = platform_get_irq(tmu->pdev, 0); + ch->irq = platform_get_irq(tmu->pdev, ch->index); if (ch->irq < 0) { dev_err(&tmu->pdev->dev, "ch%u: failed to get irq\n", ch->index); @@ -470,88 +513,127 @@ static int sh_tmu_channel_setup(struct sh_tmu_channel *ch, ch->enable_count = 0; return sh_tmu_register(ch, dev_name(&tmu->pdev->dev), - cfg->clockevent_rating != 0, - cfg->clocksource_rating != 0); + clockevent, clocksource); } -static int sh_tmu_setup(struct sh_tmu_device *tmu, struct platform_device *pdev) +static int sh_tmu_map_memory(struct sh_tmu_device *tmu) { - struct sh_timer_config *cfg = pdev->dev.platform_data; struct resource *res; - void __iomem *base; - int ret; - ret = -ENXIO; - - tmu->pdev = pdev; - - if (!cfg) { - dev_err(&tmu->pdev->dev, "missing platform data\n"); - goto err0; - } - - platform_set_drvdata(pdev, tmu); res = platform_get_resource(tmu->pdev, IORESOURCE_MEM, 0); if (!res) { dev_err(&tmu->pdev->dev, "failed to get I/O memory\n"); - goto err0; + return -ENXIO; } + tmu->mapbase = ioremap_nocache(res->start, resource_size(res)); + if (tmu->mapbase == NULL) + return -ENXIO; + /* - * Map memory, let base point to our channel and mapbase to the - * start/stop shared register. + * In legacy platform device configuration (with one device per channel) + * the resource points to the channel base address. */ - base = ioremap_nocache(res->start, resource_size(res)); - if (base == NULL) { - dev_err(&tmu->pdev->dev, "failed to remap I/O memory\n"); - goto err0; + if (tmu->model == SH_TMU_LEGACY) { + struct sh_timer_config *cfg = tmu->pdev->dev.platform_data; + tmu->mapbase -= cfg->channel_offset; } - tmu->mapbase = base - cfg->channel_offset; + return 0; +} - /* get hold of clock */ +static void sh_tmu_unmap_memory(struct sh_tmu_device *tmu) +{ + if (tmu->model == SH_TMU_LEGACY) { + struct sh_timer_config *cfg = tmu->pdev->dev.platform_data; + tmu->mapbase += cfg->channel_offset; + } + + iounmap(tmu->mapbase); +} + +static int sh_tmu_setup(struct sh_tmu_device *tmu, struct platform_device *pdev) +{ + struct sh_timer_config *cfg = pdev->dev.platform_data; + const struct platform_device_id *id = pdev->id_entry; + unsigned int i; + int ret; + + if (!cfg) { + dev_err(&tmu->pdev->dev, "missing platform data\n"); + return -ENXIO; + } + + tmu->pdev = pdev; + tmu->model = id->driver_data; + + /* Get hold of clock. */ tmu->clk = clk_get(&tmu->pdev->dev, "tmu_fck"); if (IS_ERR(tmu->clk)) { dev_err(&tmu->pdev->dev, "cannot get clock\n"); - ret = PTR_ERR(tmu->clk); - goto err1; + return PTR_ERR(tmu->clk); } ret = clk_prepare(tmu->clk); if (ret < 0) - goto err2; + goto err_clk_put; + + /* Map the memory resource. */ + ret = sh_tmu_map_memory(tmu); + if (ret < 0) { + dev_err(&tmu->pdev->dev, "failed to remap I/O memory\n"); + goto err_clk_unprepare; + } - tmu->channels = kzalloc(sizeof(*tmu->channels), GFP_KERNEL); + /* Allocate and setup the channels. */ + if (tmu->model == SH_TMU_LEGACY) + tmu->num_channels = 1; + else + tmu->num_channels = hweight8(cfg->channels_mask); + + tmu->channels = kzalloc(sizeof(*tmu->channels) * tmu->num_channels, + GFP_KERNEL); if (tmu->channels == NULL) { ret = -ENOMEM; - goto err3; + goto err_unmap; } - tmu->num_channels = 1; - - tmu->channels[0].base = base; + if (tmu->model == SH_TMU_LEGACY) { + ret = sh_tmu_channel_setup(&tmu->channels[0], 0, + cfg->clockevent_rating != 0, + cfg->clocksource_rating != 0, tmu); + if (ret < 0) + goto err_unmap; + } else { + /* + * Use the first channel as a clock event device and the second + * channel as a clock source. + */ + for (i = 0; i < tmu->num_channels; ++i) { + ret = sh_tmu_channel_setup(&tmu->channels[i], i, + i == 0, i == 1, tmu); + if (ret < 0) + goto err_unmap; + } + } - ret = sh_tmu_channel_setup(&tmu->channels[0], tmu); - if (ret < 0) - goto err3; + platform_set_drvdata(pdev, tmu); return 0; - err3: +err_unmap: kfree(tmu->channels); + sh_tmu_unmap_memory(tmu); +err_clk_unprepare: clk_unprepare(tmu->clk); - err2: +err_clk_put: clk_put(tmu->clk); - err1: - iounmap(base); - err0: return ret; } static int sh_tmu_probe(struct platform_device *pdev) { struct sh_tmu_device *tmu = platform_get_drvdata(pdev); - struct sh_timer_config *cfg = pdev->dev.platform_data; int ret; if (!is_early_platform_device(pdev)) { @@ -580,7 +662,7 @@ static int sh_tmu_probe(struct platform_device *pdev) return 0; out: - if (cfg->clockevent_rating || cfg->clocksource_rating) + if (tmu->has_clockevent || tmu->has_clocksource) pm_runtime_irq_safe(&pdev->dev); else pm_runtime_idle(&pdev->dev); @@ -593,12 +675,21 @@ static int sh_tmu_remove(struct platform_device *pdev) return -EBUSY; /* cannot unregister clockevent and clocksource */ } +static const struct platform_device_id sh_tmu_id_table[] = { + { "sh_tmu", SH_TMU_LEGACY }, + { "sh-tmu", SH_TMU }, + { "sh-tmu-sh3", SH_TMU_SH3 }, + { } +}; +MODULE_DEVICE_TABLE(platform, sh_tmu_id_table); + static struct platform_driver sh_tmu_device_driver = { .probe = sh_tmu_probe, .remove = sh_tmu_remove, .driver = { .name = "sh_tmu", - } + }, + .id_table = sh_tmu_id_table, }; static int __init sh_tmu_init(void) -- cgit v1.2.3 From a27d922749f3be0a88f7e0aeb507c373703c08ee Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Fri, 14 Feb 2014 00:35:18 +0100 Subject: clocksource: sh_tmu: Rename clock to "fck" in the non-legacy case The sh_tmu driver gets the TMU functional clock using a connection ID of "tmu_fck". While all SH SoCs create clock lookup entries with a NULL device ID and a "tmu_fck" connection ID, the ARM SoCs use the device ID only with a NULL connection ID. This works on legacy platforms but will break on ARM with DT boot. Fix the situation by using a connection ID of "fck" in the non-legacy platform data case. Clock lookup entries will be renamed to use the device ID as well as the connection ID as platforms get moved to new platform data. The legacy code will eventually be dropped, leaving us with device ID based clock lookup, compatible with DT boot. Signed-off-by: Laurent Pinchart --- drivers/clocksource/sh_tmu.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/clocksource/sh_tmu.c b/drivers/clocksource/sh_tmu.c index 0306d31e9f1d..cf07797dbcf3 100644 --- a/drivers/clocksource/sh_tmu.c +++ b/drivers/clocksource/sh_tmu.c @@ -568,7 +568,8 @@ static int sh_tmu_setup(struct sh_tmu_device *tmu, struct platform_device *pdev) tmu->model = id->driver_data; /* Get hold of clock. */ - tmu->clk = clk_get(&tmu->pdev->dev, "tmu_fck"); + tmu->clk = clk_get(&tmu->pdev->dev, + tmu->model == SH_TMU_LEGACY ? "tmu_fck" : "fck"); if (IS_ERR(tmu->clk)) { dev_err(&tmu->pdev->dev, "cannot get clock\n"); return PTR_ERR(tmu->clk); -- cgit v1.2.3 From 6b96c15b034813ec0b46e5bebbf8cffae0ac72d0 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Fri, 14 Feb 2014 01:25:50 +0100 Subject: clocksource: sh_tmu: Remove FSF mail address from GPL notice Do not include the paragraph about writing to the Free Software Foundation's mailing address from the sample GPL notice. The FSF has changed addresses in the past, and may do so again. Linux already includes a copy of the GPL. Signed-off-by: Laurent Pinchart --- drivers/clocksource/sh_tmu.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/drivers/clocksource/sh_tmu.c b/drivers/clocksource/sh_tmu.c index cf07797dbcf3..981f8d302a2a 100644 --- a/drivers/clocksource/sh_tmu.c +++ b/drivers/clocksource/sh_tmu.c @@ -11,10 +11,6 @@ * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include -- cgit v1.2.3 From 13931f8065fabff117828999e007f62a5cabea34 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Wed, 12 Feb 2014 16:56:44 +0100 Subject: clocksource: sh_tmu: Sort headers alphabetically This helps locating duplicates and inserting new headers. Signed-off-by: Laurent Pinchart --- drivers/clocksource/sh_tmu.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/clocksource/sh_tmu.c b/drivers/clocksource/sh_tmu.c index 981f8d302a2a..4ba2c0fea580 100644 --- a/drivers/clocksource/sh_tmu.c +++ b/drivers/clocksource/sh_tmu.c @@ -13,23 +13,23 @@ * GNU General Public License for more details. */ +#include +#include +#include +#include +#include #include -#include -#include #include -#include -#include #include -#include +#include #include -#include -#include -#include -#include -#include #include +#include #include #include +#include +#include +#include enum sh_tmu_model { SH_TMU_LEGACY, -- cgit v1.2.3 From 276bee05d8b72e98d530b55161e0a2131da99f58 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Mon, 17 Feb 2014 11:27:49 +0100 Subject: clocksource: sh_mtu2: Use request_irq() instead of setup_irq() The driver claims it needs to register an interrupt handler too early for request_irq(). This might have been true in the past, but the only meaningful difference between request_irq() and setup_irq() today is an additional kzalloc() call in request_irq(). As the driver calls kmalloc() itself we know that the slab allocator is available, we can thus switch to request_irq(). Signed-off-by: Laurent Pinchart Tested-by: Wolfram Sang --- drivers/clocksource/sh_mtu2.c | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/drivers/clocksource/sh_mtu2.c b/drivers/clocksource/sh_mtu2.c index e30d76e0a6fa..77992e081205 100644 --- a/drivers/clocksource/sh_mtu2.c +++ b/drivers/clocksource/sh_mtu2.c @@ -37,7 +37,7 @@ struct sh_mtu2_priv { void __iomem *mapbase; struct clk *clk; - struct irqaction irqaction; + int irq; struct platform_device *pdev; unsigned long rate; unsigned long periodic; @@ -244,10 +244,11 @@ static void sh_mtu2_register_clockevent(struct sh_mtu2_priv *p, dev_info(&p->pdev->dev, "used for clock events\n"); clockevents_register_device(ced); - ret = setup_irq(p->irqaction.irq, &p->irqaction); + ret = request_irq(p->irq, sh_mtu2_interrupt, + IRQF_TIMER | IRQF_IRQPOLL | IRQF_NOBALANCING, + dev_name(&p->pdev->dev), p); if (ret) { - dev_err(&p->pdev->dev, "failed to request irq %d\n", - p->irqaction.irq); + dev_err(&p->pdev->dev, "failed to request irq %d\n", p->irq); return; } } @@ -265,7 +266,7 @@ static int sh_mtu2_setup(struct sh_mtu2_priv *p, struct platform_device *pdev) { struct sh_timer_config *cfg = pdev->dev.platform_data; struct resource *res; - int irq, ret; + int ret; ret = -ENXIO; memset(p, 0, sizeof(*p)); @@ -284,8 +285,8 @@ static int sh_mtu2_setup(struct sh_mtu2_priv *p, struct platform_device *pdev) goto err0; } - irq = platform_get_irq(p->pdev, 0); - if (irq < 0) { + p->irq = platform_get_irq(p->pdev, 0); + if (p->irq < 0) { dev_err(&p->pdev->dev, "failed to get irq\n"); goto err0; } @@ -297,13 +298,6 @@ static int sh_mtu2_setup(struct sh_mtu2_priv *p, struct platform_device *pdev) goto err0; } - /* setup data for setup_irq() (too early for request_irq()) */ - p->irqaction.name = dev_name(&p->pdev->dev); - p->irqaction.handler = sh_mtu2_interrupt; - p->irqaction.dev_id = p; - p->irqaction.irq = irq; - p->irqaction.flags = IRQF_TIMER | IRQF_IRQPOLL | IRQF_NOBALANCING; - /* get hold of clock */ p->clk = clk_get(&p->pdev->dev, "mtu2_fck"); if (IS_ERR(p->clk)) { -- cgit v1.2.3 From f92d62f53973466cccb25900c2597ff6df950d74 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Tue, 4 Mar 2014 12:59:54 +0100 Subject: clocksource: sh_mtu2: Turn sh_mtu2_priv fields into local variables The rate and periodic fields are used in a single function only, as local variables. Remove them from the structure. Signed-off-by: Laurent Pinchart Tested-by: Wolfram Sang --- drivers/clocksource/sh_mtu2.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/clocksource/sh_mtu2.c b/drivers/clocksource/sh_mtu2.c index 77992e081205..66684552fcc9 100644 --- a/drivers/clocksource/sh_mtu2.c +++ b/drivers/clocksource/sh_mtu2.c @@ -39,8 +39,6 @@ struct sh_mtu2_priv { struct clk *clk; int irq; struct platform_device *pdev; - unsigned long rate; - unsigned long periodic; struct clock_event_device ced; }; @@ -122,6 +120,8 @@ static void sh_mtu2_start_stop_ch(struct sh_mtu2_priv *p, int start) static int sh_mtu2_enable(struct sh_mtu2_priv *p) { + unsigned long periodic; + unsigned long rate; int ret; pm_runtime_get_sync(&p->pdev->dev); @@ -137,13 +137,13 @@ static int sh_mtu2_enable(struct sh_mtu2_priv *p) /* make sure channel is disabled */ sh_mtu2_start_stop_ch(p, 0); - p->rate = clk_get_rate(p->clk) / 64; - p->periodic = (p->rate + HZ/2) / HZ; + rate = clk_get_rate(p->clk) / 64; + periodic = (rate + HZ/2) / HZ; /* "Periodic Counter Operation" */ sh_mtu2_write(p, TCR, 0x23); /* TGRA clear, divide clock by 64 */ sh_mtu2_write(p, TIOR, 0); - sh_mtu2_write(p, TGR, p->periodic); + sh_mtu2_write(p, TGR, periodic); sh_mtu2_write(p, TCNT, 0); sh_mtu2_write(p, TMDR, 0); sh_mtu2_write(p, TIER, 0x01); -- cgit v1.2.3 From 42752cc619c0ee619b56f86932ce42b00adb5052 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Tue, 4 Mar 2014 12:58:30 +0100 Subject: clocksource: sh_mtu2: Split channel fields from sh_mtu2_priv Create a new sh_mtu2_channel structure to hold the channel-specific fields in preparation for multiple channels per device support. Signed-off-by: Laurent Pinchart Tested-by: Wolfram Sang --- drivers/clocksource/sh_mtu2.c | 125 +++++++++++++++++++++++------------------- 1 file changed, 69 insertions(+), 56 deletions(-) diff --git a/drivers/clocksource/sh_mtu2.c b/drivers/clocksource/sh_mtu2.c index 66684552fcc9..e509f417ef64 100644 --- a/drivers/clocksource/sh_mtu2.c +++ b/drivers/clocksource/sh_mtu2.c @@ -34,12 +34,21 @@ #include #include +struct sh_mtu2_priv; + +struct sh_mtu2_channel { + struct sh_mtu2_priv *mtu; + int irq; + struct clock_event_device ced; +}; + struct sh_mtu2_priv { + struct platform_device *pdev; + void __iomem *mapbase; struct clk *clk; - int irq; - struct platform_device *pdev; - struct clock_event_device ced; + + struct sh_mtu2_channel channel; }; static DEFINE_RAW_SPINLOCK(sh_mtu2_lock); @@ -63,10 +72,10 @@ static unsigned long mtu2_reg_offs[] = { [TGR] = 8, }; -static inline unsigned long sh_mtu2_read(struct sh_mtu2_priv *p, int reg_nr) +static inline unsigned long sh_mtu2_read(struct sh_mtu2_channel *ch, int reg_nr) { - struct sh_timer_config *cfg = p->pdev->dev.platform_data; - void __iomem *base = p->mapbase; + struct sh_timer_config *cfg = ch->mtu->pdev->dev.platform_data; + void __iomem *base = ch->mtu->mapbase; unsigned long offs; if (reg_nr == TSTR) @@ -80,11 +89,11 @@ static inline unsigned long sh_mtu2_read(struct sh_mtu2_priv *p, int reg_nr) return ioread8(base + offs); } -static inline void sh_mtu2_write(struct sh_mtu2_priv *p, int reg_nr, +static inline void sh_mtu2_write(struct sh_mtu2_channel *ch, int reg_nr, unsigned long value) { - struct sh_timer_config *cfg = p->pdev->dev.platform_data; - void __iomem *base = p->mapbase; + struct sh_timer_config *cfg = ch->mtu->pdev->dev.platform_data; + void __iomem *base = ch->mtu->mapbase; unsigned long offs; if (reg_nr == TSTR) { @@ -100,100 +109,100 @@ static inline void sh_mtu2_write(struct sh_mtu2_priv *p, int reg_nr, iowrite8(value, base + offs); } -static void sh_mtu2_start_stop_ch(struct sh_mtu2_priv *p, int start) +static void sh_mtu2_start_stop_ch(struct sh_mtu2_channel *ch, int start) { - struct sh_timer_config *cfg = p->pdev->dev.platform_data; + struct sh_timer_config *cfg = ch->mtu->pdev->dev.platform_data; unsigned long flags, value; /* start stop register shared by multiple timer channels */ raw_spin_lock_irqsave(&sh_mtu2_lock, flags); - value = sh_mtu2_read(p, TSTR); + value = sh_mtu2_read(ch, TSTR); if (start) value |= 1 << cfg->timer_bit; else value &= ~(1 << cfg->timer_bit); - sh_mtu2_write(p, TSTR, value); + sh_mtu2_write(ch, TSTR, value); raw_spin_unlock_irqrestore(&sh_mtu2_lock, flags); } -static int sh_mtu2_enable(struct sh_mtu2_priv *p) +static int sh_mtu2_enable(struct sh_mtu2_channel *ch) { unsigned long periodic; unsigned long rate; int ret; - pm_runtime_get_sync(&p->pdev->dev); - dev_pm_syscore_device(&p->pdev->dev, true); + pm_runtime_get_sync(&ch->mtu->pdev->dev); + dev_pm_syscore_device(&ch->mtu->pdev->dev, true); /* enable clock */ - ret = clk_enable(p->clk); + ret = clk_enable(ch->mtu->clk); if (ret) { - dev_err(&p->pdev->dev, "cannot enable clock\n"); + dev_err(&ch->mtu->pdev->dev, "cannot enable clock\n"); return ret; } /* make sure channel is disabled */ - sh_mtu2_start_stop_ch(p, 0); + sh_mtu2_start_stop_ch(ch, 0); - rate = clk_get_rate(p->clk) / 64; + rate = clk_get_rate(ch->mtu->clk) / 64; periodic = (rate + HZ/2) / HZ; /* "Periodic Counter Operation" */ - sh_mtu2_write(p, TCR, 0x23); /* TGRA clear, divide clock by 64 */ - sh_mtu2_write(p, TIOR, 0); - sh_mtu2_write(p, TGR, periodic); - sh_mtu2_write(p, TCNT, 0); - sh_mtu2_write(p, TMDR, 0); - sh_mtu2_write(p, TIER, 0x01); + sh_mtu2_write(ch, TCR, 0x23); /* TGRA clear, divide clock by 64 */ + sh_mtu2_write(ch, TIOR, 0); + sh_mtu2_write(ch, TGR, periodic); + sh_mtu2_write(ch, TCNT, 0); + sh_mtu2_write(ch, TMDR, 0); + sh_mtu2_write(ch, TIER, 0x01); /* enable channel */ - sh_mtu2_start_stop_ch(p, 1); + sh_mtu2_start_stop_ch(ch, 1); return 0; } -static void sh_mtu2_disable(struct sh_mtu2_priv *p) +static void sh_mtu2_disable(struct sh_mtu2_channel *ch) { /* disable channel */ - sh_mtu2_start_stop_ch(p, 0); + sh_mtu2_start_stop_ch(ch, 0); /* stop clock */ - clk_disable(p->clk); + clk_disable(ch->mtu->clk); - dev_pm_syscore_device(&p->pdev->dev, false); - pm_runtime_put(&p->pdev->dev); + dev_pm_syscore_device(&ch->mtu->pdev->dev, false); + pm_runtime_put(&ch->mtu->pdev->dev); } static irqreturn_t sh_mtu2_interrupt(int irq, void *dev_id) { - struct sh_mtu2_priv *p = dev_id; + struct sh_mtu2_channel *ch = dev_id; /* acknowledge interrupt */ - sh_mtu2_read(p, TSR); - sh_mtu2_write(p, TSR, 0xfe); + sh_mtu2_read(ch, TSR); + sh_mtu2_write(ch, TSR, 0xfe); /* notify clockevent layer */ - p->ced.event_handler(&p->ced); + ch->ced.event_handler(&ch->ced); return IRQ_HANDLED; } -static struct sh_mtu2_priv *ced_to_sh_mtu2(struct clock_event_device *ced) +static struct sh_mtu2_channel *ced_to_sh_mtu2(struct clock_event_device *ced) { - return container_of(ced, struct sh_mtu2_priv, ced); + return container_of(ced, struct sh_mtu2_channel, ced); } static void sh_mtu2_clock_event_mode(enum clock_event_mode mode, struct clock_event_device *ced) { - struct sh_mtu2_priv *p = ced_to_sh_mtu2(ced); + struct sh_mtu2_channel *ch = ced_to_sh_mtu2(ced); int disabled = 0; /* deal with old setting first */ switch (ced->mode) { case CLOCK_EVT_MODE_PERIODIC: - sh_mtu2_disable(p); + sh_mtu2_disable(ch); disabled = 1; break; default: @@ -202,12 +211,13 @@ static void sh_mtu2_clock_event_mode(enum clock_event_mode mode, switch (mode) { case CLOCK_EVT_MODE_PERIODIC: - dev_info(&p->pdev->dev, "used for periodic clock events\n"); - sh_mtu2_enable(p); + dev_info(&ch->mtu->pdev->dev, + "used for periodic clock events\n"); + sh_mtu2_enable(ch); break; case CLOCK_EVT_MODE_UNUSED: if (!disabled) - sh_mtu2_disable(p); + sh_mtu2_disable(ch); break; case CLOCK_EVT_MODE_SHUTDOWN: default: @@ -217,18 +227,18 @@ static void sh_mtu2_clock_event_mode(enum clock_event_mode mode, static void sh_mtu2_clock_event_suspend(struct clock_event_device *ced) { - pm_genpd_syscore_poweroff(&ced_to_sh_mtu2(ced)->pdev->dev); + pm_genpd_syscore_poweroff(&ced_to_sh_mtu2(ced)->mtu->pdev->dev); } static void sh_mtu2_clock_event_resume(struct clock_event_device *ced) { - pm_genpd_syscore_poweron(&ced_to_sh_mtu2(ced)->pdev->dev); + pm_genpd_syscore_poweron(&ced_to_sh_mtu2(ced)->mtu->pdev->dev); } -static void sh_mtu2_register_clockevent(struct sh_mtu2_priv *p, +static void sh_mtu2_register_clockevent(struct sh_mtu2_channel *ch, char *name, unsigned long rating) { - struct clock_event_device *ced = &p->ced; + struct clock_event_device *ced = &ch->ced; int ret; memset(ced, 0, sizeof(*ced)); @@ -241,23 +251,24 @@ static void sh_mtu2_register_clockevent(struct sh_mtu2_priv *p, ced->suspend = sh_mtu2_clock_event_suspend; ced->resume = sh_mtu2_clock_event_resume; - dev_info(&p->pdev->dev, "used for clock events\n"); + dev_info(&ch->mtu->pdev->dev, "used for clock events\n"); clockevents_register_device(ced); - ret = request_irq(p->irq, sh_mtu2_interrupt, + ret = request_irq(ch->irq, sh_mtu2_interrupt, IRQF_TIMER | IRQF_IRQPOLL | IRQF_NOBALANCING, - dev_name(&p->pdev->dev), p); + dev_name(&ch->mtu->pdev->dev), ch); if (ret) { - dev_err(&p->pdev->dev, "failed to request irq %d\n", p->irq); + dev_err(&ch->mtu->pdev->dev, "failed to request irq %d\n", + ch->irq); return; } } -static int sh_mtu2_register(struct sh_mtu2_priv *p, char *name, +static int sh_mtu2_register(struct sh_mtu2_channel *ch, char *name, unsigned long clockevent_rating) { if (clockevent_rating) - sh_mtu2_register_clockevent(p, name, clockevent_rating); + sh_mtu2_register_clockevent(ch, name, clockevent_rating); return 0; } @@ -285,8 +296,8 @@ static int sh_mtu2_setup(struct sh_mtu2_priv *p, struct platform_device *pdev) goto err0; } - p->irq = platform_get_irq(p->pdev, 0); - if (p->irq < 0) { + p->channel.irq = platform_get_irq(p->pdev, 0); + if (p->channel.irq < 0) { dev_err(&p->pdev->dev, "failed to get irq\n"); goto err0; } @@ -310,7 +321,9 @@ static int sh_mtu2_setup(struct sh_mtu2_priv *p, struct platform_device *pdev) if (ret < 0) goto err2; - ret = sh_mtu2_register(p, (char *)dev_name(&p->pdev->dev), + p->channel.mtu = p; + + ret = sh_mtu2_register(&p->channel, (char *)dev_name(&p->pdev->dev), cfg->clockevent_rating); if (ret < 0) goto err3; -- cgit v1.2.3 From 7dad72de1b475d02935e5c79c218637b6c63108b Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Tue, 4 Mar 2014 13:04:48 +0100 Subject: clocksource: sh_mtu2: Rename struct sh_mtu2_priv to sh_mtu2_device Channel data is private as well, rename priv to device to make the distrinction between the core device and the channels clearer. Signed-off-by: Laurent Pinchart Tested-by: Wolfram Sang --- drivers/clocksource/sh_mtu2.c | 65 ++++++++++++++++++++++--------------------- 1 file changed, 33 insertions(+), 32 deletions(-) diff --git a/drivers/clocksource/sh_mtu2.c b/drivers/clocksource/sh_mtu2.c index e509f417ef64..256621c156e6 100644 --- a/drivers/clocksource/sh_mtu2.c +++ b/drivers/clocksource/sh_mtu2.c @@ -34,15 +34,15 @@ #include #include -struct sh_mtu2_priv; +struct sh_mtu2_device; struct sh_mtu2_channel { - struct sh_mtu2_priv *mtu; + struct sh_mtu2_device *mtu; int irq; struct clock_event_device ced; }; -struct sh_mtu2_priv { +struct sh_mtu2_device { struct platform_device *pdev; void __iomem *mapbase; @@ -273,75 +273,76 @@ static int sh_mtu2_register(struct sh_mtu2_channel *ch, char *name, return 0; } -static int sh_mtu2_setup(struct sh_mtu2_priv *p, struct platform_device *pdev) +static int sh_mtu2_setup(struct sh_mtu2_device *mtu, + struct platform_device *pdev) { struct sh_timer_config *cfg = pdev->dev.platform_data; struct resource *res; int ret; ret = -ENXIO; - memset(p, 0, sizeof(*p)); - p->pdev = pdev; + memset(mtu, 0, sizeof(*mtu)); + mtu->pdev = pdev; if (!cfg) { - dev_err(&p->pdev->dev, "missing platform data\n"); + dev_err(&mtu->pdev->dev, "missing platform data\n"); goto err0; } - platform_set_drvdata(pdev, p); + platform_set_drvdata(pdev, mtu); - res = platform_get_resource(p->pdev, IORESOURCE_MEM, 0); + res = platform_get_resource(mtu->pdev, IORESOURCE_MEM, 0); if (!res) { - dev_err(&p->pdev->dev, "failed to get I/O memory\n"); + dev_err(&mtu->pdev->dev, "failed to get I/O memory\n"); goto err0; } - p->channel.irq = platform_get_irq(p->pdev, 0); - if (p->channel.irq < 0) { - dev_err(&p->pdev->dev, "failed to get irq\n"); + mtu->channel.irq = platform_get_irq(mtu->pdev, 0); + if (mtu->channel.irq < 0) { + dev_err(&mtu->pdev->dev, "failed to get irq\n"); goto err0; } /* map memory, let mapbase point to our channel */ - p->mapbase = ioremap_nocache(res->start, resource_size(res)); - if (p->mapbase == NULL) { - dev_err(&p->pdev->dev, "failed to remap I/O memory\n"); + mtu->mapbase = ioremap_nocache(res->start, resource_size(res)); + if (mtu->mapbase == NULL) { + dev_err(&mtu->pdev->dev, "failed to remap I/O memory\n"); goto err0; } /* get hold of clock */ - p->clk = clk_get(&p->pdev->dev, "mtu2_fck"); - if (IS_ERR(p->clk)) { - dev_err(&p->pdev->dev, "cannot get clock\n"); - ret = PTR_ERR(p->clk); + mtu->clk = clk_get(&mtu->pdev->dev, "mtu2_fck"); + if (IS_ERR(mtu->clk)) { + dev_err(&mtu->pdev->dev, "cannot get clock\n"); + ret = PTR_ERR(mtu->clk); goto err1; } - ret = clk_prepare(p->clk); + ret = clk_prepare(mtu->clk); if (ret < 0) goto err2; - p->channel.mtu = p; + mtu->channel.mtu = mtu; - ret = sh_mtu2_register(&p->channel, (char *)dev_name(&p->pdev->dev), + ret = sh_mtu2_register(&mtu->channel, (char *)dev_name(&mtu->pdev->dev), cfg->clockevent_rating); if (ret < 0) goto err3; return 0; err3: - clk_unprepare(p->clk); + clk_unprepare(mtu->clk); err2: - clk_put(p->clk); + clk_put(mtu->clk); err1: - iounmap(p->mapbase); + iounmap(mtu->mapbase); err0: return ret; } static int sh_mtu2_probe(struct platform_device *pdev) { - struct sh_mtu2_priv *p = platform_get_drvdata(pdev); + struct sh_mtu2_device *mtu = platform_get_drvdata(pdev); struct sh_timer_config *cfg = pdev->dev.platform_data; int ret; @@ -350,20 +351,20 @@ static int sh_mtu2_probe(struct platform_device *pdev) pm_runtime_enable(&pdev->dev); } - if (p) { + if (mtu) { dev_info(&pdev->dev, "kept as earlytimer\n"); goto out; } - p = kmalloc(sizeof(*p), GFP_KERNEL); - if (p == NULL) { + mtu = kmalloc(sizeof(*mtu), GFP_KERNEL); + if (mtu == NULL) { dev_err(&pdev->dev, "failed to allocate driver data\n"); return -ENOMEM; } - ret = sh_mtu2_setup(p, pdev); + ret = sh_mtu2_setup(mtu, pdev); if (ret) { - kfree(p); + kfree(mtu); pm_runtime_idle(&pdev->dev); return ret; } -- cgit v1.2.3 From 2e1a53265d550002fdd1658778854d56ae4cadc1 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Tue, 4 Mar 2014 13:11:23 +0100 Subject: clocksource: sh_mtu2: Split channel setup to separate function Move the channel setup code from sh_mtu2_setup to a new sh_mtu2_setup_channel function and call it from sh_mtu2_setup. Signed-off-by: Laurent Pinchart Tested-by: Wolfram Sang --- drivers/clocksource/sh_mtu2.c | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/drivers/clocksource/sh_mtu2.c b/drivers/clocksource/sh_mtu2.c index 256621c156e6..8fd705909f98 100644 --- a/drivers/clocksource/sh_mtu2.c +++ b/drivers/clocksource/sh_mtu2.c @@ -273,6 +273,24 @@ static int sh_mtu2_register(struct sh_mtu2_channel *ch, char *name, return 0; } +static int sh_mtu2_setup_channel(struct sh_mtu2_channel *ch, + struct sh_mtu2_device *mtu) +{ + struct sh_timer_config *cfg = mtu->pdev->dev.platform_data; + + memset(ch, 0, sizeof(*ch)); + ch->mtu = mtu; + + ch->irq = platform_get_irq(mtu->pdev, 0); + if (ch->irq < 0) { + dev_err(&mtu->pdev->dev, "failed to get irq\n"); + return ch->irq; + } + + return sh_mtu2_register(ch, (char *)dev_name(&mtu->pdev->dev), + cfg->clockevent_rating); +} + static int sh_mtu2_setup(struct sh_mtu2_device *mtu, struct platform_device *pdev) { @@ -297,12 +315,6 @@ static int sh_mtu2_setup(struct sh_mtu2_device *mtu, goto err0; } - mtu->channel.irq = platform_get_irq(mtu->pdev, 0); - if (mtu->channel.irq < 0) { - dev_err(&mtu->pdev->dev, "failed to get irq\n"); - goto err0; - } - /* map memory, let mapbase point to our channel */ mtu->mapbase = ioremap_nocache(res->start, resource_size(res)); if (mtu->mapbase == NULL) { @@ -322,10 +334,7 @@ static int sh_mtu2_setup(struct sh_mtu2_device *mtu, if (ret < 0) goto err2; - mtu->channel.mtu = mtu; - - ret = sh_mtu2_register(&mtu->channel, (char *)dev_name(&mtu->pdev->dev), - cfg->clockevent_rating); + ret = sh_mtu2_setup_channel(&mtu->channel, mtu); if (ret < 0) goto err3; -- cgit v1.2.3 From aa83804af705731d2802b80fb4b94a79045d31a3 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Tue, 4 Mar 2014 13:57:14 +0100 Subject: clocksource: sh_mtu2: Constify name argument to sh_mtu2_register() The name argument is assigned to const structure fields only, constify it. Signed-off-by: Laurent Pinchart Tested-by: Wolfram Sang --- drivers/clocksource/sh_mtu2.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/clocksource/sh_mtu2.c b/drivers/clocksource/sh_mtu2.c index 8fd705909f98..2fe3ab4c3231 100644 --- a/drivers/clocksource/sh_mtu2.c +++ b/drivers/clocksource/sh_mtu2.c @@ -236,7 +236,7 @@ static void sh_mtu2_clock_event_resume(struct clock_event_device *ced) } static void sh_mtu2_register_clockevent(struct sh_mtu2_channel *ch, - char *name, unsigned long rating) + const char *name, unsigned long rating) { struct clock_event_device *ced = &ch->ced; int ret; @@ -264,7 +264,7 @@ static void sh_mtu2_register_clockevent(struct sh_mtu2_channel *ch, } } -static int sh_mtu2_register(struct sh_mtu2_channel *ch, char *name, +static int sh_mtu2_register(struct sh_mtu2_channel *ch, const char *name, unsigned long clockevent_rating) { if (clockevent_rating) @@ -287,7 +287,7 @@ static int sh_mtu2_setup_channel(struct sh_mtu2_channel *ch, return ch->irq; } - return sh_mtu2_register(ch, (char *)dev_name(&mtu->pdev->dev), + return sh_mtu2_register(ch, dev_name(&mtu->pdev->dev), cfg->clockevent_rating); } -- cgit v1.2.3 From da90a1c67751a412499a9f5698c3bf0bf80f65a6 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Tue, 4 Mar 2014 14:04:24 +0100 Subject: clocksource: sh_mtu2: Add memory base to sh_mtu2_channel structure The channel memory base is channel-specific, add it to the channel structure in preparation for support of multiple channels per device. Signed-off-by: Laurent Pinchart Tested-by: Wolfram Sang --- drivers/clocksource/sh_mtu2.c | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/drivers/clocksource/sh_mtu2.c b/drivers/clocksource/sh_mtu2.c index 2fe3ab4c3231..97714ce5e851 100644 --- a/drivers/clocksource/sh_mtu2.c +++ b/drivers/clocksource/sh_mtu2.c @@ -38,7 +38,10 @@ struct sh_mtu2_device; struct sh_mtu2_channel { struct sh_mtu2_device *mtu; + + void __iomem *base; int irq; + struct clock_event_device ced; }; @@ -74,39 +77,35 @@ static unsigned long mtu2_reg_offs[] = { static inline unsigned long sh_mtu2_read(struct sh_mtu2_channel *ch, int reg_nr) { - struct sh_timer_config *cfg = ch->mtu->pdev->dev.platform_data; - void __iomem *base = ch->mtu->mapbase; unsigned long offs; if (reg_nr == TSTR) - return ioread8(base + cfg->channel_offset); + return ioread8(ch->mtu->mapbase); offs = mtu2_reg_offs[reg_nr]; if ((reg_nr == TCNT) || (reg_nr == TGR)) - return ioread16(base + offs); + return ioread16(ch->base + offs); else - return ioread8(base + offs); + return ioread8(ch->base + offs); } static inline void sh_mtu2_write(struct sh_mtu2_channel *ch, int reg_nr, unsigned long value) { - struct sh_timer_config *cfg = ch->mtu->pdev->dev.platform_data; - void __iomem *base = ch->mtu->mapbase; unsigned long offs; if (reg_nr == TSTR) { - iowrite8(value, base + cfg->channel_offset); + iowrite8(value, ch->mtu->mapbase); return; } offs = mtu2_reg_offs[reg_nr]; if ((reg_nr == TCNT) || (reg_nr == TGR)) - iowrite16(value, base + offs); + iowrite16(value, ch->base + offs); else - iowrite8(value, base + offs); + iowrite8(value, ch->base + offs); } static void sh_mtu2_start_stop_ch(struct sh_mtu2_channel *ch, int start) @@ -315,13 +314,18 @@ static int sh_mtu2_setup(struct sh_mtu2_device *mtu, goto err0; } - /* map memory, let mapbase point to our channel */ - mtu->mapbase = ioremap_nocache(res->start, resource_size(res)); - if (mtu->mapbase == NULL) { + /* + * Map memory, let channel.base point to our channel and mapbase to the + * start/stop shared register. + */ + mtu->channel.base = ioremap_nocache(res->start, resource_size(res)); + if (mtu->channel.base == NULL) { dev_err(&mtu->pdev->dev, "failed to remap I/O memory\n"); goto err0; } + mtu->mapbase = mtu->channel.base + cfg->channel_offset; + /* get hold of clock */ mtu->clk = clk_get(&mtu->pdev->dev, "mtu2_fck"); if (IS_ERR(mtu->clk)) { @@ -344,7 +348,7 @@ static int sh_mtu2_setup(struct sh_mtu2_device *mtu, err2: clk_put(mtu->clk); err1: - iounmap(mtu->mapbase); + iounmap(mtu->channel.base); err0: return ret; } -- cgit v1.2.3 From d2b93177065fd8e1e18f4f42880326e0881ff457 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Tue, 4 Mar 2014 14:17:26 +0100 Subject: clocksource: sh_mtu2: Add index to struct sh_mtu2_channel Use the index as the timer start/stop bit and when printing messages to identify the channel. Signed-off-by: Laurent Pinchart Tested-by: Wolfram Sang --- drivers/clocksource/sh_mtu2.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/drivers/clocksource/sh_mtu2.c b/drivers/clocksource/sh_mtu2.c index 97714ce5e851..61827c66f7d3 100644 --- a/drivers/clocksource/sh_mtu2.c +++ b/drivers/clocksource/sh_mtu2.c @@ -38,6 +38,7 @@ struct sh_mtu2_device; struct sh_mtu2_channel { struct sh_mtu2_device *mtu; + unsigned int index; void __iomem *base; int irq; @@ -110,7 +111,6 @@ static inline void sh_mtu2_write(struct sh_mtu2_channel *ch, int reg_nr, static void sh_mtu2_start_stop_ch(struct sh_mtu2_channel *ch, int start) { - struct sh_timer_config *cfg = ch->mtu->pdev->dev.platform_data; unsigned long flags, value; /* start stop register shared by multiple timer channels */ @@ -118,9 +118,9 @@ static void sh_mtu2_start_stop_ch(struct sh_mtu2_channel *ch, int start) value = sh_mtu2_read(ch, TSTR); if (start) - value |= 1 << cfg->timer_bit; + value |= 1 << ch->index; else - value &= ~(1 << cfg->timer_bit); + value &= ~(1 << ch->index); sh_mtu2_write(ch, TSTR, value); raw_spin_unlock_irqrestore(&sh_mtu2_lock, flags); @@ -138,7 +138,8 @@ static int sh_mtu2_enable(struct sh_mtu2_channel *ch) /* enable clock */ ret = clk_enable(ch->mtu->clk); if (ret) { - dev_err(&ch->mtu->pdev->dev, "cannot enable clock\n"); + dev_err(&ch->mtu->pdev->dev, "ch%u: cannot enable clock\n", + ch->index); return ret; } @@ -211,7 +212,7 @@ static void sh_mtu2_clock_event_mode(enum clock_event_mode mode, switch (mode) { case CLOCK_EVT_MODE_PERIODIC: dev_info(&ch->mtu->pdev->dev, - "used for periodic clock events\n"); + "ch%u: used for periodic clock events\n", ch->index); sh_mtu2_enable(ch); break; case CLOCK_EVT_MODE_UNUSED: @@ -250,15 +251,16 @@ static void sh_mtu2_register_clockevent(struct sh_mtu2_channel *ch, ced->suspend = sh_mtu2_clock_event_suspend; ced->resume = sh_mtu2_clock_event_resume; - dev_info(&ch->mtu->pdev->dev, "used for clock events\n"); + dev_info(&ch->mtu->pdev->dev, "ch%u: used for clock events\n", + ch->index); clockevents_register_device(ced); ret = request_irq(ch->irq, sh_mtu2_interrupt, IRQF_TIMER | IRQF_IRQPOLL | IRQF_NOBALANCING, dev_name(&ch->mtu->pdev->dev), ch); if (ret) { - dev_err(&ch->mtu->pdev->dev, "failed to request irq %d\n", - ch->irq); + dev_err(&ch->mtu->pdev->dev, "ch%u: failed to request irq %d\n", + ch->index, ch->irq); return; } } @@ -279,10 +281,12 @@ static int sh_mtu2_setup_channel(struct sh_mtu2_channel *ch, memset(ch, 0, sizeof(*ch)); ch->mtu = mtu; + ch->index = cfg->timer_bit; ch->irq = platform_get_irq(mtu->pdev, 0); if (ch->irq < 0) { - dev_err(&mtu->pdev->dev, "failed to get irq\n"); + dev_err(&mtu->pdev->dev, "ch%u: failed to get irq\n", + ch->index); return ch->irq; } -- cgit v1.2.3 From 810c651369b343618d949826e0acd0df1b8b06eb Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Tue, 4 Mar 2014 14:10:55 +0100 Subject: clocksource: sh_mtu2: Replace kmalloc + memset with kzalloc One kzalloc a day keeps the bugs away. Signed-off-by: Laurent Pinchart Tested-by: Wolfram Sang --- drivers/clocksource/sh_mtu2.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/drivers/clocksource/sh_mtu2.c b/drivers/clocksource/sh_mtu2.c index 61827c66f7d3..94a53428a556 100644 --- a/drivers/clocksource/sh_mtu2.c +++ b/drivers/clocksource/sh_mtu2.c @@ -241,8 +241,6 @@ static void sh_mtu2_register_clockevent(struct sh_mtu2_channel *ch, struct clock_event_device *ced = &ch->ced; int ret; - memset(ced, 0, sizeof(*ced)); - ced->name = name; ced->features = CLOCK_EVT_FEAT_PERIODIC; ced->rating = rating; @@ -279,7 +277,6 @@ static int sh_mtu2_setup_channel(struct sh_mtu2_channel *ch, { struct sh_timer_config *cfg = mtu->pdev->dev.platform_data; - memset(ch, 0, sizeof(*ch)); ch->mtu = mtu; ch->index = cfg->timer_bit; @@ -302,7 +299,6 @@ static int sh_mtu2_setup(struct sh_mtu2_device *mtu, int ret; ret = -ENXIO; - memset(mtu, 0, sizeof(*mtu)); mtu->pdev = pdev; if (!cfg) { @@ -373,7 +369,7 @@ static int sh_mtu2_probe(struct platform_device *pdev) goto out; } - mtu = kmalloc(sizeof(*mtu), GFP_KERNEL); + mtu = kzalloc(sizeof(*mtu), GFP_KERNEL); if (mtu == NULL) { dev_err(&pdev->dev, "failed to allocate driver data\n"); return -ENOMEM; -- cgit v1.2.3 From c54ccb431ce6ce813bb850e8659991fc4c5bc6bc Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Tue, 4 Mar 2014 14:23:00 +0100 Subject: clocksource: sh_mtu2: Allocate channels dynamically This prepares the driver for multi-channel support. Signed-off-by: Laurent Pinchart Tested-by: Wolfram Sang --- drivers/clocksource/sh_mtu2.c | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/drivers/clocksource/sh_mtu2.c b/drivers/clocksource/sh_mtu2.c index 94a53428a556..45e1e85fcbeb 100644 --- a/drivers/clocksource/sh_mtu2.c +++ b/drivers/clocksource/sh_mtu2.c @@ -52,7 +52,8 @@ struct sh_mtu2_device { void __iomem *mapbase; struct clk *clk; - struct sh_mtu2_channel channel; + struct sh_mtu2_channel *channels; + unsigned int num_channels; }; static DEFINE_RAW_SPINLOCK(sh_mtu2_lock); @@ -296,6 +297,7 @@ static int sh_mtu2_setup(struct sh_mtu2_device *mtu, { struct sh_timer_config *cfg = pdev->dev.platform_data; struct resource *res; + void __iomem *base; int ret; ret = -ENXIO; @@ -315,16 +317,16 @@ static int sh_mtu2_setup(struct sh_mtu2_device *mtu, } /* - * Map memory, let channel.base point to our channel and mapbase to the + * Map memory, let base point to our channel and mapbase to the * start/stop shared register. */ - mtu->channel.base = ioremap_nocache(res->start, resource_size(res)); - if (mtu->channel.base == NULL) { + base = ioremap_nocache(res->start, resource_size(res)); + if (base == NULL) { dev_err(&mtu->pdev->dev, "failed to remap I/O memory\n"); goto err0; } - mtu->mapbase = mtu->channel.base + cfg->channel_offset; + mtu->mapbase = base + cfg->channel_offset; /* get hold of clock */ mtu->clk = clk_get(&mtu->pdev->dev, "mtu2_fck"); @@ -338,17 +340,28 @@ static int sh_mtu2_setup(struct sh_mtu2_device *mtu, if (ret < 0) goto err2; - ret = sh_mtu2_setup_channel(&mtu->channel, mtu); + mtu->channels = kzalloc(sizeof(*mtu->channels), GFP_KERNEL); + if (mtu->channels == NULL) { + ret = -ENOMEM; + goto err3; + } + + mtu->num_channels = 1; + + mtu->channels[0].base = base; + + ret = sh_mtu2_setup_channel(&mtu->channels[0], mtu); if (ret < 0) goto err3; return 0; err3: + kfree(mtu->channels); clk_unprepare(mtu->clk); err2: clk_put(mtu->clk); err1: - iounmap(mtu->channel.base); + iounmap(base); err0: return ret; } -- cgit v1.2.3 From f992c2410bd31b7c80ba8cc8b989d91b9cac3c30 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Tue, 4 Mar 2014 15:16:25 +0100 Subject: clocksource: sh_mtu2: Replace hardcoded register values with macros Define symbolic macros for all used registers bits. Signed-off-by: Laurent Pinchart Tested-by: Wolfram Sang --- drivers/clocksource/sh_mtu2.c | 98 ++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 92 insertions(+), 6 deletions(-) diff --git a/drivers/clocksource/sh_mtu2.c b/drivers/clocksource/sh_mtu2.c index 45e1e85fcbeb..2cf004880746 100644 --- a/drivers/clocksource/sh_mtu2.c +++ b/drivers/clocksource/sh_mtu2.c @@ -67,6 +67,88 @@ static DEFINE_RAW_SPINLOCK(sh_mtu2_lock); #define TCNT 5 /* channel register */ #define TGR 6 /* channel register */ +#define TCR_CCLR_NONE (0 << 5) +#define TCR_CCLR_TGRA (1 << 5) +#define TCR_CCLR_TGRB (2 << 5) +#define TCR_CCLR_SYNC (3 << 5) +#define TCR_CCLR_TGRC (5 << 5) +#define TCR_CCLR_TGRD (6 << 5) +#define TCR_CCLR_MASK (7 << 5) +#define TCR_CKEG_RISING (0 << 3) +#define TCR_CKEG_FALLING (1 << 3) +#define TCR_CKEG_BOTH (2 << 3) +#define TCR_CKEG_MASK (3 << 3) +/* Values 4 to 7 are channel-dependent */ +#define TCR_TPSC_P1 (0 << 0) +#define TCR_TPSC_P4 (1 << 0) +#define TCR_TPSC_P16 (2 << 0) +#define TCR_TPSC_P64 (3 << 0) +#define TCR_TPSC_CH0_TCLKA (4 << 0) +#define TCR_TPSC_CH0_TCLKB (5 << 0) +#define TCR_TPSC_CH0_TCLKC (6 << 0) +#define TCR_TPSC_CH0_TCLKD (7 << 0) +#define TCR_TPSC_CH1_TCLKA (4 << 0) +#define TCR_TPSC_CH1_TCLKB (5 << 0) +#define TCR_TPSC_CH1_P256 (6 << 0) +#define TCR_TPSC_CH1_TCNT2 (7 << 0) +#define TCR_TPSC_CH2_TCLKA (4 << 0) +#define TCR_TPSC_CH2_TCLKB (5 << 0) +#define TCR_TPSC_CH2_TCLKC (6 << 0) +#define TCR_TPSC_CH2_P1024 (7 << 0) +#define TCR_TPSC_CH34_P256 (4 << 0) +#define TCR_TPSC_CH34_P1024 (5 << 0) +#define TCR_TPSC_CH34_TCLKA (6 << 0) +#define TCR_TPSC_CH34_TCLKB (7 << 0) +#define TCR_TPSC_MASK (7 << 0) + +#define TMDR_BFE (1 << 6) +#define TMDR_BFB (1 << 5) +#define TMDR_BFA (1 << 4) +#define TMDR_MD_NORMAL (0 << 0) +#define TMDR_MD_PWM_1 (2 << 0) +#define TMDR_MD_PWM_2 (3 << 0) +#define TMDR_MD_PHASE_1 (4 << 0) +#define TMDR_MD_PHASE_2 (5 << 0) +#define TMDR_MD_PHASE_3 (6 << 0) +#define TMDR_MD_PHASE_4 (7 << 0) +#define TMDR_MD_PWM_SYNC (8 << 0) +#define TMDR_MD_PWM_COMP_CREST (13 << 0) +#define TMDR_MD_PWM_COMP_TROUGH (14 << 0) +#define TMDR_MD_PWM_COMP_BOTH (15 << 0) +#define TMDR_MD_MASK (15 << 0) + +#define TIOC_IOCH(n) ((n) << 4) +#define TIOC_IOCL(n) ((n) << 0) +#define TIOR_OC_RETAIN (0 << 0) +#define TIOR_OC_0_CLEAR (1 << 0) +#define TIOR_OC_0_SET (2 << 0) +#define TIOR_OC_0_TOGGLE (3 << 0) +#define TIOR_OC_1_CLEAR (5 << 0) +#define TIOR_OC_1_SET (6 << 0) +#define TIOR_OC_1_TOGGLE (7 << 0) +#define TIOR_IC_RISING (8 << 0) +#define TIOR_IC_FALLING (9 << 0) +#define TIOR_IC_BOTH (10 << 0) +#define TIOR_IC_TCNT (12 << 0) +#define TIOR_MASK (15 << 0) + +#define TIER_TTGE (1 << 7) +#define TIER_TTGE2 (1 << 6) +#define TIER_TCIEU (1 << 5) +#define TIER_TCIEV (1 << 4) +#define TIER_TGIED (1 << 3) +#define TIER_TGIEC (1 << 2) +#define TIER_TGIEB (1 << 1) +#define TIER_TGIEA (1 << 0) + +#define TSR_TCFD (1 << 7) +#define TSR_TCFU (1 << 5) +#define TSR_TCFV (1 << 4) +#define TSR_TGFD (1 << 3) +#define TSR_TGFC (1 << 2) +#define TSR_TGFB (1 << 1) +#define TSR_TGFA (1 << 0) + static unsigned long mtu2_reg_offs[] = { [TCR] = 0, [TMDR] = 1, @@ -150,13 +232,17 @@ static int sh_mtu2_enable(struct sh_mtu2_channel *ch) rate = clk_get_rate(ch->mtu->clk) / 64; periodic = (rate + HZ/2) / HZ; - /* "Periodic Counter Operation" */ - sh_mtu2_write(ch, TCR, 0x23); /* TGRA clear, divide clock by 64 */ - sh_mtu2_write(ch, TIOR, 0); + /* + * "Periodic Counter Operation" + * Clear on TGRA compare match, divide clock by 64. + */ + sh_mtu2_write(ch, TCR, TCR_CCLR_TGRA | TCR_TPSC_P64); + sh_mtu2_write(ch, TIOR, TIOC_IOCH(TIOR_OC_0_CLEAR) | + TIOC_IOCL(TIOR_OC_0_CLEAR)); sh_mtu2_write(ch, TGR, periodic); sh_mtu2_write(ch, TCNT, 0); - sh_mtu2_write(ch, TMDR, 0); - sh_mtu2_write(ch, TIER, 0x01); + sh_mtu2_write(ch, TMDR, TMDR_MD_NORMAL); + sh_mtu2_write(ch, TIER, TIER_TGIEA); /* enable channel */ sh_mtu2_start_stop_ch(ch, 1); @@ -182,7 +268,7 @@ static irqreturn_t sh_mtu2_interrupt(int irq, void *dev_id) /* acknowledge interrupt */ sh_mtu2_read(ch, TSR); - sh_mtu2_write(ch, TSR, 0xfe); + sh_mtu2_write(ch, TSR, ~TSR_TGFA); /* notify clockevent layer */ ch->ced.event_handler(&ch->ced); -- cgit v1.2.3 From 3cc950479891040366629247357512f1cc928da3 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Tue, 4 Mar 2014 15:22:19 +0100 Subject: clocksource: sh_mtu2: Set cpumask to cpu_possible_mask The MTU2 is not tied to CPU0, make it usable on any CPU. Signed-off-by: Laurent Pinchart Tested-by: Wolfram Sang --- drivers/clocksource/sh_mtu2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/clocksource/sh_mtu2.c b/drivers/clocksource/sh_mtu2.c index 2cf004880746..702ce6044793 100644 --- a/drivers/clocksource/sh_mtu2.c +++ b/drivers/clocksource/sh_mtu2.c @@ -331,7 +331,7 @@ static void sh_mtu2_register_clockevent(struct sh_mtu2_channel *ch, ced->name = name; ced->features = CLOCK_EVT_FEAT_PERIODIC; ced->rating = rating; - ced->cpumask = cpumask_of(0); + ced->cpumask = cpu_possible_mask; ced->set_mode = sh_mtu2_clock_event_mode; ced->suspend = sh_mtu2_clock_event_suspend; ced->resume = sh_mtu2_clock_event_resume; -- cgit v1.2.3 From 207e21a9732a27f58843ccae1c9644f3a1636b66 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Tue, 4 Mar 2014 15:19:41 +0100 Subject: clocksource: sh_mtu2: Hardcode MTU2 clock event rating to 200 All boards use clock event ratings of 200 for the MTU2, hardcode it in the driver. Signed-off-by: Laurent Pinchart Tested-by: Wolfram Sang --- drivers/clocksource/sh_mtu2.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/clocksource/sh_mtu2.c b/drivers/clocksource/sh_mtu2.c index 702ce6044793..14cc7b6f703b 100644 --- a/drivers/clocksource/sh_mtu2.c +++ b/drivers/clocksource/sh_mtu2.c @@ -323,14 +323,14 @@ static void sh_mtu2_clock_event_resume(struct clock_event_device *ced) } static void sh_mtu2_register_clockevent(struct sh_mtu2_channel *ch, - const char *name, unsigned long rating) + const char *name) { struct clock_event_device *ced = &ch->ced; int ret; ced->name = name; ced->features = CLOCK_EVT_FEAT_PERIODIC; - ced->rating = rating; + ced->rating = 200; ced->cpumask = cpu_possible_mask; ced->set_mode = sh_mtu2_clock_event_mode; ced->suspend = sh_mtu2_clock_event_suspend; @@ -351,10 +351,10 @@ static void sh_mtu2_register_clockevent(struct sh_mtu2_channel *ch, } static int sh_mtu2_register(struct sh_mtu2_channel *ch, const char *name, - unsigned long clockevent_rating) + bool clockevent) { - if (clockevent_rating) - sh_mtu2_register_clockevent(ch, name, clockevent_rating); + if (clockevent) + sh_mtu2_register_clockevent(ch, name); return 0; } @@ -375,7 +375,7 @@ static int sh_mtu2_setup_channel(struct sh_mtu2_channel *ch, } return sh_mtu2_register(ch, dev_name(&mtu->pdev->dev), - cfg->clockevent_rating); + cfg->clockevent_rating != 0); } static int sh_mtu2_setup(struct sh_mtu2_device *mtu, -- cgit v1.2.3 From faf3f4f8c805f5f8a786ba544c94bf3e01838388 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Tue, 4 Mar 2014 18:05:45 +0100 Subject: clocksource: sh_mtu2: Add support for multiple channels per device MTU2 hardware devices can support multiple channels, with global registers and per-channel registers. The sh_mtu2 driver currently models the hardware with one Linux device per channel. This model makes it difficult to handle global registers in a clean way. Add support for a new model that uses one Linux device per timer with multiple channels per device. This requires changes to platform data, add new channel configuration fields. Support for the legacy model is kept and will be removed after all platforms switch to the new model. Signed-off-by: Laurent Pinchart Tested-by: Wolfram Sang --- drivers/clocksource/sh_mtu2.c | 184 +++++++++++++++++++++++++++++------------- 1 file changed, 130 insertions(+), 54 deletions(-) diff --git a/drivers/clocksource/sh_mtu2.c b/drivers/clocksource/sh_mtu2.c index 14cc7b6f703b..7cc6d9429f81 100644 --- a/drivers/clocksource/sh_mtu2.c +++ b/drivers/clocksource/sh_mtu2.c @@ -54,6 +54,9 @@ struct sh_mtu2_device { struct sh_mtu2_channel *channels; unsigned int num_channels; + + bool legacy; + bool has_clockevent; }; static DEFINE_RAW_SPINLOCK(sh_mtu2_lock); @@ -163,8 +166,12 @@ static inline unsigned long sh_mtu2_read(struct sh_mtu2_channel *ch, int reg_nr) { unsigned long offs; - if (reg_nr == TSTR) - return ioread8(ch->mtu->mapbase); + if (reg_nr == TSTR) { + if (ch->mtu->legacy) + return ioread8(ch->mtu->mapbase); + else + return ioread8(ch->mtu->mapbase + 0x280); + } offs = mtu2_reg_offs[reg_nr]; @@ -180,8 +187,10 @@ static inline void sh_mtu2_write(struct sh_mtu2_channel *ch, int reg_nr, unsigned long offs; if (reg_nr == TSTR) { - iowrite8(value, ch->mtu->mapbase); - return; + if (ch->mtu->legacy) + return iowrite8(value, ch->mtu->mapbase); + else + return iowrite8(value, ch->mtu->mapbase + 0x280); } offs = mtu2_reg_offs[reg_nr]; @@ -353,109 +362,168 @@ static void sh_mtu2_register_clockevent(struct sh_mtu2_channel *ch, static int sh_mtu2_register(struct sh_mtu2_channel *ch, const char *name, bool clockevent) { - if (clockevent) + if (clockevent) { + ch->mtu->has_clockevent = true; sh_mtu2_register_clockevent(ch, name); + } return 0; } -static int sh_mtu2_setup_channel(struct sh_mtu2_channel *ch, +static int sh_mtu2_setup_channel(struct sh_mtu2_channel *ch, unsigned int index, struct sh_mtu2_device *mtu) { - struct sh_timer_config *cfg = mtu->pdev->dev.platform_data; + static const unsigned int channel_offsets[] = { + 0x300, 0x380, 0x000, + }; + bool clockevent; ch->mtu = mtu; - ch->index = cfg->timer_bit; - ch->irq = platform_get_irq(mtu->pdev, 0); + if (mtu->legacy) { + struct sh_timer_config *cfg = mtu->pdev->dev.platform_data; + + clockevent = cfg->clockevent_rating != 0; + + ch->irq = platform_get_irq(mtu->pdev, 0); + ch->base = mtu->mapbase - cfg->channel_offset; + ch->index = cfg->timer_bit; + } else { + char name[6]; + + clockevent = true; + + sprintf(name, "tgi%ua", index); + ch->irq = platform_get_irq_byname(mtu->pdev, name); + ch->base = mtu->mapbase + channel_offsets[index]; + ch->index = index; + } + if (ch->irq < 0) { + /* Skip channels with no declared interrupt. */ + if (!mtu->legacy) + return 0; + dev_err(&mtu->pdev->dev, "ch%u: failed to get irq\n", ch->index); return ch->irq; } - return sh_mtu2_register(ch, dev_name(&mtu->pdev->dev), - cfg->clockevent_rating != 0); + return sh_mtu2_register(ch, dev_name(&mtu->pdev->dev), clockevent); } -static int sh_mtu2_setup(struct sh_mtu2_device *mtu, - struct platform_device *pdev) +static int sh_mtu2_map_memory(struct sh_mtu2_device *mtu) { - struct sh_timer_config *cfg = pdev->dev.platform_data; struct resource *res; - void __iomem *base; - int ret; - ret = -ENXIO; - - mtu->pdev = pdev; - - if (!cfg) { - dev_err(&mtu->pdev->dev, "missing platform data\n"); - goto err0; - } - - platform_set_drvdata(pdev, mtu); res = platform_get_resource(mtu->pdev, IORESOURCE_MEM, 0); if (!res) { dev_err(&mtu->pdev->dev, "failed to get I/O memory\n"); - goto err0; + return -ENXIO; } + mtu->mapbase = ioremap_nocache(res->start, resource_size(res)); + if (mtu->mapbase == NULL) + return -ENXIO; + /* - * Map memory, let base point to our channel and mapbase to the - * start/stop shared register. + * In legacy platform device configuration (with one device per channel) + * the resource points to the channel base address. */ - base = ioremap_nocache(res->start, resource_size(res)); - if (base == NULL) { - dev_err(&mtu->pdev->dev, "failed to remap I/O memory\n"); - goto err0; + if (mtu->legacy) { + struct sh_timer_config *cfg = mtu->pdev->dev.platform_data; + mtu->mapbase += cfg->channel_offset; + } + + return 0; +} + +static void sh_mtu2_unmap_memory(struct sh_mtu2_device *mtu) +{ + if (mtu->legacy) { + struct sh_timer_config *cfg = mtu->pdev->dev.platform_data; + mtu->mapbase -= cfg->channel_offset; } - mtu->mapbase = base + cfg->channel_offset; + iounmap(mtu->mapbase); +} + +static int sh_mtu2_setup(struct sh_mtu2_device *mtu, + struct platform_device *pdev) +{ + struct sh_timer_config *cfg = pdev->dev.platform_data; + const struct platform_device_id *id = pdev->id_entry; + unsigned int i; + int ret; + + mtu->pdev = pdev; + mtu->legacy = id->driver_data; + + if (mtu->legacy && !cfg) { + dev_err(&mtu->pdev->dev, "missing platform data\n"); + return -ENXIO; + } - /* get hold of clock */ + /* Get hold of clock. */ mtu->clk = clk_get(&mtu->pdev->dev, "mtu2_fck"); if (IS_ERR(mtu->clk)) { dev_err(&mtu->pdev->dev, "cannot get clock\n"); - ret = PTR_ERR(mtu->clk); - goto err1; + return PTR_ERR(mtu->clk); } ret = clk_prepare(mtu->clk); if (ret < 0) - goto err2; + goto err_clk_put; - mtu->channels = kzalloc(sizeof(*mtu->channels), GFP_KERNEL); + /* Map the memory resource. */ + ret = sh_mtu2_map_memory(mtu); + if (ret < 0) { + dev_err(&mtu->pdev->dev, "failed to remap I/O memory\n"); + goto err_clk_unprepare; + } + + /* Allocate and setup the channels. */ + if (mtu->legacy) + mtu->num_channels = 1; + else + mtu->num_channels = 3; + + mtu->channels = kzalloc(sizeof(*mtu->channels) * mtu->num_channels, + GFP_KERNEL); if (mtu->channels == NULL) { ret = -ENOMEM; - goto err3; + goto err_unmap; } - mtu->num_channels = 1; - - mtu->channels[0].base = base; + if (mtu->legacy) { + ret = sh_mtu2_setup_channel(&mtu->channels[0], 0, mtu); + if (ret < 0) + goto err_unmap; + } else { + for (i = 0; i < mtu->num_channels; ++i) { + ret = sh_mtu2_setup_channel(&mtu->channels[i], i, mtu); + if (ret < 0) + goto err_unmap; + } + } - ret = sh_mtu2_setup_channel(&mtu->channels[0], mtu); - if (ret < 0) - goto err3; + platform_set_drvdata(pdev, mtu); return 0; - err3: + +err_unmap: kfree(mtu->channels); + sh_mtu2_unmap_memory(mtu); +err_clk_unprepare: clk_unprepare(mtu->clk); - err2: +err_clk_put: clk_put(mtu->clk); - err1: - iounmap(base); - err0: return ret; } static int sh_mtu2_probe(struct platform_device *pdev) { struct sh_mtu2_device *mtu = platform_get_drvdata(pdev); - struct sh_timer_config *cfg = pdev->dev.platform_data; int ret; if (!is_early_platform_device(pdev)) { @@ -484,7 +552,7 @@ static int sh_mtu2_probe(struct platform_device *pdev) return 0; out: - if (cfg->clockevent_rating) + if (mtu->has_clockevent) pm_runtime_irq_safe(&pdev->dev); else pm_runtime_idle(&pdev->dev); @@ -497,12 +565,20 @@ static int sh_mtu2_remove(struct platform_device *pdev) return -EBUSY; /* cannot unregister clockevent */ } +static const struct platform_device_id sh_mtu2_id_table[] = { + { "sh_mtu2", 1 }, + { "sh-mtu2", 0 }, + { }, +}; +MODULE_DEVICE_TABLE(platform, sh_mtu2_id_table); + static struct platform_driver sh_mtu2_device_driver = { .probe = sh_mtu2_probe, .remove = sh_mtu2_remove, .driver = { .name = "sh_mtu2", - } + }, + .id_table = sh_mtu2_id_table, }; static int __init sh_mtu2_init(void) -- cgit v1.2.3 From 6dc9693bb3997cb324a2ffb39deaa72081a9bd0d Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Tue, 4 Mar 2014 18:09:15 +0100 Subject: clocksource: sh_mtu2: Rename clock to "fck" in the non-legacy case The sh_mtu2 driver gets the MTU2 functional clock using a connection ID of "mtu2_fck". While all SH SoCs create clock lookup entries with a NULL device ID and a "mtu2_fck" connection ID, the ARM SoCs use the device ID only with a NULL connection ID. This works on legacy platforms but will break on ARM with DT boot. Fix the situation by using a connection ID of "fck" in the non-legacy platform data case. Clock lookup entries will be renamed to use the device ID as well as the connection ID as platforms get moved to new platform data. The legacy code will eventually be dropped, leaving us with device ID based clock lookup, compatible with DT boot. Signed-off-by: Laurent Pinchart Tested-by: Wolfram Sang --- drivers/clocksource/sh_mtu2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/clocksource/sh_mtu2.c b/drivers/clocksource/sh_mtu2.c index 7cc6d9429f81..3a3785702422 100644 --- a/drivers/clocksource/sh_mtu2.c +++ b/drivers/clocksource/sh_mtu2.c @@ -465,7 +465,7 @@ static int sh_mtu2_setup(struct sh_mtu2_device *mtu, } /* Get hold of clock. */ - mtu->clk = clk_get(&mtu->pdev->dev, "mtu2_fck"); + mtu->clk = clk_get(&mtu->pdev->dev, mtu->legacy ? "mtu2_fck" : "fck"); if (IS_ERR(mtu->clk)) { dev_err(&mtu->pdev->dev, "cannot get clock\n"); return PTR_ERR(mtu->clk); -- cgit v1.2.3 From 24c8f71707087eb177b45f4a24faedaa0d8f0287 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Tue, 4 Mar 2014 14:12:32 +0100 Subject: clocksource: sh_mtu2: Remove FSF mail address from GPL notice Do not include the paragraph about writing to the Free Software Foundation's mailing address from the sample GPL notice. The FSF has changed addresses in the past, and may do so again. Linux already includes a copy of the GPL. Signed-off-by: Laurent Pinchart Tested-by: Wolfram Sang --- drivers/clocksource/sh_mtu2.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/drivers/clocksource/sh_mtu2.c b/drivers/clocksource/sh_mtu2.c index 3a3785702422..510bd324c1a9 100644 --- a/drivers/clocksource/sh_mtu2.c +++ b/drivers/clocksource/sh_mtu2.c @@ -11,10 +11,6 @@ * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include -- cgit v1.2.3 From 346f5e76b3822a2530a03f33b00ee89dfc463326 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Tue, 4 Mar 2014 14:11:47 +0100 Subject: clocksource: sh_mtu2: Sort headers alphabetically This helps locating duplicates and inserting new headers. Signed-off-by: Laurent Pinchart Tested-by: Wolfram Sang --- drivers/clocksource/sh_mtu2.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/clocksource/sh_mtu2.c b/drivers/clocksource/sh_mtu2.c index 510bd324c1a9..f2c1c36139e1 100644 --- a/drivers/clocksource/sh_mtu2.c +++ b/drivers/clocksource/sh_mtu2.c @@ -13,22 +13,22 @@ * GNU General Public License for more details. */ +#include +#include +#include +#include #include -#include -#include #include -#include -#include #include -#include +#include #include -#include -#include -#include -#include #include +#include #include #include +#include +#include +#include struct sh_mtu2_device; -- cgit v1.2.3 From 7ded6e3d1bf5f83786753d1e0556a5c9711ced8a Mon Sep 17 00:00:00 2001 From: Monam Agarwal Date: Mon, 24 Mar 2014 01:02:42 +0530 Subject: crypto: nx - Use RCU_INIT_POINTER(x, NULL) This patch replaces rcu_assign_pointer(x, NULL) with RCU_INIT_POINTER(x, NULL) The rcu_assign_pointer() ensures that the initialization of a structure is carried out before storing a pointer to that structure. And in the case of the NULL pointer, there is no structure to initialize. So, rcu_assign_pointer(p, NULL) can be safely converted to RCU_INIT_POINTER(p, NULL) Signed-off-by: Monam Agarwal Signed-off-by: Herbert Xu --- drivers/crypto/nx/nx-842.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/crypto/nx/nx-842.c b/drivers/crypto/nx/nx-842.c index 1e5481d88a26..c4fcbf47475f 100644 --- a/drivers/crypto/nx/nx-842.c +++ b/drivers/crypto/nx/nx-842.c @@ -1234,7 +1234,7 @@ static int __exit nx842_remove(struct vio_dev *viodev) old_devdata = rcu_dereference_check(devdata, lockdep_is_held(&devdata_mutex)); of_reconfig_notifier_unregister(&nx842_of_nb); - rcu_assign_pointer(devdata, NULL); + RCU_INIT_POINTER(devdata, NULL); spin_unlock_irqrestore(&devdata_mutex, flags); synchronize_rcu(); dev_set_drvdata(&viodev->dev, NULL); @@ -1285,7 +1285,7 @@ static void __exit nx842_exit(void) spin_lock_irqsave(&devdata_mutex, flags); old_devdata = rcu_dereference_check(devdata, lockdep_is_held(&devdata_mutex)); - rcu_assign_pointer(devdata, NULL); + RCU_INIT_POINTER(devdata, NULL); spin_unlock_irqrestore(&devdata_mutex, flags); synchronize_rcu(); if (old_devdata) -- cgit v1.2.3 From 4585988f838605e34194a4a8121b64c7039adba9 Mon Sep 17 00:00:00 2001 From: Ard Biesheuvel Date: Wed, 16 Apr 2014 20:40:04 +0800 Subject: crypto: testmgr - add test cases for SHA-1, SHA-224, SHA-256 and AES-CCM This adds test cases for SHA-1, SHA-224, SHA-256 and AES-CCM with an input size that is an exact multiple of the block size. The reason is that some implementations use a different code path for these cases. Signed-off-by: Ard Biesheuvel Signed-off-by: Herbert Xu --- crypto/testmgr.h | 53 +++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 47 insertions(+), 6 deletions(-) diff --git a/crypto/testmgr.h b/crypto/testmgr.h index 3db83dbba1d9..c5d911dd8039 100644 --- a/crypto/testmgr.h +++ b/crypto/testmgr.h @@ -487,7 +487,7 @@ static struct hash_testvec crct10dif_tv_template[] = { * SHA1 test vectors from from FIPS PUB 180-1 * Long vector from CAVS 5.0 */ -#define SHA1_TEST_VECTORS 3 +#define SHA1_TEST_VECTORS 4 static struct hash_testvec sha1_tv_template[] = { { @@ -529,6 +529,11 @@ static struct hash_testvec sha1_tv_template[] = { "\x45\x9c\x02\xb6\x9b\x4a\xa8\xf5\x82\x17", .np = 4, .tap = { 63, 64, 31, 5 } + }, { + .plaintext = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-", + .psize = 64, + .digest = "\xc8\x71\xf6\x9a\x63\xcc\xa9\x84\x84\x82" + "\x64\xe7\x79\x95\x5d\xd7\x19\x41\x7c\x91", } }; @@ -536,7 +541,7 @@ static struct hash_testvec sha1_tv_template[] = { /* * SHA224 test vectors from from FIPS PUB 180-2 */ -#define SHA224_TEST_VECTORS 2 +#define SHA224_TEST_VECTORS 3 static struct hash_testvec sha224_tv_template[] = { { @@ -556,13 +561,20 @@ static struct hash_testvec sha224_tv_template[] = { "\x52\x52\x25\x25", .np = 2, .tap = { 28, 28 } + }, { + .plaintext = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-", + .psize = 64, + .digest = "\xc4\xdb\x2b\x3a\x58\xc3\x99\x01" + "\x42\xfd\x10\x92\xaa\x4e\x04\x08" + "\x58\xbb\xbb\xe8\xf8\x14\xa7\x0c" + "\xef\x3b\xcb\x0e", } }; /* * SHA256 test vectors from from NIST */ -#define SHA256_TEST_VECTORS 2 +#define SHA256_TEST_VECTORS 3 static struct hash_testvec sha256_tv_template[] = { { @@ -581,7 +593,14 @@ static struct hash_testvec sha256_tv_template[] = { "\xf6\xec\xed\xd4\x19\xdb\x06\xc1", .np = 2, .tap = { 28, 28 } - }, + }, { + .plaintext = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-", + .psize = 64, + .digest = "\xb5\xfe\xad\x56\x7d\xff\xcb\xa4" + "\x2c\x32\x29\x32\x19\xbb\xfb\xfa" + "\xd6\xff\x94\xa3\x72\x91\x85\x66" + "\x3b\xa7\x87\x77\x58\xa3\x40\x3a", + } }; /* @@ -12844,7 +12863,7 @@ static struct cipher_testvec cast6_xts_dec_tv_template[] = { #define AES_GCM_4106_DEC_TEST_VECTORS 7 #define AES_GCM_4543_ENC_TEST_VECTORS 1 #define AES_GCM_4543_DEC_TEST_VECTORS 2 -#define AES_CCM_ENC_TEST_VECTORS 7 +#define AES_CCM_ENC_TEST_VECTORS 8 #define AES_CCM_DEC_TEST_VECTORS 7 #define AES_CCM_4309_ENC_TEST_VECTORS 7 #define AES_CCM_4309_DEC_TEST_VECTORS 10 @@ -18746,7 +18765,29 @@ static struct aead_testvec aes_ccm_enc_tv_template[] = { "\x7c\xf9\xbe\xc2\x40\x88\x97\xc6" "\xba", .rlen = 33, - }, + }, { + /* + * This is the same vector as aes_ccm_rfc4309_enc_tv_template[0] + * below but rewritten to use the ccm algorithm directly. + */ + .key = "\x83\xac\x54\x66\xc2\xeb\xe5\x05" + "\x2e\x01\xd1\xfc\x5d\x82\x66\x2e", + .klen = 16, + .iv = "\x03\x96\xac\x59\x30\x07\xa1\xe2\xa2\xc7\x55\x24\0\0\0\0", + .alen = 0, + .input = "\x19\xc8\x81\xf6\xe9\x86\xff\x93" + "\x0b\x78\x67\xe5\xbb\xb7\xfc\x6e" + "\x83\x77\xb3\xa6\x0c\x8c\x9f\x9c" + "\x35\x2e\xad\xe0\x62\xf9\x91\xa1", + .ilen = 32, + .result = "\xab\x6f\xe1\x69\x1d\x19\x99\xa8" + "\x92\xa0\xc4\x6f\x7e\xe2\x8b\xb1" + "\x70\xbb\x8c\xa6\x4c\x6e\x97\x8a" + "\x57\x2b\xbe\x5d\x98\xa6\xb1\x32" + "\xda\x24\xea\xd9\xa1\x39\x98\xfd" + "\xa4\xbe\xd9\xf2\x1a\x6d\x22\xa8", + .rlen = 48, + } }; static struct aead_testvec aes_ccm_dec_tv_template[] = { -- cgit v1.2.3 From 2496be2eddd33e9d478d591501c97831554ef469 Mon Sep 17 00:00:00 2001 From: Jingoo Han Date: Tue, 8 Apr 2014 13:54:22 +0900 Subject: crypto: omap-des - use devm_ioremap_resource() Use devm_ioremap_resource() because devm_request_and_ioremap() is obsoleted by devm_ioremap_resource(). Signed-off-by: Jingoo Han Acked-by: Joel Fernandes Reviewed-by: Marek Vasut Signed-off-by: Herbert Xu --- drivers/crypto/omap-des.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/crypto/omap-des.c b/drivers/crypto/omap-des.c index ec5f13162b73..4a13624bb82b 100644 --- a/drivers/crypto/omap-des.c +++ b/drivers/crypto/omap-des.c @@ -1074,10 +1074,9 @@ static int omap_des_probe(struct platform_device *pdev) if (err) goto err_res; - dd->io_base = devm_request_and_ioremap(dev, res); - if (!dd->io_base) { - dev_err(dev, "can't ioremap\n"); - err = -ENOMEM; + dd->io_base = devm_ioremap_resource(dev, res); + if (IS_ERR(dd->io_base)) { + err = PTR_ERR(dd->io_base); goto err_res; } dd->phys_base = res->start; -- cgit v1.2.3 From dc64ef00878b3d45567b2bcfcd2b5243d3d2ccb1 Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Tue, 8 Apr 2014 14:27:31 +0200 Subject: hwrng: Move UML_RANDOM at the last position UML_RANDOM is the only hardware random number generator option which does not depend on HW_RANDOM. Having it in the middle of the other options breaks the alignment in "make menuconfig". Move it at the last position to avoid that. Signed-off-by: Jean Delvare Cc: Matt Mackall Signed-off-by: Herbert Xu --- drivers/char/hw_random/Kconfig | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/drivers/char/hw_random/Kconfig b/drivers/char/hw_random/Kconfig index 2f2b08457c67..ef5010605659 100644 --- a/drivers/char/hw_random/Kconfig +++ b/drivers/char/hw_random/Kconfig @@ -275,21 +275,6 @@ config HW_RANDOM_PPC4XX If unsure, say N. -config UML_RANDOM - depends on UML - tristate "Hardware random number generator" - help - This option enables UML's "hardware" random number generator. It - attaches itself to the host's /dev/random, supplying as much entropy - as the host has, rather than the small amount the UML gets from its - own drivers. It registers itself as a standard hardware random number - generator, major 10, minor 183, and the canonical device name is - /dev/hwrng. - The way to make use of this is to install the rng-tools package - (check your distro, or download from - http://sourceforge.net/projects/gkernel/). rngd periodically reads - /dev/hwrng and injects the entropy into /dev/random. - config HW_RANDOM_PSERIES tristate "pSeries HW Random Number Generator support" depends on HW_RANDOM && PPC64 && IBMVIO @@ -352,3 +337,18 @@ config HW_RANDOM_MSM module will be called msm-rng. If unsure, say Y. + +config UML_RANDOM + depends on UML + tristate "Hardware random number generator" + help + This option enables UML's "hardware" random number generator. It + attaches itself to the host's /dev/random, supplying as much entropy + as the host has, rather than the small amount the UML gets from its + own drivers. It registers itself as a standard hardware random number + generator, major 10, minor 183, and the canonical device name is + /dev/hwrng. + The way to make use of this is to install the rng-tools package + (check your distro, or download from + http://sourceforge.net/projects/gkernel/). rngd periodically reads + /dev/hwrng and injects the entropy into /dev/random. -- cgit v1.2.3 From 0200161834534fb79df03eac47314607dabd58d8 Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Tue, 8 Apr 2014 14:33:04 +0200 Subject: hwrng: Turn HW_RANDOM into a menuconfig This makes configuration more convenient IMHO, and avoids having to repeat the dependency on HW_RANDOM for every single driver. Signed-off-by: Jean Delvare Cc: Matt Mackall Signed-off-by: Herbert Xu --- drivers/char/hw_random/Kconfig | 56 ++++++++++++++++++++++-------------------- 1 file changed, 30 insertions(+), 26 deletions(-) diff --git a/drivers/char/hw_random/Kconfig b/drivers/char/hw_random/Kconfig index ef5010605659..1e9d23769281 100644 --- a/drivers/char/hw_random/Kconfig +++ b/drivers/char/hw_random/Kconfig @@ -2,7 +2,7 @@ # Hardware Random Number Generator (RNG) configuration # -config HW_RANDOM +menuconfig HW_RANDOM tristate "Hardware Random Number Generator Core support" default m ---help--- @@ -20,9 +20,11 @@ config HW_RANDOM If unsure, say Y. +if HW_RANDOM + config HW_RANDOM_TIMERIOMEM tristate "Timer IOMEM HW Random Number Generator support" - depends on HW_RANDOM && HAS_IOMEM + depends on HAS_IOMEM ---help--- This driver provides kernel-side support for a generic Random Number Generator used by reading a 'dumb' iomem address that @@ -36,7 +38,7 @@ config HW_RANDOM_TIMERIOMEM config HW_RANDOM_INTEL tristate "Intel HW Random Number Generator support" - depends on HW_RANDOM && (X86 || IA64) && PCI + depends on (X86 || IA64) && PCI default HW_RANDOM ---help--- This driver provides kernel-side support for the Random Number @@ -49,7 +51,7 @@ config HW_RANDOM_INTEL config HW_RANDOM_AMD tristate "AMD HW Random Number Generator support" - depends on HW_RANDOM && (X86 || PPC_MAPLE) && PCI + depends on (X86 || PPC_MAPLE) && PCI default HW_RANDOM ---help--- This driver provides kernel-side support for the Random Number @@ -62,7 +64,7 @@ config HW_RANDOM_AMD config HW_RANDOM_ATMEL tristate "Atmel Random Number Generator support" - depends on HW_RANDOM && HAVE_CLK + depends on HAVE_CLK default (HW_RANDOM && ARCH_AT91) ---help--- This driver provides kernel-side support for the Random Number @@ -75,7 +77,7 @@ config HW_RANDOM_ATMEL config HW_RANDOM_BCM63XX tristate "Broadcom BCM63xx Random Number Generator support" - depends on HW_RANDOM && BCM63XX + depends on BCM63XX default HW_RANDOM ---help--- This driver provides kernel-side support for the Random Number @@ -88,7 +90,7 @@ config HW_RANDOM_BCM63XX config HW_RANDOM_BCM2835 tristate "Broadcom BCM2835 Random Number Generator support" - depends on HW_RANDOM && ARCH_BCM2835 + depends on ARCH_BCM2835 default HW_RANDOM ---help--- This driver provides kernel-side support for the Random Number @@ -101,7 +103,7 @@ config HW_RANDOM_BCM2835 config HW_RANDOM_GEODE tristate "AMD Geode HW Random Number Generator support" - depends on HW_RANDOM && X86_32 && PCI + depends on X86_32 && PCI default HW_RANDOM ---help--- This driver provides kernel-side support for the Random Number @@ -114,7 +116,7 @@ config HW_RANDOM_GEODE config HW_RANDOM_N2RNG tristate "Niagara2 Random Number Generator support" - depends on HW_RANDOM && SPARC64 + depends on SPARC64 default HW_RANDOM ---help--- This driver provides kernel-side support for the Random Number @@ -127,7 +129,7 @@ config HW_RANDOM_N2RNG config HW_RANDOM_VIA tristate "VIA HW Random Number Generator support" - depends on HW_RANDOM && X86 + depends on X86 default HW_RANDOM ---help--- This driver provides kernel-side support for the Random Number @@ -140,7 +142,7 @@ config HW_RANDOM_VIA config HW_RANDOM_IXP4XX tristate "Intel IXP4xx NPU HW Pseudo-Random Number Generator support" - depends on HW_RANDOM && ARCH_IXP4XX + depends on ARCH_IXP4XX default HW_RANDOM ---help--- This driver provides kernel-side support for the Pseudo-Random @@ -153,7 +155,7 @@ config HW_RANDOM_IXP4XX config HW_RANDOM_OMAP tristate "OMAP Random Number Generator support" - depends on HW_RANDOM && (ARCH_OMAP16XX || ARCH_OMAP2PLUS) + depends on ARCH_OMAP16XX || ARCH_OMAP2PLUS default HW_RANDOM ---help--- This driver provides kernel-side support for the Random Number @@ -167,7 +169,7 @@ config HW_RANDOM_OMAP config HW_RANDOM_OMAP3_ROM tristate "OMAP3 ROM Random Number Generator support" - depends on HW_RANDOM && ARCH_OMAP3 + depends on ARCH_OMAP3 default HW_RANDOM ---help--- This driver provides kernel-side support for the Random Number @@ -180,7 +182,7 @@ config HW_RANDOM_OMAP3_ROM config HW_RANDOM_OCTEON tristate "Octeon Random Number Generator support" - depends on HW_RANDOM && CAVIUM_OCTEON_SOC + depends on CAVIUM_OCTEON_SOC default HW_RANDOM ---help--- This driver provides kernel-side support for the Random Number @@ -193,7 +195,7 @@ config HW_RANDOM_OCTEON config HW_RANDOM_PASEMI tristate "PA Semi HW Random Number Generator support" - depends on HW_RANDOM && PPC_PASEMI + depends on PPC_PASEMI default HW_RANDOM ---help--- This driver provides kernel-side support for the Random Number @@ -206,7 +208,7 @@ config HW_RANDOM_PASEMI config HW_RANDOM_VIRTIO tristate "VirtIO Random Number Generator support" - depends on HW_RANDOM && VIRTIO + depends on VIRTIO ---help--- This driver provides kernel-side support for the virtual Random Number Generator hardware. @@ -216,7 +218,7 @@ config HW_RANDOM_VIRTIO config HW_RANDOM_TX4939 tristate "TX4939 Random Number Generator support" - depends on HW_RANDOM && SOC_TX4939 + depends on SOC_TX4939 default HW_RANDOM ---help--- This driver provides kernel-side support for the Random Number @@ -229,7 +231,7 @@ config HW_RANDOM_TX4939 config HW_RANDOM_MXC_RNGA tristate "Freescale i.MX RNGA Random Number Generator" - depends on HW_RANDOM && ARCH_HAS_RNGA + depends on ARCH_HAS_RNGA ---help--- This driver provides kernel-side support for the Random Number Generator hardware found on Freescale i.MX processors. @@ -241,7 +243,7 @@ config HW_RANDOM_MXC_RNGA config HW_RANDOM_NOMADIK tristate "ST-Ericsson Nomadik Random Number Generator support" - depends on HW_RANDOM && ARCH_NOMADIK + depends on ARCH_NOMADIK ---help--- This driver provides kernel-side support for the Random Number Generator hardware found on ST-Ericsson SoCs (8815 and 8500). @@ -253,7 +255,7 @@ config HW_RANDOM_NOMADIK config HW_RANDOM_PICOXCELL tristate "Picochip picoXcell true random number generator support" - depends on HW_RANDOM && ARCH_PICOXCELL && PICOXCELL_PC3X3 + depends on ARCH_PICOXCELL && PICOXCELL_PC3X3 ---help--- This driver provides kernel-side support for the Random Number Generator hardware found on Picochip PC3x3 and later devices. @@ -265,7 +267,7 @@ config HW_RANDOM_PICOXCELL config HW_RANDOM_PPC4XX tristate "PowerPC 4xx generic true random number generator support" - depends on HW_RANDOM && PPC && 4xx + depends on PPC && 4xx ---help--- This driver provides the kernel-side support for the TRNG hardware found in the security function of some PowerPC 4xx SoCs. @@ -277,7 +279,7 @@ config HW_RANDOM_PPC4XX config HW_RANDOM_PSERIES tristate "pSeries HW Random Number Generator support" - depends on HW_RANDOM && PPC64 && IBMVIO + depends on PPC64 && IBMVIO default HW_RANDOM ---help--- This driver provides kernel-side support for the Random Number @@ -290,7 +292,7 @@ config HW_RANDOM_PSERIES config HW_RANDOM_POWERNV tristate "PowerNV Random Number Generator support" - depends on HW_RANDOM && PPC_POWERNV + depends on PPC_POWERNV default HW_RANDOM ---help--- This is the driver for Random Number Generator hardware found @@ -303,7 +305,7 @@ config HW_RANDOM_POWERNV config HW_RANDOM_EXYNOS tristate "EXYNOS HW random number generator support" - depends on HW_RANDOM && HAS_IOMEM && HAVE_CLK + depends on HAS_IOMEM && HAVE_CLK ---help--- This driver provides kernel-side support for the Random Number Generator hardware found on EXYNOS SOCs. @@ -315,7 +317,7 @@ config HW_RANDOM_EXYNOS config HW_RANDOM_TPM tristate "TPM HW Random Number Generator support" - depends on HW_RANDOM && TCG_TPM + depends on TCG_TPM default HW_RANDOM ---help--- This driver provides kernel-side support for the Random Number @@ -328,7 +330,7 @@ config HW_RANDOM_TPM config HW_RANDOM_MSM tristate "Qualcomm MSM Random Number Generator support" - depends on HW_RANDOM && ARCH_MSM + depends on ARCH_MSM ---help--- This driver provides kernel-side support for the Random Number Generator hardware found on Qualcomm MSM SoCs. @@ -338,6 +340,8 @@ config HW_RANDOM_MSM If unsure, say Y. +endif # HW_RANDOM + config UML_RANDOM depends on UML tristate "Hardware random number generator" -- cgit v1.2.3 From 2d9cab5194c89a0d20fb8dce09e9d3a7c85e8f37 Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Tue, 8 Apr 2014 14:36:37 +0200 Subject: hwrng: Fix a few driver dependencies and defaults HW_RANDOM_ATMEL should not only default to ARCH_AT91, it should depend on it. This driver is useless on other architectures. Likewise, HW_RANDOM_EXYNOS should depend on ARCH_EXYNOS, as it it useless on other architectures. Also set the default to HW_RANDOM for the few architecture-specific drivers which didn't have it yet, for consistency. Signed-off-by: Jean Delvare Cc: Nicolas Ferre Cc: Matt Mackall Cc: Kukjin Kim Signed-off-by: Herbert Xu --- drivers/char/hw_random/Kconfig | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/char/hw_random/Kconfig b/drivers/char/hw_random/Kconfig index 1e9d23769281..58a15f28789f 100644 --- a/drivers/char/hw_random/Kconfig +++ b/drivers/char/hw_random/Kconfig @@ -64,8 +64,8 @@ config HW_RANDOM_AMD config HW_RANDOM_ATMEL tristate "Atmel Random Number Generator support" - depends on HAVE_CLK - default (HW_RANDOM && ARCH_AT91) + depends on ARCH_AT91 && HAVE_CLK + default HW_RANDOM ---help--- This driver provides kernel-side support for the Random Number Generator hardware found on Atmel AT91 devices. @@ -232,6 +232,7 @@ config HW_RANDOM_TX4939 config HW_RANDOM_MXC_RNGA tristate "Freescale i.MX RNGA Random Number Generator" depends on ARCH_HAS_RNGA + default HW_RANDOM ---help--- This driver provides kernel-side support for the Random Number Generator hardware found on Freescale i.MX processors. @@ -244,6 +245,7 @@ config HW_RANDOM_MXC_RNGA config HW_RANDOM_NOMADIK tristate "ST-Ericsson Nomadik Random Number Generator support" depends on ARCH_NOMADIK + default HW_RANDOM ---help--- This driver provides kernel-side support for the Random Number Generator hardware found on ST-Ericsson SoCs (8815 and 8500). @@ -256,6 +258,7 @@ config HW_RANDOM_NOMADIK config HW_RANDOM_PICOXCELL tristate "Picochip picoXcell true random number generator support" depends on ARCH_PICOXCELL && PICOXCELL_PC3X3 + default HW_RANDOM ---help--- This driver provides kernel-side support for the Random Number Generator hardware found on Picochip PC3x3 and later devices. @@ -268,6 +271,7 @@ config HW_RANDOM_PICOXCELL config HW_RANDOM_PPC4XX tristate "PowerPC 4xx generic true random number generator support" depends on PPC && 4xx + default HW_RANDOM ---help--- This driver provides the kernel-side support for the TRNG hardware found in the security function of some PowerPC 4xx SoCs. @@ -305,7 +309,8 @@ config HW_RANDOM_POWERNV config HW_RANDOM_EXYNOS tristate "EXYNOS HW random number generator support" - depends on HAS_IOMEM && HAVE_CLK + depends on ARCH_EXYNOS + default HW_RANDOM ---help--- This driver provides kernel-side support for the Random Number Generator hardware found on EXYNOS SOCs. @@ -331,6 +336,7 @@ config HW_RANDOM_TPM config HW_RANDOM_MSM tristate "Qualcomm MSM Random Number Generator support" depends on ARCH_MSM + default HW_RANDOM ---help--- This driver provides kernel-side support for the Random Number Generator hardware found on Qualcomm MSM SoCs. -- cgit v1.2.3 From 52e6e543f2d8c8320b6e9c53110bd1c5768d6b43 Mon Sep 17 00:00:00 2001 From: Sonic Zhang Date: Thu, 10 Apr 2014 14:30:56 +0800 Subject: crypto: bfin_crc - access crc registers by readl and writel functions Move architecture independant crc header file out of the blackfin folder. Signed-off-by: Sonic Zhang Reviewed-by: Marek Vasut Signed-off-by: Herbert Xu --- arch/blackfin/include/asm/bfin_crc.h | 125 ----------------------------------- drivers/crypto/bfin_crc.c | 42 +++++++----- drivers/crypto/bfin_crc.h | 125 +++++++++++++++++++++++++++++++++++ 3 files changed, 150 insertions(+), 142 deletions(-) delete mode 100644 arch/blackfin/include/asm/bfin_crc.h create mode 100644 drivers/crypto/bfin_crc.h diff --git a/arch/blackfin/include/asm/bfin_crc.h b/arch/blackfin/include/asm/bfin_crc.h deleted file mode 100644 index 75cef4dc85a1..000000000000 --- a/arch/blackfin/include/asm/bfin_crc.h +++ /dev/null @@ -1,125 +0,0 @@ -/* - * bfin_crc.h - interface to Blackfin CRC controllers - * - * Copyright 2012 Analog Devices Inc. - * - * Licensed under the GPL-2 or later. - */ - -#ifndef __BFIN_CRC_H__ -#define __BFIN_CRC_H__ - -/* Function driver which use hardware crc must initialize the structure */ -struct crc_info { - /* Input data address */ - unsigned char *in_addr; - /* Output data address */ - unsigned char *out_addr; - /* Input or output bytes */ - unsigned long datasize; - union { - /* CRC to compare with that of input buffer */ - unsigned long crc_compare; - /* Value to compare with input data */ - unsigned long val_verify; - /* Value to fill */ - unsigned long val_fill; - }; - /* Value to program the 32b CRC Polynomial */ - unsigned long crc_poly; - union { - /* CRC calculated from the input data */ - unsigned long crc_result; - /* First failed position to verify input data */ - unsigned long pos_verify; - }; - /* CRC mirror flags */ - unsigned int bitmirr:1; - unsigned int bytmirr:1; - unsigned int w16swp:1; - unsigned int fdsel:1; - unsigned int rsltmirr:1; - unsigned int polymirr:1; - unsigned int cmpmirr:1; -}; - -/* Userspace interface */ -#define CRC_IOC_MAGIC 'C' -#define CRC_IOC_CALC_CRC _IOWR('C', 0x01, unsigned int) -#define CRC_IOC_MEMCPY_CRC _IOWR('C', 0x02, unsigned int) -#define CRC_IOC_VERIFY_VAL _IOWR('C', 0x03, unsigned int) -#define CRC_IOC_FILL_VAL _IOWR('C', 0x04, unsigned int) - - -#ifdef __KERNEL__ - -#include -#include -#include - -struct crc_register { - u32 control; - u32 datacnt; - u32 datacntrld; - u32 __pad_1[2]; - u32 compare; - u32 fillval; - u32 datafifo; - u32 intren; - u32 intrenset; - u32 intrenclr; - u32 poly; - u32 __pad_2[4]; - u32 status; - u32 datacntcap; - u32 __pad_3; - u32 result; - u32 curresult; - u32 __pad_4[3]; - u32 revid; -}; - -/* CRC_STATUS Masks */ -#define CMPERR 0x00000002 /* Compare error */ -#define DCNTEXP 0x00000010 /* datacnt register expired */ -#define IBR 0x00010000 /* Input buffer ready */ -#define OBR 0x00020000 /* Output buffer ready */ -#define IRR 0x00040000 /* Immediate result readt */ -#define LUTDONE 0x00080000 /* Look-up table generation done */ -#define FSTAT 0x00700000 /* FIFO status */ -#define MAX_FIFO 4 /* Max fifo size */ - -/* CRC_CONTROL Masks */ -#define BLKEN 0x00000001 /* Block enable */ -#define OPMODE 0x000000F0 /* Operation mode */ -#define OPMODE_OFFSET 4 /* Operation mode mask offset*/ -#define MODE_DMACPY_CRC 1 /* MTM CRC compute and compare */ -#define MODE_DATA_FILL 2 /* MTM data fill */ -#define MODE_CALC_CRC 3 /* MSM CRC compute and compare */ -#define MODE_DATA_VERIFY 4 /* MSM data verify */ -#define AUTOCLRZ 0x00000100 /* Auto clear to zero */ -#define AUTOCLRF 0x00000200 /* Auto clear to one */ -#define OBRSTALL 0x00001000 /* Stall on output buffer ready */ -#define IRRSTALL 0x00002000 /* Stall on immediate result ready */ -#define BITMIRR 0x00010000 /* Mirror bits within each byte of 32-bit input data */ -#define BITMIRR_OFFSET 16 /* Mirror bits offset */ -#define BYTMIRR 0x00020000 /* Mirror bytes of 32-bit input data */ -#define BYTMIRR_OFFSET 17 /* Mirror bytes offset */ -#define W16SWP 0x00040000 /* Mirror uppper and lower 16-bit word of 32-bit input data */ -#define W16SWP_OFFSET 18 /* Mirror 16-bit word offset */ -#define FDSEL 0x00080000 /* FIFO is written after input data is mirrored */ -#define FDSEL_OFFSET 19 /* Mirror FIFO offset */ -#define RSLTMIRR 0x00100000 /* CRC result registers are mirrored. */ -#define RSLTMIRR_OFFSET 20 /* Mirror CRC result offset. */ -#define POLYMIRR 0x00200000 /* CRC poly register is mirrored. */ -#define POLYMIRR_OFFSET 21 /* Mirror CRC poly offset. */ -#define CMPMIRR 0x00400000 /* CRC compare register is mirrored. */ -#define CMPMIRR_OFFSET 22 /* Mirror CRC compare offset. */ - -/* CRC_INTREN Masks */ -#define CMPERRI 0x02 /* CRC_ERROR_INTR */ -#define DCNTEXPI 0x10 /* CRC_STATUS_INTR */ - -#endif - -#endif diff --git a/drivers/crypto/bfin_crc.c b/drivers/crypto/bfin_crc.c index c9ff298e6d26..cea3e8c1fdf9 100644 --- a/drivers/crypto/bfin_crc.c +++ b/drivers/crypto/bfin_crc.c @@ -30,9 +30,11 @@ #include #include -#include #include #include +#include + +#include "bfin_crc.h" #define CRC_CCRYPTO_QUEUE_LENGTH 5 @@ -54,7 +56,7 @@ struct bfin_crypto_crc { int irq; int dma_ch; u32 poly; - volatile struct crc_register *regs; + struct crc_register *regs; struct ahash_request *req; /* current request in operation */ struct dma_desc_array *sg_cpu; /* virt addr of sg dma descriptors */ @@ -132,13 +134,13 @@ static struct scatterlist *sg_get(struct scatterlist *sg_list, unsigned int nent static int bfin_crypto_crc_init_hw(struct bfin_crypto_crc *crc, u32 key) { - crc->regs->datacntrld = 0; - crc->regs->control = MODE_CALC_CRC << OPMODE_OFFSET; - crc->regs->curresult = key; + writel(0, &crc->regs->datacntrld); + writel(MODE_CALC_CRC << OPMODE_OFFSET, &crc->regs->control); + writel(key, &crc->regs->curresult); /* setup CRC interrupts */ - crc->regs->status = CMPERRI | DCNTEXPI; - crc->regs->intrenset = CMPERRI | DCNTEXPI; + writel(CMPERRI | DCNTEXPI, &crc->regs->status); + writel(CMPERRI | DCNTEXPI, &crc->regs->intrenset); return 0; } @@ -303,6 +305,7 @@ static int bfin_crypto_crc_handle_queue(struct bfin_crypto_crc *crc, int nsg, i, j; unsigned int nextlen; unsigned long flags; + u32 reg; spin_lock_irqsave(&crc->lock, flags); if (req) @@ -402,13 +405,14 @@ finish_update: ctx->sg_buflen += CHKSUM_DIGEST_SIZE; /* set CRC data count before start DMA */ - crc->regs->datacnt = ctx->sg_buflen >> 2; + writel(ctx->sg_buflen >> 2, &crc->regs->datacnt); /* setup and enable CRC DMA */ bfin_crypto_crc_config_dma(crc); /* finally kick off CRC operation */ - crc->regs->control |= BLKEN; + reg = readl(&crc->regs->control); + writel(reg | BLKEN, &crc->regs->control); return -EINPROGRESS; } @@ -529,14 +533,17 @@ static void bfin_crypto_crc_done_task(unsigned long data) static irqreturn_t bfin_crypto_crc_handler(int irq, void *dev_id) { struct bfin_crypto_crc *crc = dev_id; + u32 reg; - if (crc->regs->status & DCNTEXP) { - crc->regs->status = DCNTEXP; + if (readl(&crc->regs->status) & DCNTEXP) { + writel(DCNTEXP, &crc->regs->status); /* prepare results */ - put_unaligned_le32(crc->regs->result, crc->req->result); + put_unaligned_le32(readl(&crc->regs->result), + crc->req->result); - crc->regs->control &= ~BLKEN; + reg = readl(&crc->regs->control); + writel(reg & ~BLKEN, &crc->regs->control); crc->busy = 0; if (crc->req->base.complete) @@ -560,7 +567,7 @@ static int bfin_crypto_crc_suspend(struct platform_device *pdev, pm_message_t st struct bfin_crypto_crc *crc = platform_get_drvdata(pdev); int i = 100000; - while ((crc->regs->control & BLKEN) && --i) + while ((readl(&crc->regs->control) & BLKEN) && --i) cpu_relax(); if (i == 0) @@ -648,10 +655,11 @@ static int bfin_crypto_crc_probe(struct platform_device *pdev) */ crc->sg_mid_buf = (u8 *)(crc->sg_cpu + ((CRC_MAX_DMA_DESC + 1) << 1)); - crc->regs->control = 0; - crc->regs->poly = crc->poly = (u32)pdev->dev.platform_data; + writel(0, &crc->regs->control); + crc->poly = (u32)pdev->dev.platform_data; + writel(crc->poly, &crc->regs->poly); - while (!(crc->regs->status & LUTDONE) && (--timeout) > 0) + while (!(readl(&crc->regs->status) & LUTDONE) && (--timeout) > 0) cpu_relax(); if (timeout == 0) diff --git a/drivers/crypto/bfin_crc.h b/drivers/crypto/bfin_crc.h new file mode 100644 index 000000000000..75cef4dc85a1 --- /dev/null +++ b/drivers/crypto/bfin_crc.h @@ -0,0 +1,125 @@ +/* + * bfin_crc.h - interface to Blackfin CRC controllers + * + * Copyright 2012 Analog Devices Inc. + * + * Licensed under the GPL-2 or later. + */ + +#ifndef __BFIN_CRC_H__ +#define __BFIN_CRC_H__ + +/* Function driver which use hardware crc must initialize the structure */ +struct crc_info { + /* Input data address */ + unsigned char *in_addr; + /* Output data address */ + unsigned char *out_addr; + /* Input or output bytes */ + unsigned long datasize; + union { + /* CRC to compare with that of input buffer */ + unsigned long crc_compare; + /* Value to compare with input data */ + unsigned long val_verify; + /* Value to fill */ + unsigned long val_fill; + }; + /* Value to program the 32b CRC Polynomial */ + unsigned long crc_poly; + union { + /* CRC calculated from the input data */ + unsigned long crc_result; + /* First failed position to verify input data */ + unsigned long pos_verify; + }; + /* CRC mirror flags */ + unsigned int bitmirr:1; + unsigned int bytmirr:1; + unsigned int w16swp:1; + unsigned int fdsel:1; + unsigned int rsltmirr:1; + unsigned int polymirr:1; + unsigned int cmpmirr:1; +}; + +/* Userspace interface */ +#define CRC_IOC_MAGIC 'C' +#define CRC_IOC_CALC_CRC _IOWR('C', 0x01, unsigned int) +#define CRC_IOC_MEMCPY_CRC _IOWR('C', 0x02, unsigned int) +#define CRC_IOC_VERIFY_VAL _IOWR('C', 0x03, unsigned int) +#define CRC_IOC_FILL_VAL _IOWR('C', 0x04, unsigned int) + + +#ifdef __KERNEL__ + +#include +#include +#include + +struct crc_register { + u32 control; + u32 datacnt; + u32 datacntrld; + u32 __pad_1[2]; + u32 compare; + u32 fillval; + u32 datafifo; + u32 intren; + u32 intrenset; + u32 intrenclr; + u32 poly; + u32 __pad_2[4]; + u32 status; + u32 datacntcap; + u32 __pad_3; + u32 result; + u32 curresult; + u32 __pad_4[3]; + u32 revid; +}; + +/* CRC_STATUS Masks */ +#define CMPERR 0x00000002 /* Compare error */ +#define DCNTEXP 0x00000010 /* datacnt register expired */ +#define IBR 0x00010000 /* Input buffer ready */ +#define OBR 0x00020000 /* Output buffer ready */ +#define IRR 0x00040000 /* Immediate result readt */ +#define LUTDONE 0x00080000 /* Look-up table generation done */ +#define FSTAT 0x00700000 /* FIFO status */ +#define MAX_FIFO 4 /* Max fifo size */ + +/* CRC_CONTROL Masks */ +#define BLKEN 0x00000001 /* Block enable */ +#define OPMODE 0x000000F0 /* Operation mode */ +#define OPMODE_OFFSET 4 /* Operation mode mask offset*/ +#define MODE_DMACPY_CRC 1 /* MTM CRC compute and compare */ +#define MODE_DATA_FILL 2 /* MTM data fill */ +#define MODE_CALC_CRC 3 /* MSM CRC compute and compare */ +#define MODE_DATA_VERIFY 4 /* MSM data verify */ +#define AUTOCLRZ 0x00000100 /* Auto clear to zero */ +#define AUTOCLRF 0x00000200 /* Auto clear to one */ +#define OBRSTALL 0x00001000 /* Stall on output buffer ready */ +#define IRRSTALL 0x00002000 /* Stall on immediate result ready */ +#define BITMIRR 0x00010000 /* Mirror bits within each byte of 32-bit input data */ +#define BITMIRR_OFFSET 16 /* Mirror bits offset */ +#define BYTMIRR 0x00020000 /* Mirror bytes of 32-bit input data */ +#define BYTMIRR_OFFSET 17 /* Mirror bytes offset */ +#define W16SWP 0x00040000 /* Mirror uppper and lower 16-bit word of 32-bit input data */ +#define W16SWP_OFFSET 18 /* Mirror 16-bit word offset */ +#define FDSEL 0x00080000 /* FIFO is written after input data is mirrored */ +#define FDSEL_OFFSET 19 /* Mirror FIFO offset */ +#define RSLTMIRR 0x00100000 /* CRC result registers are mirrored. */ +#define RSLTMIRR_OFFSET 20 /* Mirror CRC result offset. */ +#define POLYMIRR 0x00200000 /* CRC poly register is mirrored. */ +#define POLYMIRR_OFFSET 21 /* Mirror CRC poly offset. */ +#define CMPMIRR 0x00400000 /* CRC compare register is mirrored. */ +#define CMPMIRR_OFFSET 22 /* Mirror CRC compare offset. */ + +/* CRC_INTREN Masks */ +#define CMPERRI 0x02 /* CRC_ERROR_INTR */ +#define DCNTEXPI 0x10 /* CRC_STATUS_INTR */ + +#endif + +#endif -- cgit v1.2.3 From 8d390395fa8cb32aeb3030398e441dd1a1ab4437 Mon Sep 17 00:00:00 2001 From: Sonic Zhang Date: Fri, 11 Apr 2014 17:30:25 +0800 Subject: crypto: bfin_crc - ignore duplicated registration of the same algorithm in case of multiple crc devices are probed. Call platform_set_drvdata() before adding new CRC device into the list. Signed-off-by: Sonic Zhang Reviewed-by: Marek Vasut Signed-off-by: Herbert Xu --- drivers/crypto/bfin_crc.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/crypto/bfin_crc.c b/drivers/crypto/bfin_crc.c index cea3e8c1fdf9..ce9a831a6c70 100644 --- a/drivers/crypto/bfin_crc.c +++ b/drivers/crypto/bfin_crc.c @@ -665,19 +665,19 @@ static int bfin_crypto_crc_probe(struct platform_device *pdev) if (timeout == 0) dev_info(&pdev->dev, "init crc poly timeout\n"); + platform_set_drvdata(pdev, crc); + spin_lock(&crc_list.lock); list_add(&crc->list, &crc_list.dev_list); spin_unlock(&crc_list.lock); - platform_set_drvdata(pdev, crc); - - ret = crypto_register_ahash(&algs); - if (ret) { - spin_lock(&crc_list.lock); - list_del(&crc->list); - spin_unlock(&crc_list.lock); - dev_err(&pdev->dev, "Cann't register crypto ahash device\n"); - goto out_error_dma; + if (list_is_singular(&crc_list.dev_list)) { + ret = crypto_register_ahash(&algs); + if (ret) { + dev_err(&pdev->dev, + "Can't register crypto ahash device\n"); + goto out_error_dma; + } } dev_info(&pdev->dev, "initialized\n"); -- cgit v1.2.3 From 52d77eb177a034c6ddc6f33ad16458b7df0c5190 Mon Sep 17 00:00:00 2001 From: Sonic Zhang Date: Thu, 10 Apr 2014 16:40:59 +0800 Subject: cryptoo: bfin_crc - avoid get physical address of coherence memory by dma_map_single - The 4-byte sg_mid_buf is located in the middle of the coherence memory sg_cpu. Don't call dma_map_single to get its physical address. Get the its base physical address from the physical address of sg_cpu instead. - Should set up the dma descriptor data after the 4-byte sg_mid_buf is filled in completely from next sg buffer. - memory copy from sg buffer should be done via virtual address. - Remove unused reference to blackfin header Signed-off-by: Sonic Zhang Reviewed-by: Marek Vasut Signed-off-by: Herbert Xu --- drivers/crypto/bfin_crc.c | 43 +++++++++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/drivers/crypto/bfin_crc.c b/drivers/crypto/bfin_crc.c index ce9a831a6c70..b099e33cb073 100644 --- a/drivers/crypto/bfin_crc.c +++ b/drivers/crypto/bfin_crc.c @@ -29,7 +29,6 @@ #include #include -#include #include #include #include @@ -62,6 +61,7 @@ struct bfin_crypto_crc { struct dma_desc_array *sg_cpu; /* virt addr of sg dma descriptors */ dma_addr_t sg_dma; /* phy addr of sg dma descriptors */ u8 *sg_mid_buf; + dma_addr_t sg_mid_dma; /* phy addr of sg mid buffer */ struct tasklet_struct done_task; struct crypto_queue queue; /* waiting requests */ @@ -196,7 +196,6 @@ static void bfin_crypto_crc_config_dma(struct bfin_crypto_crc *crc) dma_map_sg(crc->dev, ctx->sg, ctx->sg_nents, DMA_TO_DEVICE); for_each_sg(ctx->sg, sg, ctx->sg_nents, j) { - dma_config = DMAFLOW_ARRAY | RESTART | NDSIZE_3 | DMAEN | PSIZE_32; dma_addr = sg_dma_address(sg); /* deduce extra bytes in last sg */ if (sg_is_last(sg)) @@ -209,12 +208,29 @@ static void bfin_crypto_crc_config_dma(struct bfin_crypto_crc *crc) bytes in current sg buffer. Move addr of current sg and deduce the length of current sg. */ - memcpy(crc->sg_mid_buf +((i-1) << 2) + mid_dma_count, - (void *)dma_addr, + memcpy(crc->sg_mid_buf +(i << 2) + mid_dma_count, + sg_virt(sg), CHKSUM_DIGEST_SIZE - mid_dma_count); dma_addr += CHKSUM_DIGEST_SIZE - mid_dma_count; dma_count -= CHKSUM_DIGEST_SIZE - mid_dma_count; + + dma_config = DMAFLOW_ARRAY | RESTART | NDSIZE_3 | + DMAEN | PSIZE_32 | WDSIZE_32; + + /* setup new dma descriptor for next middle dma */ + crc->sg_cpu[i].start_addr = crc->sg_mid_dma + (i << 2); + crc->sg_cpu[i].cfg = dma_config; + crc->sg_cpu[i].x_count = 1; + crc->sg_cpu[i].x_modify = CHKSUM_DIGEST_SIZE; + dev_dbg(crc->dev, "%d: crc_dma: start_addr:0x%lx, " + "cfg:0x%lx, x_count:0x%lx, x_modify:0x%lx\n", + i, crc->sg_cpu[i].start_addr, + crc->sg_cpu[i].cfg, crc->sg_cpu[i].x_count, + crc->sg_cpu[i].x_modify); + i++; } + + dma_config = DMAFLOW_ARRAY | RESTART | NDSIZE_3 | DMAEN | PSIZE_32; /* chop current sg dma len to multiple of 32 bits */ mid_dma_count = dma_count % 4; dma_count &= ~0x3; @@ -245,24 +261,9 @@ static void bfin_crypto_crc_config_dma(struct bfin_crypto_crc *crc) if (mid_dma_count) { /* copy extra bytes to next middle dma buffer */ - dma_config = DMAFLOW_ARRAY | RESTART | NDSIZE_3 | - DMAEN | PSIZE_32 | WDSIZE_32; memcpy(crc->sg_mid_buf + (i << 2), - (void *)(dma_addr + (dma_count << 2)), + (u8*)sg_virt(sg) + (dma_count << 2), mid_dma_count); - /* setup new dma descriptor for next middle dma */ - crc->sg_cpu[i].start_addr = dma_map_single(crc->dev, - crc->sg_mid_buf + (i << 2), - CHKSUM_DIGEST_SIZE, DMA_TO_DEVICE); - crc->sg_cpu[i].cfg = dma_config; - crc->sg_cpu[i].x_count = 1; - crc->sg_cpu[i].x_modify = CHKSUM_DIGEST_SIZE; - dev_dbg(crc->dev, "%d: crc_dma: start_addr:0x%lx, " - "cfg:0x%lx, x_count:0x%lx, x_modify:0x%lx\n", - i, crc->sg_cpu[i].start_addr, - crc->sg_cpu[i].cfg, crc->sg_cpu[i].x_count, - crc->sg_cpu[i].x_modify); - i++; } } @@ -654,6 +655,8 @@ static int bfin_crypto_crc_probe(struct platform_device *pdev) * 1 last + 1 next dma descriptors */ crc->sg_mid_buf = (u8 *)(crc->sg_cpu + ((CRC_MAX_DMA_DESC + 1) << 1)); + crc->sg_mid_dma = crc->sg_dma + sizeof(struct dma_desc_array) + * ((CRC_MAX_DMA_DESC + 1) << 1); writel(0, &crc->regs->control); crc->poly = (u32)pdev->dev.platform_data; -- cgit v1.2.3 From 950e4e1c1b334c4975b91106f23fd343be3eb7a0 Mon Sep 17 00:00:00 2001 From: Jussi Kivilinna Date: Sat, 12 Apr 2014 15:35:29 +0300 Subject: crypto: testmgr - add empty and large test vectors for SHA-1, SHA-224, SHA-256, SHA-384 and SHA-512 Patch adds large test-vectors for SHA algorithms for better code coverage in optimized assembly implementations. Empty test-vectors are also added, as some crypto drivers appear to have special case handling for empty input. Signed-off-by: Jussi Kivilinna Signed-off-by: Herbert Xu --- crypto/testmgr.h | 728 ++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 721 insertions(+), 7 deletions(-) diff --git a/crypto/testmgr.h b/crypto/testmgr.h index c5d911dd8039..3c95bda11d51 100644 --- a/crypto/testmgr.h +++ b/crypto/testmgr.h @@ -487,10 +487,15 @@ static struct hash_testvec crct10dif_tv_template[] = { * SHA1 test vectors from from FIPS PUB 180-1 * Long vector from CAVS 5.0 */ -#define SHA1_TEST_VECTORS 4 +#define SHA1_TEST_VECTORS 6 static struct hash_testvec sha1_tv_template[] = { { + .plaintext = "", + .psize = 0, + .digest = "\xda\x39\xa3\xee\x5e\x6b\x4b\x0d\x32\x55" + "\xbf\xef\x95\x60\x18\x90\xaf\xd8\x07\x09", + }, { .plaintext = "abc", .psize = 3, .digest = "\xa9\x99\x3e\x36\x47\x06\x81\x6a\xba\x3e" @@ -534,6 +539,139 @@ static struct hash_testvec sha1_tv_template[] = { .psize = 64, .digest = "\xc8\x71\xf6\x9a\x63\xcc\xa9\x84\x84\x82" "\x64\xe7\x79\x95\x5d\xd7\x19\x41\x7c\x91", + }, { + .plaintext = "\x08\x9f\x13\xaa\x41\xd8\x4c\xe3" + "\x7a\x11\x85\x1c\xb3\x27\xbe\x55" + "\xec\x60\xf7\x8e\x02\x99\x30\xc7" + "\x3b\xd2\x69\x00\x74\x0b\xa2\x16" + "\xad\x44\xdb\x4f\xe6\x7d\x14\x88" + "\x1f\xb6\x2a\xc1\x58\xef\x63\xfa" + "\x91\x05\x9c\x33\xca\x3e\xd5\x6c" + "\x03\x77\x0e\xa5\x19\xb0\x47\xde" + "\x52\xe9\x80\x17\x8b\x22\xb9\x2d" + "\xc4\x5b\xf2\x66\xfd\x94\x08\x9f" + "\x36\xcd\x41\xd8\x6f\x06\x7a\x11" + "\xa8\x1c\xb3\x4a\xe1\x55\xec\x83" + "\x1a\x8e\x25\xbc\x30\xc7\x5e\xf5" + "\x69\x00\x97\x0b\xa2\x39\xd0\x44" + "\xdb\x72\x09\x7d\x14\xab\x1f\xb6" + "\x4d\xe4\x58\xef\x86\x1d\x91\x28" + "\xbf\x33\xca\x61\xf8\x6c\x03\x9a" + "\x0e\xa5\x3c\xd3\x47\xde\x75\x0c" + "\x80\x17\xae\x22\xb9\x50\xe7\x5b" + "\xf2\x89\x20\x94\x2b\xc2\x36\xcd" + "\x64\xfb\x6f\x06\x9d\x11\xa8\x3f" + "\xd6\x4a\xe1\x78\x0f\x83\x1a\xb1" + "\x25\xbc\x53\xea\x5e\xf5\x8c\x00" + "\x97\x2e\xc5\x39\xd0\x67\xfe\x72" + "\x09\xa0\x14\xab\x42\xd9\x4d\xe4" + "\x7b\x12\x86\x1d\xb4\x28\xbf\x56" + "\xed\x61\xf8\x8f\x03\x9a\x31\xc8" + "\x3c\xd3\x6a\x01\x75\x0c\xa3\x17" + "\xae\x45\xdc\x50\xe7\x7e\x15\x89" + "\x20\xb7\x2b\xc2\x59\xf0\x64\xfb" + "\x92\x06\x9d\x34\xcb\x3f\xd6\x6d" + "\x04\x78\x0f\xa6\x1a\xb1\x48\xdf" + "\x53\xea\x81\x18\x8c\x23\xba\x2e" + "\xc5\x5c\xf3\x67\xfe\x95\x09\xa0" + "\x37\xce\x42\xd9\x70\x07\x7b\x12" + "\xa9\x1d\xb4\x4b\xe2\x56\xed\x84" + "\x1b\x8f\x26\xbd\x31\xc8\x5f\xf6" + "\x6a\x01\x98\x0c\xa3\x3a\xd1\x45" + "\xdc\x73\x0a\x7e\x15\xac\x20\xb7" + "\x4e\xe5\x59\xf0\x87\x1e\x92\x29" + "\xc0\x34\xcb\x62\xf9\x6d\x04\x9b" + "\x0f\xa6\x3d\xd4\x48\xdf\x76\x0d" + "\x81\x18\xaf\x23\xba\x51\xe8\x5c" + "\xf3\x8a\x21\x95\x2c\xc3\x37\xce" + "\x65\xfc\x70\x07\x9e\x12\xa9\x40" + "\xd7\x4b\xe2\x79\x10\x84\x1b\xb2" + "\x26\xbd\x54\xeb\x5f\xf6\x8d\x01" + "\x98\x2f\xc6\x3a\xd1\x68\xff\x73" + "\x0a\xa1\x15\xac\x43\xda\x4e\xe5" + "\x7c\x13\x87\x1e\xb5\x29\xc0\x57" + "\xee\x62\xf9\x90\x04\x9b\x32\xc9" + "\x3d\xd4\x6b\x02\x76\x0d\xa4\x18" + "\xaf\x46\xdd\x51\xe8\x7f\x16\x8a" + "\x21\xb8\x2c\xc3\x5a\xf1\x65\xfc" + "\x93\x07\x9e\x35\xcc\x40\xd7\x6e" + "\x05\x79\x10\xa7\x1b\xb2\x49\xe0" + "\x54\xeb\x82\x19\x8d\x24\xbb\x2f" + "\xc6\x5d\xf4\x68\xff\x96\x0a\xa1" + "\x38\xcf\x43\xda\x71\x08\x7c\x13" + "\xaa\x1e\xb5\x4c\xe3\x57\xee\x85" + "\x1c\x90\x27\xbe\x32\xc9\x60\xf7" + "\x6b\x02\x99\x0d\xa4\x3b\xd2\x46" + "\xdd\x74\x0b\x7f\x16\xad\x21\xb8" + "\x4f\xe6\x5a\xf1\x88\x1f\x93\x2a" + "\xc1\x35\xcc\x63\xfa\x6e\x05\x9c" + "\x10\xa7\x3e\xd5\x49\xe0\x77\x0e" + "\x82\x19\xb0\x24\xbb\x52\xe9\x5d" + "\xf4\x8b\x22\x96\x2d\xc4\x38\xcf" + "\x66\xfd\x71\x08\x9f\x13\xaa\x41" + "\xd8\x4c\xe3\x7a\x11\x85\x1c\xb3" + "\x27\xbe\x55\xec\x60\xf7\x8e\x02" + "\x99\x30\xc7\x3b\xd2\x69\x00\x74" + "\x0b\xa2\x16\xad\x44\xdb\x4f\xe6" + "\x7d\x14\x88\x1f\xb6\x2a\xc1\x58" + "\xef\x63\xfa\x91\x05\x9c\x33\xca" + "\x3e\xd5\x6c\x03\x77\x0e\xa5\x19" + "\xb0\x47\xde\x52\xe9\x80\x17\x8b" + "\x22\xb9\x2d\xc4\x5b\xf2\x66\xfd" + "\x94\x08\x9f\x36\xcd\x41\xd8\x6f" + "\x06\x7a\x11\xa8\x1c\xb3\x4a\xe1" + "\x55\xec\x83\x1a\x8e\x25\xbc\x30" + "\xc7\x5e\xf5\x69\x00\x97\x0b\xa2" + "\x39\xd0\x44\xdb\x72\x09\x7d\x14" + "\xab\x1f\xb6\x4d\xe4\x58\xef\x86" + "\x1d\x91\x28\xbf\x33\xca\x61\xf8" + "\x6c\x03\x9a\x0e\xa5\x3c\xd3\x47" + "\xde\x75\x0c\x80\x17\xae\x22\xb9" + "\x50\xe7\x5b\xf2\x89\x20\x94\x2b" + "\xc2\x36\xcd\x64\xfb\x6f\x06\x9d" + "\x11\xa8\x3f\xd6\x4a\xe1\x78\x0f" + "\x83\x1a\xb1\x25\xbc\x53\xea\x5e" + "\xf5\x8c\x00\x97\x2e\xc5\x39\xd0" + "\x67\xfe\x72\x09\xa0\x14\xab\x42" + "\xd9\x4d\xe4\x7b\x12\x86\x1d\xb4" + "\x28\xbf\x56\xed\x61\xf8\x8f\x03" + "\x9a\x31\xc8\x3c\xd3\x6a\x01\x75" + "\x0c\xa3\x17\xae\x45\xdc\x50\xe7" + "\x7e\x15\x89\x20\xb7\x2b\xc2\x59" + "\xf0\x64\xfb\x92\x06\x9d\x34\xcb" + "\x3f\xd6\x6d\x04\x78\x0f\xa6\x1a" + "\xb1\x48\xdf\x53\xea\x81\x18\x8c" + "\x23\xba\x2e\xc5\x5c\xf3\x67\xfe" + "\x95\x09\xa0\x37\xce\x42\xd9\x70" + "\x07\x7b\x12\xa9\x1d\xb4\x4b\xe2" + "\x56\xed\x84\x1b\x8f\x26\xbd\x31" + "\xc8\x5f\xf6\x6a\x01\x98\x0c\xa3" + "\x3a\xd1\x45\xdc\x73\x0a\x7e\x15" + "\xac\x20\xb7\x4e\xe5\x59\xf0\x87" + "\x1e\x92\x29\xc0\x34\xcb\x62\xf9" + "\x6d\x04\x9b\x0f\xa6\x3d\xd4\x48" + "\xdf\x76\x0d\x81\x18\xaf\x23\xba" + "\x51\xe8\x5c\xf3\x8a\x21\x95\x2c" + "\xc3\x37\xce\x65\xfc\x70\x07\x9e" + "\x12\xa9\x40\xd7\x4b\xe2\x79\x10" + "\x84\x1b\xb2\x26\xbd\x54\xeb\x5f" + "\xf6\x8d\x01\x98\x2f\xc6\x3a\xd1" + "\x68\xff\x73\x0a\xa1\x15\xac\x43" + "\xda\x4e\xe5\x7c\x13\x87\x1e\xb5" + "\x29\xc0\x57\xee\x62\xf9\x90\x04" + "\x9b\x32\xc9\x3d\xd4\x6b\x02\x76" + "\x0d\xa4\x18\xaf\x46\xdd\x51\xe8" + "\x7f\x16\x8a\x21\xb8\x2c\xc3\x5a" + "\xf1\x65\xfc\x93\x07\x9e\x35\xcc" + "\x40\xd7\x6e\x05\x79\x10\xa7\x1b" + "\xb2\x49\xe0\x54\xeb\x82\x19\x8d" + "\x24\xbb\x2f\xc6\x5d\xf4\x68\xff" + "\x96\x0a\xa1\x38\xcf\x43\xda\x71" + "\x08\x7c\x13\xaa\x1e\xb5\x4c", + .psize = 1023, + .digest = "\xb8\xe3\x54\xed\xc5\xfc\xef\xa4" + "\x55\x73\x4a\x81\x99\xe4\x47\x2a" + "\x30\xd6\xc9\x85", } }; @@ -541,10 +679,17 @@ static struct hash_testvec sha1_tv_template[] = { /* * SHA224 test vectors from from FIPS PUB 180-2 */ -#define SHA224_TEST_VECTORS 3 +#define SHA224_TEST_VECTORS 5 static struct hash_testvec sha224_tv_template[] = { { + .plaintext = "", + .psize = 0, + .digest = "\xd1\x4a\x02\x8c\x2a\x3a\x2b\xc9" + "\x47\x61\x02\xbb\x28\x82\x34\xc4" + "\x15\xa2\xb0\x1f\x82\x8e\xa6\x2a" + "\xc5\xb3\xe4\x2f", + }, { .plaintext = "abc", .psize = 3, .digest = "\x23\x09\x7D\x22\x34\x05\xD8\x22" @@ -568,16 +713,157 @@ static struct hash_testvec sha224_tv_template[] = { "\x42\xfd\x10\x92\xaa\x4e\x04\x08" "\x58\xbb\xbb\xe8\xf8\x14\xa7\x0c" "\xef\x3b\xcb\x0e", + }, { + .plaintext = "\x08\x9f\x13\xaa\x41\xd8\x4c\xe3" + "\x7a\x11\x85\x1c\xb3\x27\xbe\x55" + "\xec\x60\xf7\x8e\x02\x99\x30\xc7" + "\x3b\xd2\x69\x00\x74\x0b\xa2\x16" + "\xad\x44\xdb\x4f\xe6\x7d\x14\x88" + "\x1f\xb6\x2a\xc1\x58\xef\x63\xfa" + "\x91\x05\x9c\x33\xca\x3e\xd5\x6c" + "\x03\x77\x0e\xa5\x19\xb0\x47\xde" + "\x52\xe9\x80\x17\x8b\x22\xb9\x2d" + "\xc4\x5b\xf2\x66\xfd\x94\x08\x9f" + "\x36\xcd\x41\xd8\x6f\x06\x7a\x11" + "\xa8\x1c\xb3\x4a\xe1\x55\xec\x83" + "\x1a\x8e\x25\xbc\x30\xc7\x5e\xf5" + "\x69\x00\x97\x0b\xa2\x39\xd0\x44" + "\xdb\x72\x09\x7d\x14\xab\x1f\xb6" + "\x4d\xe4\x58\xef\x86\x1d\x91\x28" + "\xbf\x33\xca\x61\xf8\x6c\x03\x9a" + "\x0e\xa5\x3c\xd3\x47\xde\x75\x0c" + "\x80\x17\xae\x22\xb9\x50\xe7\x5b" + "\xf2\x89\x20\x94\x2b\xc2\x36\xcd" + "\x64\xfb\x6f\x06\x9d\x11\xa8\x3f" + "\xd6\x4a\xe1\x78\x0f\x83\x1a\xb1" + "\x25\xbc\x53\xea\x5e\xf5\x8c\x00" + "\x97\x2e\xc5\x39\xd0\x67\xfe\x72" + "\x09\xa0\x14\xab\x42\xd9\x4d\xe4" + "\x7b\x12\x86\x1d\xb4\x28\xbf\x56" + "\xed\x61\xf8\x8f\x03\x9a\x31\xc8" + "\x3c\xd3\x6a\x01\x75\x0c\xa3\x17" + "\xae\x45\xdc\x50\xe7\x7e\x15\x89" + "\x20\xb7\x2b\xc2\x59\xf0\x64\xfb" + "\x92\x06\x9d\x34\xcb\x3f\xd6\x6d" + "\x04\x78\x0f\xa6\x1a\xb1\x48\xdf" + "\x53\xea\x81\x18\x8c\x23\xba\x2e" + "\xc5\x5c\xf3\x67\xfe\x95\x09\xa0" + "\x37\xce\x42\xd9\x70\x07\x7b\x12" + "\xa9\x1d\xb4\x4b\xe2\x56\xed\x84" + "\x1b\x8f\x26\xbd\x31\xc8\x5f\xf6" + "\x6a\x01\x98\x0c\xa3\x3a\xd1\x45" + "\xdc\x73\x0a\x7e\x15\xac\x20\xb7" + "\x4e\xe5\x59\xf0\x87\x1e\x92\x29" + "\xc0\x34\xcb\x62\xf9\x6d\x04\x9b" + "\x0f\xa6\x3d\xd4\x48\xdf\x76\x0d" + "\x81\x18\xaf\x23\xba\x51\xe8\x5c" + "\xf3\x8a\x21\x95\x2c\xc3\x37\xce" + "\x65\xfc\x70\x07\x9e\x12\xa9\x40" + "\xd7\x4b\xe2\x79\x10\x84\x1b\xb2" + "\x26\xbd\x54\xeb\x5f\xf6\x8d\x01" + "\x98\x2f\xc6\x3a\xd1\x68\xff\x73" + "\x0a\xa1\x15\xac\x43\xda\x4e\xe5" + "\x7c\x13\x87\x1e\xb5\x29\xc0\x57" + "\xee\x62\xf9\x90\x04\x9b\x32\xc9" + "\x3d\xd4\x6b\x02\x76\x0d\xa4\x18" + "\xaf\x46\xdd\x51\xe8\x7f\x16\x8a" + "\x21\xb8\x2c\xc3\x5a\xf1\x65\xfc" + "\x93\x07\x9e\x35\xcc\x40\xd7\x6e" + "\x05\x79\x10\xa7\x1b\xb2\x49\xe0" + "\x54\xeb\x82\x19\x8d\x24\xbb\x2f" + "\xc6\x5d\xf4\x68\xff\x96\x0a\xa1" + "\x38\xcf\x43\xda\x71\x08\x7c\x13" + "\xaa\x1e\xb5\x4c\xe3\x57\xee\x85" + "\x1c\x90\x27\xbe\x32\xc9\x60\xf7" + "\x6b\x02\x99\x0d\xa4\x3b\xd2\x46" + "\xdd\x74\x0b\x7f\x16\xad\x21\xb8" + "\x4f\xe6\x5a\xf1\x88\x1f\x93\x2a" + "\xc1\x35\xcc\x63\xfa\x6e\x05\x9c" + "\x10\xa7\x3e\xd5\x49\xe0\x77\x0e" + "\x82\x19\xb0\x24\xbb\x52\xe9\x5d" + "\xf4\x8b\x22\x96\x2d\xc4\x38\xcf" + "\x66\xfd\x71\x08\x9f\x13\xaa\x41" + "\xd8\x4c\xe3\x7a\x11\x85\x1c\xb3" + "\x27\xbe\x55\xec\x60\xf7\x8e\x02" + "\x99\x30\xc7\x3b\xd2\x69\x00\x74" + "\x0b\xa2\x16\xad\x44\xdb\x4f\xe6" + "\x7d\x14\x88\x1f\xb6\x2a\xc1\x58" + "\xef\x63\xfa\x91\x05\x9c\x33\xca" + "\x3e\xd5\x6c\x03\x77\x0e\xa5\x19" + "\xb0\x47\xde\x52\xe9\x80\x17\x8b" + "\x22\xb9\x2d\xc4\x5b\xf2\x66\xfd" + "\x94\x08\x9f\x36\xcd\x41\xd8\x6f" + "\x06\x7a\x11\xa8\x1c\xb3\x4a\xe1" + "\x55\xec\x83\x1a\x8e\x25\xbc\x30" + "\xc7\x5e\xf5\x69\x00\x97\x0b\xa2" + "\x39\xd0\x44\xdb\x72\x09\x7d\x14" + "\xab\x1f\xb6\x4d\xe4\x58\xef\x86" + "\x1d\x91\x28\xbf\x33\xca\x61\xf8" + "\x6c\x03\x9a\x0e\xa5\x3c\xd3\x47" + "\xde\x75\x0c\x80\x17\xae\x22\xb9" + "\x50\xe7\x5b\xf2\x89\x20\x94\x2b" + "\xc2\x36\xcd\x64\xfb\x6f\x06\x9d" + "\x11\xa8\x3f\xd6\x4a\xe1\x78\x0f" + "\x83\x1a\xb1\x25\xbc\x53\xea\x5e" + "\xf5\x8c\x00\x97\x2e\xc5\x39\xd0" + "\x67\xfe\x72\x09\xa0\x14\xab\x42" + "\xd9\x4d\xe4\x7b\x12\x86\x1d\xb4" + "\x28\xbf\x56\xed\x61\xf8\x8f\x03" + "\x9a\x31\xc8\x3c\xd3\x6a\x01\x75" + "\x0c\xa3\x17\xae\x45\xdc\x50\xe7" + "\x7e\x15\x89\x20\xb7\x2b\xc2\x59" + "\xf0\x64\xfb\x92\x06\x9d\x34\xcb" + "\x3f\xd6\x6d\x04\x78\x0f\xa6\x1a" + "\xb1\x48\xdf\x53\xea\x81\x18\x8c" + "\x23\xba\x2e\xc5\x5c\xf3\x67\xfe" + "\x95\x09\xa0\x37\xce\x42\xd9\x70" + "\x07\x7b\x12\xa9\x1d\xb4\x4b\xe2" + "\x56\xed\x84\x1b\x8f\x26\xbd\x31" + "\xc8\x5f\xf6\x6a\x01\x98\x0c\xa3" + "\x3a\xd1\x45\xdc\x73\x0a\x7e\x15" + "\xac\x20\xb7\x4e\xe5\x59\xf0\x87" + "\x1e\x92\x29\xc0\x34\xcb\x62\xf9" + "\x6d\x04\x9b\x0f\xa6\x3d\xd4\x48" + "\xdf\x76\x0d\x81\x18\xaf\x23\xba" + "\x51\xe8\x5c\xf3\x8a\x21\x95\x2c" + "\xc3\x37\xce\x65\xfc\x70\x07\x9e" + "\x12\xa9\x40\xd7\x4b\xe2\x79\x10" + "\x84\x1b\xb2\x26\xbd\x54\xeb\x5f" + "\xf6\x8d\x01\x98\x2f\xc6\x3a\xd1" + "\x68\xff\x73\x0a\xa1\x15\xac\x43" + "\xda\x4e\xe5\x7c\x13\x87\x1e\xb5" + "\x29\xc0\x57\xee\x62\xf9\x90\x04" + "\x9b\x32\xc9\x3d\xd4\x6b\x02\x76" + "\x0d\xa4\x18\xaf\x46\xdd\x51\xe8" + "\x7f\x16\x8a\x21\xb8\x2c\xc3\x5a" + "\xf1\x65\xfc\x93\x07\x9e\x35\xcc" + "\x40\xd7\x6e\x05\x79\x10\xa7\x1b" + "\xb2\x49\xe0\x54\xeb\x82\x19\x8d" + "\x24\xbb\x2f\xc6\x5d\xf4\x68\xff" + "\x96\x0a\xa1\x38\xcf\x43\xda\x71" + "\x08\x7c\x13\xaa\x1e\xb5\x4c", + .psize = 1023, + .digest = "\x98\x43\x07\x63\x75\xe0\xa7\x1c" + "\x78\xb1\x8b\xfd\x04\xf5\x2d\x91" + "\x20\x48\xa4\x28\xff\x55\xb1\xd3" + "\xe6\xf9\x4f\xcc", } }; /* * SHA256 test vectors from from NIST */ -#define SHA256_TEST_VECTORS 3 +#define SHA256_TEST_VECTORS 5 static struct hash_testvec sha256_tv_template[] = { { + .plaintext = "", + .psize = 0, + .digest = "\xe3\xb0\xc4\x42\x98\xfc\x1c\x14" + "\x9a\xfb\xf4\xc8\x99\x6f\xb9\x24" + "\x27\xae\x41\xe4\x64\x9b\x93\x4c" + "\xa4\x95\x99\x1b\x78\x52\xb8\x55", + }, { .plaintext = "abc", .psize = 3, .digest = "\xba\x78\x16\xbf\x8f\x01\xcf\xea" @@ -600,16 +886,159 @@ static struct hash_testvec sha256_tv_template[] = { "\x2c\x32\x29\x32\x19\xbb\xfb\xfa" "\xd6\xff\x94\xa3\x72\x91\x85\x66" "\x3b\xa7\x87\x77\x58\xa3\x40\x3a", + }, { + .plaintext = "\x08\x9f\x13\xaa\x41\xd8\x4c\xe3" + "\x7a\x11\x85\x1c\xb3\x27\xbe\x55" + "\xec\x60\xf7\x8e\x02\x99\x30\xc7" + "\x3b\xd2\x69\x00\x74\x0b\xa2\x16" + "\xad\x44\xdb\x4f\xe6\x7d\x14\x88" + "\x1f\xb6\x2a\xc1\x58\xef\x63\xfa" + "\x91\x05\x9c\x33\xca\x3e\xd5\x6c" + "\x03\x77\x0e\xa5\x19\xb0\x47\xde" + "\x52\xe9\x80\x17\x8b\x22\xb9\x2d" + "\xc4\x5b\xf2\x66\xfd\x94\x08\x9f" + "\x36\xcd\x41\xd8\x6f\x06\x7a\x11" + "\xa8\x1c\xb3\x4a\xe1\x55\xec\x83" + "\x1a\x8e\x25\xbc\x30\xc7\x5e\xf5" + "\x69\x00\x97\x0b\xa2\x39\xd0\x44" + "\xdb\x72\x09\x7d\x14\xab\x1f\xb6" + "\x4d\xe4\x58\xef\x86\x1d\x91\x28" + "\xbf\x33\xca\x61\xf8\x6c\x03\x9a" + "\x0e\xa5\x3c\xd3\x47\xde\x75\x0c" + "\x80\x17\xae\x22\xb9\x50\xe7\x5b" + "\xf2\x89\x20\x94\x2b\xc2\x36\xcd" + "\x64\xfb\x6f\x06\x9d\x11\xa8\x3f" + "\xd6\x4a\xe1\x78\x0f\x83\x1a\xb1" + "\x25\xbc\x53\xea\x5e\xf5\x8c\x00" + "\x97\x2e\xc5\x39\xd0\x67\xfe\x72" + "\x09\xa0\x14\xab\x42\xd9\x4d\xe4" + "\x7b\x12\x86\x1d\xb4\x28\xbf\x56" + "\xed\x61\xf8\x8f\x03\x9a\x31\xc8" + "\x3c\xd3\x6a\x01\x75\x0c\xa3\x17" + "\xae\x45\xdc\x50\xe7\x7e\x15\x89" + "\x20\xb7\x2b\xc2\x59\xf0\x64\xfb" + "\x92\x06\x9d\x34\xcb\x3f\xd6\x6d" + "\x04\x78\x0f\xa6\x1a\xb1\x48\xdf" + "\x53\xea\x81\x18\x8c\x23\xba\x2e" + "\xc5\x5c\xf3\x67\xfe\x95\x09\xa0" + "\x37\xce\x42\xd9\x70\x07\x7b\x12" + "\xa9\x1d\xb4\x4b\xe2\x56\xed\x84" + "\x1b\x8f\x26\xbd\x31\xc8\x5f\xf6" + "\x6a\x01\x98\x0c\xa3\x3a\xd1\x45" + "\xdc\x73\x0a\x7e\x15\xac\x20\xb7" + "\x4e\xe5\x59\xf0\x87\x1e\x92\x29" + "\xc0\x34\xcb\x62\xf9\x6d\x04\x9b" + "\x0f\xa6\x3d\xd4\x48\xdf\x76\x0d" + "\x81\x18\xaf\x23\xba\x51\xe8\x5c" + "\xf3\x8a\x21\x95\x2c\xc3\x37\xce" + "\x65\xfc\x70\x07\x9e\x12\xa9\x40" + "\xd7\x4b\xe2\x79\x10\x84\x1b\xb2" + "\x26\xbd\x54\xeb\x5f\xf6\x8d\x01" + "\x98\x2f\xc6\x3a\xd1\x68\xff\x73" + "\x0a\xa1\x15\xac\x43\xda\x4e\xe5" + "\x7c\x13\x87\x1e\xb5\x29\xc0\x57" + "\xee\x62\xf9\x90\x04\x9b\x32\xc9" + "\x3d\xd4\x6b\x02\x76\x0d\xa4\x18" + "\xaf\x46\xdd\x51\xe8\x7f\x16\x8a" + "\x21\xb8\x2c\xc3\x5a\xf1\x65\xfc" + "\x93\x07\x9e\x35\xcc\x40\xd7\x6e" + "\x05\x79\x10\xa7\x1b\xb2\x49\xe0" + "\x54\xeb\x82\x19\x8d\x24\xbb\x2f" + "\xc6\x5d\xf4\x68\xff\x96\x0a\xa1" + "\x38\xcf\x43\xda\x71\x08\x7c\x13" + "\xaa\x1e\xb5\x4c\xe3\x57\xee\x85" + "\x1c\x90\x27\xbe\x32\xc9\x60\xf7" + "\x6b\x02\x99\x0d\xa4\x3b\xd2\x46" + "\xdd\x74\x0b\x7f\x16\xad\x21\xb8" + "\x4f\xe6\x5a\xf1\x88\x1f\x93\x2a" + "\xc1\x35\xcc\x63\xfa\x6e\x05\x9c" + "\x10\xa7\x3e\xd5\x49\xe0\x77\x0e" + "\x82\x19\xb0\x24\xbb\x52\xe9\x5d" + "\xf4\x8b\x22\x96\x2d\xc4\x38\xcf" + "\x66\xfd\x71\x08\x9f\x13\xaa\x41" + "\xd8\x4c\xe3\x7a\x11\x85\x1c\xb3" + "\x27\xbe\x55\xec\x60\xf7\x8e\x02" + "\x99\x30\xc7\x3b\xd2\x69\x00\x74" + "\x0b\xa2\x16\xad\x44\xdb\x4f\xe6" + "\x7d\x14\x88\x1f\xb6\x2a\xc1\x58" + "\xef\x63\xfa\x91\x05\x9c\x33\xca" + "\x3e\xd5\x6c\x03\x77\x0e\xa5\x19" + "\xb0\x47\xde\x52\xe9\x80\x17\x8b" + "\x22\xb9\x2d\xc4\x5b\xf2\x66\xfd" + "\x94\x08\x9f\x36\xcd\x41\xd8\x6f" + "\x06\x7a\x11\xa8\x1c\xb3\x4a\xe1" + "\x55\xec\x83\x1a\x8e\x25\xbc\x30" + "\xc7\x5e\xf5\x69\x00\x97\x0b\xa2" + "\x39\xd0\x44\xdb\x72\x09\x7d\x14" + "\xab\x1f\xb6\x4d\xe4\x58\xef\x86" + "\x1d\x91\x28\xbf\x33\xca\x61\xf8" + "\x6c\x03\x9a\x0e\xa5\x3c\xd3\x47" + "\xde\x75\x0c\x80\x17\xae\x22\xb9" + "\x50\xe7\x5b\xf2\x89\x20\x94\x2b" + "\xc2\x36\xcd\x64\xfb\x6f\x06\x9d" + "\x11\xa8\x3f\xd6\x4a\xe1\x78\x0f" + "\x83\x1a\xb1\x25\xbc\x53\xea\x5e" + "\xf5\x8c\x00\x97\x2e\xc5\x39\xd0" + "\x67\xfe\x72\x09\xa0\x14\xab\x42" + "\xd9\x4d\xe4\x7b\x12\x86\x1d\xb4" + "\x28\xbf\x56\xed\x61\xf8\x8f\x03" + "\x9a\x31\xc8\x3c\xd3\x6a\x01\x75" + "\x0c\xa3\x17\xae\x45\xdc\x50\xe7" + "\x7e\x15\x89\x20\xb7\x2b\xc2\x59" + "\xf0\x64\xfb\x92\x06\x9d\x34\xcb" + "\x3f\xd6\x6d\x04\x78\x0f\xa6\x1a" + "\xb1\x48\xdf\x53\xea\x81\x18\x8c" + "\x23\xba\x2e\xc5\x5c\xf3\x67\xfe" + "\x95\x09\xa0\x37\xce\x42\xd9\x70" + "\x07\x7b\x12\xa9\x1d\xb4\x4b\xe2" + "\x56\xed\x84\x1b\x8f\x26\xbd\x31" + "\xc8\x5f\xf6\x6a\x01\x98\x0c\xa3" + "\x3a\xd1\x45\xdc\x73\x0a\x7e\x15" + "\xac\x20\xb7\x4e\xe5\x59\xf0\x87" + "\x1e\x92\x29\xc0\x34\xcb\x62\xf9" + "\x6d\x04\x9b\x0f\xa6\x3d\xd4\x48" + "\xdf\x76\x0d\x81\x18\xaf\x23\xba" + "\x51\xe8\x5c\xf3\x8a\x21\x95\x2c" + "\xc3\x37\xce\x65\xfc\x70\x07\x9e" + "\x12\xa9\x40\xd7\x4b\xe2\x79\x10" + "\x84\x1b\xb2\x26\xbd\x54\xeb\x5f" + "\xf6\x8d\x01\x98\x2f\xc6\x3a\xd1" + "\x68\xff\x73\x0a\xa1\x15\xac\x43" + "\xda\x4e\xe5\x7c\x13\x87\x1e\xb5" + "\x29\xc0\x57\xee\x62\xf9\x90\x04" + "\x9b\x32\xc9\x3d\xd4\x6b\x02\x76" + "\x0d\xa4\x18\xaf\x46\xdd\x51\xe8" + "\x7f\x16\x8a\x21\xb8\x2c\xc3\x5a" + "\xf1\x65\xfc\x93\x07\x9e\x35\xcc" + "\x40\xd7\x6e\x05\x79\x10\xa7\x1b" + "\xb2\x49\xe0\x54\xeb\x82\x19\x8d" + "\x24\xbb\x2f\xc6\x5d\xf4\x68\xff" + "\x96\x0a\xa1\x38\xcf\x43\xda\x71" + "\x08\x7c\x13\xaa\x1e\xb5\x4c", + .psize = 1023, + .digest = "\xc5\xce\x0c\xca\x01\x4f\x53\x3a" + "\x32\x32\x17\xcc\xd4\x6a\x71\xa9" + "\xf3\xed\x50\x10\x64\x8e\x06\xbe" + "\x9b\x4a\xa6\xbb\x05\x89\x59\x51", } }; /* * SHA384 test vectors from from NIST and kerneli */ -#define SHA384_TEST_VECTORS 4 +#define SHA384_TEST_VECTORS 6 static struct hash_testvec sha384_tv_template[] = { { + .plaintext = "", + .psize = 0, + .digest = "\x38\xb0\x60\xa7\x51\xac\x96\x38" + "\x4c\xd9\x32\x7e\xb1\xb1\xe3\x6a" + "\x21\xfd\xb7\x11\x14\xbe\x07\x43" + "\x4c\x0c\xc7\xbf\x63\xf6\xe1\xda" + "\x27\x4e\xde\xbf\xe7\x6f\x65\xfb" + "\xd5\x1a\xd2\xf1\x48\x98\xb9\x5b", + }, { .plaintext= "abc", .psize = 3, .digest = "\xcb\x00\x75\x3f\x45\xa3\x5e\x8b" @@ -649,16 +1078,163 @@ static struct hash_testvec sha384_tv_template[] = { "\xc9\x38\xe2\xd1\x99\xe8\xbe\xa4", .np = 4, .tap = { 26, 26, 26, 26 } - }, + }, { + .plaintext = "\x08\x9f\x13\xaa\x41\xd8\x4c\xe3" + "\x7a\x11\x85\x1c\xb3\x27\xbe\x55" + "\xec\x60\xf7\x8e\x02\x99\x30\xc7" + "\x3b\xd2\x69\x00\x74\x0b\xa2\x16" + "\xad\x44\xdb\x4f\xe6\x7d\x14\x88" + "\x1f\xb6\x2a\xc1\x58\xef\x63\xfa" + "\x91\x05\x9c\x33\xca\x3e\xd5\x6c" + "\x03\x77\x0e\xa5\x19\xb0\x47\xde" + "\x52\xe9\x80\x17\x8b\x22\xb9\x2d" + "\xc4\x5b\xf2\x66\xfd\x94\x08\x9f" + "\x36\xcd\x41\xd8\x6f\x06\x7a\x11" + "\xa8\x1c\xb3\x4a\xe1\x55\xec\x83" + "\x1a\x8e\x25\xbc\x30\xc7\x5e\xf5" + "\x69\x00\x97\x0b\xa2\x39\xd0\x44" + "\xdb\x72\x09\x7d\x14\xab\x1f\xb6" + "\x4d\xe4\x58\xef\x86\x1d\x91\x28" + "\xbf\x33\xca\x61\xf8\x6c\x03\x9a" + "\x0e\xa5\x3c\xd3\x47\xde\x75\x0c" + "\x80\x17\xae\x22\xb9\x50\xe7\x5b" + "\xf2\x89\x20\x94\x2b\xc2\x36\xcd" + "\x64\xfb\x6f\x06\x9d\x11\xa8\x3f" + "\xd6\x4a\xe1\x78\x0f\x83\x1a\xb1" + "\x25\xbc\x53\xea\x5e\xf5\x8c\x00" + "\x97\x2e\xc5\x39\xd0\x67\xfe\x72" + "\x09\xa0\x14\xab\x42\xd9\x4d\xe4" + "\x7b\x12\x86\x1d\xb4\x28\xbf\x56" + "\xed\x61\xf8\x8f\x03\x9a\x31\xc8" + "\x3c\xd3\x6a\x01\x75\x0c\xa3\x17" + "\xae\x45\xdc\x50\xe7\x7e\x15\x89" + "\x20\xb7\x2b\xc2\x59\xf0\x64\xfb" + "\x92\x06\x9d\x34\xcb\x3f\xd6\x6d" + "\x04\x78\x0f\xa6\x1a\xb1\x48\xdf" + "\x53\xea\x81\x18\x8c\x23\xba\x2e" + "\xc5\x5c\xf3\x67\xfe\x95\x09\xa0" + "\x37\xce\x42\xd9\x70\x07\x7b\x12" + "\xa9\x1d\xb4\x4b\xe2\x56\xed\x84" + "\x1b\x8f\x26\xbd\x31\xc8\x5f\xf6" + "\x6a\x01\x98\x0c\xa3\x3a\xd1\x45" + "\xdc\x73\x0a\x7e\x15\xac\x20\xb7" + "\x4e\xe5\x59\xf0\x87\x1e\x92\x29" + "\xc0\x34\xcb\x62\xf9\x6d\x04\x9b" + "\x0f\xa6\x3d\xd4\x48\xdf\x76\x0d" + "\x81\x18\xaf\x23\xba\x51\xe8\x5c" + "\xf3\x8a\x21\x95\x2c\xc3\x37\xce" + "\x65\xfc\x70\x07\x9e\x12\xa9\x40" + "\xd7\x4b\xe2\x79\x10\x84\x1b\xb2" + "\x26\xbd\x54\xeb\x5f\xf6\x8d\x01" + "\x98\x2f\xc6\x3a\xd1\x68\xff\x73" + "\x0a\xa1\x15\xac\x43\xda\x4e\xe5" + "\x7c\x13\x87\x1e\xb5\x29\xc0\x57" + "\xee\x62\xf9\x90\x04\x9b\x32\xc9" + "\x3d\xd4\x6b\x02\x76\x0d\xa4\x18" + "\xaf\x46\xdd\x51\xe8\x7f\x16\x8a" + "\x21\xb8\x2c\xc3\x5a\xf1\x65\xfc" + "\x93\x07\x9e\x35\xcc\x40\xd7\x6e" + "\x05\x79\x10\xa7\x1b\xb2\x49\xe0" + "\x54\xeb\x82\x19\x8d\x24\xbb\x2f" + "\xc6\x5d\xf4\x68\xff\x96\x0a\xa1" + "\x38\xcf\x43\xda\x71\x08\x7c\x13" + "\xaa\x1e\xb5\x4c\xe3\x57\xee\x85" + "\x1c\x90\x27\xbe\x32\xc9\x60\xf7" + "\x6b\x02\x99\x0d\xa4\x3b\xd2\x46" + "\xdd\x74\x0b\x7f\x16\xad\x21\xb8" + "\x4f\xe6\x5a\xf1\x88\x1f\x93\x2a" + "\xc1\x35\xcc\x63\xfa\x6e\x05\x9c" + "\x10\xa7\x3e\xd5\x49\xe0\x77\x0e" + "\x82\x19\xb0\x24\xbb\x52\xe9\x5d" + "\xf4\x8b\x22\x96\x2d\xc4\x38\xcf" + "\x66\xfd\x71\x08\x9f\x13\xaa\x41" + "\xd8\x4c\xe3\x7a\x11\x85\x1c\xb3" + "\x27\xbe\x55\xec\x60\xf7\x8e\x02" + "\x99\x30\xc7\x3b\xd2\x69\x00\x74" + "\x0b\xa2\x16\xad\x44\xdb\x4f\xe6" + "\x7d\x14\x88\x1f\xb6\x2a\xc1\x58" + "\xef\x63\xfa\x91\x05\x9c\x33\xca" + "\x3e\xd5\x6c\x03\x77\x0e\xa5\x19" + "\xb0\x47\xde\x52\xe9\x80\x17\x8b" + "\x22\xb9\x2d\xc4\x5b\xf2\x66\xfd" + "\x94\x08\x9f\x36\xcd\x41\xd8\x6f" + "\x06\x7a\x11\xa8\x1c\xb3\x4a\xe1" + "\x55\xec\x83\x1a\x8e\x25\xbc\x30" + "\xc7\x5e\xf5\x69\x00\x97\x0b\xa2" + "\x39\xd0\x44\xdb\x72\x09\x7d\x14" + "\xab\x1f\xb6\x4d\xe4\x58\xef\x86" + "\x1d\x91\x28\xbf\x33\xca\x61\xf8" + "\x6c\x03\x9a\x0e\xa5\x3c\xd3\x47" + "\xde\x75\x0c\x80\x17\xae\x22\xb9" + "\x50\xe7\x5b\xf2\x89\x20\x94\x2b" + "\xc2\x36\xcd\x64\xfb\x6f\x06\x9d" + "\x11\xa8\x3f\xd6\x4a\xe1\x78\x0f" + "\x83\x1a\xb1\x25\xbc\x53\xea\x5e" + "\xf5\x8c\x00\x97\x2e\xc5\x39\xd0" + "\x67\xfe\x72\x09\xa0\x14\xab\x42" + "\xd9\x4d\xe4\x7b\x12\x86\x1d\xb4" + "\x28\xbf\x56\xed\x61\xf8\x8f\x03" + "\x9a\x31\xc8\x3c\xd3\x6a\x01\x75" + "\x0c\xa3\x17\xae\x45\xdc\x50\xe7" + "\x7e\x15\x89\x20\xb7\x2b\xc2\x59" + "\xf0\x64\xfb\x92\x06\x9d\x34\xcb" + "\x3f\xd6\x6d\x04\x78\x0f\xa6\x1a" + "\xb1\x48\xdf\x53\xea\x81\x18\x8c" + "\x23\xba\x2e\xc5\x5c\xf3\x67\xfe" + "\x95\x09\xa0\x37\xce\x42\xd9\x70" + "\x07\x7b\x12\xa9\x1d\xb4\x4b\xe2" + "\x56\xed\x84\x1b\x8f\x26\xbd\x31" + "\xc8\x5f\xf6\x6a\x01\x98\x0c\xa3" + "\x3a\xd1\x45\xdc\x73\x0a\x7e\x15" + "\xac\x20\xb7\x4e\xe5\x59\xf0\x87" + "\x1e\x92\x29\xc0\x34\xcb\x62\xf9" + "\x6d\x04\x9b\x0f\xa6\x3d\xd4\x48" + "\xdf\x76\x0d\x81\x18\xaf\x23\xba" + "\x51\xe8\x5c\xf3\x8a\x21\x95\x2c" + "\xc3\x37\xce\x65\xfc\x70\x07\x9e" + "\x12\xa9\x40\xd7\x4b\xe2\x79\x10" + "\x84\x1b\xb2\x26\xbd\x54\xeb\x5f" + "\xf6\x8d\x01\x98\x2f\xc6\x3a\xd1" + "\x68\xff\x73\x0a\xa1\x15\xac\x43" + "\xda\x4e\xe5\x7c\x13\x87\x1e\xb5" + "\x29\xc0\x57\xee\x62\xf9\x90\x04" + "\x9b\x32\xc9\x3d\xd4\x6b\x02\x76" + "\x0d\xa4\x18\xaf\x46\xdd\x51\xe8" + "\x7f\x16\x8a\x21\xb8\x2c\xc3\x5a" + "\xf1\x65\xfc\x93\x07\x9e\x35\xcc" + "\x40\xd7\x6e\x05\x79\x10\xa7\x1b" + "\xb2\x49\xe0\x54\xeb\x82\x19\x8d" + "\x24\xbb\x2f\xc6\x5d\xf4\x68\xff" + "\x96\x0a\xa1\x38\xcf\x43\xda\x71" + "\x08\x7c\x13\xaa\x1e\xb5\x4c", + .psize = 1023, + .digest = "\x4d\x97\x23\xc8\xea\x7a\x7c\x15" + "\xb8\xff\x97\x9c\xf5\x13\x4f\x31" + "\xde\x67\xf7\x24\x73\xcd\x70\x1c" + "\x03\x4a\xba\x8a\x87\x49\xfe\xdc" + "\x75\x29\x62\x83\xae\x3f\x17\xab" + "\xfd\x10\x4d\x8e\x17\x1c\x1f\xca", + } }; /* * SHA512 test vectors from from NIST and kerneli */ -#define SHA512_TEST_VECTORS 4 +#define SHA512_TEST_VECTORS 6 static struct hash_testvec sha512_tv_template[] = { { + .plaintext = "", + .psize = 0, + .digest = "\xcf\x83\xe1\x35\x7e\xef\xb8\xbd" + "\xf1\x54\x28\x50\xd6\x6d\x80\x07" + "\xd6\x20\xe4\x05\x0b\x57\x15\xdc" + "\x83\xf4\xa9\x21\xd3\x6c\xe9\xce" + "\x47\xd0\xd1\x3c\x5d\x85\xf2\xb0" + "\xff\x83\x18\xd2\x87\x7e\xec\x2f" + "\x63\xb9\x31\xbd\x47\x41\x7a\x81" + "\xa5\x38\x32\x7a\xf9\x27\xda\x3e", + }, { .plaintext = "abc", .psize = 3, .digest = "\xdd\xaf\x35\xa1\x93\x61\x7a\xba" @@ -706,7 +1282,145 @@ static struct hash_testvec sha512_tv_template[] = { "\xed\xb4\x19\x87\x23\x28\x50\xc9", .np = 4, .tap = { 26, 26, 26, 26 } - }, + }, { + .plaintext = "\x08\x9f\x13\xaa\x41\xd8\x4c\xe3" + "\x7a\x11\x85\x1c\xb3\x27\xbe\x55" + "\xec\x60\xf7\x8e\x02\x99\x30\xc7" + "\x3b\xd2\x69\x00\x74\x0b\xa2\x16" + "\xad\x44\xdb\x4f\xe6\x7d\x14\x88" + "\x1f\xb6\x2a\xc1\x58\xef\x63\xfa" + "\x91\x05\x9c\x33\xca\x3e\xd5\x6c" + "\x03\x77\x0e\xa5\x19\xb0\x47\xde" + "\x52\xe9\x80\x17\x8b\x22\xb9\x2d" + "\xc4\x5b\xf2\x66\xfd\x94\x08\x9f" + "\x36\xcd\x41\xd8\x6f\x06\x7a\x11" + "\xa8\x1c\xb3\x4a\xe1\x55\xec\x83" + "\x1a\x8e\x25\xbc\x30\xc7\x5e\xf5" + "\x69\x00\x97\x0b\xa2\x39\xd0\x44" + "\xdb\x72\x09\x7d\x14\xab\x1f\xb6" + "\x4d\xe4\x58\xef\x86\x1d\x91\x28" + "\xbf\x33\xca\x61\xf8\x6c\x03\x9a" + "\x0e\xa5\x3c\xd3\x47\xde\x75\x0c" + "\x80\x17\xae\x22\xb9\x50\xe7\x5b" + "\xf2\x89\x20\x94\x2b\xc2\x36\xcd" + "\x64\xfb\x6f\x06\x9d\x11\xa8\x3f" + "\xd6\x4a\xe1\x78\x0f\x83\x1a\xb1" + "\x25\xbc\x53\xea\x5e\xf5\x8c\x00" + "\x97\x2e\xc5\x39\xd0\x67\xfe\x72" + "\x09\xa0\x14\xab\x42\xd9\x4d\xe4" + "\x7b\x12\x86\x1d\xb4\x28\xbf\x56" + "\xed\x61\xf8\x8f\x03\x9a\x31\xc8" + "\x3c\xd3\x6a\x01\x75\x0c\xa3\x17" + "\xae\x45\xdc\x50\xe7\x7e\x15\x89" + "\x20\xb7\x2b\xc2\x59\xf0\x64\xfb" + "\x92\x06\x9d\x34\xcb\x3f\xd6\x6d" + "\x04\x78\x0f\xa6\x1a\xb1\x48\xdf" + "\x53\xea\x81\x18\x8c\x23\xba\x2e" + "\xc5\x5c\xf3\x67\xfe\x95\x09\xa0" + "\x37\xce\x42\xd9\x70\x07\x7b\x12" + "\xa9\x1d\xb4\x4b\xe2\x56\xed\x84" + "\x1b\x8f\x26\xbd\x31\xc8\x5f\xf6" + "\x6a\x01\x98\x0c\xa3\x3a\xd1\x45" + "\xdc\x73\x0a\x7e\x15\xac\x20\xb7" + "\x4e\xe5\x59\xf0\x87\x1e\x92\x29" + "\xc0\x34\xcb\x62\xf9\x6d\x04\x9b" + "\x0f\xa6\x3d\xd4\x48\xdf\x76\x0d" + "\x81\x18\xaf\x23\xba\x51\xe8\x5c" + "\xf3\x8a\x21\x95\x2c\xc3\x37\xce" + "\x65\xfc\x70\x07\x9e\x12\xa9\x40" + "\xd7\x4b\xe2\x79\x10\x84\x1b\xb2" + "\x26\xbd\x54\xeb\x5f\xf6\x8d\x01" + "\x98\x2f\xc6\x3a\xd1\x68\xff\x73" + "\x0a\xa1\x15\xac\x43\xda\x4e\xe5" + "\x7c\x13\x87\x1e\xb5\x29\xc0\x57" + "\xee\x62\xf9\x90\x04\x9b\x32\xc9" + "\x3d\xd4\x6b\x02\x76\x0d\xa4\x18" + "\xaf\x46\xdd\x51\xe8\x7f\x16\x8a" + "\x21\xb8\x2c\xc3\x5a\xf1\x65\xfc" + "\x93\x07\x9e\x35\xcc\x40\xd7\x6e" + "\x05\x79\x10\xa7\x1b\xb2\x49\xe0" + "\x54\xeb\x82\x19\x8d\x24\xbb\x2f" + "\xc6\x5d\xf4\x68\xff\x96\x0a\xa1" + "\x38\xcf\x43\xda\x71\x08\x7c\x13" + "\xaa\x1e\xb5\x4c\xe3\x57\xee\x85" + "\x1c\x90\x27\xbe\x32\xc9\x60\xf7" + "\x6b\x02\x99\x0d\xa4\x3b\xd2\x46" + "\xdd\x74\x0b\x7f\x16\xad\x21\xb8" + "\x4f\xe6\x5a\xf1\x88\x1f\x93\x2a" + "\xc1\x35\xcc\x63\xfa\x6e\x05\x9c" + "\x10\xa7\x3e\xd5\x49\xe0\x77\x0e" + "\x82\x19\xb0\x24\xbb\x52\xe9\x5d" + "\xf4\x8b\x22\x96\x2d\xc4\x38\xcf" + "\x66\xfd\x71\x08\x9f\x13\xaa\x41" + "\xd8\x4c\xe3\x7a\x11\x85\x1c\xb3" + "\x27\xbe\x55\xec\x60\xf7\x8e\x02" + "\x99\x30\xc7\x3b\xd2\x69\x00\x74" + "\x0b\xa2\x16\xad\x44\xdb\x4f\xe6" + "\x7d\x14\x88\x1f\xb6\x2a\xc1\x58" + "\xef\x63\xfa\x91\x05\x9c\x33\xca" + "\x3e\xd5\x6c\x03\x77\x0e\xa5\x19" + "\xb0\x47\xde\x52\xe9\x80\x17\x8b" + "\x22\xb9\x2d\xc4\x5b\xf2\x66\xfd" + "\x94\x08\x9f\x36\xcd\x41\xd8\x6f" + "\x06\x7a\x11\xa8\x1c\xb3\x4a\xe1" + "\x55\xec\x83\x1a\x8e\x25\xbc\x30" + "\xc7\x5e\xf5\x69\x00\x97\x0b\xa2" + "\x39\xd0\x44\xdb\x72\x09\x7d\x14" + "\xab\x1f\xb6\x4d\xe4\x58\xef\x86" + "\x1d\x91\x28\xbf\x33\xca\x61\xf8" + "\x6c\x03\x9a\x0e\xa5\x3c\xd3\x47" + "\xde\x75\x0c\x80\x17\xae\x22\xb9" + "\x50\xe7\x5b\xf2\x89\x20\x94\x2b" + "\xc2\x36\xcd\x64\xfb\x6f\x06\x9d" + "\x11\xa8\x3f\xd6\x4a\xe1\x78\x0f" + "\x83\x1a\xb1\x25\xbc\x53\xea\x5e" + "\xf5\x8c\x00\x97\x2e\xc5\x39\xd0" + "\x67\xfe\x72\x09\xa0\x14\xab\x42" + "\xd9\x4d\xe4\x7b\x12\x86\x1d\xb4" + "\x28\xbf\x56\xed\x61\xf8\x8f\x03" + "\x9a\x31\xc8\x3c\xd3\x6a\x01\x75" + "\x0c\xa3\x17\xae\x45\xdc\x50\xe7" + "\x7e\x15\x89\x20\xb7\x2b\xc2\x59" + "\xf0\x64\xfb\x92\x06\x9d\x34\xcb" + "\x3f\xd6\x6d\x04\x78\x0f\xa6\x1a" + "\xb1\x48\xdf\x53\xea\x81\x18\x8c" + "\x23\xba\x2e\xc5\x5c\xf3\x67\xfe" + "\x95\x09\xa0\x37\xce\x42\xd9\x70" + "\x07\x7b\x12\xa9\x1d\xb4\x4b\xe2" + "\x56\xed\x84\x1b\x8f\x26\xbd\x31" + "\xc8\x5f\xf6\x6a\x01\x98\x0c\xa3" + "\x3a\xd1\x45\xdc\x73\x0a\x7e\x15" + "\xac\x20\xb7\x4e\xe5\x59\xf0\x87" + "\x1e\x92\x29\xc0\x34\xcb\x62\xf9" + "\x6d\x04\x9b\x0f\xa6\x3d\xd4\x48" + "\xdf\x76\x0d\x81\x18\xaf\x23\xba" + "\x51\xe8\x5c\xf3\x8a\x21\x95\x2c" + "\xc3\x37\xce\x65\xfc\x70\x07\x9e" + "\x12\xa9\x40\xd7\x4b\xe2\x79\x10" + "\x84\x1b\xb2\x26\xbd\x54\xeb\x5f" + "\xf6\x8d\x01\x98\x2f\xc6\x3a\xd1" + "\x68\xff\x73\x0a\xa1\x15\xac\x43" + "\xda\x4e\xe5\x7c\x13\x87\x1e\xb5" + "\x29\xc0\x57\xee\x62\xf9\x90\x04" + "\x9b\x32\xc9\x3d\xd4\x6b\x02\x76" + "\x0d\xa4\x18\xaf\x46\xdd\x51\xe8" + "\x7f\x16\x8a\x21\xb8\x2c\xc3\x5a" + "\xf1\x65\xfc\x93\x07\x9e\x35\xcc" + "\x40\xd7\x6e\x05\x79\x10\xa7\x1b" + "\xb2\x49\xe0\x54\xeb\x82\x19\x8d" + "\x24\xbb\x2f\xc6\x5d\xf4\x68\xff" + "\x96\x0a\xa1\x38\xcf\x43\xda\x71" + "\x08\x7c\x13\xaa\x1e\xb5\x4c", + .psize = 1023, + .digest = "\x76\xc9\xd4\x91\x7a\x5f\x0f\xaa" + "\x13\x39\xf3\x01\x7a\xfa\xe5\x41" + "\x5f\x0b\xf8\xeb\x32\xfc\xbf\xb0" + "\xfa\x8c\xcd\x17\x83\xe2\xfa\xeb" + "\x1c\x19\xde\xe2\x75\xdc\x34\x64" + "\x5f\x35\x9c\x61\x2f\x10\xf9\xec" + "\x59\xca\x9d\xcc\x25\x0c\x43\xba" + "\x85\xa8\xf8\xfe\xb5\x24\xb2\xee", + } }; -- cgit v1.2.3 From 5347ee8eff1965f5a63a3da4a13aa92aed3e682d Mon Sep 17 00:00:00 2001 From: Alexander Gordeev Date: Tue, 15 Apr 2014 09:54:31 +0200 Subject: crypto: ccp - Use pci_enable_msix_range() instead of pci_enable_msix() As result of deprecation of MSI-X/MSI enablement functions pci_enable_msix() and pci_enable_msi_block() all drivers using these two interfaces need to be updated to use the new pci_enable_msi_range() or pci_enable_msi_exact() and pci_enable_msix_range() or pci_enable_msix_exact() interfaces. Signed-off-by: Alexander Gordeev Cc: Tom Lendacky Cc: "David S. Miller" Cc: linux-crypto@vger.kernel.org Cc: linux-pci@vger.kernel.org Signed-off-by: Herbert Xu --- drivers/crypto/ccp/ccp-pci.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/crypto/ccp/ccp-pci.c b/drivers/crypto/ccp/ccp-pci.c index 93319f9db753..0d746236df5e 100644 --- a/drivers/crypto/ccp/ccp-pci.c +++ b/drivers/crypto/ccp/ccp-pci.c @@ -48,12 +48,11 @@ static int ccp_get_msix_irqs(struct ccp_device *ccp) for (v = 0; v < ARRAY_SIZE(msix_entry); v++) msix_entry[v].entry = v; - while ((ret = pci_enable_msix(pdev, msix_entry, v)) > 0) - v = ret; - if (ret) + ret = pci_enable_msix_range(pdev, msix_entry, 1, v); + if (ret < 0) return ret; - ccp_pci->msix_count = v; + ccp_pci->msix_count = ret; for (v = 0; v < ccp_pci->msix_count; v++) { /* Set the interrupt names and request the irqs */ snprintf(ccp_pci->msix[v].name, name_len, "ccp-%u", v); -- cgit v1.2.3 From 8ece117104068de3e0e50d1601bca15f58e912fd Mon Sep 17 00:00:00 2001 From: Paul Bolle Date: Tue, 15 Apr 2014 10:55:18 +0200 Subject: hwrng: picoxcell - remove unbuildable picoxcell TRNG The driver for the "Picochip picoXcell true random number generator" was added in v2.6.39. Its Kconfig symbol has always depended on PICOXCELL_PC3X3. But that Kconfig symbol has never been part of the tree. This means this driver has never been buildable. Let's remove it. It can be re-added if its dependencies are actually part of the tree. Signed-off-by: Paul Bolle Acked-by: Jamie Iles Signed-off-by: Herbert Xu --- drivers/char/hw_random/Kconfig | 13 --- drivers/char/hw_random/Makefile | 1 - drivers/char/hw_random/picoxcell-rng.c | 181 --------------------------------- 3 files changed, 195 deletions(-) delete mode 100644 drivers/char/hw_random/picoxcell-rng.c diff --git a/drivers/char/hw_random/Kconfig b/drivers/char/hw_random/Kconfig index 58a15f28789f..38cfae686cc4 100644 --- a/drivers/char/hw_random/Kconfig +++ b/drivers/char/hw_random/Kconfig @@ -255,19 +255,6 @@ config HW_RANDOM_NOMADIK If unsure, say Y. -config HW_RANDOM_PICOXCELL - tristate "Picochip picoXcell true random number generator support" - depends on ARCH_PICOXCELL && PICOXCELL_PC3X3 - default HW_RANDOM - ---help--- - This driver provides kernel-side support for the Random Number - Generator hardware found on Picochip PC3x3 and later devices. - - To compile this driver as a module, choose M here: the - module will be called picoxcell-rng. - - If unsure, say Y. - config HW_RANDOM_PPC4XX tristate "PowerPC 4xx generic true random number generator support" depends on PPC && 4xx diff --git a/drivers/char/hw_random/Makefile b/drivers/char/hw_random/Makefile index 3ae7755a52e7..199ed283e149 100644 --- a/drivers/char/hw_random/Makefile +++ b/drivers/char/hw_random/Makefile @@ -22,7 +22,6 @@ obj-$(CONFIG_HW_RANDOM_TX4939) += tx4939-rng.o obj-$(CONFIG_HW_RANDOM_MXC_RNGA) += mxc-rnga.o obj-$(CONFIG_HW_RANDOM_OCTEON) += octeon-rng.o obj-$(CONFIG_HW_RANDOM_NOMADIK) += nomadik-rng.o -obj-$(CONFIG_HW_RANDOM_PICOXCELL) += picoxcell-rng.o obj-$(CONFIG_HW_RANDOM_PPC4XX) += ppc4xx-rng.o obj-$(CONFIG_HW_RANDOM_PSERIES) += pseries-rng.o obj-$(CONFIG_HW_RANDOM_POWERNV) += powernv-rng.o diff --git a/drivers/char/hw_random/picoxcell-rng.c b/drivers/char/hw_random/picoxcell-rng.c deleted file mode 100644 index eab5448ad56f..000000000000 --- a/drivers/char/hw_random/picoxcell-rng.c +++ /dev/null @@ -1,181 +0,0 @@ -/* - * Copyright (c) 2010-2011 Picochip Ltd., Jamie Iles - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - * - * All enquiries to support@picochip.com - */ -#include -#include -#include -#include -#include -#include -#include -#include - -#define DATA_REG_OFFSET 0x0200 -#define CSR_REG_OFFSET 0x0278 -#define CSR_OUT_EMPTY_MASK (1 << 24) -#define CSR_FAULT_MASK (1 << 1) -#define TRNG_BLOCK_RESET_MASK (1 << 0) -#define TAI_REG_OFFSET 0x0380 - -/* - * The maximum amount of time in microseconds to spend waiting for data if the - * core wants us to wait. The TRNG should generate 32 bits every 320ns so a - * timeout of 20us seems reasonable. The TRNG does builtin tests of the data - * for randomness so we can't always assume there is data present. - */ -#define PICO_TRNG_TIMEOUT 20 - -static void __iomem *rng_base; -static struct clk *rng_clk; -static struct device *rng_dev; - -static inline u32 picoxcell_trng_read_csr(void) -{ - return __raw_readl(rng_base + CSR_REG_OFFSET); -} - -static inline bool picoxcell_trng_is_empty(void) -{ - return picoxcell_trng_read_csr() & CSR_OUT_EMPTY_MASK; -} - -/* - * Take the random number generator out of reset and make sure the interrupts - * are masked. We shouldn't need to get large amounts of random bytes so just - * poll the status register. The hardware generates 32 bits every 320ns so we - * shouldn't have to wait long enough to warrant waiting for an IRQ. - */ -static void picoxcell_trng_start(void) -{ - __raw_writel(0, rng_base + TAI_REG_OFFSET); - __raw_writel(0, rng_base + CSR_REG_OFFSET); -} - -static void picoxcell_trng_reset(void) -{ - __raw_writel(TRNG_BLOCK_RESET_MASK, rng_base + CSR_REG_OFFSET); - __raw_writel(TRNG_BLOCK_RESET_MASK, rng_base + TAI_REG_OFFSET); - picoxcell_trng_start(); -} - -/* - * Get some random data from the random number generator. The hw_random core - * layer provides us with locking. - */ -static int picoxcell_trng_read(struct hwrng *rng, void *buf, size_t max, - bool wait) -{ - int i; - - /* Wait for some data to become available. */ - for (i = 0; i < PICO_TRNG_TIMEOUT && picoxcell_trng_is_empty(); ++i) { - if (!wait) - return 0; - - udelay(1); - } - - if (picoxcell_trng_read_csr() & CSR_FAULT_MASK) { - dev_err(rng_dev, "fault detected, resetting TRNG\n"); - picoxcell_trng_reset(); - return -EIO; - } - - if (i == PICO_TRNG_TIMEOUT) - return 0; - - *(u32 *)buf = __raw_readl(rng_base + DATA_REG_OFFSET); - return sizeof(u32); -} - -static struct hwrng picoxcell_trng = { - .name = "picoxcell", - .read = picoxcell_trng_read, -}; - -static int picoxcell_trng_probe(struct platform_device *pdev) -{ - int ret; - struct resource *mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); - - rng_base = devm_ioremap_resource(&pdev->dev, mem); - if (IS_ERR(rng_base)) - return PTR_ERR(rng_base); - - rng_clk = devm_clk_get(&pdev->dev, NULL); - if (IS_ERR(rng_clk)) { - dev_warn(&pdev->dev, "no clk\n"); - return PTR_ERR(rng_clk); - } - - ret = clk_enable(rng_clk); - if (ret) { - dev_warn(&pdev->dev, "unable to enable clk\n"); - return ret; - } - - picoxcell_trng_start(); - ret = hwrng_register(&picoxcell_trng); - if (ret) - goto err_register; - - rng_dev = &pdev->dev; - dev_info(&pdev->dev, "pixoxcell random number generator active\n"); - - return 0; - -err_register: - clk_disable(rng_clk); - return ret; -} - -static int picoxcell_trng_remove(struct platform_device *pdev) -{ - hwrng_unregister(&picoxcell_trng); - clk_disable(rng_clk); - - return 0; -} - -#ifdef CONFIG_PM -static int picoxcell_trng_suspend(struct device *dev) -{ - clk_disable(rng_clk); - - return 0; -} - -static int picoxcell_trng_resume(struct device *dev) -{ - return clk_enable(rng_clk); -} - -static const struct dev_pm_ops picoxcell_trng_pm_ops = { - .suspend = picoxcell_trng_suspend, - .resume = picoxcell_trng_resume, -}; -#endif /* CONFIG_PM */ - -static struct platform_driver picoxcell_trng_driver = { - .probe = picoxcell_trng_probe, - .remove = picoxcell_trng_remove, - .driver = { - .name = "picoxcell-trng", - .owner = THIS_MODULE, -#ifdef CONFIG_PM - .pm = &picoxcell_trng_pm_ops, -#endif /* CONFIG_PM */ - }, -}; - -module_platform_driver(picoxcell_trng_driver); - -MODULE_LICENSE("GPL"); -MODULE_AUTHOR("Jamie Iles"); -MODULE_DESCRIPTION("Picochip picoXcell TRNG driver"); -- cgit v1.2.3 From f51f593b3eb194d01d8980316e6bb1f7d72f567a Mon Sep 17 00:00:00 2001 From: Nishanth Menon Date: Tue, 15 Apr 2014 11:58:31 -0500 Subject: crypto: omap-des - handle error of pm_runtime_get_sync pm_runtime_get_sync may not always succeed depending on SoC involved. So handle the error appropriately ensuring usage_count is accurate in case of failure. Signed-off-by: Nishanth Menon Reviewed-by: Felipe Balbi Reported-by: Joachim Eastwood Tested-by: Joachim Eastwood Acked-by: Joel Fernandes Signed-off-by: Herbert Xu --- drivers/crypto/omap-des.c | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/drivers/crypto/omap-des.c b/drivers/crypto/omap-des.c index 4a13624bb82b..b8bc84be8741 100644 --- a/drivers/crypto/omap-des.c +++ b/drivers/crypto/omap-des.c @@ -223,12 +223,19 @@ static void omap_des_write_n(struct omap_des_dev *dd, u32 offset, static int omap_des_hw_init(struct omap_des_dev *dd) { + int err; + /* * clocks are enabled when request starts and disabled when finished. * It may be long delays between requests. * Device might go to off mode to save power. */ - pm_runtime_get_sync(dd->dev); + err = pm_runtime_get_sync(dd->dev); + if (err < 0) { + pm_runtime_put_noidle(dd->dev); + dev_err(dd->dev, "%s: failed to get_sync(%d)\n", __func__, err); + return err; + } if (!(dd->flags & FLAGS_INIT)) { dd->flags |= FLAGS_INIT; @@ -1082,7 +1089,12 @@ static int omap_des_probe(struct platform_device *pdev) dd->phys_base = res->start; pm_runtime_enable(dev); - pm_runtime_get_sync(dev); + err = pm_runtime_get_sync(dev); + if (err < 0) { + pm_runtime_put_noidle(dev); + dev_err(dd->dev, "%s: failed to get_sync(%d)\n", __func__, err); + goto err_get; + } omap_des_dma_stop(dd); @@ -1147,6 +1159,7 @@ err_algs: err_irq: tasklet_kill(&dd->done_task); tasklet_kill(&dd->queue_task); +err_get: pm_runtime_disable(dev); err_res: dd = NULL; @@ -1190,7 +1203,14 @@ static int omap_des_suspend(struct device *dev) static int omap_des_resume(struct device *dev) { - pm_runtime_get_sync(dev); + int err; + + err = pm_runtime_get_sync(dev); + if (err < 0) { + pm_runtime_put_noidle(dev); + dev_err(dev, "%s: failed to get_sync(%d)\n", __func__, err); + return err; + } return 0; } #endif -- cgit v1.2.3 From a9358bc3531901a15e2f7cd48550c9555fc0288f Mon Sep 17 00:00:00 2001 From: Peter Foley Date: Tue, 15 Apr 2014 13:58:13 -0400 Subject: x86/build: Supress realmode.bin is up to date message Supress this unnecessary message during kernel re-build: make[3]: 'arch/x86/realmode/rm/realmode.bin' is up to date. Signed-off-by: Peter Foley Link: http://lkml.kernel.org/r/1397584693-15902-1-git-send-email-pefoley2@pefoley.com Signed-off-by: Ingo Molnar --- arch/x86/realmode/rm/Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/x86/realmode/rm/Makefile b/arch/x86/realmode/rm/Makefile index 3497f14e4dea..7c0d7be176a5 100644 --- a/arch/x86/realmode/rm/Makefile +++ b/arch/x86/realmode/rm/Makefile @@ -52,8 +52,9 @@ $(obj)/realmode.elf: $(obj)/realmode.lds $(REALMODE_OBJS) FORCE OBJCOPYFLAGS_realmode.bin := -O binary targets += realmode.bin -$(obj)/realmode.bin: $(obj)/realmode.elf $(obj)/realmode.relocs +$(obj)/realmode.bin: $(obj)/realmode.elf $(obj)/realmode.relocs FORCE $(call if_changed,objcopy) + @: quiet_cmd_relocs = RELOCS $@ cmd_relocs = arch/x86/tools/relocs --realmode $< > $@ -- cgit v1.2.3 From 00d90154404ae6218730068d25bf2faad3186631 Mon Sep 17 00:00:00 2001 From: Tim Gardner Date: Wed, 16 Apr 2014 08:18:35 -0600 Subject: ALSA: pcm: 'BUG:' message unnecessarily triggers kerneloops BugLink: http://bugs.launchpad.net/bugs/1305480 The kerneloops-daemon scans dmesg for common crash signatures, among which is 'BUG:'. The message emitted by the PCM library is really a warning, so the most expedient thing to do seems to be to change the string. Signed-off-by: Tim Gardner Signed-off-by: Takashi Iwai --- sound/core/pcm_lib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/core/pcm_lib.c b/sound/core/pcm_lib.c index ce83def9f43b..9acc77eae487 100644 --- a/sound/core/pcm_lib.c +++ b/sound/core/pcm_lib.c @@ -345,7 +345,7 @@ static int snd_pcm_update_hw_ptr0(struct snd_pcm_substream *substream, snd_pcm_debug_name(substream, name, sizeof(name)); xrun_log_show(substream); pcm_err(substream->pcm, - "BUG: %s, pos = %ld, buffer size = %ld, period size = %ld\n", + "XRUN: %s, pos = %ld, buffer size = %ld, period size = %ld\n", name, pos, runtime->buffer_size, runtime->period_size); } -- cgit v1.2.3 From d760e3e0f1afb96e0b813384258cea0afcf1b4d4 Mon Sep 17 00:00:00 2001 From: Suman Anna Date: Mon, 17 Mar 2014 20:31:32 -0500 Subject: iommu/omap: Correct init value of iotlb_entry valid field The iotlb_entry field values are used directly in omap2_alloc_cr, a function used in preparing the MMU_CAM and MMU_RAM registers. The iotlb_entry.valid value is being set incorrectly to 1 at the moment, and this would result in overriding the PAGESIZE bit field of the MMU_CAM register if prefetching of the entries were to be supported. The bug has not caused any MMU faults due to incorrect size programming so far as the prefetching is disabled by default. Fix this by using the correct init value for the iotlb_entry.valid field. Signed-off-by: Suman Anna Signed-off-by: Laurent Pinchart --- drivers/iommu/omap-iommu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iommu/omap-iommu.c b/drivers/iommu/omap-iommu.c index 7fcbfc498fa9..64d935b0d08e 100644 --- a/drivers/iommu/omap-iommu.c +++ b/drivers/iommu/omap-iommu.c @@ -1044,7 +1044,7 @@ static u32 iotlb_init_entry(struct iotlb_entry *e, u32 da, u32 pa, e->da = da; e->pa = pa; - e->valid = 1; + e->valid = MMU_CAM_V; /* FIXME: add OMAP1 support */ e->pgsz = flags & MMU_CAM_PGSZ_MASK; e->endian = flags & MMU_RAM_ENDIAN_MASK; -- cgit v1.2.3 From 2ac6133bf6280350105b3181bbed31fb183b9734 Mon Sep 17 00:00:00 2001 From: Suman Anna Date: Mon, 17 Mar 2014 20:31:33 -0500 Subject: iommu/omap: Remove omap_iommu_domain_has_cap() function The current OMAP IOMMU ops for .domain_has_cap is a stub, and the iommu core already returns a value of 0 if the domain doesn't have a .domain_has_cap ops plugged in. So, clean up this stub function. Signed-off-by: Suman Anna Signed-off-by: Laurent Pinchart --- drivers/iommu/omap-iommu.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/drivers/iommu/omap-iommu.c b/drivers/iommu/omap-iommu.c index 64d935b0d08e..7ce136da9c2d 100644 --- a/drivers/iommu/omap-iommu.c +++ b/drivers/iommu/omap-iommu.c @@ -1248,12 +1248,6 @@ static phys_addr_t omap_iommu_iova_to_phys(struct iommu_domain *domain, return ret; } -static int omap_iommu_domain_has_cap(struct iommu_domain *domain, - unsigned long cap) -{ - return 0; -} - static int omap_iommu_add_device(struct device *dev) { struct omap_iommu_arch_data *arch_data; @@ -1305,7 +1299,6 @@ static struct iommu_ops omap_iommu_ops = { .map = omap_iommu_map, .unmap = omap_iommu_unmap, .iova_to_phys = omap_iommu_iova_to_phys, - .domain_has_cap = omap_iommu_domain_has_cap, .add_device = omap_iommu_add_device, .remove_device = omap_iommu_remove_device, .pgsize_bitmap = OMAP_IOMMU_PGSIZES, -- cgit v1.2.3 From 5acc97db94321343f42866f2da90c3b02095c374 Mon Sep 17 00:00:00 2001 From: Suman Anna Date: Mon, 17 Mar 2014 20:31:34 -0500 Subject: iommu/omap: Move to_iommu definition from omap-iopgtable.h The to_iommu definition is used only locally to the omap-iommu.c source file, and it has nothing to do with the page attributes defined in omap-iopgtable.h. So, move the definition out of omap-iopgtable.h header file. Signed-off-by: Suman Anna Signed-off-by: Laurent Pinchart --- drivers/iommu/omap-iommu.c | 3 +++ drivers/iommu/omap-iopgtable.h | 3 --- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/iommu/omap-iommu.c b/drivers/iommu/omap-iommu.c index 7ce136da9c2d..78f32d13dd66 100644 --- a/drivers/iommu/omap-iommu.c +++ b/drivers/iommu/omap-iommu.c @@ -34,6 +34,9 @@ #include "omap-iopgtable.h" #include "omap-iommu.h" +#define to_iommu(dev) \ + ((struct omap_iommu *)platform_get_drvdata(to_platform_device(dev))) + #define for_each_iotlb_cr(obj, n, __i, cr) \ for (__i = 0; \ (__i < (n)) && (cr = __iotlb_read_cr((obj), __i), true); \ diff --git a/drivers/iommu/omap-iopgtable.h b/drivers/iommu/omap-iopgtable.h index b6f9a51746ca..f891683e3f05 100644 --- a/drivers/iommu/omap-iopgtable.h +++ b/drivers/iommu/omap-iopgtable.h @@ -93,6 +93,3 @@ static inline phys_addr_t omap_iommu_translate(u32 d, u32 va, u32 mask) /* to find an entry in the second-level page table. */ #define iopte_index(da) (((da) >> IOPTE_SHIFT) & (PTRS_PER_IOPTE - 1)) #define iopte_offset(iopgd, da) (iopgd_page_vaddr(iopgd) + iopte_index(da)) - -#define to_iommu(dev) \ - (platform_get_drvdata(to_platform_device(dev))) -- cgit v1.2.3 From f7129a0e4d5835b7851208d35984bc80116f1ed0 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Fri, 7 Mar 2014 23:47:03 +0100 Subject: iommu/omap: Fix 'no page for' debug message in flush_iotlb_page() The flush_iotlb_page() function prints a debug message when no corresponding page was found in the TLB. That condition is incorrectly checked and always resolves to true, given that the for_each_iotlb_cr() loop is never interrupted and always reaches obj->nr_tlb_entries. Given that we can't have two TLB entries for the same VA, break from the loop when a match is found. Signed-off-by: Laurent Pinchart Acked-by: Suman Anna --- drivers/iommu/omap-iommu.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/iommu/omap-iommu.c b/drivers/iommu/omap-iommu.c index 78f32d13dd66..b5787f151dfc 100644 --- a/drivers/iommu/omap-iommu.c +++ b/drivers/iommu/omap-iommu.c @@ -394,6 +394,7 @@ static void flush_iotlb_page(struct omap_iommu *obj, u32 da) __func__, start, da, bytes); iotlb_load_cr(obj, &cr); iommu_write_reg(obj, 1, MMU_FLUSH_ENTRY); + break; } } pm_runtime_put_sync(obj->dev); -- cgit v1.2.3 From 67b779d28d6e8afdd79a70423324273018114cad Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Sat, 8 Mar 2014 00:50:39 +0100 Subject: iommu/omap: Remove comment about supporting single page mappings only The IOMMU core breaks out mappings into pages already, there's no need to support mapping multiple pages in one go. Signed-off-by: Laurent Pinchart Reviewed-by: Sakari Ailus --- drivers/iommu/omap-iommu.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/iommu/omap-iommu.c b/drivers/iommu/omap-iommu.c index b5787f151dfc..31cebf20285c 100644 --- a/drivers/iommu/omap-iommu.c +++ b/drivers/iommu/omap-iommu.c @@ -1068,7 +1068,6 @@ static int omap_iommu_map(struct iommu_domain *domain, unsigned long da, int omap_pgsz; u32 ret, flags; - /* we only support mapping a single iommu page for now */ omap_pgsz = bytes_to_iopgsz(bytes); if (omap_pgsz < 0) { dev_err(dev, "invalid size to map: %d\n", bytes); -- cgit v1.2.3 From 286f600bc890347f7ec7bd50d33210d53a9095a3 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Sat, 8 Mar 2014 00:44:38 +0100 Subject: iommu/omap: Fix map protection value handling The prot flags passed to the IOMMU map handler are defined in include/linux/iommu.h as IOMMU_(READ|WRITE|CACHE|EXEC). However, the driver expects to receive MMU_RAM_* OMAP-specific flags. This causes IOMMU flags being interpreted as page sizes, leading to failures. Hardcode the OMAP mapping parameters to little-endian, 8-bits and non-mixed page attributes. Furthermore, as the OMAP IOMMU doesn't support read-only or write-only mappings, ignore the prot value. Signed-off-by: Laurent Pinchart Reviewed-by: Sakari Ailus Acked-by: Suman Anna --- drivers/iommu/omap-iommu.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/drivers/iommu/omap-iommu.c b/drivers/iommu/omap-iommu.c index 31cebf20285c..895af06a667f 100644 --- a/drivers/iommu/omap-iommu.c +++ b/drivers/iommu/omap-iommu.c @@ -1041,8 +1041,7 @@ static void iopte_cachep_ctor(void *iopte) clean_dcache_area(iopte, IOPTE_TABLE_SIZE); } -static u32 iotlb_init_entry(struct iotlb_entry *e, u32 da, u32 pa, - u32 flags) +static u32 iotlb_init_entry(struct iotlb_entry *e, u32 da, u32 pa, int pgsz) { memset(e, 0, sizeof(*e)); @@ -1050,10 +1049,10 @@ static u32 iotlb_init_entry(struct iotlb_entry *e, u32 da, u32 pa, e->pa = pa; e->valid = MMU_CAM_V; /* FIXME: add OMAP1 support */ - e->pgsz = flags & MMU_CAM_PGSZ_MASK; - e->endian = flags & MMU_RAM_ENDIAN_MASK; - e->elsz = flags & MMU_RAM_ELSZ_MASK; - e->mixed = flags & MMU_RAM_MIXED_MASK; + e->pgsz = pgsz; + e->endian = MMU_RAM_ENDIAN_LITTLE; + e->elsz = MMU_RAM_ELSZ_8; + e->mixed = 0; return iopgsz_to_bytes(e->pgsz); } @@ -1066,7 +1065,7 @@ static int omap_iommu_map(struct iommu_domain *domain, unsigned long da, struct device *dev = oiommu->dev; struct iotlb_entry e; int omap_pgsz; - u32 ret, flags; + u32 ret; omap_pgsz = bytes_to_iopgsz(bytes); if (omap_pgsz < 0) { @@ -1076,9 +1075,7 @@ static int omap_iommu_map(struct iommu_domain *domain, unsigned long da, dev_dbg(dev, "mapping da 0x%lx to pa 0x%x size 0x%x\n", da, pa, bytes); - flags = omap_pgsz | prot; - - iotlb_init_entry(&e, da, pa, flags); + iotlb_init_entry(&e, da, pa, omap_pgsz); ret = omap_iopgtable_store_entry(oiommu, &e); if (ret) -- cgit v1.2.3 From a1253ef6d3fabfe60838cd417b0624ab53df285e Mon Sep 17 00:00:00 2001 From: Brian Austin Date: Tue, 15 Apr 2014 15:49:33 -0500 Subject: ASoC: cs42l51: split i2c from codec driver This patch removes the i2c bus code from the codec driver and creates seperate i2c driver. Signed-off-by: Brian Austin Signed-off-by: Mark Brown --- sound/soc/codecs/Kconfig | 6 +++- sound/soc/codecs/Makefile | 2 ++ sound/soc/codecs/cs42l51-i2c.c | 59 +++++++++++++++++++++++++++++++++ sound/soc/codecs/cs42l51.c | 75 +++++++++++------------------------------- sound/soc/codecs/cs42l51.h | 5 +++ 5 files changed, 90 insertions(+), 57 deletions(-) create mode 100644 sound/soc/codecs/cs42l51-i2c.c diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig index f0e840137887..5279ef41597d 100644 --- a/sound/soc/codecs/Kconfig +++ b/sound/soc/codecs/Kconfig @@ -39,7 +39,7 @@ config SND_SOC_ALL_CODECS select SND_SOC_ALC5623 if I2C select SND_SOC_ALC5632 if I2C select SND_SOC_CQ0093VC if MFD_DAVINCI_VOICECODEC - select SND_SOC_CS42L51 if I2C + select SND_SOC_CS42L51_I2C if I2C select SND_SOC_CS42L52 if I2C select SND_SOC_CS42L73 if I2C select SND_SOC_CS4270 if I2C @@ -280,6 +280,10 @@ config SND_SOC_CQ0093VC config SND_SOC_CS42L51 tristate +config SND_SOC_CS42L51_I2C + tristate + select SND_SOC_CS42L51 + config SND_SOC_CS42L52 tristate "Cirrus Logic CS42L52 CODEC" depends on I2C diff --git a/sound/soc/codecs/Makefile b/sound/soc/codecs/Makefile index 3c4d275d064b..e06f10032344 100644 --- a/sound/soc/codecs/Makefile +++ b/sound/soc/codecs/Makefile @@ -26,6 +26,7 @@ snd-soc-ak5386-objs := ak5386.o snd-soc-arizona-objs := arizona.o snd-soc-cq93vc-objs := cq93vc.o snd-soc-cs42l51-objs := cs42l51.o +snd-soc-cs42l51-i2c-objs := cs42l51-i2c.o snd-soc-cs42l52-objs := cs42l52.o snd-soc-cs42l73-objs := cs42l73.o snd-soc-cs4270-objs := cs4270.o @@ -177,6 +178,7 @@ obj-$(CONFIG_SND_SOC_ALC5632) += snd-soc-alc5632.o obj-$(CONFIG_SND_SOC_ARIZONA) += snd-soc-arizona.o obj-$(CONFIG_SND_SOC_CQ0093VC) += snd-soc-cq93vc.o obj-$(CONFIG_SND_SOC_CS42L51) += snd-soc-cs42l51.o +obj-$(CONFIG_SND_SOC_CS42L51_I2C) += snd-soc-cs42l51-i2c.o obj-$(CONFIG_SND_SOC_CS42L52) += snd-soc-cs42l52.o obj-$(CONFIG_SND_SOC_CS42L73) += snd-soc-cs42l73.o obj-$(CONFIG_SND_SOC_CS4270) += snd-soc-cs4270.o diff --git a/sound/soc/codecs/cs42l51-i2c.c b/sound/soc/codecs/cs42l51-i2c.c new file mode 100644 index 000000000000..cee51ae177c1 --- /dev/null +++ b/sound/soc/codecs/cs42l51-i2c.c @@ -0,0 +1,59 @@ +/* + * cs42l56.c -- CS42L51 ALSA SoC I2C audio driver + * + * Copyright 2014 CirrusLogic, Inc. + * + * Author: Brian Austin + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + */ + +#include +#include +#include + +#include "cs42l51.h" + +static struct i2c_device_id cs42l51_i2c_id[] = { + {"cs42l51", 0}, + {} +}; +MODULE_DEVICE_TABLE(i2c, cs42l51_i2c_id); + +static int cs42l51_i2c_probe(struct i2c_client *i2c, + const struct i2c_device_id *id) +{ + struct regmap_config config; + + config = cs42l51_regmap; + config.val_bits = 8; + config.reg_bits = 8; + + return cs42l51_probe(&i2c->dev, devm_regmap_init_i2c(i2c, &config)); +} + +static int cs42l51_i2c_remove(struct i2c_client *i2c) +{ + snd_soc_unregister_codec(&i2c->dev); + + return 0; +} + +static struct i2c_driver cs42l51_i2c_driver = { + .driver = { + .name = "cs42l51", + .owner = THIS_MODULE, + }, + .probe = cs42l51_i2c_probe, + .remove = cs42l51_i2c_remove, + .id_table = cs42l51_i2c_id, +}; + +module_i2c_driver(cs42l51_i2c_driver); + +MODULE_DESCRIPTION("ASoC CS42L51 I2C Driver"); +MODULE_AUTHOR("Brian Austin, Cirrus Logic Inc, "); +MODULE_LICENSE("GPL"); diff --git a/sound/soc/codecs/cs42l51.c b/sound/soc/codecs/cs42l51.c index 6c0da2baa154..46abd3e02f14 100644 --- a/sound/soc/codecs/cs42l51.c +++ b/sound/soc/codecs/cs42l51.c @@ -29,7 +29,6 @@ #include #include #include -#include #include #include "cs42l51.h" @@ -483,7 +482,7 @@ static struct snd_soc_dai_driver cs42l51_dai = { .ops = &cs42l51_dai_ops, }; -static int cs42l51_probe(struct snd_soc_codec *codec) +static int cs42l51_codec_probe(struct snd_soc_codec *codec) { int ret, reg; @@ -504,7 +503,7 @@ static int cs42l51_probe(struct snd_soc_codec *codec) } static struct snd_soc_codec_driver soc_codec_device_cs42l51 = { - .probe = cs42l51_probe, + .probe = cs42l51_codec_probe, .controls = cs42l51_snd_controls, .num_controls = ARRAY_SIZE(cs42l51_snd_controls), @@ -514,91 +513,55 @@ static struct snd_soc_codec_driver soc_codec_device_cs42l51 = { .num_dapm_routes = ARRAY_SIZE(cs42l51_routes), }; -static const struct regmap_config cs42l51_regmap = { - .reg_bits = 8, - .val_bits = 8, - +const struct regmap_config cs42l51_regmap = { .max_register = CS42L51_CHARGE_FREQ, .cache_type = REGCACHE_RBTREE, }; +EXPORT_SYMBOL_GPL(cs42l51_regmap); -static int cs42l51_i2c_probe(struct i2c_client *i2c_client, - const struct i2c_device_id *id) +int cs42l51_probe(struct device *dev, struct regmap *regmap) { struct cs42l51_private *cs42l51; - struct regmap *regmap; unsigned int val; int ret; - regmap = devm_regmap_init_i2c(i2c_client, &cs42l51_regmap); - if (IS_ERR(regmap)) { - ret = PTR_ERR(regmap); - dev_err(&i2c_client->dev, "Failed to create regmap: %d\n", - ret); - return ret; - } + if (IS_ERR(regmap)) + return PTR_ERR(regmap); + + cs42l51 = devm_kzalloc(dev, sizeof(struct cs42l51_private), + GFP_KERNEL); + if (!cs42l51) + return -ENOMEM; + + dev_set_drvdata(dev, cs42l51); /* Verify that we have a CS42L51 */ ret = regmap_read(regmap, CS42L51_CHIP_REV_ID, &val); if (ret < 0) { - dev_err(&i2c_client->dev, "failed to read I2C\n"); + dev_err(dev, "failed to read I2C\n"); goto error; } if ((val != CS42L51_MK_CHIP_REV(CS42L51_CHIP_ID, CS42L51_CHIP_REV_A)) && (val != CS42L51_MK_CHIP_REV(CS42L51_CHIP_ID, CS42L51_CHIP_REV_B))) { - dev_err(&i2c_client->dev, "Invalid chip id: %x\n", val); + dev_err(dev, "Invalid chip id: %x\n", val); ret = -ENODEV; goto error; } + dev_info(dev, "Cirrus Logic CS42L51, Revision: %02X\n", val & 0xFF); - dev_info(&i2c_client->dev, "found device cs42l51 rev %d\n", - val & 7); - - cs42l51 = devm_kzalloc(&i2c_client->dev, sizeof(struct cs42l51_private), - GFP_KERNEL); - if (!cs42l51) - return -ENOMEM; - - i2c_set_clientdata(i2c_client, cs42l51); - - ret = snd_soc_register_codec(&i2c_client->dev, + ret = snd_soc_register_codec(dev, &soc_codec_device_cs42l51, &cs42l51_dai, 1); error: return ret; } - -static int cs42l51_i2c_remove(struct i2c_client *client) -{ - snd_soc_unregister_codec(&client->dev); - return 0; -} - -static const struct i2c_device_id cs42l51_id[] = { - {"cs42l51", 0}, - {} -}; -MODULE_DEVICE_TABLE(i2c, cs42l51_id); +EXPORT_SYMBOL_GPL(cs42l51_probe); static const struct of_device_id cs42l51_of_match[] = { { .compatible = "cirrus,cs42l51", }, { } }; MODULE_DEVICE_TABLE(of, cs42l51_of_match); - -static struct i2c_driver cs42l51_i2c_driver = { - .driver = { - .name = "cs42l51-codec", - .owner = THIS_MODULE, - .of_match_table = cs42l51_of_match, - }, - .id_table = cs42l51_id, - .probe = cs42l51_i2c_probe, - .remove = cs42l51_i2c_remove, -}; - -module_i2c_driver(cs42l51_i2c_driver); - MODULE_AUTHOR("Arnaud Patard "); MODULE_DESCRIPTION("Cirrus Logic CS42L51 ALSA SoC Codec Driver"); MODULE_LICENSE("GPL"); diff --git a/sound/soc/codecs/cs42l51.h b/sound/soc/codecs/cs42l51.h index 2beeb171db4b..641ef18435b3 100644 --- a/sound/soc/codecs/cs42l51.h +++ b/sound/soc/codecs/cs42l51.h @@ -18,6 +18,11 @@ #ifndef _CS42L51_H #define _CS42L51_H +struct device; + +extern const struct regmap_config cs42l51_regmap; +int cs42l51_probe(struct device *dev, struct regmap *regmap); + #define CS42L51_CHIP_ID 0x1B #define CS42L51_CHIP_REV_A 0x00 #define CS42L51_CHIP_REV_B 0x01 -- cgit v1.2.3 From 1ab1fa5dfb429c533fbc791e524788cf0cc43775 Mon Sep 17 00:00:00 2001 From: Namhyung Kim Date: Thu, 26 Dec 2013 15:11:52 +0900 Subject: perf hists: Add support for showing relative percentage When filtering by thread, dso or symbol on TUI it also update total period so that the output shows different result than no filter - the percentage changed to relative to filtered entries only. Sometimes this is not desired since users might expect same results with filter. So new filtered_* fields to hists->stats to count them separately. They'll be controlled/used by user later. Signed-off-by: Namhyung Kim Link: http://lkml.kernel.org/r/1397145720-8063-2-git-send-email-namhyung@kernel.org Signed-off-by: Jiri Olsa --- tools/perf/builtin-report.c | 6 ++++++ tools/perf/builtin-top.c | 3 +++ tools/perf/util/hist.c | 17 ++++++++++++++--- tools/perf/util/hist.h | 3 +++ 4 files changed, 26 insertions(+), 3 deletions(-) diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c index c8f21137dfd8..2fca56c9d68a 100644 --- a/tools/perf/builtin-report.c +++ b/tools/perf/builtin-report.c @@ -123,6 +123,8 @@ static int report__add_mem_hist_entry(struct report *rep, struct addr_location * evsel->hists.stats.total_period += cost; hists__inc_nr_events(&evsel->hists, PERF_RECORD_SAMPLE); + if (!he->filtered) + evsel->hists.stats.nr_non_filtered_samples++; err = hist_entry__append_callchain(he, sample); out: return err; @@ -176,6 +178,8 @@ static int report__add_branch_hist_entry(struct report *rep, struct addr_locatio evsel->hists.stats.total_period += 1; hists__inc_nr_events(&evsel->hists, PERF_RECORD_SAMPLE); + if (!he->filtered) + evsel->hists.stats.nr_non_filtered_samples++; } else goto out; } @@ -209,6 +213,8 @@ static int report__add_hist_entry(struct report *rep, struct perf_evsel *evsel, err = hist_entry__inc_addr_samples(he, evsel->idx, al->addr); evsel->hists.stats.total_period += sample->period; + if (!he->filtered) + evsel->hists.stats.nr_non_filtered_samples++; hists__inc_nr_events(&evsel->hists, PERF_RECORD_SAMPLE); out: return err; diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c index 65aaa5bbf7ec..25269014164a 100644 --- a/tools/perf/builtin-top.c +++ b/tools/perf/builtin-top.c @@ -253,6 +253,9 @@ static struct hist_entry *perf_evsel__add_hist_entry(struct perf_evsel *evsel, return NULL; hists__inc_nr_events(&evsel->hists, PERF_RECORD_SAMPLE); + if (!he->filtered) + evsel->hists.stats.nr_non_filtered_samples++; + return he; } diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c index f38590d7561b..1ed3e2b86f0b 100644 --- a/tools/perf/util/hist.c +++ b/tools/perf/util/hist.c @@ -674,8 +674,8 @@ void hists__output_resort(struct hists *hists) next = rb_first(root); hists->entries = RB_ROOT; - hists->nr_entries = 0; - hists->stats.total_period = 0; + hists->nr_entries = hists->nr_non_filtered_entries = 0; + hists->stats.total_period = hists->stats.total_non_filtered_period = 0; hists__reset_col_len(hists); while (next) { @@ -695,11 +695,16 @@ static void hists__remove_entry_filter(struct hists *hists, struct hist_entry *h return; ++hists->nr_entries; - if (h->ms.unfolded) + ++hists->nr_non_filtered_entries; + if (h->ms.unfolded) { hists->nr_entries += h->nr_rows; + hists->nr_non_filtered_entries += h->nr_rows; + } h->row_offset = 0; hists->stats.total_period += h->stat.period; + hists->stats.total_non_filtered_period += h->stat.period; hists->stats.nr_events[PERF_RECORD_SAMPLE] += h->stat.nr_events; + hists->stats.nr_non_filtered_samples += h->stat.nr_events; hists__calc_col_len(hists, h); } @@ -722,7 +727,9 @@ void hists__filter_by_dso(struct hists *hists) struct rb_node *nd; hists->nr_entries = hists->stats.total_period = 0; + hists->nr_non_filtered_entries = hists->stats.total_non_filtered_period = 0; hists->stats.nr_events[PERF_RECORD_SAMPLE] = 0; + hists->stats.nr_non_filtered_samples = 0; hists__reset_col_len(hists); for (nd = rb_first(&hists->entries); nd; nd = rb_next(nd)) { @@ -755,7 +762,9 @@ void hists__filter_by_thread(struct hists *hists) struct rb_node *nd; hists->nr_entries = hists->stats.total_period = 0; + hists->nr_non_filtered_entries = hists->stats.total_non_filtered_period = 0; hists->stats.nr_events[PERF_RECORD_SAMPLE] = 0; + hists->stats.nr_non_filtered_samples = 0; hists__reset_col_len(hists); for (nd = rb_first(&hists->entries); nd; nd = rb_next(nd)) { @@ -786,7 +795,9 @@ void hists__filter_by_symbol(struct hists *hists) struct rb_node *nd; hists->nr_entries = hists->stats.total_period = 0; + hists->nr_non_filtered_entries = hists->stats.total_non_filtered_period = 0; hists->stats.nr_events[PERF_RECORD_SAMPLE] = 0; + hists->stats.nr_non_filtered_samples = 0; hists__reset_col_len(hists); for (nd = rb_first(&hists->entries); nd; nd = rb_next(nd)) { diff --git a/tools/perf/util/hist.h b/tools/perf/util/hist.h index 1f1f513dfe7f..213551469f36 100644 --- a/tools/perf/util/hist.h +++ b/tools/perf/util/hist.h @@ -37,9 +37,11 @@ enum hist_filter { */ struct events_stats { u64 total_period; + u64 total_non_filtered_period; u64 total_lost; u64 total_invalid_chains; u32 nr_events[PERF_RECORD_HEADER_MAX]; + u32 nr_non_filtered_samples; u32 nr_lost_warned; u32 nr_unknown_events; u32 nr_invalid_chains; @@ -83,6 +85,7 @@ struct hists { struct rb_root entries; struct rb_root entries_collapsed; u64 nr_entries; + u64 nr_non_filtered_entries; const struct thread *thread_filter; const struct dso *dso_filter; const char *uid_filter_str; -- cgit v1.2.3 From f2148330544a697481219b5bc34261f6dd049bfb Mon Sep 17 00:00:00 2001 From: Namhyung Kim Date: Tue, 14 Jan 2014 11:52:48 +0900 Subject: perf report: Add --percentage option The --percentage option is for controlling overhead percentage displayed. It can only receive either of "relative" or "absolute". "relative" means it's relative to filtered entries only so that the sum of shown entries will be always 100%. "absolute" means it retains the original value before and after the filter is applied. $ perf report -s comm # Overhead Command # ........ ............ # 74.19% cc1 7.61% gcc 6.11% as 4.35% sh 4.14% make 1.13% fixdep ... $ perf report -s comm -c cc1,gcc --percentage absolute # Overhead Command # ........ ............ # 74.19% cc1 7.61% gcc $ perf report -s comm -c cc1,gcc --percentage relative # Overhead Command # ........ ............ # 90.69% cc1 9.31% gcc Note that it has zero effect if no filter was applied. Suggested-by: Arnaldo Carvalho de Melo Signed-off-by: Namhyung Kim Link: http://lkml.kernel.org/r/1397145720-8063-3-git-send-email-namhyung@kernel.org Signed-off-by: Jiri Olsa --- tools/perf/Documentation/perf-report.txt | 24 +++++++++++++++----- tools/perf/builtin-report.c | 30 ++++++++++++++++++++++-- tools/perf/ui/browsers/hists.c | 35 +++++++++++++++++++++------- tools/perf/ui/gtk/hists.c | 11 ++++----- tools/perf/ui/hist.c | 8 +++---- tools/perf/util/hist.c | 39 ++++++++++++++++---------------- tools/perf/util/hist.h | 1 + tools/perf/util/symbol.c | 1 + tools/perf/util/symbol.h | 3 ++- 9 files changed, 106 insertions(+), 46 deletions(-) diff --git a/tools/perf/Documentation/perf-report.txt b/tools/perf/Documentation/perf-report.txt index 8eab8a4bdeb8..09af66298564 100644 --- a/tools/perf/Documentation/perf-report.txt +++ b/tools/perf/Documentation/perf-report.txt @@ -25,10 +25,6 @@ OPTIONS --verbose:: Be more verbose. (show symbol address, etc) --d:: ---dsos=:: - Only consider symbols in these dsos. CSV that understands - file://filename entries. -n:: --show-nr-samples:: Show the number of samples for each symbol @@ -42,11 +38,18 @@ OPTIONS -c:: --comms=:: Only consider symbols in these comms. CSV that understands - file://filename entries. + file://filename entries. This option will affect the percentage of + the overhead column. See --percentage for more info. +-d:: +--dsos=:: + Only consider symbols in these dsos. CSV that understands + file://filename entries. This option will affect the percentage of + the overhead column. See --percentage for more info. -S:: --symbols=:: Only consider these symbols. CSV that understands - file://filename entries. + file://filename entries. This option will affect the percentage of + the overhead column. See --percentage for more info. --symbol-filter=:: Only show symbols that match (partially) with this filter. @@ -237,6 +240,15 @@ OPTIONS Do not show entries which have an overhead under that percent. (Default: 0). +--percentage:: + Determine how to display the overhead percentage of filtered entries. + Filters can be applied by --comms, --dsos and/or --symbols options and + Zoom operations on the TUI (thread, dso, etc). + + "relative" means it's relative to filtered entries only so that the + sum of shown entries will be always 100%. "absolute" means it retains + the original value before and after the filter is applied. + --header:: Show header information in the perf.data file. This includes various information like hostname, OS and perf version, cpu/mem diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c index 2fca56c9d68a..7ec351bda833 100644 --- a/tools/perf/builtin-report.c +++ b/tools/perf/builtin-report.c @@ -343,6 +343,11 @@ static size_t hists__fprintf_nr_sample_events(struct hists *hists, struct report char buf[512]; size_t size = sizeof(buf); + if (symbol_conf.filter_relative) { + nr_samples = hists->stats.nr_non_filtered_samples; + nr_events = hists->stats.total_non_filtered_period; + } + if (perf_evsel__is_group_event(evsel)) { struct perf_evsel *pos; @@ -350,8 +355,13 @@ static size_t hists__fprintf_nr_sample_events(struct hists *hists, struct report evname = buf; for_each_group_member(pos, evsel) { - nr_samples += pos->hists.stats.nr_events[PERF_RECORD_SAMPLE]; - nr_events += pos->hists.stats.total_period; + if (symbol_conf.filter_relative) { + nr_samples += pos->hists.stats.nr_non_filtered_samples; + nr_events += pos->hists.stats.total_non_filtered_period; + } else { + nr_samples += pos->hists.stats.nr_events[PERF_RECORD_SAMPLE]; + nr_events += pos->hists.stats.total_period; + } } } @@ -707,6 +717,20 @@ parse_percent_limit(const struct option *opt, const char *str, return 0; } +static int +parse_percentage(const struct option *opt __maybe_unused, const char *str, + int unset __maybe_unused) +{ + if (!strcmp(str, "relative")) + symbol_conf.filter_relative = true; + else if (!strcmp(str, "absolute")) + symbol_conf.filter_relative = false; + else + return -1; + + return 0; +} + int cmd_report(int argc, const char **argv, const char *prefix __maybe_unused) { struct perf_session *session; @@ -829,6 +853,8 @@ int cmd_report(int argc, const char **argv, const char *prefix __maybe_unused) OPT_BOOLEAN(0, "mem-mode", &report.mem_mode, "mem access profile"), OPT_CALLBACK(0, "percent-limit", &report, "percent", "Don't show entries under that percent", parse_percent_limit), + OPT_CALLBACK(0, "percentage", NULL, "relative|absolute", + "how to display percentage of filtered entries", parse_percentage), OPT_END() }; struct perf_data_file file = { diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c index 7ec871af3f6f..7ad11477a0f5 100644 --- a/tools/perf/ui/browsers/hists.c +++ b/tools/perf/ui/browsers/hists.c @@ -769,12 +769,15 @@ static unsigned int hist_browser__refresh(struct ui_browser *browser) for (nd = browser->top; nd; nd = rb_next(nd)) { struct hist_entry *h = rb_entry(nd, struct hist_entry, rb_node); - float percent = h->stat.period * 100.0 / - hb->hists->stats.total_period; + u64 total = hists__total_period(h->hists); + float percent = 0.0; if (h->filtered) continue; + if (total) + percent = h->stat.period * 100.0 / total; + if (percent < hb->min_pcnt) continue; @@ -792,8 +795,11 @@ static struct rb_node *hists__filter_entries(struct rb_node *nd, { while (nd != NULL) { struct hist_entry *h = rb_entry(nd, struct hist_entry, rb_node); - float percent = h->stat.period * 100.0 / - hists->stats.total_period; + u64 total = hists__total_period(hists); + float percent = 0.0; + + if (total) + percent = h->stat.period * 100.0 / total; if (percent < min_pcnt) return NULL; @@ -813,8 +819,11 @@ static struct rb_node *hists__filter_prev_entries(struct rb_node *nd, { while (nd != NULL) { struct hist_entry *h = rb_entry(nd, struct hist_entry, rb_node); - float percent = h->stat.period * 100.0 / - hists->stats.total_period; + u64 total = hists__total_period(hists); + float percent = 0.0; + + if (total) + percent = h->stat.period * 100.0 / total; if (!h->filtered && percent >= min_pcnt) return nd; @@ -1189,6 +1198,11 @@ static int hists__browser_title(struct hists *hists, char *bf, size_t size, char buf[512]; size_t buflen = sizeof(buf); + if (symbol_conf.filter_relative) { + nr_samples = hists->stats.nr_non_filtered_samples; + nr_events = hists->stats.total_non_filtered_period; + } + if (perf_evsel__is_group_event(evsel)) { struct perf_evsel *pos; @@ -1196,8 +1210,13 @@ static int hists__browser_title(struct hists *hists, char *bf, size_t size, ev_name = buf; for_each_group_member(pos, evsel) { - nr_samples += pos->hists.stats.nr_events[PERF_RECORD_SAMPLE]; - nr_events += pos->hists.stats.total_period; + if (symbol_conf.filter_relative) { + nr_samples += pos->hists.stats.nr_non_filtered_samples; + nr_events += pos->hists.stats.total_non_filtered_period; + } else { + nr_samples += pos->hists.stats.nr_events[PERF_RECORD_SAMPLE]; + nr_events += pos->hists.stats.total_period; + } } } diff --git a/tools/perf/ui/gtk/hists.c b/tools/perf/ui/gtk/hists.c index e395ef9b0ae0..91f10f3f6dd1 100644 --- a/tools/perf/ui/gtk/hists.c +++ b/tools/perf/ui/gtk/hists.c @@ -228,12 +228,15 @@ static void perf_gtk__show_hists(GtkWidget *window, struct hists *hists, for (nd = rb_first(&hists->entries); nd; nd = rb_next(nd)) { struct hist_entry *h = rb_entry(nd, struct hist_entry, rb_node); GtkTreeIter iter; - float percent = h->stat.period * 100.0 / - hists->stats.total_period; + u64 total = hists__total_period(h->hists); + float percent = 0.0; if (h->filtered) continue; + if (total) + percent = h->stat.period * 100.0 / total; + if (percent < min_pcnt) continue; @@ -261,12 +264,8 @@ static void perf_gtk__show_hists(GtkWidget *window, struct hists *hists, } if (symbol_conf.use_callchain && sort__has_sym) { - u64 total; - if (callchain_param.mode == CHAIN_GRAPH_REL) total = h->stat.period; - else - total = hists->stats.total_period; perf_gtk__add_callchain(&h->sorted_chain, store, &iter, sym_col, total); diff --git a/tools/perf/ui/hist.c b/tools/perf/ui/hist.c index 0f403b83e9d1..0912805c08f4 100644 --- a/tools/perf/ui/hist.c +++ b/tools/perf/ui/hist.c @@ -32,10 +32,10 @@ int __hpp__fmt(struct perf_hpp *hpp, struct hist_entry *he, if (fmt_percent) { double percent = 0.0; + u64 total = hists__total_period(hists); - if (hists->stats.total_period) - percent = 100.0 * get_field(he) / - hists->stats.total_period; + if (total) + percent = 100.0 * get_field(he) / total; ret += hpp__call_print_fn(hpp, print_fn, fmt, percent); } else @@ -50,7 +50,7 @@ int __hpp__fmt(struct perf_hpp *hpp, struct hist_entry *he, list_for_each_entry(pair, &he->pairs.head, pairs.node) { u64 period = get_field(pair); - u64 total = pair->hists->stats.total_period; + u64 total = hists__total_period(pair->hists); if (!total) continue; diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c index 1ed3e2b86f0b..3ebd89a28257 100644 --- a/tools/perf/util/hist.c +++ b/tools/perf/util/hist.c @@ -321,9 +321,11 @@ void hists__inc_nr_entries(struct hists *hists, struct hist_entry *h) { if (!h->filtered) { hists__calc_col_len(hists, h); - ++hists->nr_entries; - hists->stats.total_period += h->stat.period; + hists->nr_non_filtered_entries++; + hists->stats.total_non_filtered_period += h->stat.period; } + hists->nr_entries++; + hists->stats.total_period += h->stat.period; } static u8 symbol__parent_filter(const struct symbol *parent) @@ -674,8 +676,9 @@ void hists__output_resort(struct hists *hists) next = rb_first(root); hists->entries = RB_ROOT; - hists->nr_entries = hists->nr_non_filtered_entries = 0; - hists->stats.total_period = hists->stats.total_non_filtered_period = 0; + hists->nr_non_filtered_entries = 0; + hists->stats.total_period = 0; + hists->stats.total_non_filtered_period = 0; hists__reset_col_len(hists); while (next) { @@ -694,16 +697,11 @@ static void hists__remove_entry_filter(struct hists *hists, struct hist_entry *h if (h->filtered) return; - ++hists->nr_entries; ++hists->nr_non_filtered_entries; - if (h->ms.unfolded) { - hists->nr_entries += h->nr_rows; + if (h->ms.unfolded) hists->nr_non_filtered_entries += h->nr_rows; - } h->row_offset = 0; - hists->stats.total_period += h->stat.period; hists->stats.total_non_filtered_period += h->stat.period; - hists->stats.nr_events[PERF_RECORD_SAMPLE] += h->stat.nr_events; hists->stats.nr_non_filtered_samples += h->stat.nr_events; hists__calc_col_len(hists, h); @@ -726,9 +724,8 @@ void hists__filter_by_dso(struct hists *hists) { struct rb_node *nd; - hists->nr_entries = hists->stats.total_period = 0; - hists->nr_non_filtered_entries = hists->stats.total_non_filtered_period = 0; - hists->stats.nr_events[PERF_RECORD_SAMPLE] = 0; + hists->nr_non_filtered_entries = 0; + hists->stats.total_non_filtered_period = 0; hists->stats.nr_non_filtered_samples = 0; hists__reset_col_len(hists); @@ -761,9 +758,8 @@ void hists__filter_by_thread(struct hists *hists) { struct rb_node *nd; - hists->nr_entries = hists->stats.total_period = 0; - hists->nr_non_filtered_entries = hists->stats.total_non_filtered_period = 0; - hists->stats.nr_events[PERF_RECORD_SAMPLE] = 0; + hists->nr_non_filtered_entries = 0; + hists->stats.total_non_filtered_period = 0; hists->stats.nr_non_filtered_samples = 0; hists__reset_col_len(hists); @@ -794,9 +790,8 @@ void hists__filter_by_symbol(struct hists *hists) { struct rb_node *nd; - hists->nr_entries = hists->stats.total_period = 0; - hists->nr_non_filtered_entries = hists->stats.total_non_filtered_period = 0; - hists->stats.nr_events[PERF_RECORD_SAMPLE] = 0; + hists->nr_non_filtered_entries = 0; + hists->stats.total_non_filtered_period = 0; hists->stats.nr_non_filtered_samples = 0; hists__reset_col_len(hists); @@ -942,3 +937,9 @@ int hists__link(struct hists *leader, struct hists *other) return 0; } + +u64 hists__total_period(struct hists *hists) +{ + return symbol_conf.filter_relative ? hists->stats.total_non_filtered_period : + hists->stats.total_period; +} diff --git a/tools/perf/util/hist.h b/tools/perf/util/hist.h index 213551469f36..3191496bd3b7 100644 --- a/tools/perf/util/hist.h +++ b/tools/perf/util/hist.h @@ -115,6 +115,7 @@ void hists__collapse_resort(struct hists *hists, struct ui_progress *prog); void hists__decay_entries(struct hists *hists, bool zap_user, bool zap_kernel); void hists__output_recalc_col_len(struct hists *hists, int max_rows); +u64 hists__total_period(struct hists *hists); void hists__inc_nr_entries(struct hists *hists, struct hist_entry *h); void hists__inc_nr_events(struct hists *hists, u32 type); void events_stats__inc(struct events_stats *stats, u32 type); diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c index 95e249779931..b2eca6c17a70 100644 --- a/tools/perf/util/symbol.c +++ b/tools/perf/util/symbol.c @@ -33,6 +33,7 @@ struct symbol_conf symbol_conf = { .try_vmlinux_path = true, .annotate_src = true, .demangle = true, + .filter_relative = true, .symfs = "", }; diff --git a/tools/perf/util/symbol.h b/tools/perf/util/symbol.h index 501e4e722e8e..ae94e006a52d 100644 --- a/tools/perf/util/symbol.h +++ b/tools/perf/util/symbol.h @@ -115,7 +115,8 @@ struct symbol_conf { annotate_asm_raw, annotate_src, event_group, - demangle; + demangle, + filter_relative; const char *vmlinux_name, *kallsyms_name, *source_prefix, -- cgit v1.2.3 From 33db4568e1f41efe6d0e4695483f968fc1135bf3 Mon Sep 17 00:00:00 2001 From: Namhyung Kim Date: Fri, 7 Feb 2014 12:06:07 +0900 Subject: perf top: Add --percentage option The --percentage option is for controlling overhead percentage displayed. It can only receive either of "relative" or "absolute". Move the parser callback function into a common location since it's used by multiple commands now. For more information, please see previous commit same thing done to "perf report". Signed-off-by: Namhyung Kim Link: http://lkml.kernel.org/r/1397145720-8063-4-git-send-email-namhyung@kernel.org Signed-off-by: Jiri Olsa --- tools/perf/Documentation/perf-top.txt | 18 +++++++++++++++--- tools/perf/builtin-report.c | 16 +--------------- tools/perf/builtin-top.c | 5 +++-- tools/perf/util/hist.c | 13 +++++++++++++ tools/perf/util/hist.h | 5 +++++ 5 files changed, 37 insertions(+), 20 deletions(-) diff --git a/tools/perf/Documentation/perf-top.txt b/tools/perf/Documentation/perf-top.txt index 976b00c6cdb1..64ed79c43639 100644 --- a/tools/perf/Documentation/perf-top.txt +++ b/tools/perf/Documentation/perf-top.txt @@ -123,13 +123,16 @@ Default is to monitor all CPUS. Show a column with the sum of periods. --dsos:: - Only consider symbols in these dsos. + Only consider symbols in these dsos. This option will affect the + percentage of the overhead column. See --percentage for more info. --comms:: - Only consider symbols in these comms. + Only consider symbols in these comms. This option will affect the + percentage of the overhead column. See --percentage for more info. --symbols:: - Only consider these symbols. + Only consider these symbols. This option will affect the + percentage of the overhead column. See --percentage for more info. -M:: --disassembler-style=:: Set disassembler style for objdump. @@ -165,6 +168,15 @@ Default is to monitor all CPUS. Do not show entries which have an overhead under that percent. (Default: 0). +--percentage:: + Determine how to display the overhead percentage of filtered entries. + Filters can be applied by --comms, --dsos and/or --symbols options and + Zoom operations on the TUI (thread, dso, etc). + + "relative" means it's relative to filtered entries only so that the + sum of shown entries will be always 100%. "absolute" means it retains + the original value before and after the filter is applied. + INTERACTIVE PROMPTING KEYS -------------------------- diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c index 7ec351bda833..af8cb7a2c9b6 100644 --- a/tools/perf/builtin-report.c +++ b/tools/perf/builtin-report.c @@ -717,20 +717,6 @@ parse_percent_limit(const struct option *opt, const char *str, return 0; } -static int -parse_percentage(const struct option *opt __maybe_unused, const char *str, - int unset __maybe_unused) -{ - if (!strcmp(str, "relative")) - symbol_conf.filter_relative = true; - else if (!strcmp(str, "absolute")) - symbol_conf.filter_relative = false; - else - return -1; - - return 0; -} - int cmd_report(int argc, const char **argv, const char *prefix __maybe_unused) { struct perf_session *session; @@ -854,7 +840,7 @@ int cmd_report(int argc, const char **argv, const char *prefix __maybe_unused) OPT_CALLBACK(0, "percent-limit", &report, "percent", "Don't show entries under that percent", parse_percent_limit), OPT_CALLBACK(0, "percentage", NULL, "relative|absolute", - "how to display percentage of filtered entries", parse_percentage), + "how to display percentage of filtered entries", parse_filter_percentage), OPT_END() }; struct perf_data_file file = { diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c index 25269014164a..37d30460bada 100644 --- a/tools/perf/builtin-top.c +++ b/tools/perf/builtin-top.c @@ -697,8 +697,7 @@ static void perf_event__process_sample(struct perf_tool *tool, if (event->header.misc & PERF_RECORD_MISC_EXACT_IP) top->exact_samples++; - if (perf_event__preprocess_sample(event, machine, &al, sample) < 0 || - al.filtered) + if (perf_event__preprocess_sample(event, machine, &al, sample) < 0) return; if (!top->kptr_restrict_warned && @@ -1119,6 +1118,8 @@ int cmd_top(int argc, const char **argv, const char *prefix __maybe_unused) OPT_STRING('u', "uid", &target->uid_str, "user", "user to profile"), OPT_CALLBACK(0, "percent-limit", &top, "percent", "Don't show entries under that percent", parse_percent_limit), + OPT_CALLBACK(0, "percentage", NULL, "relative|absolute", + "How to display percentage of filtered entries", parse_filter_percentage), OPT_END() }; const char * const top_usage[] = { diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c index 3ebd89a28257..3c2dd233b98e 100644 --- a/tools/perf/util/hist.c +++ b/tools/perf/util/hist.c @@ -943,3 +943,16 @@ u64 hists__total_period(struct hists *hists) return symbol_conf.filter_relative ? hists->stats.total_non_filtered_period : hists->stats.total_period; } + +int parse_filter_percentage(const struct option *opt __maybe_unused, + const char *arg, int unset __maybe_unused) +{ + if (!strcmp(arg, "relative")) + symbol_conf.filter_relative = true; + else if (!strcmp(arg, "absolute")) + symbol_conf.filter_relative = false; + else + return -1; + + return 0; +} diff --git a/tools/perf/util/hist.h b/tools/perf/util/hist.h index 3191496bd3b7..a4ec336ae3fe 100644 --- a/tools/perf/util/hist.h +++ b/tools/perf/util/hist.h @@ -254,4 +254,9 @@ static inline int script_browse(const char *script_opt __maybe_unused) #endif unsigned int hists__sort_list_width(struct hists *hists); + +struct option; +int parse_filter_percentage(const struct option *opt __maybe_unused, + const char *arg, int unset __maybe_unused); + #endif /* __PERF_HIST_H */ -- cgit v1.2.3 From 8810f6ced73556c1a63b6269a6cdad8d630aaaf0 Mon Sep 17 00:00:00 2001 From: Namhyung Kim Date: Fri, 7 Feb 2014 12:06:07 +0900 Subject: perf diff: Add --percentage option The --percentage option is for controlling overhead percentage displayed. It can only receive either of "relative" or "absolute" and affects -c delta output only. For more information, please see previous commit same thing done to "perf report". Signed-off-by: Namhyung Kim Link: http://lkml.kernel.org/r/1397145720-8063-5-git-send-email-namhyung@kernel.org Signed-off-by: Jiri Olsa --- tools/perf/Documentation/perf-diff.txt | 21 ++++++++++++++++++--- tools/perf/builtin-diff.c | 30 ++++++++++++++++++++++-------- 2 files changed, 40 insertions(+), 11 deletions(-) diff --git a/tools/perf/Documentation/perf-diff.txt b/tools/perf/Documentation/perf-diff.txt index fdfceee0ffd0..fbfa1192923c 100644 --- a/tools/perf/Documentation/perf-diff.txt +++ b/tools/perf/Documentation/perf-diff.txt @@ -33,17 +33,20 @@ OPTIONS -d:: --dsos=:: Only consider symbols in these dsos. CSV that understands - file://filename entries. + file://filename entries. This option will affect the percentage + of the Baseline/Delta column. See --percentage for more info. -C:: --comms=:: Only consider symbols in these comms. CSV that understands - file://filename entries. + file://filename entries. This option will affect the percentage + of the Baseline/Delta column. See --percentage for more info. -S:: --symbols=:: Only consider these symbols. CSV that understands - file://filename entries. + file://filename entries. This option will affect the percentage + of the Baseline/Delta column. See --percentage for more info. -s:: --sort=:: @@ -89,6 +92,14 @@ OPTIONS --order:: Specify compute sorting column number. +--percentage:: + Determine how to display the overhead percentage of filtered entries. + Filters can be applied by --comms, --dsos and/or --symbols options. + + "relative" means it's relative to filtered entries only so that the + sum of shown entries will be always 100%. "absolute" means it retains + the original value before and after the filter is applied. + COMPARISON ---------- The comparison is governed by the baseline file. The baseline perf.data @@ -157,6 +168,10 @@ with: - period_percent being the % of the hist entry period value within single data file + - with filtering by -C, -d and/or -S, period_percent might be changed + relative to how entries are filtered. Use --percentage=absolute to + prevent such fluctuation. + ratio ~~~~~ If specified the 'Ratio' column is displayed with value 'r' computed as: diff --git a/tools/perf/builtin-diff.c b/tools/perf/builtin-diff.c index 204fffe22532..c903fe13c173 100644 --- a/tools/perf/builtin-diff.c +++ b/tools/perf/builtin-diff.c @@ -220,7 +220,8 @@ static int setup_compute(const struct option *opt, const char *str, static double period_percent(struct hist_entry *he, u64 period) { - u64 total = he->hists->stats.total_period; + u64 total = hists__total_period(he->hists); + return (period * 100.0) / total; } @@ -259,11 +260,18 @@ static s64 compute_wdiff(struct hist_entry *he, struct hist_entry *pair) static int formula_delta(struct hist_entry *he, struct hist_entry *pair, char *buf, size_t size) { + u64 he_total = he->hists->stats.total_period; + u64 pair_total = pair->hists->stats.total_period; + + if (symbol_conf.filter_relative) { + he_total = he->hists->stats.total_non_filtered_period; + pair_total = pair->hists->stats.total_non_filtered_period; + } return scnprintf(buf, size, "(%" PRIu64 " * 100 / %" PRIu64 ") - " "(%" PRIu64 " * 100 / %" PRIu64 ")", - pair->stat.period, pair->hists->stats.total_period, - he->stat.period, he->hists->stats.total_period); + pair->stat.period, pair_total, + he->stat.period, he_total); } static int formula_ratio(struct hist_entry *he, struct hist_entry *pair, @@ -327,15 +335,16 @@ static int diff__process_sample_event(struct perf_tool *tool __maybe_unused, return -1; } - if (al.filtered) - return 0; - if (hists__add_entry(&evsel->hists, &al, sample->period, sample->weight, sample->transaction)) { pr_warning("problem incrementing symbol period, skipping event\n"); return -1; } + if (al.filtered == 0) { + evsel->hists.stats.total_non_filtered_period += sample->period; + evsel->hists.nr_non_filtered_entries++; + } evsel->hists.stats.total_period += sample->period; return 0; } @@ -565,7 +574,9 @@ static void hists__compute_resort(struct hists *hists) next = rb_first(root); hists->nr_entries = 0; + hists->nr_non_filtered_entries = 0; hists->stats.total_period = 0; + hists->stats.total_non_filtered_period = 0; hists__reset_col_len(hists); while (next != NULL) { @@ -732,13 +743,16 @@ static const struct option options[] = { OPT_STRING(0, "symfs", &symbol_conf.symfs, "directory", "Look for files with symbols relative to this directory"), OPT_UINTEGER('o', "order", &sort_compute, "Specify compute sorting."), + OPT_CALLBACK(0, "percentage", NULL, "relative|absolute", + "How to display percentage of filtered entries", parse_filter_percentage), OPT_END() }; static double baseline_percent(struct hist_entry *he) { - struct hists *hists = he->hists; - return 100.0 * he->stat.period / hists->stats.total_period; + u64 total = hists__total_period(he->hists); + + return 100.0 * he->stat.period / total; } static int hpp__color_baseline(struct perf_hpp_fmt *fmt, -- cgit v1.2.3 From 0b93da1756df4fe930ee0220a6addce263a6e0ab Mon Sep 17 00:00:00 2001 From: Namhyung Kim Date: Tue, 14 Jan 2014 12:02:15 +0900 Subject: perf tools: Add hist.percentage config option Add hist.percentage option for setting default value of the symbol_conf.filter_relative. It affects the output of various perf commands (like perf report, top and diff) only if filter(s) applied. An user can write .perfconfig file like below to show absolute percentage of filtered entries by default: $ cat ~/.perfconfig [hist] percentage = absolute And it can be changed through command line: $ perf report --percentage relative Signed-off-by: Namhyung Kim Link: http://lkml.kernel.org/r/1397145720-8063-6-git-send-email-namhyung@kernel.org Signed-off-by: Jiri Olsa --- tools/perf/builtin-diff.c | 2 ++ tools/perf/util/config.c | 4 ++++ tools/perf/util/hist.c | 8 ++++++++ tools/perf/util/hist.h | 1 + 4 files changed, 15 insertions(+) diff --git a/tools/perf/builtin-diff.c b/tools/perf/builtin-diff.c index c903fe13c173..6ef80f22c1e2 100644 --- a/tools/perf/builtin-diff.c +++ b/tools/perf/builtin-diff.c @@ -1134,6 +1134,8 @@ static int data_init(int argc, const char **argv) int cmd_diff(int argc, const char **argv, const char *prefix __maybe_unused) { + perf_config(perf_default_config, NULL); + sort_order = diff__default_sort_order; argc = parse_options(argc, argv, options, diff_usage, 0); diff --git a/tools/perf/util/config.c b/tools/perf/util/config.c index 3e0fdd369ccb..24519e14ac56 100644 --- a/tools/perf/util/config.c +++ b/tools/perf/util/config.c @@ -11,6 +11,7 @@ #include "util.h" #include "cache.h" #include "exec_cmd.h" +#include "util/hist.h" /* perf_hist_config */ #define MAXNAME (256) @@ -355,6 +356,9 @@ int perf_default_config(const char *var, const char *value, if (!prefixcmp(var, "core.")) return perf_default_core_config(var, value); + if (!prefixcmp(var, "hist.")) + return perf_hist_config(var, value); + /* Add other config variables here. */ return 0; } diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c index 3c2dd233b98e..5a892477aa50 100644 --- a/tools/perf/util/hist.c +++ b/tools/perf/util/hist.c @@ -956,3 +956,11 @@ int parse_filter_percentage(const struct option *opt __maybe_unused, return 0; } + +int perf_hist_config(const char *var, const char *value) +{ + if (!strcmp(var, "hist.percentage")) + return parse_filter_percentage(NULL, value, 0); + + return 0; +} diff --git a/tools/perf/util/hist.h b/tools/perf/util/hist.h index a4ec336ae3fe..5a0343eb22e2 100644 --- a/tools/perf/util/hist.h +++ b/tools/perf/util/hist.h @@ -258,5 +258,6 @@ unsigned int hists__sort_list_width(struct hists *hists); struct option; int parse_filter_percentage(const struct option *opt __maybe_unused, const char *arg, int unset __maybe_unused); +int perf_hist_config(const char *var, const char *value); #endif /* __PERF_HIST_H */ -- cgit v1.2.3 From 105eb30f18197a217695eac4ddf87526f2cba867 Mon Sep 17 00:00:00 2001 From: Namhyung Kim Date: Mon, 10 Feb 2014 11:20:10 +0900 Subject: perf ui/tui: Add 'F' hotkey to toggle percentage output Add 'F' hotkey to toggle relative and absolute percentage of filtered entries. Suggested-by: Jiri Olsa Signed-off-by: Namhyung Kim Link: http://lkml.kernel.org/r/1397145720-8063-7-git-send-email-namhyung@kernel.org Signed-off-by: Jiri Olsa --- tools/perf/ui/browsers/hists.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c index 7ad11477a0f5..4d416984c59d 100644 --- a/tools/perf/ui/browsers/hists.c +++ b/tools/perf/ui/browsers/hists.c @@ -1389,6 +1389,7 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events, "C Collapse all callchains\n" \ "d Zoom into current DSO\n" \ "E Expand all callchains\n" \ + "F Toggle percentage of filtered entries\n" \ /* help messages are sorted by lexical order of the hotkey */ const char report_help[] = HIST_BROWSER_HELP_COMMON @@ -1494,6 +1495,9 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events, if (env->arch) tui__header_window(env); continue; + case 'F': + symbol_conf.filter_relative ^= 1; + continue; case K_F1: case 'h': case '?': -- cgit v1.2.3 From 95ce0ba17d5a0a04bbad61720512381d8165d157 Mon Sep 17 00:00:00 2001 From: Namhyung Kim Date: Tue, 14 Jan 2014 12:05:27 +0900 Subject: perf tools: Show absolute percentage by default Now perf report will show absolute percentage on filter entries by default. Suggested-by: Jiri Olsa Signed-off-by: Namhyung Kim Link: http://lkml.kernel.org/r/1397145720-8063-8-git-send-email-namhyung@kernel.org Signed-off-by: Jiri Olsa --- tools/perf/util/symbol.c | 1 - 1 file changed, 1 deletion(-) diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c index b2eca6c17a70..95e249779931 100644 --- a/tools/perf/util/symbol.c +++ b/tools/perf/util/symbol.c @@ -33,7 +33,6 @@ struct symbol_conf symbol_conf = { .try_vmlinux_path = true, .annotate_src = true, .demangle = true, - .filter_relative = true, .symfs = "", }; -- cgit v1.2.3 From 3bca23543b910a84d3c58a819663e0a4fad72bb6 Mon Sep 17 00:00:00 2001 From: Ramkumar Ramachandra Date: Fri, 14 Mar 2014 23:17:51 -0400 Subject: perf kmem: Introduce --list-cmds for use by scripts Signed-off-by: Ramkumar Ramachandra Acked-by: David Ahern Cc: Jiri Olsa Link: http://lkml.kernel.org/r/1394853474-31019-2-git-send-email-artagnon@gmail.com Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: Jiri Olsa --- tools/perf/builtin-kmem.c | 8 +++++--- tools/perf/perf-completion.sh | 4 ++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/tools/perf/builtin-kmem.c b/tools/perf/builtin-kmem.c index 929462aa4943..bd91de07d2a9 100644 --- a/tools/perf/builtin-kmem.c +++ b/tools/perf/builtin-kmem.c @@ -756,11 +756,13 @@ int cmd_kmem(int argc, const char **argv, const char *prefix __maybe_unused) OPT_BOOLEAN(0, "raw-ip", &raw_ip, "show raw ip instead of symbol"), OPT_END() }; - const char * const kmem_usage[] = { - "perf kmem [] {record|stat}", + const char *const kmem_subcommands[] = { "record", "stat", NULL }; + const char *kmem_usage[] = { + NULL, NULL }; - argc = parse_options(argc, argv, kmem_options, kmem_usage, 0); + argc = parse_options_subcommand(argc, argv, kmem_options, + kmem_subcommands, kmem_usage, 0); if (!argc) usage_with_options(kmem_usage, kmem_options); diff --git a/tools/perf/perf-completion.sh b/tools/perf/perf-completion.sh index ae3a57694b6b..0ef59dd4c78d 100644 --- a/tools/perf/perf-completion.sh +++ b/tools/perf/perf-completion.sh @@ -121,8 +121,8 @@ __perf_main () elif [[ $prev == "-e" && "${words[1]}" == @(record|stat|top) ]]; then evts=$($cmd list --raw-dump) __perfcomp_colon "$evts" "$cur" - # List subcommands for 'perf kvm' - elif [[ $prev == "kvm" ]]; then + # List subcommands for perf commands + elif [[ $prev == @(kvm|kmem) ]]; then subcmds=$($cmd $prev --list-cmds) __perfcomp_colon "$subcmds" "$cur" # List long option names -- cgit v1.2.3 From 8d2a2a1d885d36e978c4619a3db8791f9768dd6a Mon Sep 17 00:00:00 2001 From: Ramkumar Ramachandra Date: Fri, 14 Mar 2014 23:17:52 -0400 Subject: perf mem: Introduce --list-cmds for use by scripts Signed-off-by: Ramkumar Ramachandra Acked-by: David Ahern Cc: David Ahern Cc: Jiri Olsa Link: http://lkml.kernel.org/r/1394853474-31019-3-git-send-email-artagnon@gmail.com Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: Jiri Olsa --- tools/perf/builtin-mem.c | 15 ++++++++------- tools/perf/perf-completion.sh | 2 +- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/tools/perf/builtin-mem.c b/tools/perf/builtin-mem.c index 2e3ade69a58e..4a1a6c94a5eb 100644 --- a/tools/perf/builtin-mem.c +++ b/tools/perf/builtin-mem.c @@ -21,11 +21,6 @@ struct perf_mem { DECLARE_BITMAP(cpu_bitmap, MAX_NR_CPUS); }; -static const char * const mem_usage[] = { - "perf mem [] {record |report}", - NULL -}; - static int __cmd_record(int argc, const char **argv) { int rec_argc, i = 0, j; @@ -220,9 +215,15 @@ int cmd_mem(int argc, const char **argv, const char *prefix __maybe_unused) " between columns '.' is reserved."), OPT_END() }; + const char *const mem_subcommands[] = { "record", "report", NULL }; + const char *mem_usage[] = { + NULL, + NULL + }; + - argc = parse_options(argc, argv, mem_options, mem_usage, - PARSE_OPT_STOP_AT_NON_OPTION); + argc = parse_options_subcommand(argc, argv, mem_options, mem_subcommands, + mem_usage, PARSE_OPT_STOP_AT_NON_OPTION); if (!argc || !(strncmp(argv[0], "rec", 3) || mem_operation)) usage_with_options(mem_usage, mem_options); diff --git a/tools/perf/perf-completion.sh b/tools/perf/perf-completion.sh index 0ef59dd4c78d..f44c04b1015d 100644 --- a/tools/perf/perf-completion.sh +++ b/tools/perf/perf-completion.sh @@ -122,7 +122,7 @@ __perf_main () evts=$($cmd list --raw-dump) __perfcomp_colon "$evts" "$cur" # List subcommands for perf commands - elif [[ $prev == @(kvm|kmem) ]]; then + elif [[ $prev == @(kvm|kmem|mem) ]]; then subcmds=$($cmd $prev --list-cmds) __perfcomp_colon "$subcmds" "$cur" # List long option names -- cgit v1.2.3 From a2368c3199eba493d72c6d0e5b804f908a09706c Mon Sep 17 00:00:00 2001 From: Ramkumar Ramachandra Date: Fri, 14 Mar 2014 23:17:53 -0400 Subject: perf lock: Introduce --list-cmds for use by scripts Signed-off-by: Ramkumar Ramachandra Acked-by: David Ahern Cc: David Ahern Cc: Jiri Olsa Link: http://lkml.kernel.org/r/1394853474-31019-4-git-send-email-artagnon@gmail.com Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: Jiri Olsa --- tools/perf/builtin-lock.c | 10 ++++++---- tools/perf/perf-completion.sh | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/tools/perf/builtin-lock.c b/tools/perf/builtin-lock.c index c852c7a85d32..6148afc995c6 100644 --- a/tools/perf/builtin-lock.c +++ b/tools/perf/builtin-lock.c @@ -961,8 +961,10 @@ int cmd_lock(int argc, const char **argv, const char *prefix __maybe_unused) "perf lock info []", NULL }; - const char * const lock_usage[] = { - "perf lock [] {record|report|script|info}", + const char *const lock_subcommands[] = { "record", "report", "script", + "info", NULL }; + const char *lock_usage[] = { + NULL, NULL }; const char * const report_usage[] = { @@ -976,8 +978,8 @@ int cmd_lock(int argc, const char **argv, const char *prefix __maybe_unused) for (i = 0; i < LOCKHASH_SIZE; i++) INIT_LIST_HEAD(lockhash_table + i); - argc = parse_options(argc, argv, lock_options, lock_usage, - PARSE_OPT_STOP_AT_NON_OPTION); + argc = parse_options_subcommand(argc, argv, lock_options, lock_subcommands, + lock_usage, PARSE_OPT_STOP_AT_NON_OPTION); if (!argc) usage_with_options(lock_usage, lock_options); diff --git a/tools/perf/perf-completion.sh b/tools/perf/perf-completion.sh index f44c04b1015d..ecedab6524e4 100644 --- a/tools/perf/perf-completion.sh +++ b/tools/perf/perf-completion.sh @@ -122,7 +122,7 @@ __perf_main () evts=$($cmd list --raw-dump) __perfcomp_colon "$evts" "$cur" # List subcommands for perf commands - elif [[ $prev == @(kvm|kmem|mem) ]]; then + elif [[ $prev == @(kvm|kmem|mem|lock) ]]; then subcmds=$($cmd $prev --list-cmds) __perfcomp_colon "$subcmds" "$cur" # List long option names -- cgit v1.2.3 From a83edb2dfc5989fbadc594109c933bae528a2809 Mon Sep 17 00:00:00 2001 From: Ramkumar Ramachandra Date: Fri, 14 Mar 2014 23:17:54 -0400 Subject: perf sched: Introduce --list-cmds for use by scripts Signed-off-by: Ramkumar Ramachandra Acked-by: David Ahern Cc: David Ahern Cc: Jiri Olsa Link: http://lkml.kernel.org/r/1394853474-31019-5-git-send-email-artagnon@gmail.com Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: Jiri Olsa --- tools/perf/builtin-sched.c | 10 ++++++---- tools/perf/perf-completion.sh | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c index 9ac0a495c954..d3fb0ed7240a 100644 --- a/tools/perf/builtin-sched.c +++ b/tools/perf/builtin-sched.c @@ -1713,8 +1713,10 @@ int cmd_sched(int argc, const char **argv, const char *prefix __maybe_unused) "perf sched replay []", NULL }; - const char * const sched_usage[] = { - "perf sched [] {record|latency|map|replay|script}", + const char *const sched_subcommands[] = { "record", "latency", "map", + "replay", "script", NULL }; + const char *sched_usage[] = { + NULL, NULL }; struct trace_sched_handler lat_ops = { @@ -1736,8 +1738,8 @@ int cmd_sched(int argc, const char **argv, const char *prefix __maybe_unused) for (i = 0; i < ARRAY_SIZE(sched.curr_pid); i++) sched.curr_pid[i] = -1; - argc = parse_options(argc, argv, sched_options, sched_usage, - PARSE_OPT_STOP_AT_NON_OPTION); + argc = parse_options_subcommand(argc, argv, sched_options, sched_subcommands, + sched_usage, PARSE_OPT_STOP_AT_NON_OPTION); if (!argc) usage_with_options(sched_usage, sched_options); diff --git a/tools/perf/perf-completion.sh b/tools/perf/perf-completion.sh index ecedab6524e4..33569847fdcc 100644 --- a/tools/perf/perf-completion.sh +++ b/tools/perf/perf-completion.sh @@ -122,7 +122,7 @@ __perf_main () evts=$($cmd list --raw-dump) __perfcomp_colon "$evts" "$cur" # List subcommands for perf commands - elif [[ $prev == @(kvm|kmem|mem|lock) ]]; then + elif [[ $prev == @(kvm|kmem|mem|lock|sched) ]]; then subcmds=$($cmd $prev --list-cmds) __perfcomp_colon "$subcmds" "$cur" # List long option names -- cgit v1.2.3 From 687ef9817df7ed960d14575b9033dde3d04631fe Mon Sep 17 00:00:00 2001 From: Felipe Balbi Date: Wed, 16 Apr 2014 10:30:33 -0500 Subject: usb: dwc3: gadget: clear stall when disabling endpoint so it seems like DWC3 IP doesn't clear stalls automatically when we disable an endpoint, because of that, we _must_ make sure stalls are cleared before clearing the proper bit in DALEPENA register. Cc: # v3.4+ Reported-by: Johannes Stezenbach Signed-off-by: Felipe Balbi --- drivers/usb/dwc3/gadget.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c index a740eac74d56..f0dc0ee85ded 100644 --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c @@ -608,6 +608,10 @@ static int __dwc3_gadget_ep_disable(struct dwc3_ep *dep) dwc3_remove_requests(dwc, dep); + /* make sure HW endpoint isn't stalled */ + if (dep->flags & DWC3_EP_STALL) + __dwc3_gadget_ep_set_halt(dep, 0); + reg = dwc3_readl(dwc->regs, DWC3_DALEPENA); reg &= ~DWC3_DALEPENA_EP(dep->number); dwc3_writel(dwc->regs, DWC3_DALEPENA, reg); -- cgit v1.2.3 From 3c9f94aca66aa8c83d531961ea8c7b8bace9433c Mon Sep 17 00:00:00 2001 From: Felipe Balbi Date: Wed, 16 Apr 2014 15:08:29 -0500 Subject: usb: dwc3: core: refactor PHY initialization our probe() routine is too large and we can easily refactor PHY-related code out to another function to make it slightly less painful to read. Signed-off-by: Felipe Balbi --- drivers/usb/dwc3/core.c | 120 ++++++++++++++++++++++++++---------------------- 1 file changed, 66 insertions(+), 54 deletions(-) diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index d001417e8e37..38976f3123d3 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c @@ -486,70 +486,20 @@ static void dwc3_core_exit(struct dwc3 *dwc) phy_exit(dwc->usb3_generic_phy); } -#define DWC3_ALIGN_MASK (16 - 1) - -static int dwc3_probe(struct platform_device *pdev) +static int dwc3_core_get_phy(struct dwc3 *dwc) { - struct device *dev = &pdev->dev; - struct dwc3_platform_data *pdata = dev_get_platdata(dev); + struct device *dev = dwc->dev; struct device_node *node = dev->of_node; - struct resource *res; - struct dwc3 *dwc; - - int ret = -ENOMEM; - - void __iomem *regs; - void *mem; - - mem = devm_kzalloc(dev, sizeof(*dwc) + DWC3_ALIGN_MASK, GFP_KERNEL); - if (!mem) { - dev_err(dev, "not enough memory\n"); - return -ENOMEM; - } - dwc = PTR_ALIGN(mem, DWC3_ALIGN_MASK + 1); - dwc->mem = mem; - - res = platform_get_resource(pdev, IORESOURCE_IRQ, 0); - if (!res) { - dev_err(dev, "missing IRQ\n"); - return -ENODEV; - } - dwc->xhci_resources[1].start = res->start; - dwc->xhci_resources[1].end = res->end; - dwc->xhci_resources[1].flags = res->flags; - dwc->xhci_resources[1].name = res->name; - - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - if (!res) { - dev_err(dev, "missing memory resource\n"); - return -ENODEV; - } + int ret; if (node) { - dwc->maximum_speed = of_usb_get_maximum_speed(node); - dwc->usb2_phy = devm_usb_get_phy_by_phandle(dev, "usb-phy", 0); dwc->usb3_phy = devm_usb_get_phy_by_phandle(dev, "usb-phy", 1); - - dwc->needs_fifo_resize = of_property_read_bool(node, "tx-fifo-resize"); - dwc->dr_mode = of_usb_get_dr_mode(node); - } else if (pdata) { - dwc->maximum_speed = pdata->maximum_speed; - - dwc->usb2_phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB2); - dwc->usb3_phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB3); - - dwc->needs_fifo_resize = pdata->tx_fifo_resize; - dwc->dr_mode = pdata->dr_mode; } else { dwc->usb2_phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB2); dwc->usb3_phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB3); } - /* default to superspeed if no maximum_speed passed */ - if (dwc->maximum_speed == USB_SPEED_UNKNOWN) - dwc->maximum_speed = USB_SPEED_SUPER; - if (IS_ERR(dwc->usb2_phy)) { ret = PTR_ERR(dwc->usb2_phy); if (ret == -ENXIO || ret == -ENODEV) { @@ -600,6 +550,69 @@ static int dwc3_probe(struct platform_device *pdev) } } + return 0; +} + +#define DWC3_ALIGN_MASK (16 - 1) + +static int dwc3_probe(struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + struct dwc3_platform_data *pdata = dev_get_platdata(dev); + struct device_node *node = dev->of_node; + struct resource *res; + struct dwc3 *dwc; + + int ret = -ENOMEM; + + void __iomem *regs; + void *mem; + + mem = devm_kzalloc(dev, sizeof(*dwc) + DWC3_ALIGN_MASK, GFP_KERNEL); + if (!mem) { + dev_err(dev, "not enough memory\n"); + return -ENOMEM; + } + dwc = PTR_ALIGN(mem, DWC3_ALIGN_MASK + 1); + dwc->mem = mem; + dwc->dev = dev; + + res = platform_get_resource(pdev, IORESOURCE_IRQ, 0); + if (!res) { + dev_err(dev, "missing IRQ\n"); + return -ENODEV; + } + dwc->xhci_resources[1].start = res->start; + dwc->xhci_resources[1].end = res->end; + dwc->xhci_resources[1].flags = res->flags; + dwc->xhci_resources[1].name = res->name; + + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + if (!res) { + dev_err(dev, "missing memory resource\n"); + return -ENODEV; + } + + if (node) { + dwc->maximum_speed = of_usb_get_maximum_speed(node); + + dwc->needs_fifo_resize = of_property_read_bool(node, "tx-fifo-resize"); + dwc->dr_mode = of_usb_get_dr_mode(node); + } else if (pdata) { + dwc->maximum_speed = pdata->maximum_speed; + + dwc->needs_fifo_resize = pdata->tx_fifo_resize; + dwc->dr_mode = pdata->dr_mode; + } + + /* default to superspeed if no maximum_speed passed */ + if (dwc->maximum_speed == USB_SPEED_UNKNOWN) + dwc->maximum_speed = USB_SPEED_SUPER; + + ret = dwc3_core_get_phy(dwc); + if (ret) + return ret; + dwc->xhci_resources[0].start = res->start; dwc->xhci_resources[0].end = dwc->xhci_resources[0].start + DWC3_XHCI_REGS_END; @@ -621,7 +634,6 @@ static int dwc3_probe(struct platform_device *pdev) dwc->regs = regs; dwc->regs_size = resource_size(res); - dwc->dev = dev; dev->dma_mask = dev->parent->dma_mask; dev->dma_parms = dev->parent->dma_parms; -- cgit v1.2.3 From 8e1a6287d950ca386a738ff2043b3e2252fc0e76 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Wed, 16 Apr 2014 08:26:20 -0600 Subject: gdrom: missed conversion from req->buffer The friendly Intel kbuild test robot reported: drivers/cdrom/gdrom.c: In function 'gdrom_readdisk_dma': drivers/cdrom/gdrom.c:605:3: error: 'struct request' has no member named 'buffer' Convert that from req->buffer to bio_data(rq->bio). Apparently my grep missed this one, and I don't build for Sega Dreamcast enough. Signed-off-by: Jens Axboe --- drivers/cdrom/gdrom.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/cdrom/gdrom.c b/drivers/cdrom/gdrom.c index 51e75ad96422..584bc3126403 100644 --- a/drivers/cdrom/gdrom.c +++ b/drivers/cdrom/gdrom.c @@ -602,7 +602,7 @@ static void gdrom_readdisk_dma(struct work_struct *work) spin_unlock(&gdrom_lock); block = blk_rq_pos(req)/GD_TO_BLK + GD_SESSION_OFFSET; block_cnt = blk_rq_sectors(req)/GD_TO_BLK; - __raw_writel(virt_to_phys(req->buffer), GDROM_DMA_STARTADDR_REG); + __raw_writel(virt_to_phys(bio_data(req->bio)), GDROM_DMA_STARTADDR_REG); __raw_writel(block_cnt * GDROM_HARD_SECTOR, GDROM_DMA_LENGTH_REG); __raw_writel(1, GDROM_DMA_DIRECTION_REG); __raw_writel(1, GDROM_DMA_ENABLE_REG); -- cgit v1.2.3 From fd1270d5df6a005e1248e87042159a799cc4b2c9 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Wed, 16 Apr 2014 09:23:48 -0600 Subject: blk-mq: don't use preempt_count() to check for right CPU UP or CONFIG_PREEMPT_NONE will return 0, and what we really want to check is whether or not we are on the right CPU. So don't make PREEMPT part of this, just test the CPU in the mask directly. Signed-off-by: Jens Axboe --- block/blk-mq.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/blk-mq.c b/block/blk-mq.c index 9180052d42cc..1fa01ff0f9bc 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -534,7 +534,7 @@ static void __blk_mq_run_hw_queue(struct blk_mq_hw_ctx *hctx) LIST_HEAD(rq_list); int bit, queued; - WARN_ON(!preempt_count()); + WARN_ON(!cpumask_test_cpu(raw_smp_processor_id(), hctx->cpumask)); if (unlikely(test_bit(BLK_MQ_S_STOPPED, &hctx->state))) return; -- cgit v1.2.3 From 6700a678c02e47b6d50c51da2a46ff80efedb8c7 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Wed, 16 Apr 2014 10:38:35 -0600 Subject: blk-mq: kill preempt disable/enable in blk_mq_work_fn() blk_mq_work_fn() is always invoked off the bounded workqueues, so it can happily preempt among the queues in that set without causing any issues for blk-mq. Signed-off-by: Jens Axboe --- block/blk-mq.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/block/blk-mq.c b/block/blk-mq.c index 1fa01ff0f9bc..b59a8d027dff 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -714,9 +714,7 @@ static void blk_mq_work_fn(struct work_struct *work) hctx = container_of(work, struct blk_mq_hw_ctx, delayed_work.work); - preempt_disable(); __blk_mq_run_hw_queue(hctx); - preempt_enable(); } static void __blk_mq_insert_request(struct blk_mq_hw_ctx *hctx, -- cgit v1.2.3 From 63151a449ebaef062ffac5b302206565ff5ef62e Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Wed, 16 Apr 2014 09:44:52 +0200 Subject: blk-mq: allow drivers to hook into I/O completion Split out the bottom half of blk_mq_end_io so that drivers can perform work when they know a request has been completed, but before it has been freed. This also obsoletes blk_mq_end_io_partial as drivers can now pass any value to blk_update_request directly. Signed-off-by: Christoph Hellwig Signed-off-by: Jens Axboe --- block/blk-mq.c | 16 ++++++++++------ include/linux/blk-mq.h | 9 ++------- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/block/blk-mq.c b/block/blk-mq.c index b59a8d027dff..86d66e0e900c 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -294,20 +294,24 @@ void blk_mq_clone_flush_request(struct request *flush_rq, hctx->cmd_size); } -bool blk_mq_end_io_partial(struct request *rq, int error, unsigned int nr_bytes) +inline void __blk_mq_end_io(struct request *rq, int error) { - if (blk_update_request(rq, error, blk_rq_bytes(rq))) - return true; - blk_account_io_done(rq); if (rq->end_io) rq->end_io(rq, error); else blk_mq_free_request(rq); - return false; } -EXPORT_SYMBOL(blk_mq_end_io_partial); +EXPORT_SYMBOL(__blk_mq_end_io); + +void blk_mq_end_io(struct request *rq, int error) +{ + if (blk_update_request(rq, error, blk_rq_bytes(rq))) + BUG(); + __blk_mq_end_io(rq, error); +} +EXPORT_SYMBOL(blk_mq_end_io); static void __blk_mq_complete_request_remote(void *data) { diff --git a/include/linux/blk-mq.h b/include/linux/blk-mq.h index a4ea0ce83b07..a81b474b794f 100644 --- a/include/linux/blk-mq.h +++ b/include/linux/blk-mq.h @@ -149,13 +149,8 @@ struct blk_mq_hw_ctx *blk_mq_map_queue(struct request_queue *, const int ctx_ind struct blk_mq_hw_ctx *blk_mq_alloc_single_hw_queue(struct blk_mq_tag_set *, unsigned int); void blk_mq_free_single_hw_queue(struct blk_mq_hw_ctx *, unsigned int); -bool blk_mq_end_io_partial(struct request *rq, int error, - unsigned int nr_bytes); -static inline void blk_mq_end_io(struct request *rq, int error) -{ - bool done = !blk_mq_end_io_partial(rq, error, blk_rq_bytes(rq)); - BUG_ON(!done); -} +void blk_mq_end_io(struct request *rq, int error); +void __blk_mq_end_io(struct request *rq, int error); void blk_mq_complete_request(struct request *rq); -- cgit v1.2.3 From 91b63639c7d59dbf86da5311faff43691dcae832 Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Wed, 16 Apr 2014 09:44:53 +0200 Subject: blk-mq: bidi support Add two unlinkely branches to make sure the resid is initialized correctly for bidi request pairs, and the second request gets properly freed. Signed-off-by: Christoph Hellwig Signed-off-by: Jens Axboe --- block/blk-mq.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/block/blk-mq.c b/block/blk-mq.c index 86d66e0e900c..963a82109386 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -298,10 +298,13 @@ inline void __blk_mq_end_io(struct request *rq, int error) { blk_account_io_done(rq); - if (rq->end_io) + if (rq->end_io) { rq->end_io(rq, error); - else + } else { + if (unlikely(blk_bidi_rq(rq))) + blk_mq_free_request(rq->next_rq); blk_mq_free_request(rq); + } } EXPORT_SYMBOL(__blk_mq_end_io); @@ -366,6 +369,8 @@ static void blk_mq_start_request(struct request *rq, bool last) trace_block_rq_issue(q, rq); rq->resid_len = blk_rq_bytes(rq); + if (unlikely(blk_bidi_rq(rq))) + rq->next_rq->resid_len = blk_rq_bytes(rq->next_rq); /* * Just mark start time and set the started bit. Due to memory -- cgit v1.2.3 From 1b4a325858f695a9b5041313602d34b36f463724 Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Wed, 16 Apr 2014 09:44:54 +0200 Subject: blk-mq: add async parameter to blk_mq_start_stopped_hw_queues Signed-off-by: Christoph Hellwig Signed-off-by: Jens Axboe --- block/blk-mq.c | 4 ++-- drivers/block/virtio_blk.c | 4 ++-- include/linux/blk-mq.h | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/block/blk-mq.c b/block/blk-mq.c index 963a82109386..da3808823e44 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -700,7 +700,7 @@ void blk_mq_start_hw_queue(struct blk_mq_hw_ctx *hctx) } EXPORT_SYMBOL(blk_mq_start_hw_queue); -void blk_mq_start_stopped_hw_queues(struct request_queue *q) +void blk_mq_start_stopped_hw_queues(struct request_queue *q, bool async) { struct blk_mq_hw_ctx *hctx; int i; @@ -711,7 +711,7 @@ void blk_mq_start_stopped_hw_queues(struct request_queue *q) clear_bit(BLK_MQ_S_STOPPED, &hctx->state); preempt_disable(); - blk_mq_run_hw_queue(hctx, true); + blk_mq_run_hw_queue(hctx, async); preempt_enable(); } } diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c index f909a8821e65..7a51f065edcd 100644 --- a/drivers/block/virtio_blk.c +++ b/drivers/block/virtio_blk.c @@ -151,7 +151,7 @@ static void virtblk_done(struct virtqueue *vq) /* In case queue is stopped waiting for more buffers. */ if (req_done) - blk_mq_start_stopped_hw_queues(vblk->disk->queue); + blk_mq_start_stopped_hw_queues(vblk->disk->queue, true); } static int virtio_queue_rq(struct blk_mq_hw_ctx *hctx, struct request *req) @@ -762,7 +762,7 @@ static int virtblk_restore(struct virtio_device *vdev) vblk->config_enable = true; ret = init_vq(vdev->priv); if (!ret) - blk_mq_start_stopped_hw_queues(vblk->disk->queue); + blk_mq_start_stopped_hw_queues(vblk->disk->queue, true); return ret; } diff --git a/include/linux/blk-mq.h b/include/linux/blk-mq.h index a81b474b794f..9ecfab96d8c9 100644 --- a/include/linux/blk-mq.h +++ b/include/linux/blk-mq.h @@ -157,7 +157,7 @@ void blk_mq_complete_request(struct request *rq); void blk_mq_stop_hw_queue(struct blk_mq_hw_ctx *hctx); void blk_mq_start_hw_queue(struct blk_mq_hw_ctx *hctx); void blk_mq_stop_hw_queues(struct request_queue *q); -void blk_mq_start_stopped_hw_queues(struct request_queue *q); +void blk_mq_start_stopped_hw_queues(struct request_queue *q, bool async); /* * Driver command data is immediately after the request. So subtract request -- cgit v1.2.3 From 70f4db639c5b2479e08657392cbf3ba3cceea11c Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Wed, 16 Apr 2014 10:48:08 -0600 Subject: blk-mq: add blk_mq_delay_queue Add a blk-mq equivalent to blk_delay_queue so that the scsi layer can ask to be kicked again after a delay. Signed-off-by: Christoph Hellwig Modified by me to kill the unnecessary preempt disable/enable in the delayed workqueue handler. Signed-off-by: Jens Axboe --- block/blk-core.c | 6 ++++-- block/blk-mq.c | 45 +++++++++++++++++++++++++++++++++++++++------ include/linux/blk-mq.h | 4 +++- 3 files changed, 46 insertions(+), 9 deletions(-) diff --git a/block/blk-core.c b/block/blk-core.c index ae6227fd07aa..90b6e63b8769 100644 --- a/block/blk-core.c +++ b/block/blk-core.c @@ -251,8 +251,10 @@ void blk_sync_queue(struct request_queue *q) struct blk_mq_hw_ctx *hctx; int i; - queue_for_each_hw_ctx(q, hctx, i) - cancel_delayed_work_sync(&hctx->delayed_work); + queue_for_each_hw_ctx(q, hctx, i) { + cancel_delayed_work_sync(&hctx->run_work); + cancel_delayed_work_sync(&hctx->delay_work); + } } else { cancel_delayed_work_sync(&q->delay_work); } diff --git a/block/blk-mq.c b/block/blk-mq.c index da3808823e44..0cf52dddfa6b 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -640,7 +640,7 @@ void blk_mq_run_hw_queue(struct blk_mq_hw_ctx *hctx, bool async) if (!async && cpumask_test_cpu(smp_processor_id(), hctx->cpumask)) __blk_mq_run_hw_queue(hctx); else if (hctx->queue->nr_hw_queues == 1) - kblockd_schedule_delayed_work(&hctx->delayed_work, 0); + kblockd_schedule_delayed_work(&hctx->run_work, 0); else { unsigned int cpu; @@ -651,7 +651,7 @@ void blk_mq_run_hw_queue(struct blk_mq_hw_ctx *hctx, bool async) * just queue on the first CPU. */ cpu = cpumask_first(hctx->cpumask); - kblockd_schedule_delayed_work_on(cpu, &hctx->delayed_work, 0); + kblockd_schedule_delayed_work_on(cpu, &hctx->run_work, 0); } } @@ -675,7 +675,8 @@ EXPORT_SYMBOL(blk_mq_run_queues); void blk_mq_stop_hw_queue(struct blk_mq_hw_ctx *hctx) { - cancel_delayed_work(&hctx->delayed_work); + cancel_delayed_work(&hctx->run_work); + cancel_delayed_work(&hctx->delay_work); set_bit(BLK_MQ_S_STOPPED, &hctx->state); } EXPORT_SYMBOL(blk_mq_stop_hw_queue); @@ -717,15 +718,46 @@ void blk_mq_start_stopped_hw_queues(struct request_queue *q, bool async) } EXPORT_SYMBOL(blk_mq_start_stopped_hw_queues); -static void blk_mq_work_fn(struct work_struct *work) +static void blk_mq_run_work_fn(struct work_struct *work) { struct blk_mq_hw_ctx *hctx; - hctx = container_of(work, struct blk_mq_hw_ctx, delayed_work.work); + hctx = container_of(work, struct blk_mq_hw_ctx, run_work.work); __blk_mq_run_hw_queue(hctx); } +static void blk_mq_delay_work_fn(struct work_struct *work) +{ + struct blk_mq_hw_ctx *hctx; + + hctx = container_of(work, struct blk_mq_hw_ctx, delay_work.work); + + if (test_and_clear_bit(BLK_MQ_S_STOPPED, &hctx->state)) + __blk_mq_run_hw_queue(hctx); +} + +void blk_mq_delay_queue(struct blk_mq_hw_ctx *hctx, unsigned long msecs) +{ + unsigned long tmo = msecs_to_jiffies(msecs); + + if (hctx->queue->nr_hw_queues == 1) + kblockd_schedule_delayed_work(&hctx->delay_work, tmo); + else { + unsigned int cpu; + + /* + * It'd be great if the workqueue API had a way to pass + * in a mask and had some smarts for more clever placement + * than the first CPU. Or we could round-robin here. For now, + * just queue on the first CPU. + */ + cpu = cpumask_first(hctx->cpumask); + kblockd_schedule_delayed_work_on(cpu, &hctx->delay_work, tmo); + } +} +EXPORT_SYMBOL(blk_mq_delay_queue); + static void __blk_mq_insert_request(struct blk_mq_hw_ctx *hctx, struct request *rq, bool at_head) { @@ -1179,7 +1211,8 @@ static int blk_mq_init_hw_queues(struct request_queue *q, if (node == NUMA_NO_NODE) node = hctx->numa_node = set->numa_node; - INIT_DELAYED_WORK(&hctx->delayed_work, blk_mq_work_fn); + INIT_DELAYED_WORK(&hctx->run_work, blk_mq_run_work_fn); + INIT_DELAYED_WORK(&hctx->delay_work, blk_mq_delay_work_fn); spin_lock_init(&hctx->lock); INIT_LIST_HEAD(&hctx->dispatch); hctx->queue = q; diff --git a/include/linux/blk-mq.h b/include/linux/blk-mq.h index 9ecfab96d8c9..ae868e77bc2f 100644 --- a/include/linux/blk-mq.h +++ b/include/linux/blk-mq.h @@ -18,7 +18,8 @@ struct blk_mq_hw_ctx { } ____cacheline_aligned_in_smp; unsigned long state; /* BLK_MQ_S_* flags */ - struct delayed_work delayed_work; + struct delayed_work run_work; + struct delayed_work delay_work; cpumask_var_t cpumask; unsigned long flags; /* BLK_MQ_F_* flags */ @@ -158,6 +159,7 @@ void blk_mq_stop_hw_queue(struct blk_mq_hw_ctx *hctx); void blk_mq_start_hw_queue(struct blk_mq_hw_ctx *hctx); void blk_mq_stop_hw_queues(struct request_queue *q); void blk_mq_start_stopped_hw_queues(struct request_queue *q, bool async); +void blk_mq_delay_queue(struct blk_mq_hw_ctx *hctx, unsigned long msecs); /* * Driver command data is immediately after the request. So subtract request -- cgit v1.2.3 From 2f268556567ebeb3538f99b9bdad177581439dcb Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Wed, 16 Apr 2014 09:44:56 +0200 Subject: blk-mq: add blk_mq_start_hw_queues Add a helper to unconditionally kick contexts of a queue. This will be needed by the SCSI layer to provide fair queueing between multiple devices on a single host. Signed-off-by: Christoph Hellwig Signed-off-by: Jens Axboe --- block/blk-mq.c | 11 +++++++++++ include/linux/blk-mq.h | 1 + 2 files changed, 12 insertions(+) diff --git a/block/blk-mq.c b/block/blk-mq.c index 0cf52dddfa6b..543bbc08a261 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -701,6 +701,17 @@ void blk_mq_start_hw_queue(struct blk_mq_hw_ctx *hctx) } EXPORT_SYMBOL(blk_mq_start_hw_queue); +void blk_mq_start_hw_queues(struct request_queue *q) +{ + struct blk_mq_hw_ctx *hctx; + int i; + + queue_for_each_hw_ctx(q, hctx, i) + blk_mq_start_hw_queue(hctx); +} +EXPORT_SYMBOL(blk_mq_start_hw_queues); + + void blk_mq_start_stopped_hw_queues(struct request_queue *q, bool async) { struct blk_mq_hw_ctx *hctx; diff --git a/include/linux/blk-mq.h b/include/linux/blk-mq.h index ae868e77bc2f..391377e53367 100644 --- a/include/linux/blk-mq.h +++ b/include/linux/blk-mq.h @@ -158,6 +158,7 @@ void blk_mq_complete_request(struct request *rq); void blk_mq_stop_hw_queue(struct blk_mq_hw_ctx *hctx); void blk_mq_start_hw_queue(struct blk_mq_hw_ctx *hctx); void blk_mq_stop_hw_queues(struct request_queue *q); +void blk_mq_start_hw_queues(struct request_queue *q); void blk_mq_start_stopped_hw_queues(struct request_queue *q, bool async); void blk_mq_delay_queue(struct blk_mq_hw_ctx *hctx, unsigned long msecs); -- cgit v1.2.3 From ed0791b2f83cec4e77d88c4e9baabcebf9254a78 Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Wed, 16 Apr 2014 09:44:57 +0200 Subject: blk-mq: add blk_mq_requeue_request This allows to requeue a request that has been accepted by ->queue_rq earlier. This is needed by the SCSI layer in various error conditions. The existing internal blk_mq_requeue_request is renamed to __blk_mq_requeue_request as it is a lower level building block for this funtionality. Signed-off-by: Christoph Hellwig Signed-off-by: Jens Axboe --- block/blk-mq.c | 18 ++++++++++++++++-- include/linux/blk-mq.h | 2 ++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/block/blk-mq.c b/block/blk-mq.c index 543bbc08a261..ee225cc312b8 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -400,7 +400,7 @@ static void blk_mq_start_request(struct request *rq, bool last) rq->cmd_flags |= REQ_END; } -static void blk_mq_requeue_request(struct request *rq) +static void __blk_mq_requeue_request(struct request *rq) { struct request_queue *q = rq->q; @@ -413,6 +413,20 @@ static void blk_mq_requeue_request(struct request *rq) rq->nr_phys_segments--; } +void blk_mq_requeue_request(struct request *rq) +{ + struct request_queue *q = rq->q; + + __blk_mq_requeue_request(rq); + blk_clear_rq_complete(rq); + + trace_block_rq_requeue(q, rq); + + BUG_ON(blk_queued_rq(rq)); + blk_mq_insert_request(rq, true, true, false); +} +EXPORT_SYMBOL(blk_mq_requeue_request); + struct request *blk_mq_tag_to_rq(struct blk_mq_tags *tags, unsigned int tag) { return tags->rqs[tag]; @@ -602,7 +616,7 @@ static void __blk_mq_run_hw_queue(struct blk_mq_hw_ctx *hctx) * time */ list_add(&rq->queuelist, &rq_list); - blk_mq_requeue_request(rq); + __blk_mq_requeue_request(rq); break; default: pr_err("blk-mq: bad return on queue: %d\n", ret); diff --git a/include/linux/blk-mq.h b/include/linux/blk-mq.h index 391377e53367..ab469d525894 100644 --- a/include/linux/blk-mq.h +++ b/include/linux/blk-mq.h @@ -153,6 +153,8 @@ void blk_mq_free_single_hw_queue(struct blk_mq_hw_ctx *, unsigned int); void blk_mq_end_io(struct request *rq, int error); void __blk_mq_end_io(struct request *rq, int error); +void blk_mq_requeue_request(struct request *rq); + void blk_mq_complete_request(struct request *rq); void blk_mq_stop_hw_queue(struct blk_mq_hw_ctx *hctx); -- cgit v1.2.3 From f88a164b72bd51fe4c89e06ac9939f2afe39c7ed Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Wed, 16 Apr 2014 09:44:58 +0200 Subject: blk-mq: rename mq_flush_work struct request member We will use this work_struct to requeue scsi commands from the completion handler as well, so give it a more generic name. Signed-off-by: Christoph Hellwig Signed-off-by: Jens Axboe --- block/blk-flush.c | 6 +++--- include/linux/blkdev.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/block/blk-flush.c b/block/blk-flush.c index c41fc19f75d1..ec7a224d6733 100644 --- a/block/blk-flush.c +++ b/block/blk-flush.c @@ -134,7 +134,7 @@ static void mq_flush_run(struct work_struct *work) { struct request *rq; - rq = container_of(work, struct request, mq_flush_work); + rq = container_of(work, struct request, requeue_work); memset(&rq->csd, 0, sizeof(rq->csd)); blk_mq_insert_request(rq, false, true, false); @@ -143,8 +143,8 @@ static void mq_flush_run(struct work_struct *work) static bool blk_flush_queue_rq(struct request *rq, bool add_front) { if (rq->q->mq_ops) { - INIT_WORK(&rq->mq_flush_work, mq_flush_run); - kblockd_schedule_work(&rq->mq_flush_work); + INIT_WORK(&rq->requeue_work, mq_flush_run); + kblockd_schedule_work(&rq->requeue_work); return false; } else { if (add_front) diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index 95bb551273ab..71288083a46f 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -98,7 +98,7 @@ struct request { struct list_head queuelist; union { struct call_single_data csd; - struct work_struct mq_flush_work; + struct work_struct requeue_work; unsigned long fifo_time; }; -- cgit v1.2.3 From 12120077b2612a243d158605640cd39266906667 Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Wed, 16 Apr 2014 09:44:59 +0200 Subject: block: export blk_finish_request This allows to mirror the blk-mq code flow for more a more readable I/O completion handler in SCSI. Signed-off-by: Christoph Hellwig Signed-off-by: Jens Axboe --- block/blk-core.c | 3 ++- include/linux/blkdev.h | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/block/blk-core.c b/block/blk-core.c index 90b6e63b8769..c4269701cb4f 100644 --- a/block/blk-core.c +++ b/block/blk-core.c @@ -2497,7 +2497,7 @@ EXPORT_SYMBOL_GPL(blk_unprep_request); /* * queue lock must be held */ -static void blk_finish_request(struct request *req, int error) +void blk_finish_request(struct request *req, int error) { if (blk_rq_tagged(req)) blk_queue_end_tag(req->q, req); @@ -2523,6 +2523,7 @@ static void blk_finish_request(struct request *req, int error) __blk_put_request(req->q, req); } } +EXPORT_SYMBOL(blk_finish_request); /** * blk_end_bidi_request - Complete a bidi request diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index 71288083a46f..20b26d4e53a2 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -936,6 +936,7 @@ extern struct request *blk_fetch_request(struct request_queue *q); */ extern bool blk_update_request(struct request *rq, int error, unsigned int nr_bytes); +extern void blk_finish_request(struct request *rq, int error); extern bool blk_end_request(struct request *rq, int error, unsigned int nr_bytes); extern void blk_end_request_all(struct request *rq, int error); -- cgit v1.2.3 From f793aa53786668c9e0db5900f70f560e99d62fa0 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Wed, 16 Apr 2014 11:36:54 -0600 Subject: block: relax when to modify the timeout timer Since we are now, by default, applying timer slack to expiry times, the logic for when to modify a timer in the block code is suboptimal. The block layer keeps a forward rolling timer per queue for all requests, and modifies this timer if a request has a shorter timeout than what the current expiry time is. However, this breaks down when our rounded timer values get applied slack. Then each new request ends up modifying the timer, since we're still a little in front of the timer + slack. Fix this by allowing a tolerance of HZ / 2, the timeout handling doesn't need to be very precise. This drastically cuts down the number of timer modifications we have to make. Signed-off-by: Jens Axboe --- block/blk-timeout.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/block/blk-timeout.c b/block/blk-timeout.c index d96f7061c6fd..a09e8af8186c 100644 --- a/block/blk-timeout.c +++ b/block/blk-timeout.c @@ -199,8 +199,19 @@ void __blk_add_timer(struct request *req, struct list_head *timeout_list) expiry = round_jiffies_up(req->deadline); if (!timer_pending(&q->timeout) || - time_before(expiry, q->timeout.expires)) - mod_timer(&q->timeout, expiry); + time_before(expiry, q->timeout.expires)) { + unsigned long diff = q->timeout.expires - expiry; + + /* + * Due to added timer slack to group timers, the timer + * will often be a little in front of what we asked for. + * So apply some tolerance here too, otherwise we keep + * modifying the timer because expires for value X + * will be X + something. + */ + if (diff >= HZ / 2) + mod_timer(&q->timeout, expiry); + } } -- cgit v1.2.3 From fb1be43301ce045b5e563416e701573464a2ed96 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Wed, 16 Apr 2014 14:14:33 -0600 Subject: jsflash: missed conversion from rq->buffer to bio_data(rq->bio) Signed-off-by: Jens Axboe --- drivers/sbus/char/jsflash.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/sbus/char/jsflash.c b/drivers/sbus/char/jsflash.c index 4ccb5d869389..a40ee1e37486 100644 --- a/drivers/sbus/char/jsflash.c +++ b/drivers/sbus/char/jsflash.c @@ -207,7 +207,7 @@ static void jsfd_do_request(struct request_queue *q) goto end; } - jsfd_read(req->buffer, jdp->dbase + offset, len); + jsfd_read(bio_data(req->bio), jdp->dbase + offset, len); err = 0; end: if (!__blk_end_request_cur(req, err)) -- cgit v1.2.3 From 49fd524f95cb4cc699d435e0ebb08b1c6220da6d Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Wed, 16 Apr 2014 10:57:18 -0600 Subject: bsg: update check for rq based driver for blk-mq bsg currently checks ->request_fn to check whether a queue can handle struct request. But with blk-mq, we don't have a request_fn yet are request based. Add a queue_is_rq_based() helper and use that in bsg, I'm guessing this is not the last place we need to update for this. Besides, it better explains what is being checked. Signed-off-by: Jens Axboe --- block/bsg.c | 2 +- include/linux/blkdev.h | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/block/bsg.c b/block/bsg.c index 420a5a9f1b23..e5214c148096 100644 --- a/block/bsg.c +++ b/block/bsg.c @@ -1008,7 +1008,7 @@ int bsg_register_queue(struct request_queue *q, struct device *parent, /* * we need a proper transport to send commands, not a stacked device */ - if (!q->request_fn) + if (!queue_is_rq_based(q)) return 0; bcd = &q->bsg_dev; diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index 20b26d4e53a2..74ee55fefcf0 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -612,6 +612,15 @@ static inline void queue_flag_clear(unsigned int flag, struct request_queue *q) #define rq_data_dir(rq) (((rq)->cmd_flags & 1) != 0) +/* + * Driver can handle struct request, if it either has an old style + * request_fn defined, or is blk-mq based. + */ +static inline bool queue_is_rq_based(struct request_queue *q) +{ + return q->request_fn || q->mq_ops; +} + static inline unsigned int blk_queue_cluster(struct request_queue *q) { return q->limits.cluster; -- cgit v1.2.3 From d0fb47a5237d8b9576113568bacfd27892308b62 Mon Sep 17 00:00:00 2001 From: Jane Wan Date: Wed, 16 Apr 2014 13:09:39 -0700 Subject: spi: fsl-espi: Configure FSL eSPI CSBEF and CSAFT Make FSL eSPI CSnBEF and CSnAFT fields in ESPI_SPMODEn registers (n=0,1,2,3) configurable through device tree. CSnBEF is the chip select setup time. It's the delay in bits from the activation of chip select pin to the first clock for data frame. CSnAFT is the chip select hold time. It's the delay in bits from the last clock for data frame to the deactivation of chip select pin. The FSL eSPI driver hardcodes CSnBEF and CSnAFT to 0. Need to set them to a different value for some device. Signed-off-by: Jane Wan Signed-off-by: Mark Brown --- Documentation/devicetree/bindings/spi/fsl-spi.txt | 6 ++++ drivers/spi/spi-fsl-espi.c | 34 ++++++++++++++++++++--- 2 files changed, 36 insertions(+), 4 deletions(-) diff --git a/Documentation/devicetree/bindings/spi/fsl-spi.txt b/Documentation/devicetree/bindings/spi/fsl-spi.txt index b032dd76e9d2..a2331372068c 100644 --- a/Documentation/devicetree/bindings/spi/fsl-spi.txt +++ b/Documentation/devicetree/bindings/spi/fsl-spi.txt @@ -42,6 +42,10 @@ Required properties: - interrupts : should contain eSPI interrupt, the device has one interrupt. - fsl,espi-num-chipselects : the number of the chipselect signals. +Optional properties: +- fsl,csbef: chip select assertion time in bits before frame starts +- fsl,csaft: chip select negation time in bits after frame ends + Example: spi@110000 { #address-cells = <1>; @@ -51,4 +55,6 @@ Example: interrupts = <53 0x2>; interrupt-parent = <&mpic>; fsl,espi-num-chipselects = <4>; + fsl,csbef = <1>; + fsl,csaft = <1>; }; diff --git a/drivers/spi/spi-fsl-espi.c b/drivers/spi/spi-fsl-espi.c index e767f5831b9c..24096c84e9c4 100644 --- a/drivers/spi/spi-fsl-espi.c +++ b/drivers/spi/spi-fsl-espi.c @@ -586,8 +586,10 @@ static struct spi_master * fsl_espi_probe(struct device *dev, struct spi_master *master; struct mpc8xxx_spi *mpc8xxx_spi; struct fsl_espi_reg *reg_base; - u32 regval; - int i, ret = 0; + struct device_node *nc; + const __be32 *prop; + u32 regval, csmode; + int i, len, ret = 0; master = spi_alloc_master(dev, sizeof(struct mpc8xxx_spi)); if (!master) { @@ -634,8 +636,32 @@ static struct spi_master * fsl_espi_probe(struct device *dev, mpc8xxx_spi_write_reg(®_base->event, 0xffffffff); /* Init eSPI CS mode register */ - for (i = 0; i < pdata->max_chipselect; i++) - mpc8xxx_spi_write_reg(®_base->csmode[i], CSMODE_INIT_VAL); + for_each_available_child_of_node(master->dev.of_node, nc) { + /* get chip select */ + prop = of_get_property(nc, "reg", &len); + if (!prop || len < sizeof(*prop)) + continue; + i = be32_to_cpup(prop); + if (i < 0 || i >= pdata->max_chipselect) + continue; + + csmode = CSMODE_INIT_VAL; + /* check if CSBEF is set in device tree */ + prop = of_get_property(nc, "fsl,csbef", &len); + if (prop && len >= sizeof(*prop)) { + csmode &= ~(CSMODE_BEF(0xf)); + csmode |= CSMODE_BEF(be32_to_cpup(prop)); + } + /* check if CSAFT is set in device tree */ + prop = of_get_property(nc, "fsl,csaft", &len); + if (prop && len >= sizeof(*prop)) { + csmode &= ~(CSMODE_AFT(0xf)); + csmode |= CSMODE_AFT(be32_to_cpup(prop)); + } + mpc8xxx_spi_write_reg(®_base->csmode[i], csmode); + + dev_info(dev, "cs=%d, init_csmode=0x%x\n", i, csmode); + } /* Enable SPI interface */ regval = pdata->initial_spmode | SPMODE_INIT_VAL | SPMODE_ENABLE; -- cgit v1.2.3 From ae5fd3d5305da625461a15d15637f30e8e1639f2 Mon Sep 17 00:00:00 2001 From: Ismael Luceno Date: Fri, 14 Mar 2014 16:43:23 -0300 Subject: [media] gspca_gl860: Clean up idxdata structs Signed-off-by: Ismael Luceno Acked-by: Hans de Goede Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/usb/gspca/gl860/gl860-mi2020.c | 464 ++++++++++++++++----------- 1 file changed, 268 insertions(+), 196 deletions(-) diff --git a/drivers/media/usb/gspca/gl860/gl860-mi2020.c b/drivers/media/usb/gspca/gl860/gl860-mi2020.c index 2edda6b7d653..a785828d4b9d 100644 --- a/drivers/media/usb/gspca/gl860/gl860-mi2020.c +++ b/drivers/media/usb/gspca/gl860/gl860-mi2020.c @@ -35,32 +35,34 @@ static u8 dat_hvflip5[] = {0x8c, 0xa1, 0x03}; static u8 dat_hvflip6[] = {0x90, 0x00, 0x06}; static struct idxdata tbl_middle_hvflip_low[] = { - {0x33, "\x90\x00\x06"}, - {6, "\xff\xff\xff"}, - {0x33, "\x90\x00\x06"}, - {6, "\xff\xff\xff"}, - {0x33, "\x90\x00\x06"}, - {6, "\xff\xff\xff"}, - {0x33, "\x90\x00\x06"}, - {6, "\xff\xff\xff"}, + {0x33, {0x90, 0x00, 0x06}}, + {6, {0xff, 0xff, 0xff}}, + {0x33, {0x90, 0x00, 0x06}}, + {6, {0xff, 0xff, 0xff}}, + {0x33, {0x90, 0x00, 0x06}}, + {6, {0xff, 0xff, 0xff}}, + {0x33, {0x90, 0x00, 0x06}}, + {6, {0xff, 0xff, 0xff}}, }; static struct idxdata tbl_middle_hvflip_big[] = { - {0x33, "\x8c\xa1\x03"}, {0x33, "\x90\x00\x01"}, {0x33, "\x8c\xa1\x20"}, - {0x33, "\x90\x00\x00"}, {0x33, "\x8c\xa7\x02"}, {0x33, "\x90\x00\x00"}, - {102, "\xff\xff\xff"}, - {0x33, "\x8c\xa1\x03"}, {0x33, "\x90\x00\x02"}, {0x33, "\x8c\xa1\x20"}, - {0x33, "\x90\x00\x72"}, {0x33, "\x8c\xa7\x02"}, {0x33, "\x90\x00\x01"}, + {0x33, {0x8c, 0xa1, 0x03}}, {0x33, {0x90, 0x00, 0x01}}, + {0x33, {0x8c, 0xa1, 0x20}}, {0x33, {0x90, 0x00, 0x00}}, + {0x33, {0x8c, 0xa7, 0x02}}, {0x33, {0x90, 0x00, 0x00}}, + {102, {0xff, 0xff, 0xff}}, + {0x33, {0x8c, 0xa1, 0x03}}, {0x33, {0x90, 0x00, 0x02}}, + {0x33, {0x8c, 0xa1, 0x20}}, {0x33, {0x90, 0x00, 0x72}}, + {0x33, {0x8c, 0xa7, 0x02}}, {0x33, {0x90, 0x00, 0x01}}, }; static struct idxdata tbl_end_hvflip[] = { - {0x33, "\x8c\xa1\x02"}, {0x33, "\x90\x00\x1f"}, - {6, "\xff\xff\xff"}, - {0x33, "\x8c\xa1\x02"}, {0x33, "\x90\x00\x1f"}, - {6, "\xff\xff\xff"}, - {0x33, "\x8c\xa1\x02"}, {0x33, "\x90\x00\x1f"}, - {6, "\xff\xff\xff"}, - {0x33, "\x8c\xa1\x02"}, {0x33, "\x90\x00\x1f"}, + {0x33, {0x8c, 0xa1, 0x02}}, {0x33, {0x90, 0x00, 0x1f}}, + {6, {0xff, 0xff, 0xff}}, + {0x33, {0x8c, 0xa1, 0x02}}, {0x33, {0x90, 0x00, 0x1f}}, + {6, {0xff, 0xff, 0xff}}, + {0x33, {0x8c, 0xa1, 0x02}}, {0x33, {0x90, 0x00, 0x1f}}, + {6, {0xff, 0xff, 0xff}}, + {0x33, {0x8c, 0xa1, 0x02}}, {0x33, {0x90, 0x00, 0x1f}}, }; static u8 dat_freq1[] = { 0x8c, 0xa4, 0x04 }; @@ -82,197 +84,267 @@ static struct validx tbl_common_0B[] = { }; static struct idxdata tbl_common_3B[] = { - {0x33, "\x86\x25\x01"}, {0x33, "\x86\x25\x00"}, - {2, "\xff\xff\xff"}, - {0x30, "\x1a\x0a\xcc"}, {0x32, "\x02\x00\x08"}, {0x33, "\xf4\x03\x1d"}, - {6, "\xff\xff\xff"}, /* 12 */ - {0x34, "\x1e\x8f\x09"}, {0x34, "\x1c\x01\x28"}, {0x34, "\x1e\x8f\x09"}, - {2, "\xff\xff\xff"}, /* - */ - {0x34, "\x1e\x8f\x09"}, {0x32, "\x14\x06\xe6"}, {0x33, "\x8c\x22\x23"}, - {0x33, "\x90\x00\x00"}, {0x33, "\x8c\xa2\x0f"}, {0x33, "\x90\x00\x0d"}, - {0x33, "\x8c\xa2\x10"}, {0x33, "\x90\x00\x0b"}, {0x33, "\x8c\xa2\x11"}, - {0x33, "\x90\x00\x07"}, {0x33, "\xf4\x03\x1d"}, {0x35, "\xa2\x00\xe2"}, - {0x33, "\x8c\xab\x05"}, {0x33, "\x90\x00\x01"}, {0x32, "\x6e\x00\x86"}, - {0x32, "\x70\x0f\xaa"}, {0x32, "\x72\x0f\xe4"}, {0x33, "\x8c\xa3\x4a"}, - {0x33, "\x90\x00\x5a"}, {0x33, "\x8c\xa3\x4b"}, {0x33, "\x90\x00\xa6"}, - {0x33, "\x8c\xa3\x61"}, {0x33, "\x90\x00\xc8"}, {0x33, "\x8c\xa3\x62"}, - {0x33, "\x90\x00\xe1"}, {0x34, "\xce\x01\xa8"}, {0x34, "\xd0\x66\x33"}, - {0x34, "\xd2\x31\x9a"}, {0x34, "\xd4\x94\x63"}, {0x34, "\xd6\x4b\x25"}, - {0x34, "\xd8\x26\x70"}, {0x34, "\xda\x72\x4c"}, {0x34, "\xdc\xff\x04"}, - {0x34, "\xde\x01\x5b"}, {0x34, "\xe6\x01\x13"}, {0x34, "\xee\x0b\xf0"}, - {0x34, "\xf6\x0b\xa4"}, {0x35, "\x00\xf6\xe7"}, {0x35, "\x08\x0d\xfd"}, - {0x35, "\x10\x25\x63"}, {0x35, "\x18\x35\x6c"}, {0x35, "\x20\x42\x7e"}, - {0x35, "\x28\x19\x44"}, {0x35, "\x30\x39\xd4"}, {0x35, "\x38\xf5\xa8"}, - {0x35, "\x4c\x07\x90"}, {0x35, "\x44\x07\xb8"}, {0x35, "\x5c\x06\x88"}, - {0x35, "\x54\x07\xff"}, {0x34, "\xe0\x01\x52"}, {0x34, "\xe8\x00\xcc"}, - {0x34, "\xf0\x0d\x83"}, {0x34, "\xf8\x0c\xb3"}, {0x35, "\x02\xfe\xba"}, - {0x35, "\x0a\x04\xe0"}, {0x35, "\x12\x1c\x63"}, {0x35, "\x1a\x2b\x5a"}, - {0x35, "\x22\x32\x5e"}, {0x35, "\x2a\x0d\x28"}, {0x35, "\x32\x2c\x02"}, - {0x35, "\x3a\xf4\xfa"}, {0x35, "\x4e\x07\xef"}, {0x35, "\x46\x07\x88"}, - {0x35, "\x5e\x07\xc1"}, {0x35, "\x56\x04\x64"}, {0x34, "\xe4\x01\x15"}, - {0x34, "\xec\x00\x82"}, {0x34, "\xf4\x0c\xce"}, {0x34, "\xfc\x0c\xba"}, - {0x35, "\x06\x1f\x02"}, {0x35, "\x0e\x02\xe3"}, {0x35, "\x16\x1a\x50"}, - {0x35, "\x1e\x24\x39"}, {0x35, "\x26\x23\x4c"}, {0x35, "\x2e\xf9\x1b"}, - {0x35, "\x36\x23\x19"}, {0x35, "\x3e\x12\x08"}, {0x35, "\x52\x07\x22"}, - {0x35, "\x4a\x03\xd3"}, {0x35, "\x62\x06\x54"}, {0x35, "\x5a\x04\x5d"}, - {0x34, "\xe2\x01\x04"}, {0x34, "\xea\x00\xa0"}, {0x34, "\xf2\x0c\xbc"}, - {0x34, "\xfa\x0c\x5b"}, {0x35, "\x04\x17\xf2"}, {0x35, "\x0c\x02\x08"}, - {0x35, "\x14\x28\x43"}, {0x35, "\x1c\x28\x62"}, {0x35, "\x24\x2b\x60"}, - {0x35, "\x2c\x07\x33"}, {0x35, "\x34\x1f\xb0"}, {0x35, "\x3c\xed\xcd"}, - {0x35, "\x50\x00\x06"}, {0x35, "\x48\x07\xff"}, {0x35, "\x60\x05\x89"}, - {0x35, "\x58\x07\xff"}, {0x35, "\x40\x00\xa0"}, {0x35, "\x42\x00\x00"}, - {0x32, "\x10\x01\xfc"}, {0x33, "\x8c\xa1\x18"}, {0x33, "\x90\x00\x3c"}, - {0x33, "\x78\x00\x00"}, - {2, "\xff\xff\xff"}, - {0x35, "\xb8\x1f\x20"}, {0x33, "\x8c\xa2\x06"}, {0x33, "\x90\x00\x10"}, - {0x33, "\x8c\xa2\x07"}, {0x33, "\x90\x00\x08"}, {0x33, "\x8c\xa2\x42"}, - {0x33, "\x90\x00\x0b"}, {0x33, "\x8c\xa2\x4a"}, {0x33, "\x90\x00\x8c"}, - {0x35, "\xba\xfa\x08"}, {0x33, "\x8c\xa2\x02"}, {0x33, "\x90\x00\x22"}, - {0x33, "\x8c\xa2\x03"}, {0x33, "\x90\x00\xbb"}, {0x33, "\x8c\xa4\x04"}, - {0x33, "\x90\x00\x80"}, {0x33, "\x8c\xa7\x9d"}, {0x33, "\x90\x00\x00"}, - {0x33, "\x8c\xa7\x9e"}, {0x33, "\x90\x00\x00"}, {0x33, "\x8c\xa2\x0c"}, - {0x33, "\x90\x00\x17"}, {0x33, "\x8c\xa2\x15"}, {0x33, "\x90\x00\x04"}, - {0x33, "\x8c\xa2\x14"}, {0x33, "\x90\x00\x20"}, {0x33, "\x8c\xa1\x03"}, - {0x33, "\x90\x00\x00"}, {0x33, "\x8c\x27\x17"}, {0x33, "\x90\x21\x11"}, - {0x33, "\x8c\x27\x1b"}, {0x33, "\x90\x02\x4f"}, {0x33, "\x8c\x27\x25"}, - {0x33, "\x90\x06\x0f"}, {0x33, "\x8c\x27\x39"}, {0x33, "\x90\x21\x11"}, - {0x33, "\x8c\x27\x3d"}, {0x33, "\x90\x01\x20"}, {0x33, "\x8c\x27\x47"}, - {0x33, "\x90\x09\x4c"}, {0x33, "\x8c\x27\x03"}, {0x33, "\x90\x02\x84"}, - {0x33, "\x8c\x27\x05"}, {0x33, "\x90\x01\xe2"}, {0x33, "\x8c\x27\x07"}, - {0x33, "\x90\x06\x40"}, {0x33, "\x8c\x27\x09"}, {0x33, "\x90\x04\xb0"}, - {0x33, "\x8c\x27\x0d"}, {0x33, "\x90\x00\x00"}, {0x33, "\x8c\x27\x0f"}, - {0x33, "\x90\x00\x00"}, {0x33, "\x8c\x27\x11"}, {0x33, "\x90\x04\xbd"}, - {0x33, "\x8c\x27\x13"}, {0x33, "\x90\x06\x4d"}, {0x33, "\x8c\x27\x15"}, - {0x33, "\x90\x00\x00"}, {0x33, "\x8c\x27\x17"}, {0x33, "\x90\x21\x11"}, - {0x33, "\x8c\x27\x19"}, {0x33, "\x90\x04\x6c"}, {0x33, "\x8c\x27\x1b"}, - {0x33, "\x90\x02\x4f"}, {0x33, "\x8c\x27\x1d"}, {0x33, "\x90\x01\x02"}, - {0x33, "\x8c\x27\x1f"}, {0x33, "\x90\x02\x79"}, {0x33, "\x8c\x27\x21"}, - {0x33, "\x90\x01\x55"}, {0x33, "\x8c\x27\x23"}, {0x33, "\x90\x02\x85"}, - {0x33, "\x8c\x27\x25"}, {0x33, "\x90\x06\x0f"}, {0x33, "\x8c\x27\x27"}, - {0x33, "\x90\x20\x20"}, {0x33, "\x8c\x27\x29"}, {0x33, "\x90\x20\x20"}, - {0x33, "\x8c\x27\x2b"}, {0x33, "\x90\x10\x20"}, {0x33, "\x8c\x27\x2d"}, - {0x33, "\x90\x20\x07"}, {0x33, "\x8c\x27\x2f"}, {0x33, "\x90\x00\x04"}, - {0x33, "\x8c\x27\x31"}, {0x33, "\x90\x00\x04"}, {0x33, "\x8c\x27\x33"}, - {0x33, "\x90\x04\xbb"}, {0x33, "\x8c\x27\x35"}, {0x33, "\x90\x06\x4b"}, - {0x33, "\x8c\x27\x37"}, {0x33, "\x90\x00\x00"}, {0x33, "\x8c\x27\x39"}, - {0x33, "\x90\x21\x11"}, {0x33, "\x8c\x27\x3b"}, {0x33, "\x90\x00\x24"}, - {0x33, "\x8c\x27\x3d"}, {0x33, "\x90\x01\x20"}, {0x33, "\x8c\x27\x41"}, - {0x33, "\x90\x01\x69"}, {0x33, "\x8c\x27\x45"}, {0x33, "\x90\x04\xed"}, - {0x33, "\x8c\x27\x47"}, {0x33, "\x90\x09\x4c"}, {0x33, "\x8c\x27\x51"}, - {0x33, "\x90\x00\x00"}, {0x33, "\x8c\x27\x53"}, {0x33, "\x90\x03\x20"}, - {0x33, "\x8c\x27\x55"}, {0x33, "\x90\x00\x00"}, {0x33, "\x8c\x27\x57"}, - {0x33, "\x90\x02\x58"}, {0x33, "\x8c\x27\x5f"}, {0x33, "\x90\x00\x00"}, - {0x33, "\x8c\x27\x61"}, {0x33, "\x90\x06\x40"}, {0x33, "\x8c\x27\x63"}, - {0x33, "\x90\x00\x00"}, {0x33, "\x8c\x27\x65"}, {0x33, "\x90\x04\xb0"}, - {0x33, "\x8c\x22\x2e"}, {0x33, "\x90\x00\xa1"}, {0x33, "\x8c\xa4\x08"}, - {0x33, "\x90\x00\x1f"}, {0x33, "\x8c\xa4\x09"}, {0x33, "\x90\x00\x21"}, - {0x33, "\x8c\xa4\x0a"}, {0x33, "\x90\x00\x25"}, {0x33, "\x8c\xa4\x0b"}, - {0x33, "\x90\x00\x27"}, {0x33, "\x8c\x24\x11"}, {0x33, "\x90\x00\xa1"}, - {0x33, "\x8c\x24\x13"}, {0x33, "\x90\x00\xc1"}, {0x33, "\x8c\x24\x15"}, - {0x33, "\x90\x00\x6a"}, {0x33, "\x8c\x24\x17"}, {0x33, "\x90\x00\x80"}, - {0x33, "\x8c\xa1\x03"}, {0x33, "\x90\x00\x05"}, - {2, "\xff\xff\xff"}, - {0x33, "\x8c\xa1\x03"}, {0x33, "\x90\x00\x06"}, - {3, "\xff\xff\xff"}, + {0x33, {0x86, 0x25, 0x01}}, {0x33, {0x86, 0x25, 0x00}}, + {2, {0xff, 0xff, 0xff}}, + {0x30, {0x1a, 0x0a, 0xcc}}, {0x32, {0x02, 0x00, 0x08}}, + {0x33, {0xf4, 0x03, 0x1d}}, + {6, {0xff, 0xff, 0xff}}, /* 12 */ + {0x34, {0x1e, 0x8f, 0x09}}, {0x34, {0x1c, 0x01, 0x28}}, + {0x34, {0x1e, 0x8f, 0x09}}, + {2, {0xff, 0xff, 0xff}}, /* - */ + {0x34, {0x1e, 0x8f, 0x09}}, {0x32, {0x14, 0x06, 0xe6}}, + {0x33, {0x8c, 0x22, 0x23}}, {0x33, {0x90, 0x00, 0x00}}, + {0x33, {0x8c, 0xa2, 0x0f}}, {0x33, {0x90, 0x00, 0x0d}}, + {0x33, {0x8c, 0xa2, 0x10}}, {0x33, {0x90, 0x00, 0x0b}}, + {0x33, {0x8c, 0xa2, 0x11}}, {0x33, {0x90, 0x00, 0x07}}, + {0x33, {0xf4, 0x03, 0x1d}}, {0x35, {0xa2, 0x00, 0xe2}}, + {0x33, {0x8c, 0xab, 0x05}}, {0x33, {0x90, 0x00, 0x01}}, + {0x32, {0x6e, 0x00, 0x86}}, {0x32, {0x70, 0x0f, 0xaa}}, + {0x32, {0x72, 0x0f, 0xe4}}, {0x33, {0x8c, 0xa3, 0x4a}}, + {0x33, {0x90, 0x00, 0x5a}}, {0x33, {0x8c, 0xa3, 0x4b}}, + {0x33, {0x90, 0x00, 0xa6}}, {0x33, {0x8c, 0xa3, 0x61}}, + {0x33, {0x90, 0x00, 0xc8}}, {0x33, {0x8c, 0xa3, 0x62}}, + {0x33, {0x90, 0x00, 0xe1}}, {0x34, {0xce, 0x01, 0xa8}}, + {0x34, {0xd0, 0x66, 0x33}}, {0x34, {0xd2, 0x31, 0x9a}}, + {0x34, {0xd4, 0x94, 0x63}}, {0x34, {0xd6, 0x4b, 0x25}}, + {0x34, {0xd8, 0x26, 0x70}}, {0x34, {0xda, 0x72, 0x4c}}, + {0x34, {0xdc, 0xff, 0x04}}, {0x34, {0xde, 0x01, 0x5b}}, + {0x34, {0xe6, 0x01, 0x13}}, {0x34, {0xee, 0x0b, 0xf0}}, + {0x34, {0xf6, 0x0b, 0xa4}}, {0x35, {0x00, 0xf6, 0xe7}}, + {0x35, {0x08, 0x0d, 0xfd}}, {0x35, {0x10, 0x25, 0x63}}, + {0x35, {0x18, 0x35, 0x6c}}, {0x35, {0x20, 0x42, 0x7e}}, + {0x35, {0x28, 0x19, 0x44}}, {0x35, {0x30, 0x39, 0xd4}}, + {0x35, {0x38, 0xf5, 0xa8}}, {0x35, {0x4c, 0x07, 0x90}}, + {0x35, {0x44, 0x07, 0xb8}}, {0x35, {0x5c, 0x06, 0x88}}, + {0x35, {0x54, 0x07, 0xff}}, {0x34, {0xe0, 0x01, 0x52}}, + {0x34, {0xe8, 0x00, 0xcc}}, {0x34, {0xf0, 0x0d, 0x83}}, + {0x34, {0xf8, 0x0c, 0xb3}}, {0x35, {0x02, 0xfe, 0xba}}, + {0x35, {0x0a, 0x04, 0xe0}}, {0x35, {0x12, 0x1c, 0x63}}, + {0x35, {0x1a, 0x2b, 0x5a}}, {0x35, {0x22, 0x32, 0x5e}}, + {0x35, {0x2a, 0x0d, 0x28}}, {0x35, {0x32, 0x2c, 0x02}}, + {0x35, {0x3a, 0xf4, 0xfa}}, {0x35, {0x4e, 0x07, 0xef}}, + {0x35, {0x46, 0x07, 0x88}}, {0x35, {0x5e, 0x07, 0xc1}}, + {0x35, {0x56, 0x04, 0x64}}, {0x34, {0xe4, 0x01, 0x15}}, + {0x34, {0xec, 0x00, 0x82}}, {0x34, {0xf4, 0x0c, 0xce}}, + {0x34, {0xfc, 0x0c, 0xba}}, {0x35, {0x06, 0x1f, 0x02}}, + {0x35, {0x0e, 0x02, 0xe3}}, {0x35, {0x16, 0x1a, 0x50}}, + {0x35, {0x1e, 0x24, 0x39}}, {0x35, {0x26, 0x23, 0x4c}}, + {0x35, {0x2e, 0xf9, 0x1b}}, {0x35, {0x36, 0x23, 0x19}}, + {0x35, {0x3e, 0x12, 0x08}}, {0x35, {0x52, 0x07, 0x22}}, + {0x35, {0x4a, 0x03, 0xd3}}, {0x35, {0x62, 0x06, 0x54}}, + {0x35, {0x5a, 0x04, 0x5d}}, {0x34, {0xe2, 0x01, 0x04}}, + {0x34, {0xea, 0x00, 0xa0}}, {0x34, {0xf2, 0x0c, 0xbc}}, + {0x34, {0xfa, 0x0c, 0x5b}}, {0x35, {0x04, 0x17, 0xf2}}, + {0x35, {0x0c, 0x02, 0x08}}, {0x35, {0x14, 0x28, 0x43}}, + {0x35, {0x1c, 0x28, 0x62}}, {0x35, {0x24, 0x2b, 0x60}}, + {0x35, {0x2c, 0x07, 0x33}}, {0x35, {0x34, 0x1f, 0xb0}}, + {0x35, {0x3c, 0xed, 0xcd}}, {0x35, {0x50, 0x00, 0x06}}, + {0x35, {0x48, 0x07, 0xff}}, {0x35, {0x60, 0x05, 0x89}}, + {0x35, {0x58, 0x07, 0xff}}, {0x35, {0x40, 0x00, 0xa0}}, + {0x35, {0x42, 0x00, 0x00}}, {0x32, {0x10, 0x01, 0xfc}}, + {0x33, {0x8c, 0xa1, 0x18}}, {0x33, {0x90, 0x00, 0x3c}}, + {0x33, {0x78, 0x00, 0x00}}, + {2, {0xff, 0xff, 0xff}}, + {0x35, {0xb8, 0x1f, 0x20}}, {0x33, {0x8c, 0xa2, 0x06}}, + {0x33, {0x90, 0x00, 0x10}}, {0x33, {0x8c, 0xa2, 0x07}}, + {0x33, {0x90, 0x00, 0x08}}, {0x33, {0x8c, 0xa2, 0x42}}, + {0x33, {0x90, 0x00, 0x0b}}, {0x33, {0x8c, 0xa2, 0x4a}}, + {0x33, {0x90, 0x00, 0x8c}}, {0x35, {0xba, 0xfa, 0x08}}, + {0x33, {0x8c, 0xa2, 0x02}}, {0x33, {0x90, 0x00, 0x22}}, + {0x33, {0x8c, 0xa2, 0x03}}, {0x33, {0x90, 0x00, 0xbb}}, + {0x33, {0x8c, 0xa4, 0x04}}, {0x33, {0x90, 0x00, 0x80}}, + {0x33, {0x8c, 0xa7, 0x9d}}, {0x33, {0x90, 0x00, 0x00}}, + {0x33, {0x8c, 0xa7, 0x9e}}, {0x33, {0x90, 0x00, 0x00}}, + {0x33, {0x8c, 0xa2, 0x0c}}, {0x33, {0x90, 0x00, 0x17}}, + {0x33, {0x8c, 0xa2, 0x15}}, {0x33, {0x90, 0x00, 0x04}}, + {0x33, {0x8c, 0xa2, 0x14}}, {0x33, {0x90, 0x00, 0x20}}, + {0x33, {0x8c, 0xa1, 0x03}}, {0x33, {0x90, 0x00, 0x00}}, + {0x33, {0x8c, 0x27, 0x17}}, {0x33, {0x90, 0x21, 0x11}}, + {0x33, {0x8c, 0x27, 0x1b}}, {0x33, {0x90, 0x02, 0x4f}}, + {0x33, {0x8c, 0x27, 0x25}}, {0x33, {0x90, 0x06, 0x0f}}, + {0x33, {0x8c, 0x27, 0x39}}, {0x33, {0x90, 0x21, 0x11}}, + {0x33, {0x8c, 0x27, 0x3d}}, {0x33, {0x90, 0x01, 0x20}}, + {0x33, {0x8c, 0x27, 0x47}}, {0x33, {0x90, 0x09, 0x4c}}, + {0x33, {0x8c, 0x27, 0x03}}, {0x33, {0x90, 0x02, 0x84}}, + {0x33, {0x8c, 0x27, 0x05}}, {0x33, {0x90, 0x01, 0xe2}}, + {0x33, {0x8c, 0x27, 0x07}}, {0x33, {0x90, 0x06, 0x40}}, + {0x33, {0x8c, 0x27, 0x09}}, {0x33, {0x90, 0x04, 0xb0}}, + {0x33, {0x8c, 0x27, 0x0d}}, {0x33, {0x90, 0x00, 0x00}}, + {0x33, {0x8c, 0x27, 0x0f}}, {0x33, {0x90, 0x00, 0x00}}, + {0x33, {0x8c, 0x27, 0x11}}, {0x33, {0x90, 0x04, 0xbd}}, + {0x33, {0x8c, 0x27, 0x13}}, {0x33, {0x90, 0x06, 0x4d}}, + {0x33, {0x8c, 0x27, 0x15}}, {0x33, {0x90, 0x00, 0x00}}, + {0x33, {0x8c, 0x27, 0x17}}, {0x33, {0x90, 0x21, 0x11}}, + {0x33, {0x8c, 0x27, 0x19}}, {0x33, {0x90, 0x04, 0x6c}}, + {0x33, {0x8c, 0x27, 0x1b}}, {0x33, {0x90, 0x02, 0x4f}}, + {0x33, {0x8c, 0x27, 0x1d}}, {0x33, {0x90, 0x01, 0x02}}, + {0x33, {0x8c, 0x27, 0x1f}}, {0x33, {0x90, 0x02, 0x79}}, + {0x33, {0x8c, 0x27, 0x21}}, {0x33, {0x90, 0x01, 0x55}}, + {0x33, {0x8c, 0x27, 0x23}}, {0x33, {0x90, 0x02, 0x85}}, + {0x33, {0x8c, 0x27, 0x25}}, {0x33, {0x90, 0x06, 0x0f}}, + {0x33, {0x8c, 0x27, 0x27}}, {0x33, {0x90, 0x20, 0x20}}, + {0x33, {0x8c, 0x27, 0x29}}, {0x33, {0x90, 0x20, 0x20}}, + {0x33, {0x8c, 0x27, 0x2b}}, {0x33, {0x90, 0x10, 0x20}}, + {0x33, {0x8c, 0x27, 0x2d}}, {0x33, {0x90, 0x20, 0x07}}, + {0x33, {0x8c, 0x27, 0x2f}}, {0x33, {0x90, 0x00, 0x04}}, + {0x33, {0x8c, 0x27, 0x31}}, {0x33, {0x90, 0x00, 0x04}}, + {0x33, {0x8c, 0x27, 0x33}}, {0x33, {0x90, 0x04, 0xbb}}, + {0x33, {0x8c, 0x27, 0x35}}, {0x33, {0x90, 0x06, 0x4b}}, + {0x33, {0x8c, 0x27, 0x37}}, {0x33, {0x90, 0x00, 0x00}}, + {0x33, {0x8c, 0x27, 0x39}}, {0x33, {0x90, 0x21, 0x11}}, + {0x33, {0x8c, 0x27, 0x3b}}, {0x33, {0x90, 0x00, 0x24}}, + {0x33, {0x8c, 0x27, 0x3d}}, {0x33, {0x90, 0x01, 0x20}}, + {0x33, {0x8c, 0x27, 0x41}}, {0x33, {0x90, 0x01, 0x69}}, + {0x33, {0x8c, 0x27, 0x45}}, {0x33, {0x90, 0x04, 0xed}}, + {0x33, {0x8c, 0x27, 0x47}}, {0x33, {0x90, 0x09, 0x4c}}, + {0x33, {0x8c, 0x27, 0x51}}, {0x33, {0x90, 0x00, 0x00}}, + {0x33, {0x8c, 0x27, 0x53}}, {0x33, {0x90, 0x03, 0x20}}, + {0x33, {0x8c, 0x27, 0x55}}, {0x33, {0x90, 0x00, 0x00}}, + {0x33, {0x8c, 0x27, 0x57}}, {0x33, {0x90, 0x02, 0x58}}, + {0x33, {0x8c, 0x27, 0x5f}}, {0x33, {0x90, 0x00, 0x00}}, + {0x33, {0x8c, 0x27, 0x61}}, {0x33, {0x90, 0x06, 0x40}}, + {0x33, {0x8c, 0x27, 0x63}}, {0x33, {0x90, 0x00, 0x00}}, + {0x33, {0x8c, 0x27, 0x65}}, {0x33, {0x90, 0x04, 0xb0}}, + {0x33, {0x8c, 0x22, 0x2e}}, {0x33, {0x90, 0x00, 0xa1}}, + {0x33, {0x8c, 0xa4, 0x08}}, {0x33, {0x90, 0x00, 0x1f}}, + {0x33, {0x8c, 0xa4, 0x09}}, {0x33, {0x90, 0x00, 0x21}}, + {0x33, {0x8c, 0xa4, 0x0a}}, {0x33, {0x90, 0x00, 0x25}}, + {0x33, {0x8c, 0xa4, 0x0b}}, {0x33, {0x90, 0x00, 0x27}}, + {0x33, {0x8c, 0x24, 0x11}}, {0x33, {0x90, 0x00, 0xa1}}, + {0x33, {0x8c, 0x24, 0x13}}, {0x33, {0x90, 0x00, 0xc1}}, + {0x33, {0x8c, 0x24, 0x15}}, {0x33, {0x90, 0x00, 0x6a}}, + {0x33, {0x8c, 0x24, 0x17}}, {0x33, {0x90, 0x00, 0x80}}, + {0x33, {0x8c, 0xa1, 0x03}}, {0x33, {0x90, 0x00, 0x05}}, + {2, {0xff, 0xff, 0xff}}, + {0x33, {0x8c, 0xa1, 0x03}}, {0x33, {0x90, 0x00, 0x06}}, + {3, {0xff, 0xff, 0xff}}, }; static struct idxdata tbl_init_post_alt_low1[] = { - {0x33, "\x8c\x27\x15"}, {0x33, "\x90\x00\x25"}, {0x33, "\x8c\x22\x2e"}, - {0x33, "\x90\x00\x81"}, {0x33, "\x8c\xa4\x08"}, {0x33, "\x90\x00\x17"}, - {0x33, "\x8c\xa4\x09"}, {0x33, "\x90\x00\x1a"}, {0x33, "\x8c\xa4\x0a"}, - {0x33, "\x90\x00\x1d"}, {0x33, "\x8c\xa4\x0b"}, {0x33, "\x90\x00\x20"}, - {0x33, "\x8c\x24\x11"}, {0x33, "\x90\x00\x81"}, {0x33, "\x8c\x24\x13"}, - {0x33, "\x90\x00\x9b"}, + {0x33, {0x8c, 0x27, 0x15}}, {0x33, {0x90, 0x00, 0x25}}, + {0x33, {0x8c, 0x22, 0x2e}}, {0x33, {0x90, 0x00, 0x81}}, + {0x33, {0x8c, 0xa4, 0x08}}, {0x33, {0x90, 0x00, 0x17}}, + {0x33, {0x8c, 0xa4, 0x09}}, {0x33, {0x90, 0x00, 0x1a}}, + {0x33, {0x8c, 0xa4, 0x0a}}, {0x33, {0x90, 0x00, 0x1d}}, + {0x33, {0x8c, 0xa4, 0x0b}}, {0x33, {0x90, 0x00, 0x20}}, + {0x33, {0x8c, 0x24, 0x11}}, {0x33, {0x90, 0x00, 0x81}}, + {0x33, {0x8c, 0x24, 0x13}}, {0x33, {0x90, 0x00, 0x9b}}, }; static struct idxdata tbl_init_post_alt_low2[] = { - {0x33, "\x8c\x27\x03"}, {0x33, "\x90\x03\x24"}, {0x33, "\x8c\x27\x05"}, - {0x33, "\x90\x02\x58"}, {0x33, "\x8c\xa1\x03"}, {0x33, "\x90\x00\x05"}, - {2, "\xff\xff\xff"}, - {0x33, "\x8c\xa1\x03"}, {0x33, "\x90\x00\x06"}, - {2, "\xff\xff\xff"}, + {0x33, {0x8c, 0x27, 0x03}}, {0x33, {0x90, 0x03, 0x24}}, + {0x33, {0x8c, 0x27, 0x05}}, {0x33, {0x90, 0x02, 0x58}}, + {0x33, {0x8c, 0xa1, 0x03}}, {0x33, {0x90, 0x00, 0x05}}, + {2, {0xff, 0xff, 0xff}}, + {0x33, {0x8c, 0xa1, 0x03}}, {0x33, {0x90, 0x00, 0x06}}, + {2, {0xff, 0xff, 0xff}}, }; static struct idxdata tbl_init_post_alt_low3[] = { - {0x34, "\x1e\x8f\x09"}, {0x34, "\x1c\x01\x28"}, {0x34, "\x1e\x8f\x09"}, - {2, "\xff\xff\xff"}, - {0x34, "\x1e\x8f\x09"}, {0x32, "\x14\x06\xe6"}, {0x33, "\x8c\xa1\x20"}, - {0x33, "\x90\x00\x00"}, {0x33, "\x8c\xa1\x03"}, {0x33, "\x90\x00\x01"}, - {0x33, "\x2e\x01\x00"}, {0x34, "\x04\x00\x2a"}, {0x33, "\x8c\xa7\x02"}, - {0x33, "\x90\x00\x00"}, {0x33, "\x8c\x27\x95"}, {0x33, "\x90\x01\x00"}, - {2, "\xff\xff\xff"}, - {0x33, "\x8c\xa1\x20"}, {0x33, "\x90\x00\x72"}, {0x33, "\x8c\xa1\x03"}, - {0x33, "\x90\x00\x02"}, {0x33, "\x8c\xa7\x02"}, {0x33, "\x90\x00\x01"}, - {2, "\xff\xff\xff"}, - {0x33, "\x8c\xa1\x20"}, {0x33, "\x90\x00\x00"}, {0x33, "\x8c\xa1\x03"}, - {0x33, "\x90\x00\x01"}, {0x33, "\x8c\xa7\x02"}, {0x33, "\x90\x00\x00"}, - {2, "\xff\xff\xff"}, - {0x33, "\x8c\xa1\x03"}, {0x33, "\x90\x00\x05"}, - {2, "\xff\xff\xff"}, - {0x33, "\x8c\xa1\x03"}, {0x33, "\x90\x00\x06"}, - {2, "\xff\xff\xff"}, - {0x33, "\x8c\xa1\x03"}, {0x33, "\x90\x00\x05"}, - {2, "\xff\xff\xff"}, - {0x33, "\x8c\xa1\x03"}, {0x33, "\x90\x00\x06"}, + {0x34, {0x1e, 0x8f, 0x09}}, {0x34, {0x1c, 0x01, 0x28}}, + {0x34, {0x1e, 0x8f, 0x09}}, + {2, {0xff, 0xff, 0xff}}, + {0x34, {0x1e, 0x8f, 0x09}}, {0x32, {0x14, 0x06, 0xe6}}, + {0x33, {0x8c, 0xa1, 0x20}}, {0x33, {0x90, 0x00, 0x00}}, + {0x33, {0x8c, 0xa1, 0x03}}, {0x33, {0x90, 0x00, 0x01}}, + {0x33, {0x2e, 0x01, 0x00}}, {0x34, {0x04, 0x00, 0x2a}}, + {0x33, {0x8c, 0xa7, 0x02}}, {0x33, {0x90, 0x00, 0x00}}, + {0x33, {0x8c, 0x27, 0x95}}, {0x33, {0x90, 0x01, 0x00}}, + {2, {0xff, 0xff, 0xff}}, + {0x33, {0x8c, 0xa1, 0x20}}, {0x33, {0x90, 0x00, 0x72}}, + {0x33, {0x8c, 0xa1, 0x03}}, {0x33, {0x90, 0x00, 0x02}}, + {0x33, {0x8c, 0xa7, 0x02}}, {0x33, {0x90, 0x00, 0x01}}, + {2, {0xff, 0xff, 0xff}}, + {0x33, {0x8c, 0xa1, 0x20}}, {0x33, {0x90, 0x00, 0x00}}, + {0x33, {0x8c, 0xa1, 0x03}}, {0x33, {0x90, 0x00, 0x01}}, + {0x33, {0x8c, 0xa7, 0x02}}, {0x33, {0x90, 0x00, 0x00}}, + {2, {0xff, 0xff, 0xff}}, + {0x33, {0x8c, 0xa1, 0x03}}, {0x33, {0x90, 0x00, 0x05}}, + {2, {0xff, 0xff, 0xff}}, + {0x33, {0x8c, 0xa1, 0x03}}, {0x33, {0x90, 0x00, 0x06}}, + {2, {0xff, 0xff, 0xff}}, + {0x33, {0x8c, 0xa1, 0x03}}, {0x33, {0x90, 0x00, 0x05}}, + {2, {0xff, 0xff, 0xff}}, + {0x33, {0x8c, 0xa1, 0x03}}, {0x33, {0x90, 0x00, 0x06}}, }; static struct idxdata tbl_init_post_alt_big[] = { - {0x33, "\x8c\xa1\x03"}, {0x33, "\x90\x00\x05"}, - {2, "\xff\xff\xff"}, - {0x33, "\x8c\xa1\x03"}, {0x33, "\x90\x00\x06"}, - {2, "\xff\xff\xff"}, - {0x34, "\x1e\x8f\x09"}, {0x34, "\x1c\x01\x28"}, {0x34, "\x1e\x8f\x09"}, - {2, "\xff\xff\xff"}, - {0x34, "\x1e\x8f\x09"}, {0x32, "\x14\x06\xe6"}, {0x33, "\x8c\xa1\x03"}, - {0x33, "\x90\x00\x05"}, - {2, "\xff\xff\xff"}, - {0x33, "\x8c\xa1\x03"}, {0x33, "\x90\x00\x06"}, - {2, "\xff\xff\xff"}, - {0x33, "\x8c\xa1\x03"}, {0x33, "\x90\x00\x05"}, - {2, "\xff\xff\xff"}, - {0x33, "\x8c\xa1\x03"}, {0x33, "\x90\x00\x06"}, {0x33, "\x8c\xa1\x20"}, - {0x33, "\x90\x00\x72"}, {0x33, "\x8c\xa1\x30"}, {0x33, "\x90\x00\x03"}, - {0x33, "\x8c\xa1\x31"}, {0x33, "\x90\x00\x02"}, {0x33, "\x8c\xa1\x32"}, - {0x33, "\x90\x00\x03"}, {0x33, "\x8c\xa1\x34"}, {0x33, "\x90\x00\x03"}, - {0x33, "\x8c\xa1\x03"}, {0x33, "\x90\x00\x02"}, {0x33, "\x2e\x01\x00"}, - {0x34, "\x04\x00\x2a"}, {0x33, "\x8c\xa7\x02"}, {0x33, "\x90\x00\x01"}, - {0x33, "\x8c\x27\x97"}, {0x33, "\x90\x01\x00"}, - {51, "\xff\xff\xff"}, - {0x33, "\x8c\xa1\x20"}, {0x33, "\x90\x00\x00"}, {0x33, "\x8c\xa1\x03"}, - {0x33, "\x90\x00\x01"}, {0x33, "\x8c\xa7\x02"}, {0x33, "\x90\x00\x00"}, - {51, "\xff\xff\xff"}, - {0x33, "\x8c\xa1\x20"}, {0x33, "\x90\x00\x72"}, {0x33, "\x8c\xa1\x03"}, - {0x33, "\x90\x00\x02"}, {0x33, "\x8c\xa7\x02"}, {0x33, "\x90\x00\x01"}, - {51, "\xff\xff\xff"}, + {0x33, {0x8c, 0xa1, 0x03}}, {0x33, {0x90, 0x00, 0x05}}, + {2, {0xff, 0xff, 0xff}}, + {0x33, {0x8c, 0xa1, 0x03}}, {0x33, {0x90, 0x00, 0x06}}, + {2, {0xff, 0xff, 0xff}}, + {0x34, {0x1e, 0x8f, 0x09}}, {0x34, {0x1c, 0x01, 0x28}}, + {0x34, {0x1e, 0x8f, 0x09}}, + {2, {0xff, 0xff, 0xff}}, + {0x34, {0x1e, 0x8f, 0x09}}, {0x32, {0x14, 0x06, 0xe6}}, + {0x33, {0x8c, 0xa1, 0x03}}, + {0x33, {0x90, 0x00, 0x05}}, + {2, {0xff, 0xff, 0xff}}, + {0x33, {0x8c, 0xa1, 0x03}}, {0x33, {0x90, 0x00, 0x06}}, + {2, {0xff, 0xff, 0xff}}, + {0x33, {0x8c, 0xa1, 0x03}}, {0x33, {0x90, 0x00, 0x05}}, + {2, {0xff, 0xff, 0xff}}, + {0x33, {0x8c, 0xa1, 0x03}}, {0x33, {0x90, 0x00, 0x06}}, + {0x33, {0x8c, 0xa1, 0x20}}, {0x33, {0x90, 0x00, 0x72}}, + {0x33, {0x8c, 0xa1, 0x30}}, {0x33, {0x90, 0x00, 0x03}}, + {0x33, {0x8c, 0xa1, 0x31}}, {0x33, {0x90, 0x00, 0x02}}, + {0x33, {0x8c, 0xa1, 0x32}}, {0x33, {0x90, 0x00, 0x03}}, + {0x33, {0x8c, 0xa1, 0x34}}, {0x33, {0x90, 0x00, 0x03}}, + {0x33, {0x8c, 0xa1, 0x03}}, {0x33, {0x90, 0x00, 0x02}}, + {0x33, {0x2e, 0x01, 0x00}}, {0x34, {0x04, 0x00, 0x2a}}, + {0x33, {0x8c, 0xa7, 0x02}}, {0x33, {0x90, 0x00, 0x01}}, + {0x33, {0x8c, 0x27, 0x97}}, {0x33, {0x90, 0x01, 0x00}}, + {51, {0xff, 0xff, 0xff}}, + {0x33, {0x8c, 0xa1, 0x20}}, {0x33, {0x90, 0x00, 0x00}}, + {0x33, {0x8c, 0xa1, 0x03}}, {0x33, {0x90, 0x00, 0x01}}, + {0x33, {0x8c, 0xa7, 0x02}}, {0x33, {0x90, 0x00, 0x00}}, + {51, {0xff, 0xff, 0xff}}, + {0x33, {0x8c, 0xa1, 0x20}}, {0x33, {0x90, 0x00, 0x72}}, + {0x33, {0x8c, 0xa1, 0x03}}, {0x33, {0x90, 0x00, 0x02}}, + {0x33, {0x8c, 0xa7, 0x02}}, {0x33, {0x90, 0x00, 0x01}}, + {51, {0xff, 0xff, 0xff}}, }; static struct idxdata tbl_init_post_alt_3B[] = { - {0x32, "\x10\x01\xf8"}, {0x34, "\xce\x01\xa8"}, {0x34, "\xd0\x66\x33"}, - {0x34, "\xd2\x31\x9a"}, {0x34, "\xd4\x94\x63"}, {0x34, "\xd6\x4b\x25"}, - {0x34, "\xd8\x26\x70"}, {0x34, "\xda\x72\x4c"}, {0x34, "\xdc\xff\x04"}, - {0x34, "\xde\x01\x5b"}, {0x34, "\xe6\x01\x13"}, {0x34, "\xee\x0b\xf0"}, - {0x34, "\xf6\x0b\xa4"}, {0x35, "\x00\xf6\xe7"}, {0x35, "\x08\x0d\xfd"}, - {0x35, "\x10\x25\x63"}, {0x35, "\x18\x35\x6c"}, {0x35, "\x20\x42\x7e"}, - {0x35, "\x28\x19\x44"}, {0x35, "\x30\x39\xd4"}, {0x35, "\x38\xf5\xa8"}, - {0x35, "\x4c\x07\x90"}, {0x35, "\x44\x07\xb8"}, {0x35, "\x5c\x06\x88"}, - {0x35, "\x54\x07\xff"}, {0x34, "\xe0\x01\x52"}, {0x34, "\xe8\x00\xcc"}, - {0x34, "\xf0\x0d\x83"}, {0x34, "\xf8\x0c\xb3"}, {0x35, "\x02\xfe\xba"}, - {0x35, "\x0a\x04\xe0"}, {0x35, "\x12\x1c\x63"}, {0x35, "\x1a\x2b\x5a"}, - {0x35, "\x22\x32\x5e"}, {0x35, "\x2a\x0d\x28"}, {0x35, "\x32\x2c\x02"}, - {0x35, "\x3a\xf4\xfa"}, {0x35, "\x4e\x07\xef"}, {0x35, "\x46\x07\x88"}, - {0x35, "\x5e\x07\xc1"}, {0x35, "\x56\x04\x64"}, {0x34, "\xe4\x01\x15"}, - {0x34, "\xec\x00\x82"}, {0x34, "\xf4\x0c\xce"}, {0x34, "\xfc\x0c\xba"}, - {0x35, "\x06\x1f\x02"}, {0x35, "\x0e\x02\xe3"}, {0x35, "\x16\x1a\x50"}, - {0x35, "\x1e\x24\x39"}, {0x35, "\x26\x23\x4c"}, {0x35, "\x2e\xf9\x1b"}, - {0x35, "\x36\x23\x19"}, {0x35, "\x3e\x12\x08"}, {0x35, "\x52\x07\x22"}, - {0x35, "\x4a\x03\xd3"}, {0x35, "\x62\x06\x54"}, {0x35, "\x5a\x04\x5d"}, - {0x34, "\xe2\x01\x04"}, {0x34, "\xea\x00\xa0"}, {0x34, "\xf2\x0c\xbc"}, - {0x34, "\xfa\x0c\x5b"}, {0x35, "\x04\x17\xf2"}, {0x35, "\x0c\x02\x08"}, - {0x35, "\x14\x28\x43"}, {0x35, "\x1c\x28\x62"}, {0x35, "\x24\x2b\x60"}, - {0x35, "\x2c\x07\x33"}, {0x35, "\x34\x1f\xb0"}, {0x35, "\x3c\xed\xcd"}, - {0x35, "\x50\x00\x06"}, {0x35, "\x48\x07\xff"}, {0x35, "\x60\x05\x89"}, - {0x35, "\x58\x07\xff"}, {0x35, "\x40\x00\xa0"}, {0x35, "\x42\x00\x00"}, - {0x32, "\x10\x01\xfc"}, {0x33, "\x8c\xa1\x18"}, {0x33, "\x90\x00\x3c"}, + {0x32, {0x10, 0x01, 0xf8}}, {0x34, {0xce, 0x01, 0xa8}}, + {0x34, {0xd0, 0x66, 0x33}}, {0x34, {0xd2, 0x31, 0x9a}}, + {0x34, {0xd4, 0x94, 0x63}}, {0x34, {0xd6, 0x4b, 0x25}}, + {0x34, {0xd8, 0x26, 0x70}}, {0x34, {0xda, 0x72, 0x4c}}, + {0x34, {0xdc, 0xff, 0x04}}, {0x34, {0xde, 0x01, 0x5b}}, + {0x34, {0xe6, 0x01, 0x13}}, {0x34, {0xee, 0x0b, 0xf0}}, + {0x34, {0xf6, 0x0b, 0xa4}}, {0x35, {0x00, 0xf6, 0xe7}}, + {0x35, {0x08, 0x0d, 0xfd}}, {0x35, {0x10, 0x25, 0x63}}, + {0x35, {0x18, 0x35, 0x6c}}, {0x35, {0x20, 0x42, 0x7e}}, + {0x35, {0x28, 0x19, 0x44}}, {0x35, {0x30, 0x39, 0xd4}}, + {0x35, {0x38, 0xf5, 0xa8}}, {0x35, {0x4c, 0x07, 0x90}}, + {0x35, {0x44, 0x07, 0xb8}}, {0x35, {0x5c, 0x06, 0x88}}, + {0x35, {0x54, 0x07, 0xff}}, {0x34, {0xe0, 0x01, 0x52}}, + {0x34, {0xe8, 0x00, 0xcc}}, {0x34, {0xf0, 0x0d, 0x83}}, + {0x34, {0xf8, 0x0c, 0xb3}}, {0x35, {0x02, 0xfe, 0xba}}, + {0x35, {0x0a, 0x04, 0xe0}}, {0x35, {0x12, 0x1c, 0x63}}, + {0x35, {0x1a, 0x2b, 0x5a}}, {0x35, {0x22, 0x32, 0x5e}}, + {0x35, {0x2a, 0x0d, 0x28}}, {0x35, {0x32, 0x2c, 0x02}}, + {0x35, {0x3a, 0xf4, 0xfa}}, {0x35, {0x4e, 0x07, 0xef}}, + {0x35, {0x46, 0x07, 0x88}}, {0x35, {0x5e, 0x07, 0xc1}}, + {0x35, {0x56, 0x04, 0x64}}, {0x34, {0xe4, 0x01, 0x15}}, + {0x34, {0xec, 0x00, 0x82}}, {0x34, {0xf4, 0x0c, 0xce}}, + {0x34, {0xfc, 0x0c, 0xba}}, {0x35, {0x06, 0x1f, 0x02}}, + {0x35, {0x0e, 0x02, 0xe3}}, {0x35, {0x16, 0x1a, 0x50}}, + {0x35, {0x1e, 0x24, 0x39}}, {0x35, {0x26, 0x23, 0x4c}}, + {0x35, {0x2e, 0xf9, 0x1b}}, {0x35, {0x36, 0x23, 0x19}}, + {0x35, {0x3e, 0x12, 0x08}}, {0x35, {0x52, 0x07, 0x22}}, + {0x35, {0x4a, 0x03, 0xd3}}, {0x35, {0x62, 0x06, 0x54}}, + {0x35, {0x5a, 0x04, 0x5d}}, {0x34, {0xe2, 0x01, 0x04}}, + {0x34, {0xea, 0x00, 0xa0}}, {0x34, {0xf2, 0x0c, 0xbc}}, + {0x34, {0xfa, 0x0c, 0x5b}}, {0x35, {0x04, 0x17, 0xf2}}, + {0x35, {0x0c, 0x02, 0x08}}, {0x35, {0x14, 0x28, 0x43}}, + {0x35, {0x1c, 0x28, 0x62}}, {0x35, {0x24, 0x2b, 0x60}}, + {0x35, {0x2c, 0x07, 0x33}}, {0x35, {0x34, 0x1f, 0xb0}}, + {0x35, {0x3c, 0xed, 0xcd}}, {0x35, {0x50, 0x00, 0x06}}, + {0x35, {0x48, 0x07, 0xff}}, {0x35, {0x60, 0x05, 0x89}}, + {0x35, {0x58, 0x07, 0xff}}, {0x35, {0x40, 0x00, 0xa0}}, + {0x35, {0x42, 0x00, 0x00}}, {0x32, {0x10, 0x01, 0xfc}}, + {0x33, {0x8c, 0xa1, 0x18}}, {0x33, {0x90, 0x00, 0x3c}}, }; static u8 *dat_640 = "\xd0\x02\xd1\x08\xd2\xe1\xd3\x02\xd4\x10\xd5\x81"; -- cgit v1.2.3 From ba76a6e6a5eaa3736df743818394978af456cf70 Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Mon, 17 Mar 2014 09:54:19 -0300 Subject: [media] v4l2-subdev.h: fix sparse error with v4l2_subdev_notify The notify function is a void function, yet the v4l2_subdev_notify define uses it in a ? : construction, which causes sparse warnings. Replace the define by a static inline function and move it to v4l2-device.h, which is where it belongs since it needs to know the v4l2_device struct. This wasn't a problem when it was a define, but as a static inline function this no longer compiles in v4l2-subdev.h. Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- include/media/v4l2-device.h | 8 ++++++++ include/media/v4l2-subdev.h | 5 ----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/include/media/v4l2-device.h b/include/media/v4l2-device.h index c9b1593923f6..ffb69da3ce9e 100644 --- a/include/media/v4l2-device.h +++ b/include/media/v4l2-device.h @@ -120,6 +120,14 @@ void v4l2_device_unregister_subdev(struct v4l2_subdev *sd); int __must_check v4l2_device_register_subdev_nodes(struct v4l2_device *v4l2_dev); +/* Send a notification to v4l2_device. */ +static inline void v4l2_subdev_notify(struct v4l2_subdev *sd, + unsigned int notification, void *arg) +{ + if (sd && sd->v4l2_dev && sd->v4l2_dev->notify) + sd->v4l2_dev->notify(sd, notification, arg); +} + /* Iterate over all subdevs. */ #define v4l2_device_for_each_subdev(sd, v4l2_dev) \ list_for_each_entry(sd, &(v4l2_dev)->subdevs, list) diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h index 28f4d8c3cf7d..ee1cb2d354a8 100644 --- a/include/media/v4l2-subdev.h +++ b/include/media/v4l2-subdev.h @@ -691,11 +691,6 @@ void v4l2_subdev_init(struct v4l2_subdev *sd, (!(sd) ? -ENODEV : (((sd)->ops->o && (sd)->ops->o->f) ? \ (sd)->ops->o->f((sd) , ##args) : -ENOIOCTLCMD)) -/* Send a notification to v4l2_device. */ -#define v4l2_subdev_notify(sd, notification, arg) \ - ((!(sd) || !(sd)->v4l2_dev || !(sd)->v4l2_dev->notify) ? -ENODEV : \ - (sd)->v4l2_dev->notify((sd), (notification), (arg))) - #define v4l2_subdev_has_op(sd, o, f) \ ((sd)->ops->o && (sd)->ops->o->f) -- cgit v1.2.3 From a1d36d8c705e10ad92b021c129e2d81bd9fde39c Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Mon, 17 Mar 2014 09:54:21 -0300 Subject: [media] videobuf2-core: fix sparse errors Sparse generated a bunch of errors like this: drivers/media/v4l2-core/videobuf2-core.c:2045:25: error: incompatible types in conditional expression (different base types) drivers/media/v4l2-core/videobuf2-core.c:136:17: error: incompatible types in conditional expression (different base types) drivers/media/v4l2-core/videobuf2-core.c:151:17: error: incompatible types in conditional expression (different base types) drivers/media/v4l2-core/videobuf2-core.c:168:25: error: incompatible types in conditional expression (different base types) drivers/media/v4l2-core/videobuf2-core.c:183:17: error: incompatible types in conditional expression (different base types) drivers/media/v4l2-core/videobuf2-core.c:185:9: error: incompatible types in conditional expression (different base types) drivers/media/v4l2-core/videobuf2-core.c:385:25: error: incompatible types in conditional expression (different base types) drivers/media/v4l2-core/videobuf2-core.c:1115:17: error: incompatible types in conditional expression (different base types) drivers/media/v4l2-core/videobuf2-core.c:1268:33: error: incompatible types in conditional expression (different base types) drivers/media/v4l2-core/videobuf2-core.c:1270:25: error: incompatible types in conditional expression (different base types) drivers/media/v4l2-core/videobuf2-core.c:1315:17: error: incompatible types in conditional expression (different base types) drivers/media/v4l2-core/videobuf2-core.c:1324:25: error: incompatible types in conditional expression (different base types) drivers/media/v4l2-core/videobuf2-core.c:1396:25: error: incompatible types in conditional expression (different base types) drivers/media/v4l2-core/videobuf2-core.c:1457:17: error: incompatible types in conditional expression (different base types) drivers/media/v4l2-core/videobuf2-core.c:1482:17: error: incompatible types in conditional expression (different base types) drivers/media/v4l2-core/videobuf2-core.c:1484:9: error: incompatible types in conditional expression (different base types) drivers/media/v4l2-core/videobuf2-core.c:1523:17: error: incompatible types in conditional expression (different base types) drivers/media/v4l2-core/videobuf2-core.c:1525:17: error: incompatible types in conditional expression (different base types) drivers/media/v4l2-core/videobuf2-core.c:1815:17: error: incompatible types in conditional expression (different base types) drivers/media/v4l2-core/videobuf2-core.c:1828:17: error: incompatible types in conditional expression (different base types) drivers/media/v4l2-core/videobuf2-core.c:1914:25: error: incompatible types in conditional expression (different base types) drivers/media/v4l2-core/videobuf2-core.c:1944:9: error: incompatible types in conditional expression (different base types) These are caused by the call*op defines which do something like this: (ops->op) ? ops->op(args) : 0 which is OK as long as op is not a void function, because in that case one part of the conditional expression returns void, the other an integer. Hence the sparse errors. I've replaced this by introducing three variants of the call_ macros: call_*op for int returns, call_void_*op for void returns and call_ptr_*op for pointer returns. That's the bad news. The good news is that the fail_*op macros could be removed since the call_*op macros now have enough information to determine if the op succeeded or not and can increment the op counter only on success. This at least makes it more robust w.r.t. future changes. Signed-off-by: Hans Verkuil Acked-by: Pawel Osciak Signed-off-by: Mauro Carvalho Chehab --- drivers/media/v4l2-core/videobuf2-core.c | 211 +++++++++++++++++++------------ 1 file changed, 130 insertions(+), 81 deletions(-) diff --git a/drivers/media/v4l2-core/videobuf2-core.c b/drivers/media/v4l2-core/videobuf2-core.c index f9059bb73840..98ddeb6c05c1 100644 --- a/drivers/media/v4l2-core/videobuf2-core.c +++ b/drivers/media/v4l2-core/videobuf2-core.c @@ -36,58 +36,133 @@ module_param(debug, int, 0644); #ifdef CONFIG_VIDEO_ADV_DEBUG /* - * If advanced debugging is on, then count how often each op is called, - * which can either be per-buffer or per-queue. + * If advanced debugging is on, then count how often each op is called + * successfully, which can either be per-buffer or per-queue. * - * If the op failed then the 'fail_' variant is called to decrease the - * counter. That makes it easy to check that the 'init' and 'cleanup' + * This makes it easy to check that the 'init' and 'cleanup' * (and variations thereof) stay balanced. */ +#define log_memop(vb, op) \ + dprintk(2, "call_memop(%p, %d, %s)%s\n", \ + (vb)->vb2_queue, (vb)->v4l2_buf.index, #op, \ + (vb)->vb2_queue->mem_ops->op ? "" : " (nop)") + #define call_memop(vb, op, args...) \ ({ \ struct vb2_queue *_q = (vb)->vb2_queue; \ - dprintk(2, "call_memop(%p, %d, %s)%s\n", \ - _q, (vb)->v4l2_buf.index, #op, \ - _q->mem_ops->op ? "" : " (nop)"); \ + int err; \ + \ + log_memop(vb, op); \ + err = _q->mem_ops->op ? _q->mem_ops->op(args) : 0; \ + if (!err) \ + (vb)->cnt_mem_ ## op++; \ + err; \ +}) + +#define call_ptr_memop(vb, op, args...) \ +({ \ + struct vb2_queue *_q = (vb)->vb2_queue; \ + void *ptr; \ + \ + log_memop(vb, op); \ + ptr = _q->mem_ops->op ? _q->mem_ops->op(args) : NULL; \ + if (!IS_ERR_OR_NULL(ptr)) \ + (vb)->cnt_mem_ ## op++; \ + ptr; \ +}) + +#define call_void_memop(vb, op, args...) \ +({ \ + struct vb2_queue *_q = (vb)->vb2_queue; \ + \ + log_memop(vb, op); \ + if (_q->mem_ops->op) \ + _q->mem_ops->op(args); \ (vb)->cnt_mem_ ## op++; \ - _q->mem_ops->op ? _q->mem_ops->op(args) : 0; \ }) -#define fail_memop(vb, op) ((vb)->cnt_mem_ ## op--) + +#define log_qop(q, op) \ + dprintk(2, "call_qop(%p, %s)%s\n", q, #op, \ + (q)->ops->op ? "" : " (nop)") #define call_qop(q, op, args...) \ ({ \ - dprintk(2, "call_qop(%p, %s)%s\n", q, #op, \ - (q)->ops->op ? "" : " (nop)"); \ + int err; \ + \ + log_qop(q, op); \ + err = (q)->ops->op ? (q)->ops->op(args) : 0; \ + if (!err) \ + (q)->cnt_ ## op++; \ + err; \ +}) + +#define call_void_qop(q, op, args...) \ +({ \ + log_qop(q, op); \ + if ((q)->ops->op) \ + (q)->ops->op(args); \ (q)->cnt_ ## op++; \ - (q)->ops->op ? (q)->ops->op(args) : 0; \ }) -#define fail_qop(q, op) ((q)->cnt_ ## op--) + +#define log_vb_qop(vb, op, args...) \ + dprintk(2, "call_vb_qop(%p, %d, %s)%s\n", \ + (vb)->vb2_queue, (vb)->v4l2_buf.index, #op, \ + (vb)->vb2_queue->ops->op ? "" : " (nop)") #define call_vb_qop(vb, op, args...) \ ({ \ - struct vb2_queue *_q = (vb)->vb2_queue; \ - dprintk(2, "call_vb_qop(%p, %d, %s)%s\n", \ - _q, (vb)->v4l2_buf.index, #op, \ - _q->ops->op ? "" : " (nop)"); \ + int err; \ + \ + log_vb_qop(vb, op); \ + err = (vb)->vb2_queue->ops->op ? \ + (vb)->vb2_queue->ops->op(args) : 0; \ + if (!err) \ + (vb)->cnt_ ## op++; \ + err; \ +}) + +#define call_void_vb_qop(vb, op, args...) \ +({ \ + log_vb_qop(vb, op); \ + if ((vb)->vb2_queue->ops->op) \ + (vb)->vb2_queue->ops->op(args); \ (vb)->cnt_ ## op++; \ - _q->ops->op ? _q->ops->op(args) : 0; \ }) -#define fail_vb_qop(vb, op) ((vb)->cnt_ ## op--) #else #define call_memop(vb, op, args...) \ - ((vb)->vb2_queue->mem_ops->op ? (vb)->vb2_queue->mem_ops->op(args) : 0) -#define fail_memop(vb, op) + ((vb)->vb2_queue->mem_ops->op ? \ + (vb)->vb2_queue->mem_ops->op(args) : 0) + +#define call_ptr_memop(vb, op, args...) \ + ((vb)->vb2_queue->mem_ops->op ? \ + (vb)->vb2_queue->mem_ops->op(args) : NULL) + +#define call_void_memop(vb, op, args...) \ + do { \ + if ((vb)->vb2_queue->mem_ops->op) \ + (vb)->vb2_queue->mem_ops->op(args); \ + } while (0) #define call_qop(q, op, args...) \ ((q)->ops->op ? (q)->ops->op(args) : 0) -#define fail_qop(q, op) + +#define call_void_qop(q, op, args...) \ + do { \ + if ((q)->ops->op) \ + (q)->ops->op(args); \ + } while (0) #define call_vb_qop(vb, op, args...) \ ((vb)->vb2_queue->ops->op ? (vb)->vb2_queue->ops->op(args) : 0) -#define fail_vb_qop(vb, op) + +#define call_void_vb_qop(vb, op, args...) \ + do { \ + if ((vb)->vb2_queue->ops->op) \ + (vb)->vb2_queue->ops->op(args); \ + } while (0) #endif @@ -118,7 +193,7 @@ static int __vb2_buf_mem_alloc(struct vb2_buffer *vb) for (plane = 0; plane < vb->num_planes; ++plane) { unsigned long size = PAGE_ALIGN(q->plane_sizes[plane]); - mem_priv = call_memop(vb, alloc, q->alloc_ctx[plane], + mem_priv = call_ptr_memop(vb, alloc, q->alloc_ctx[plane], size, q->gfp_flags); if (IS_ERR_OR_NULL(mem_priv)) goto free; @@ -130,10 +205,9 @@ static int __vb2_buf_mem_alloc(struct vb2_buffer *vb) return 0; free: - fail_memop(vb, alloc); /* Free already allocated memory if one of the allocations failed */ for (; plane > 0; --plane) { - call_memop(vb, put, vb->planes[plane - 1].mem_priv); + call_void_memop(vb, put, vb->planes[plane - 1].mem_priv); vb->planes[plane - 1].mem_priv = NULL; } @@ -148,7 +222,7 @@ static void __vb2_buf_mem_free(struct vb2_buffer *vb) unsigned int plane; for (plane = 0; plane < vb->num_planes; ++plane) { - call_memop(vb, put, vb->planes[plane].mem_priv); + call_void_memop(vb, put, vb->planes[plane].mem_priv); vb->planes[plane].mem_priv = NULL; dprintk(3, "Freed plane %d of buffer %d\n", plane, vb->v4l2_buf.index); @@ -165,7 +239,7 @@ static void __vb2_buf_userptr_put(struct vb2_buffer *vb) for (plane = 0; plane < vb->num_planes; ++plane) { if (vb->planes[plane].mem_priv) - call_memop(vb, put_userptr, vb->planes[plane].mem_priv); + call_void_memop(vb, put_userptr, vb->planes[plane].mem_priv); vb->planes[plane].mem_priv = NULL; } } @@ -180,9 +254,9 @@ static void __vb2_plane_dmabuf_put(struct vb2_buffer *vb, struct vb2_plane *p) return; if (p->dbuf_mapped) - call_memop(vb, unmap_dmabuf, p->mem_priv); + call_void_memop(vb, unmap_dmabuf, p->mem_priv); - call_memop(vb, detach_dmabuf, p->mem_priv); + call_void_memop(vb, detach_dmabuf, p->mem_priv); dma_buf_put(p->dbuf); memset(p, 0, sizeof(*p)); } @@ -305,7 +379,6 @@ static int __vb2_queue_alloc(struct vb2_queue *q, enum v4l2_memory memory, if (ret) { dprintk(1, "Buffer %d %p initialization" " failed\n", buffer, vb); - fail_vb_qop(vb, buf_init); __vb2_buf_mem_free(vb); kfree(vb); break; @@ -382,7 +455,7 @@ static int __vb2_queue_free(struct vb2_queue *q, unsigned int buffers) struct vb2_buffer *vb = q->bufs[buffer]; if (vb && vb->planes[0].mem_priv) - call_vb_qop(vb, buf_cleanup, vb); + call_void_vb_qop(vb, buf_cleanup, vb); } /* Release video buffer memory */ @@ -837,10 +910,8 @@ static int __reqbufs(struct vb2_queue *q, struct v4l2_requestbuffers *req) */ ret = call_qop(q, queue_setup, q, NULL, &num_buffers, &num_planes, q->plane_sizes, q->alloc_ctx); - if (ret) { - fail_qop(q, queue_setup); + if (ret) return ret; - } /* Finally, allocate buffers and video memory */ allocated_buffers = __vb2_queue_alloc(q, req->memory, num_buffers, num_planes); @@ -864,8 +935,6 @@ static int __reqbufs(struct vb2_queue *q, struct v4l2_requestbuffers *req) ret = call_qop(q, queue_setup, q, NULL, &num_buffers, &num_planes, q->plane_sizes, q->alloc_ctx); - if (ret) - fail_qop(q, queue_setup); if (!ret && allocated_buffers < num_buffers) ret = -ENOMEM; @@ -950,10 +1019,8 @@ static int __create_bufs(struct vb2_queue *q, struct v4l2_create_buffers *create */ ret = call_qop(q, queue_setup, q, &create->format, &num_buffers, &num_planes, q->plane_sizes, q->alloc_ctx); - if (ret) { - fail_qop(q, queue_setup); + if (ret) return ret; - } /* Finally, allocate buffers and video memory */ allocated_buffers = __vb2_queue_alloc(q, create->memory, num_buffers, @@ -975,8 +1042,6 @@ static int __create_bufs(struct vb2_queue *q, struct v4l2_create_buffers *create */ ret = call_qop(q, queue_setup, q, &create->format, &num_buffers, &num_planes, q->plane_sizes, q->alloc_ctx); - if (ret) - fail_qop(q, queue_setup); if (!ret && allocated_buffers < num_buffers) ret = -ENOMEM; @@ -1038,7 +1103,7 @@ void *vb2_plane_vaddr(struct vb2_buffer *vb, unsigned int plane_no) if (plane_no > vb->num_planes || !vb->planes[plane_no].mem_priv) return NULL; - return call_memop(vb, vaddr, vb->planes[plane_no].mem_priv); + return call_ptr_memop(vb, vaddr, vb->planes[plane_no].mem_priv); } EXPORT_SYMBOL_GPL(vb2_plane_vaddr); @@ -1059,7 +1124,7 @@ void *vb2_plane_cookie(struct vb2_buffer *vb, unsigned int plane_no) if (plane_no > vb->num_planes || !vb->planes[plane_no].mem_priv) return NULL; - return call_memop(vb, cookie, vb->planes[plane_no].mem_priv); + return call_ptr_memop(vb, cookie, vb->planes[plane_no].mem_priv); } EXPORT_SYMBOL_GPL(vb2_plane_cookie); @@ -1112,7 +1177,7 @@ void vb2_buffer_done(struct vb2_buffer *vb, enum vb2_buffer_state state) /* sync buffers */ for (plane = 0; plane < vb->num_planes; ++plane) - call_memop(vb, finish, vb->planes[plane].mem_priv); + call_void_memop(vb, finish, vb->planes[plane].mem_priv); /* Add the buffer to the done buffers list */ spin_lock_irqsave(&q->done_lock, flags); @@ -1265,22 +1330,21 @@ static int __qbuf_userptr(struct vb2_buffer *vb, const struct v4l2_buffer *b) if (vb->planes[plane].mem_priv) { if (!reacquired) { reacquired = true; - call_vb_qop(vb, buf_cleanup, vb); + call_void_vb_qop(vb, buf_cleanup, vb); } - call_memop(vb, put_userptr, vb->planes[plane].mem_priv); + call_void_memop(vb, put_userptr, vb->planes[plane].mem_priv); } vb->planes[plane].mem_priv = NULL; memset(&vb->v4l2_planes[plane], 0, sizeof(struct v4l2_plane)); /* Acquire each plane's memory */ - mem_priv = call_memop(vb, get_userptr, q->alloc_ctx[plane], + mem_priv = call_ptr_memop(vb, get_userptr, q->alloc_ctx[plane], planes[plane].m.userptr, planes[plane].length, write); if (IS_ERR_OR_NULL(mem_priv)) { dprintk(1, "qbuf: failed acquiring userspace " "memory for plane %d\n", plane); - fail_memop(vb, get_userptr); ret = mem_priv ? PTR_ERR(mem_priv) : -EINVAL; goto err; } @@ -1303,7 +1367,6 @@ static int __qbuf_userptr(struct vb2_buffer *vb, const struct v4l2_buffer *b) ret = call_vb_qop(vb, buf_init, vb); if (ret) { dprintk(1, "qbuf: buffer initialization failed\n"); - fail_vb_qop(vb, buf_init); goto err; } } @@ -1311,8 +1374,7 @@ static int __qbuf_userptr(struct vb2_buffer *vb, const struct v4l2_buffer *b) ret = call_vb_qop(vb, buf_prepare, vb); if (ret) { dprintk(1, "qbuf: buffer preparation failed\n"); - fail_vb_qop(vb, buf_prepare); - call_vb_qop(vb, buf_cleanup, vb); + call_void_vb_qop(vb, buf_cleanup, vb); goto err; } @@ -1321,7 +1383,7 @@ err: /* In case of errors, release planes that were already acquired */ for (plane = 0; plane < vb->num_planes; ++plane) { if (vb->planes[plane].mem_priv) - call_memop(vb, put_userptr, vb->planes[plane].mem_priv); + call_void_memop(vb, put_userptr, vb->planes[plane].mem_priv); vb->planes[plane].mem_priv = NULL; vb->v4l2_planes[plane].m.userptr = 0; vb->v4l2_planes[plane].length = 0; @@ -1335,13 +1397,8 @@ err: */ static int __qbuf_mmap(struct vb2_buffer *vb, const struct v4l2_buffer *b) { - int ret; - __fill_vb2_buffer(vb, b, vb->v4l2_planes); - ret = call_vb_qop(vb, buf_prepare, vb); - if (ret) - fail_vb_qop(vb, buf_prepare); - return ret; + return call_vb_qop(vb, buf_prepare, vb); } /** @@ -1393,7 +1450,7 @@ static int __qbuf_dmabuf(struct vb2_buffer *vb, const struct v4l2_buffer *b) if (!reacquired) { reacquired = true; - call_vb_qop(vb, buf_cleanup, vb); + call_void_vb_qop(vb, buf_cleanup, vb); } /* Release previously acquired memory if present */ @@ -1401,11 +1458,10 @@ static int __qbuf_dmabuf(struct vb2_buffer *vb, const struct v4l2_buffer *b) memset(&vb->v4l2_planes[plane], 0, sizeof(struct v4l2_plane)); /* Acquire each plane's memory */ - mem_priv = call_memop(vb, attach_dmabuf, q->alloc_ctx[plane], + mem_priv = call_ptr_memop(vb, attach_dmabuf, q->alloc_ctx[plane], dbuf, planes[plane].length, write); if (IS_ERR(mem_priv)) { dprintk(1, "qbuf: failed to attach dmabuf\n"); - fail_memop(vb, attach_dmabuf); ret = PTR_ERR(mem_priv); dma_buf_put(dbuf); goto err; @@ -1424,7 +1480,6 @@ static int __qbuf_dmabuf(struct vb2_buffer *vb, const struct v4l2_buffer *b) if (ret) { dprintk(1, "qbuf: failed to map dmabuf for plane %d\n", plane); - fail_memop(vb, map_dmabuf); goto err; } vb->planes[plane].dbuf_mapped = 1; @@ -1445,7 +1500,6 @@ static int __qbuf_dmabuf(struct vb2_buffer *vb, const struct v4l2_buffer *b) ret = call_vb_qop(vb, buf_init, vb); if (ret) { dprintk(1, "qbuf: buffer initialization failed\n"); - fail_vb_qop(vb, buf_init); goto err; } } @@ -1453,8 +1507,7 @@ static int __qbuf_dmabuf(struct vb2_buffer *vb, const struct v4l2_buffer *b) ret = call_vb_qop(vb, buf_prepare, vb); if (ret) { dprintk(1, "qbuf: buffer preparation failed\n"); - fail_vb_qop(vb, buf_prepare); - call_vb_qop(vb, buf_cleanup, vb); + call_void_vb_qop(vb, buf_cleanup, vb); goto err; } @@ -1479,9 +1532,9 @@ static void __enqueue_in_driver(struct vb2_buffer *vb) /* sync buffers */ for (plane = 0; plane < vb->num_planes; ++plane) - call_memop(vb, prepare, vb->planes[plane].mem_priv); + call_void_memop(vb, prepare, vb->planes[plane].mem_priv); - call_vb_qop(vb, buf_queue, vb); + call_void_vb_qop(vb, buf_queue, vb); } static int __buf_prepare(struct vb2_buffer *vb, const struct v4l2_buffer *b) @@ -1520,9 +1573,9 @@ static int __buf_prepare(struct vb2_buffer *vb, const struct v4l2_buffer *b) * mmap_sem and then takes the driver's lock again. */ mmap_sem = ¤t->mm->mmap_sem; - call_qop(q, wait_prepare, q); + call_void_qop(q, wait_prepare, q); down_read(mmap_sem); - call_qop(q, wait_finish, q); + call_void_qop(q, wait_finish, q); ret = __qbuf_userptr(vb, b); @@ -1647,7 +1700,6 @@ static int vb2_start_streaming(struct vb2_queue *q) if (!ret) return 0; - fail_qop(q, start_streaming); dprintk(1, "qbuf: driver refused to start streaming\n"); if (WARN_ON(atomic_read(&q->owned_by_drv_count))) { unsigned i; @@ -1812,7 +1864,7 @@ static int __vb2_wait_for_done_vb(struct vb2_queue *q, int nonblocking) * become ready or for streamoff. Driver's lock is released to * allow streamoff or qbuf to be called while waiting. */ - call_qop(q, wait_prepare, q); + call_void_qop(q, wait_prepare, q); /* * All locks have been released, it is safe to sleep now. @@ -1825,7 +1877,7 @@ static int __vb2_wait_for_done_vb(struct vb2_queue *q, int nonblocking) * We need to reevaluate both conditions again after reacquiring * the locks or return an error if one occurred. */ - call_qop(q, wait_finish, q); + call_void_qop(q, wait_finish, q); if (ret) { dprintk(1, "Sleep was interrupted\n"); return ret; @@ -1911,7 +1963,7 @@ static void __vb2_dqbuf(struct vb2_buffer *vb) for (i = 0; i < vb->num_planes; ++i) { if (!vb->planes[i].dbuf_mapped) continue; - call_memop(vb, unmap_dmabuf, vb->planes[i].mem_priv); + call_void_memop(vb, unmap_dmabuf, vb->planes[i].mem_priv); vb->planes[i].dbuf_mapped = 0; } } @@ -1941,7 +1993,7 @@ static int vb2_internal_dqbuf(struct vb2_queue *q, struct v4l2_buffer *b, bool n return -EINVAL; } - call_vb_qop(vb, buf_finish, vb); + call_void_vb_qop(vb, buf_finish, vb); /* Fill buffer information for the userspace */ __fill_v4l2_buffer(vb, b); @@ -2042,7 +2094,7 @@ static void __vb2_queue_cancel(struct vb2_queue *q) if (vb->state != VB2_BUF_STATE_DEQUEUED) { vb->state = VB2_BUF_STATE_PREPARED; - call_vb_qop(vb, buf_finish, vb); + call_void_vb_qop(vb, buf_finish, vb); } __vb2_dqbuf(vb); } @@ -2244,11 +2296,10 @@ int vb2_expbuf(struct vb2_queue *q, struct v4l2_exportbuffer *eb) vb_plane = &vb->planes[eb->plane]; - dbuf = call_memop(vb, get_dmabuf, vb_plane->mem_priv, eb->flags & O_ACCMODE); + dbuf = call_ptr_memop(vb, get_dmabuf, vb_plane->mem_priv, eb->flags & O_ACCMODE); if (IS_ERR_OR_NULL(dbuf)) { dprintk(1, "Failed to export buffer %d, plane %d\n", eb->index, eb->plane); - fail_memop(vb, get_dmabuf); return -EINVAL; } @@ -2341,10 +2392,8 @@ int vb2_mmap(struct vb2_queue *q, struct vm_area_struct *vma) } ret = call_memop(vb, mmap, vb->planes[plane].mem_priv, vma); - if (ret) { - fail_memop(vb, mmap); + if (ret) return ret; - } dprintk(3, "Buffer %d, plane %d successfully mapped\n", buffer, plane); return 0; -- cgit v1.2.3 From 2dd477dbeb53937213d741db53110ac39ca245d1 Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Mon, 17 Mar 2014 09:54:22 -0300 Subject: [media] v4l2-common.h: remove __user annotation in struct v4l2_edid The edid array is copied to kernelspace by the v4l2 core, so drivers shouldn't see the __user annotation. This conforms to other structs like v4l2_ext_controls where the data pointed to is copied to from user to kernelspace. Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- include/uapi/linux/v4l2-common.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/uapi/linux/v4l2-common.h b/include/uapi/linux/v4l2-common.h index 9bf508ad0957..2f6f8cafe773 100644 --- a/include/uapi/linux/v4l2-common.h +++ b/include/uapi/linux/v4l2-common.h @@ -75,7 +75,7 @@ struct v4l2_edid { __u32 start_block; __u32 blocks; __u32 reserved[5]; - __u8 __user *edid; + __u8 *edid; }; #endif /* __V4L2_COMMON__ */ -- cgit v1.2.3 From ba2d35c14b6fc554547cf647bedb71cd9ead3cab Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Mon, 17 Mar 2014 09:54:23 -0300 Subject: [media] v4l2-ioctl.c: fix sparse __user-related warnings Fix the use of __user in the check_array_args() prototype: instead of using 'void * __user *' you should use 'void __user **' for sparse to understand this correctly. This also required the use of __force in the '*kernel_ptr = user_ptr' assignment. Also replace a wrong cast (void *) with the correct one (void **) in check_array_args(). This fixes these sparse warnings: drivers/media/v4l2-core/v4l2-ioctl.c:2284:35: warning: incorrect type in assignment (different address spaces) drivers/media/v4l2-core/v4l2-ioctl.c:2301:35: warning: incorrect type in assignment (different address spaces) drivers/media/v4l2-core/v4l2-ioctl.c:2319:35: warning: incorrect type in assignment (different address spaces) drivers/media/v4l2-core/v4l2-ioctl.c:2386:57: warning: incorrect type in argument 4 (different address spaces) drivers/media/v4l2-core/v4l2-ioctl.c:2420:29: warning: incorrect type in assignment (different address spaces) Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/v4l2-core/v4l2-ioctl.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c index d9113cc71c77..f729bd26f6fc 100644 --- a/drivers/media/v4l2-core/v4l2-ioctl.c +++ b/drivers/media/v4l2-core/v4l2-ioctl.c @@ -2260,7 +2260,7 @@ done: } static int check_array_args(unsigned int cmd, void *parg, size_t *array_size, - void * __user *user_ptr, void ***kernel_ptr) + void __user **user_ptr, void ***kernel_ptr) { int ret = 0; @@ -2277,7 +2277,7 @@ static int check_array_args(unsigned int cmd, void *parg, size_t *array_size, break; } *user_ptr = (void __user *)buf->m.planes; - *kernel_ptr = (void *)&buf->m.planes; + *kernel_ptr = (void **)&buf->m.planes; *array_size = sizeof(struct v4l2_plane) * buf->length; ret = 1; } @@ -2294,7 +2294,7 @@ static int check_array_args(unsigned int cmd, void *parg, size_t *array_size, break; } *user_ptr = (void __user *)edid->edid; - *kernel_ptr = (void *)&edid->edid; + *kernel_ptr = (void **)&edid->edid; *array_size = edid->blocks * 128; ret = 1; } @@ -2312,7 +2312,7 @@ static int check_array_args(unsigned int cmd, void *parg, size_t *array_size, break; } *user_ptr = (void __user *)ctrls->controls; - *kernel_ptr = (void *)&ctrls->controls; + *kernel_ptr = (void **)&ctrls->controls; *array_size = sizeof(struct v4l2_ext_control) * ctrls->count; ret = 1; @@ -2412,7 +2412,7 @@ video_usercopy(struct file *file, unsigned int cmd, unsigned long arg, } if (has_array_args) { - *kernel_ptr = user_ptr; + *kernel_ptr = (void __force *)user_ptr; if (copy_to_user(user_ptr, mbuf, array_size)) err = -EFAULT; goto out_array_args; -- cgit v1.2.3 From 576f7d34871f64ac3064f5fc3892c67a90cd1677 Mon Sep 17 00:00:00 2001 From: "ileana@telecom-paristech.fr" Date: Tue, 18 Mar 2014 10:31:03 -0300 Subject: [media] staging: omap24xx: fix coding style Fix missing parentheses in macros Errors found by checkpatch.pl Signed-off-by: Ioana Ileana Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/staging/media/omap24xx/tcm825x.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/media/omap24xx/tcm825x.h b/drivers/staging/media/omap24xx/tcm825x.h index 9970fb1c596a..8a29636d1ad4 100644 --- a/drivers/staging/media/omap24xx/tcm825x.h +++ b/drivers/staging/media/omap24xx/tcm825x.h @@ -21,8 +21,8 @@ #define TCM825X_NAME "tcm825x" -#define TCM825X_MASK(x) x & 0x00ff -#define TCM825X_ADDR(x) (x & 0xff00) >> 8 +#define TCM825X_MASK(x) (x & 0x00ff) +#define TCM825X_ADDR(x) ((x & 0xff00) >> 8) /* The TCM825X I2C sensor chip has a fixed slave address of 0x3d. */ #define TCM825X_I2C_ADDR 0x3d -- cgit v1.2.3 From 5046f26b7b542ca7b70222acffeb7f1e6730eb02 Mon Sep 17 00:00:00 2001 From: Martin Bugge Date: Wed, 19 Mar 2014 06:43:43 -0300 Subject: [media] adv7842: update RGB quantization range on HDMI/DVI-D mode irq This was the reason for enabling the HDMI/DVI-D mode irq in the first place. Signed-off-by: Martin Bugge Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/i2c/adv7842.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/media/i2c/adv7842.c b/drivers/media/i2c/adv7842.c index 636ac08925f6..5d79c57f65d4 100644 --- a/drivers/media/i2c/adv7842.c +++ b/drivers/media/i2c/adv7842.c @@ -2000,6 +2000,7 @@ static int adv7842_isr(struct v4l2_subdev *sd, u32 status, bool *handled) if (irq_status[5] & 0x08) { v4l2_dbg(1, debug, sd, "%s: irq %s mode\n", __func__, (io_read(sd, 0x65) & 0x08) ? "HDMI" : "DVI"); + set_rgb_quantization_range(sd); if (handled) *handled = true; } -- cgit v1.2.3 From 2ff0f16ded0843e32acdbc683f9a04f07765987c Mon Sep 17 00:00:00 2001 From: Martin Bugge Date: Wed, 19 Mar 2014 06:43:45 -0300 Subject: [media] adv7842: Disable access to EDID DDC lines before chip power up In core_init make sure access to EDID DDC lines are disabled before chip is powered up. Also DISABLE_AUTO_EDID before power up. The correct setting is applied later when setting the EDID. Some sources (MAC) kept on reading EDID even when Hotplug was low and in the short period in core_init before the DDC lines was enabled read a corrupt EDID. Signed-off-by: Martin Bugge Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/i2c/adv7842.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/media/i2c/adv7842.c b/drivers/media/i2c/adv7842.c index 5d79c57f65d4..06c25c3fa3a9 100644 --- a/drivers/media/i2c/adv7842.c +++ b/drivers/media/i2c/adv7842.c @@ -2611,6 +2611,12 @@ static int adv7842_core_init(struct v4l2_subdev *sd) disable_input(sd); + /* + * Disable I2C access to internal EDID ram from HDMI DDC ports + * Disable auto edid enable when leaving powerdown mode + */ + rep_write_and_or(sd, 0x77, 0xd3, 0x20); + /* power */ io_write(sd, 0x0c, 0x42); /* Power up part and power down VDP */ io_write(sd, 0x15, 0x80); /* Power up pads */ @@ -2691,9 +2697,6 @@ static int adv7842_core_init(struct v4l2_subdev *sd) enable_input(sd); - /* disable I2C access to internal EDID ram from HDMI DDC ports */ - rep_write_and_or(sd, 0x77, 0xf3, 0x00); - if (pdata->hpa_auto) { /* HPA auto, HPA 0.5s after Edid set and Cable detect */ hdmi_write(sd, 0x69, 0x5c); -- cgit v1.2.3 From c8204930b21ea4d0a5504b40a73479ae318958dd Mon Sep 17 00:00:00 2001 From: Daniel Glöckner Date: Wed, 19 Mar 2014 06:50:41 -0300 Subject: [media] bttv: Add support for PCI-8604PW MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This patch adds support for the PCI-8604PW card equipped with four 878A. It is unknown who the manufacturer of this card is and no drivers were available during development of the patch. According to images found online, the card is originally sold with Linux DVR software. A CPLD on the card prevents the 878A from requesting access to the bus until an initialization sequence has been issued via GPIOs. The implemented sequence uses the minimum number of GPIOs needed to successfully unlock bus access. As there are many more GPIOs connected to the CPLD, it is very likely that some of the others have an influence on the bus arbitration scheduling. This should be investigated further in case of performance issues. The tested card contains an EEPROM on one of the 878A, but it is completely empty (i.e. contains only 0xff), so it is not possible to detect the card. Signed-off-by: Daniel Glöckner Tested-by: Robert Longbottom Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/pci/bt8xx/bttv-cards.c | 110 +++++++++++++++++++++++++++++++++++ drivers/media/pci/bt8xx/bttv.h | 1 + 2 files changed, 111 insertions(+) diff --git a/drivers/media/pci/bt8xx/bttv-cards.c b/drivers/media/pci/bt8xx/bttv-cards.c index d06963b3dcf3..d8ec583c154c 100644 --- a/drivers/media/pci/bt8xx/bttv-cards.c +++ b/drivers/media/pci/bt8xx/bttv-cards.c @@ -52,6 +52,7 @@ static void osprey_eeprom(struct bttv *btv, const u8 ee[256]); static void modtec_eeprom(struct bttv *btv); static void init_PXC200(struct bttv *btv); static void init_RTV24(struct bttv *btv); +static void init_PCI8604PW(struct bttv *btv); static void rv605_muxsel(struct bttv *btv, unsigned int input); static void eagle_muxsel(struct bttv *btv, unsigned int input); @@ -2871,6 +2872,22 @@ struct tvcard bttv_tvcards[] = { .has_remote = 1, .has_radio = 1, }, + /* ---- card 0xa6---------------------------------- */ + [BTTV_BOARD_PCI_8604PW] = { + /* PCI-8604PW with special unlock sequence */ + .name = "PCI-8604PW", + .video_inputs = 2, + /* .audio_inputs= 0, */ + .svhs = NO_SVHS, + /* The second input is available on CN4, if populated. + * The other 5x2 header (CN2?) connects to the same inputs + * as the on-board BNCs */ + .muxsel = MUXSEL(2, 3), + .tuner_type = TUNER_ABSENT, + .no_msp34xx = 1, + .no_tda7432 = 1, + .pll = PLL_35, + }, }; static const unsigned int bttv_num_tvcards = ARRAY_SIZE(bttv_tvcards); @@ -3305,6 +3322,9 @@ void bttv_init_card1(struct bttv *btv) case BTTV_BOARD_ADLINK_RTV24: init_RTV24( btv ); break; + case BTTV_BOARD_PCI_8604PW: + init_PCI8604PW(btv); + break; } if (!bttv_tvcards[btv->c.type].has_dvb) @@ -4184,6 +4204,96 @@ init_RTV24 (struct bttv *btv) +/* ----------------------------------------------------------------------- */ +/* + * The PCI-8604PW contains a CPLD, probably an ispMACH 4A, that filters + * the PCI REQ signals comming from the four BT878 chips. After power + * up, the CPLD does not forward requests to the bus, which prevents + * the BT878 from fetching RISC instructions from memory. While the + * CPLD is connected to most of the GPIOs of PCI device 0xD, only + * five appear to play a role in unlocking the REQ signal. The following + * sequence has been determined by trial and error without access to the + * original driver. + * + * Eight GPIOs of device 0xC are provided on connector CN4 (4 in, 4 out). + * Devices 0xE and 0xF do not appear to have anything connected to their + * GPIOs. + * + * The correct GPIO_OUT_EN value might have some more bits set. It should + * be possible to derive it from a boundary scan of the CPLD. Its JTAG + * pins are routed to test points. + * + */ +/* ----------------------------------------------------------------------- */ +static void +init_PCI8604PW(struct bttv *btv) +{ + int state; + + if ((PCI_SLOT(btv->c.pci->devfn) & ~3) != 0xC) { + pr_warn("This is not a PCI-8604PW\n"); + return; + } + + if (PCI_SLOT(btv->c.pci->devfn) != 0xD) + return; + + btwrite(0x080002, BT848_GPIO_OUT_EN); + + state = (btread(BT848_GPIO_DATA) >> 21) & 7; + + for (;;) { + switch (state) { + case 1: + case 5: + case 6: + case 4: + pr_debug("PCI-8604PW in state %i, toggling pin\n", + state); + btwrite(0x080000, BT848_GPIO_DATA); + msleep(1); + btwrite(0x000000, BT848_GPIO_DATA); + msleep(1); + break; + case 7: + pr_info("PCI-8604PW unlocked\n"); + return; + case 0: + /* FIXME: If we are in state 7 and toggle GPIO[19] one + more time, the CPLD goes into state 0, where PCI bus + mastering is inhibited again. We have not managed to + get out of that state. */ + + pr_err("PCI-8604PW locked until reset\n"); + return; + default: + pr_err("PCI-8604PW in unknown state %i\n", state); + return; + } + + state = (state << 4) | ((btread(BT848_GPIO_DATA) >> 21) & 7); + + switch (state) { + case 0x15: + case 0x56: + case 0x64: + case 0x47: + /* The transition from state 7 to state 0 is, as explained + above, valid but undesired and with this code impossible + as we exit as soon as we are in state 7. + case 0x70: */ + break; + default: + pr_err("PCI-8604PW invalid transition %i -> %i\n", + state >> 4, state & 7); + return; + } + state &= 7; + } +} + + + /* ----------------------------------------------------------------------- */ /* Miro Pro radio stuff -- the tea5757 is connected to some GPIO ports */ /* diff --git a/drivers/media/pci/bt8xx/bttv.h b/drivers/media/pci/bt8xx/bttv.h index bb5da349a46e..f08126244662 100644 --- a/drivers/media/pci/bt8xx/bttv.h +++ b/drivers/media/pci/bt8xx/bttv.h @@ -189,6 +189,7 @@ #define BTTV_BOARD_BT848_CAP_14 0xa3 #define BTTV_BOARD_CYBERVISION_CV06 0xa4 #define BTTV_BOARD_KWORLD_VSTREAM_XPERT 0xa5 +#define BTTV_BOARD_PCI_8604PW 0xa6 /* more card-specific defines */ #define PT2254_L_CHANNEL 0x10 -- cgit v1.2.3 From 3d7543b9196cb0de8e65750f1da9ad155c22e12f Mon Sep 17 00:00:00 2001 From: "Lad, Prabhakar" Date: Sat, 22 Mar 2014 07:57:59 -0300 Subject: [media] media: davinci: vpbe: use v4l2_fh for priority handling This patch migrates the vpbe driver to use v4l2_fh for priority handling. This also fixes v4l2-compliance test. Signed-off-by: Lad, Prabhakar Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/davinci/vpbe_display.c | 39 +++++---------------------- include/media/davinci/vpbe_display.h | 6 ++--- 2 files changed, 9 insertions(+), 36 deletions(-) diff --git a/drivers/media/platform/davinci/vpbe_display.c b/drivers/media/platform/davinci/vpbe_display.c index 656708252962..a9ad949d0c19 100644 --- a/drivers/media/platform/davinci/vpbe_display.c +++ b/drivers/media/platform/davinci/vpbe_display.c @@ -680,29 +680,6 @@ static int vpbe_try_format(struct vpbe_display *disp_dev, return 0; } -static int vpbe_display_g_priority(struct file *file, void *priv, - enum v4l2_priority *p) -{ - struct vpbe_fh *fh = file->private_data; - struct vpbe_layer *layer = fh->layer; - - *p = v4l2_prio_max(&layer->prio); - - return 0; -} - -static int vpbe_display_s_priority(struct file *file, void *priv, - enum v4l2_priority p) -{ - struct vpbe_fh *fh = file->private_data; - struct vpbe_layer *layer = fh->layer; - int ret; - - ret = v4l2_prio_change(&layer->prio, &fh->prio, p); - - return ret; -} - static int vpbe_display_querycap(struct file *file, void *priv, struct v4l2_capability *cap) { @@ -1492,6 +1469,7 @@ static int vpbe_display_open(struct file *file) { struct vpbe_fh *fh = NULL; struct vpbe_layer *layer = video_drvdata(file); + struct video_device *vdev = video_devdata(file); struct vpbe_display *disp_dev = layer->disp_dev; struct vpbe_device *vpbe_dev = disp_dev->vpbe_dev; struct osd_state *osd_device = disp_dev->osd_device; @@ -1504,6 +1482,7 @@ static int vpbe_display_open(struct file *file) "unable to allocate memory for file handle object\n"); return -ENOMEM; } + v4l2_fh_init(&fh->fh, vdev); v4l2_dbg(1, debug, &vpbe_dev->v4l2_dev, "vpbe display open plane = %d\n", layer->device_id); @@ -1532,9 +1511,7 @@ static int vpbe_display_open(struct file *file) layer->usrs++; /* Set io_allowed member to false */ fh->io_allowed = 0; - /* Initialize priority of this instance to default priority */ - fh->prio = V4L2_PRIORITY_UNSET; - v4l2_prio_open(&layer->prio, &fh->prio); + v4l2_fh_add(&fh->fh); v4l2_dbg(1, debug, &vpbe_dev->v4l2_dev, "vpbe display device opened successfully\n"); return 0; @@ -1589,8 +1566,9 @@ static int vpbe_display_release(struct file *file) osd_device->ops.release_layer(osd_device, layer->layer_info.id); } - /* Close the priority */ - v4l2_prio_close(&layer->prio, fh->prio); + + v4l2_fh_del(&fh->fh); + v4l2_fh_exit(&fh->fh); file->private_data = NULL; mutex_unlock(&layer->opslock); @@ -1618,8 +1596,6 @@ static const struct v4l2_ioctl_ops vpbe_ioctl_ops = { .vidioc_cropcap = vpbe_display_cropcap, .vidioc_g_crop = vpbe_display_g_crop, .vidioc_s_crop = vpbe_display_s_crop, - .vidioc_g_priority = vpbe_display_g_priority, - .vidioc_s_priority = vpbe_display_s_priority, .vidioc_s_std = vpbe_display_s_std, .vidioc_g_std = vpbe_display_g_std, .vidioc_enum_output = vpbe_display_enum_output, @@ -1699,8 +1675,6 @@ static int init_vpbe_layer(int i, struct vpbe_display *disp_dev, vpbe_display_layer->layer_info.id = ((i == VPBE_DISPLAY_DEVICE_0) ? WIN_VID0 : WIN_VID1); - /* Initialize prio member of layer object */ - v4l2_prio_init(&vpbe_display_layer->prio); return 0; } @@ -1727,6 +1701,7 @@ static int register_device(struct vpbe_layer *vpbe_display_layer, vpbe_display_layer->disp_dev = disp_dev; /* set the driver data in platform device */ platform_set_drvdata(pdev, disp_dev); + set_bit(V4L2_FL_USE_FH_PRIO, &vpbe_display_layer->video_dev.flags); video_set_drvdata(&vpbe_display_layer->video_dev, vpbe_display_layer); diff --git a/include/media/davinci/vpbe_display.h b/include/media/davinci/vpbe_display.h index 8dffffedbb59..637749a91432 100644 --- a/include/media/davinci/vpbe_display.h +++ b/include/media/davinci/vpbe_display.h @@ -16,6 +16,7 @@ /* Header files */ #include #include +#include #include #include #include @@ -94,8 +95,6 @@ struct vpbe_layer { * has selected */ enum v4l2_memory memory; - /* Used to keep track of state of the priority */ - struct v4l2_prio_state prio; /* Used to store pixel format */ struct v4l2_pix_format pix_fmt; enum v4l2_field buf_field; @@ -134,14 +133,13 @@ struct vpbe_display { /* File handle structure */ struct vpbe_fh { + struct v4l2_fh fh; /* vpbe device structure */ struct vpbe_display *disp_dev; /* pointer to layer object for opened device */ struct vpbe_layer *layer; /* Indicates whether this file handle is doing IO */ unsigned char io_allowed; - /* Used to keep track priority of this instance */ - enum v4l2_priority prio; }; struct buf_config_params { -- cgit v1.2.3 From 3bdaa382b294946a6b8661c3eb77e595940c8a61 Mon Sep 17 00:00:00 2001 From: "Lad, Prabhakar" Date: Sat, 22 Mar 2014 08:39:24 -0300 Subject: [media] media: davinci: vpfe: use v4l2_fh for priority handling This patch migrates the vpfe driver to use v4l2_fh for priority handling. Signed-off-by: Lad, Prabhakar Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/davinci/vpfe_capture.c | 13 ++++++------- include/media/davinci/vpfe_capture.h | 6 ++---- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/drivers/media/platform/davinci/vpfe_capture.c b/drivers/media/platform/davinci/vpfe_capture.c index 0379cb9f9a9c..ac6c8c6ac7d0 100644 --- a/drivers/media/platform/davinci/vpfe_capture.c +++ b/drivers/media/platform/davinci/vpfe_capture.c @@ -498,6 +498,7 @@ unlock: static int vpfe_open(struct file *file) { struct vpfe_device *vpfe_dev = video_drvdata(file); + struct video_device *vdev = video_devdata(file); struct vpfe_fh *fh; v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "vpfe_open\n"); @@ -517,6 +518,7 @@ static int vpfe_open(struct file *file) /* store pointer to fh in private_data member of file */ file->private_data = fh; fh->vpfe_dev = vpfe_dev; + v4l2_fh_init(&fh->fh, vdev); mutex_lock(&vpfe_dev->lock); /* If decoder is not initialized. initialize it */ if (!vpfe_dev->initialized) { @@ -529,9 +531,7 @@ static int vpfe_open(struct file *file) vpfe_dev->usrs++; /* Set io_allowed member to false */ fh->io_allowed = 0; - /* Initialize priority of this instance to default priority */ - fh->prio = V4L2_PRIORITY_UNSET; - v4l2_prio_open(&vpfe_dev->prio, &fh->prio); + v4l2_fh_add(&fh->fh); mutex_unlock(&vpfe_dev->lock); return 0; } @@ -740,8 +740,8 @@ static int vpfe_release(struct file *file) /* Decrement device usrs counter */ vpfe_dev->usrs--; - /* Close the priority */ - v4l2_prio_close(&vpfe_dev->prio, fh->prio); + v4l2_fh_del(&fh->fh); + v4l2_fh_exit(&fh->fh); /* If this is the last file handle */ if (!vpfe_dev->usrs) { vpfe_dev->initialized = 0; @@ -1910,14 +1910,13 @@ static int vpfe_probe(struct platform_device *pdev) /* Initialize field of the device objects */ vpfe_dev->numbuffers = config_params.numbuffers; - /* Initialize prio member of device object */ - v4l2_prio_init(&vpfe_dev->prio); /* register video device */ v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "trying to register vpfe device.\n"); v4l2_dbg(1, debug, &vpfe_dev->v4l2_dev, "video_dev=%x\n", (int)&vpfe_dev->video_dev); vpfe_dev->fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; + set_bit(V4L2_FL_USE_FH_PRIO, &vpfe_dev->video_dev->flags); ret = video_register_device(vpfe_dev->video_dev, VFL_TYPE_GRABBER, -1); diff --git a/include/media/davinci/vpfe_capture.h b/include/media/davinci/vpfe_capture.h index cc973ed845a7..288772e6900a 100644 --- a/include/media/davinci/vpfe_capture.h +++ b/include/media/davinci/vpfe_capture.h @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -110,8 +111,6 @@ struct vpfe_device { struct v4l2_device v4l2_dev; /* parent device */ struct device *pdev; - /* Used to keep track of state of the priority */ - struct v4l2_prio_state prio; /* number of open instances of the channel */ u32 usrs; /* Indicates id of the field which is being displayed */ @@ -174,11 +173,10 @@ struct vpfe_device { /* File handle structure */ struct vpfe_fh { + struct v4l2_fh fh; struct vpfe_device *vpfe_dev; /* Indicates whether this file handle is doing IO */ u8 io_allowed; - /* Used to keep track priority of this instance */ - enum v4l2_priority prio; }; struct vpfe_config_params { -- cgit v1.2.3 From 07002c05c31e5aee7d2a2e2af73b414c75f302c2 Mon Sep 17 00:00:00 2001 From: Mike Sampson Date: Mon, 24 Mar 2014 06:04:49 -0300 Subject: [media] sn9c102_hv7131r: fix style warnings flagged by checkpatch.pl Signed-off-by: Mike Sampson Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/staging/media/sn9c102/sn9c102_hv7131r.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/drivers/staging/media/sn9c102/sn9c102_hv7131r.c b/drivers/staging/media/sn9c102/sn9c102_hv7131r.c index 26a91115b831..51b24e000e88 100644 --- a/drivers/staging/media/sn9c102/sn9c102_hv7131r.c +++ b/drivers/staging/media/sn9c102/sn9c102_hv7131r.c @@ -23,7 +23,7 @@ #include "sn9c102_devtable.h" -static int hv7131r_init(struct sn9c102_device* cam) +static int hv7131r_init(struct sn9c102_device *cam) { int err = 0; @@ -137,8 +137,8 @@ static int hv7131r_init(struct sn9c102_device* cam) } -static int hv7131r_get_ctrl(struct sn9c102_device* cam, - struct v4l2_control* ctrl) +static int hv7131r_get_ctrl(struct sn9c102_device *cam, + struct v4l2_control *ctrl) { switch (ctrl->id) { case V4L2_CID_GAIN: @@ -176,8 +176,8 @@ static int hv7131r_get_ctrl(struct sn9c102_device* cam, } -static int hv7131r_set_ctrl(struct sn9c102_device* cam, - const struct v4l2_control* ctrl) +static int hv7131r_set_ctrl(struct sn9c102_device *cam, + const struct v4l2_control *ctrl) { int err = 0; @@ -197,6 +197,7 @@ static int hv7131r_set_ctrl(struct sn9c102_device* cam, case V4L2_CID_BLACK_LEVEL: { int r = sn9c102_i2c_read(cam, 0x01); + if (r < 0) return -EIO; err += sn9c102_i2c_write(cam, 0x01, @@ -211,10 +212,10 @@ static int hv7131r_set_ctrl(struct sn9c102_device* cam, } -static int hv7131r_set_crop(struct sn9c102_device* cam, - const struct v4l2_rect* rect) +static int hv7131r_set_crop(struct sn9c102_device *cam, + const struct v4l2_rect *rect) { - struct sn9c102_sensor* s = sn9c102_get_sensor(cam); + struct sn9c102_sensor *s = sn9c102_get_sensor(cam); int err = 0; u8 h_start = (u8)(rect->left - s->cropcap.bounds.left) + 1, v_start = (u8)(rect->top - s->cropcap.bounds.top) + 1; @@ -226,8 +227,8 @@ static int hv7131r_set_crop(struct sn9c102_device* cam, } -static int hv7131r_set_pix_format(struct sn9c102_device* cam, - const struct v4l2_pix_format* pix) +static int hv7131r_set_pix_format(struct sn9c102_device *cam, + const struct v4l2_pix_format *pix) { int err = 0; @@ -347,7 +348,7 @@ static const struct sn9c102_sensor hv7131r = { }; -int sn9c102_probe_hv7131r(struct sn9c102_device* cam) +int sn9c102_probe_hv7131r(struct sn9c102_device *cam) { int devid, err; -- cgit v1.2.3 From 933fd6e57d594ca9ae06894bb91d3fe067397dfa Mon Sep 17 00:00:00 2001 From: "Lad, Prabhakar" Date: Sun, 23 Mar 2014 03:37:24 -0300 Subject: [media] staging: media: davinci: vpfe: use v4l2_fh for priority handling Signed-off-by: Lad, Prabhakar Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/staging/media/davinci_vpfe/vpfe_mc_capture.h | 2 -- drivers/staging/media/davinci_vpfe/vpfe_video.c | 8 +++----- drivers/staging/media/davinci_vpfe/vpfe_video.h | 2 -- 3 files changed, 3 insertions(+), 9 deletions(-) diff --git a/drivers/staging/media/davinci_vpfe/vpfe_mc_capture.h b/drivers/staging/media/davinci_vpfe/vpfe_mc_capture.h index 68f6fe43a5b5..2632a806c4a8 100644 --- a/drivers/staging/media/davinci_vpfe/vpfe_mc_capture.h +++ b/drivers/staging/media/davinci_vpfe/vpfe_mc_capture.h @@ -87,8 +87,6 @@ struct vpfe_fh { struct vpfe_video_device *video; /* Indicates whether this file handle is doing IO */ u8 io_allowed; - /* Used to keep track priority of this instance */ - enum v4l2_priority prio; }; void mbus_to_pix(const struct v4l2_mbus_framefmt *mbus, diff --git a/drivers/staging/media/davinci_vpfe/vpfe_video.c b/drivers/staging/media/davinci_vpfe/vpfe_video.c index acc8184c46cd..c86ab8436c99 100644 --- a/drivers/staging/media/davinci_vpfe/vpfe_video.c +++ b/drivers/staging/media/davinci_vpfe/vpfe_video.c @@ -415,7 +415,6 @@ static int vpfe_open(struct file *file) video->usrs++; /* Set io_allowed member to false */ handle->io_allowed = 0; - v4l2_prio_open(&video->prio, &handle->prio); handle->video = video; file->private_data = &handle->vfh; mutex_unlock(&video->lock); @@ -532,8 +531,8 @@ static int vpfe_release(struct file *file) } /* Decrement device users counter */ video->usrs--; - /* Close the priority */ - v4l2_prio_close(&video->prio, fh->prio); + v4l2_fh_del(&fh->vfh); + v4l2_fh_exit(&fh->vfh); /* If this is the last file handle */ if (!video->usrs) video->initialized = 0; @@ -1590,8 +1589,6 @@ int vpfe_video_init(struct vpfe_video_device *video, const char *name) snprintf(video->video_dev.name, sizeof(video->video_dev.name), "DAVINCI VIDEO %s %s", name, direction); - /* Initialize prio member of device object */ - v4l2_prio_init(&video->prio); spin_lock_init(&video->irqlock); spin_lock_init(&video->dma_queue_lock); mutex_init(&video->lock); @@ -1600,6 +1597,7 @@ int vpfe_video_init(struct vpfe_video_device *video, const char *name) if (ret < 0) return ret; + set_bit(V4L2_FL_USE_FH_PRIO, &video->video_dev.flags); video_set_drvdata(&video->video_dev, video); return 0; diff --git a/drivers/staging/media/davinci_vpfe/vpfe_video.h b/drivers/staging/media/davinci_vpfe/vpfe_video.h index ca9a70245233..1b1b6c4a56b7 100644 --- a/drivers/staging/media/davinci_vpfe/vpfe_video.h +++ b/drivers/staging/media/davinci_vpfe/vpfe_video.h @@ -102,8 +102,6 @@ struct vpfe_video_device { * user has selected */ enum v4l2_memory memory; - /* Used to keep track of state of the priority */ - struct v4l2_prio_state prio; /* number of open instances of the channel */ u32 usrs; /* flag to indicate whether decoder is initialized */ -- cgit v1.2.3 From 8f7402a304bb80bcb5812353ef07189a1514554a Mon Sep 17 00:00:00 2001 From: "Lad, Prabhakar" Date: Sun, 23 Mar 2014 03:37:25 -0300 Subject: [media] staging: media: davinci: vpfe: release buffers in case start_streaming call back fails this patch releases the buffer by calling vb2_buffer_done(), with state marked as VB2_BUF_STATE_QUEUED if start_streaming() call back fails. Signed-off-by: Lad, Prabhakar Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/staging/media/davinci_vpfe/vpfe_video.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/staging/media/davinci_vpfe/vpfe_video.c b/drivers/staging/media/davinci_vpfe/vpfe_video.c index c86ab8436c99..9337d92c5939 100644 --- a/drivers/staging/media/davinci_vpfe/vpfe_video.c +++ b/drivers/staging/media/davinci_vpfe/vpfe_video.c @@ -1218,8 +1218,16 @@ static int vpfe_start_streaming(struct vb2_queue *vq, unsigned int count) video->state = VPFE_VIDEO_BUFFER_QUEUED; ret = vpfe_start_capture(video); - if (ret) + if (ret) { + struct vpfe_cap_buffer *buf, *tmp; + + vb2_buffer_done(&video->cur_frm->vb, VB2_BUF_STATE_QUEUED); + list_for_each_entry_safe(buf, tmp, &video->dma_queue, list) { + list_del(&buf->list); + vb2_buffer_done(&buf->vb, VB2_BUF_STATE_QUEUED); + } goto unlock_out; + } mutex_unlock(&video->lock); -- cgit v1.2.3 From ebf9edd39a9fab23758571801063820603a6465c Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Tue, 8 Apr 2014 05:00:39 -0300 Subject: [media] v4l2-dv-timings.h: add CEA-861-F 4K timings Add the CEA-861-F timings for 3840x2160p24/25/30/50/60 and 4096x2160p24/25/30/50/60. Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- include/uapi/linux/v4l2-dv-timings.h | 70 ++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) diff --git a/include/uapi/linux/v4l2-dv-timings.h b/include/uapi/linux/v4l2-dv-timings.h index b6a5fe00a470..6c8f159e416e 100644 --- a/include/uapi/linux/v4l2-dv-timings.h +++ b/include/uapi/linux/v4l2-dv-timings.h @@ -173,6 +173,76 @@ V4L2_DV_FL_CAN_REDUCE_FPS) \ } +#define V4L2_DV_BT_CEA_3840X2160P24 { \ + .type = V4L2_DV_BT_656_1120, \ + V4L2_INIT_BT_TIMINGS(3840, 2160, 0, V4L2_DV_HSYNC_POS_POL, \ + 297000000, 1276, 88, 296, 8, 10, 72, 0, 0, 0, \ + V4L2_DV_BT_STD_CEA861, V4L2_DV_FL_CAN_REDUCE_FPS) \ +} + +#define V4L2_DV_BT_CEA_3840X2160P25 { \ + .type = V4L2_DV_BT_656_1120, \ + V4L2_INIT_BT_TIMINGS(3840, 2160, 0, V4L2_DV_HSYNC_POS_POL, \ + 297000000, 1056, 88, 296, 8, 10, 72, 0, 0, 0, \ + V4L2_DV_BT_STD_CEA861, 0) \ +} + +#define V4L2_DV_BT_CEA_3840X2160P30 { \ + .type = V4L2_DV_BT_656_1120, \ + V4L2_INIT_BT_TIMINGS(3840, 2160, 0, V4L2_DV_HSYNC_POS_POL, \ + 297000000, 176, 88, 296, 8, 10, 72, 0, 0, 0, \ + V4L2_DV_BT_STD_CEA861, V4L2_DV_FL_CAN_REDUCE_FPS) \ +} + +#define V4L2_DV_BT_CEA_3840X2160P50 { \ + .type = V4L2_DV_BT_656_1120, \ + V4L2_INIT_BT_TIMINGS(3840, 2160, 0, V4L2_DV_HSYNC_POS_POL, \ + 594000000, 1056, 88, 296, 8, 10, 72, 0, 0, 0, \ + V4L2_DV_BT_STD_CEA861, 0) \ +} + +#define V4L2_DV_BT_CEA_3840X2160P60 { \ + .type = V4L2_DV_BT_656_1120, \ + V4L2_INIT_BT_TIMINGS(3840, 2160, 0, V4L2_DV_HSYNC_POS_POL, \ + 594000000, 176, 88, 296, 8, 10, 72, 0, 0, 0, \ + V4L2_DV_BT_STD_CEA861, V4L2_DV_FL_CAN_REDUCE_FPS) \ +} + +#define V4L2_DV_BT_CEA_4096X2160P24 { \ + .type = V4L2_DV_BT_656_1120, \ + V4L2_INIT_BT_TIMINGS(4096, 2160, 0, V4L2_DV_HSYNC_POS_POL, \ + 297000000, 1020, 88, 296, 8, 10, 72, 0, 0, 0, \ + V4L2_DV_BT_STD_CEA861, V4L2_DV_FL_CAN_REDUCE_FPS) \ +} + +#define V4L2_DV_BT_CEA_4096X2160P25 { \ + .type = V4L2_DV_BT_656_1120, \ + V4L2_INIT_BT_TIMINGS(4096, 2160, 0, V4L2_DV_HSYNC_POS_POL, \ + 297000000, 968, 88, 128, 8, 10, 72, 0, 0, 0, \ + V4L2_DV_BT_STD_CEA861, 0) \ +} + +#define V4L2_DV_BT_CEA_4096X2160P30 { \ + .type = V4L2_DV_BT_656_1120, \ + V4L2_INIT_BT_TIMINGS(4096, 2160, 0, V4L2_DV_HSYNC_POS_POL, \ + 297000000, 88, 88, 128, 8, 10, 72, 0, 0, 0, \ + V4L2_DV_BT_STD_CEA861, V4L2_DV_FL_CAN_REDUCE_FPS) \ +} + +#define V4L2_DV_BT_CEA_4096X2160P50 { \ + .type = V4L2_DV_BT_656_1120, \ + V4L2_INIT_BT_TIMINGS(4096, 2160, 0, V4L2_DV_HSYNC_POS_POL, \ + 594000000, 968, 88, 128, 8, 10, 72, 0, 0, 0, \ + V4L2_DV_BT_STD_CEA861, 0) \ +} + +#define V4L2_DV_BT_CEA_4096X2160P60 { \ + .type = V4L2_DV_BT_656_1120, \ + V4L2_INIT_BT_TIMINGS(4096, 2160, 0, V4L2_DV_HSYNC_POS_POL, \ + 594000000, 88, 88, 128, 8, 10, 72, 0, 0, 0, \ + V4L2_DV_BT_STD_CEA861, V4L2_DV_FL_CAN_REDUCE_FPS) \ +} + /* VESA Discrete Monitor Timings as per version 1.0, revision 12 */ -- cgit v1.2.3 From bc96f30c3b96ccb0b9bc0f79d1538cba75e501a9 Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Tue, 8 Apr 2014 05:01:52 -0300 Subject: [media] v4l2-dv-timings.c: add the new 4K timings to the list Add the new CEA-861-F and DMT 4K timings to the list of predefined timings. Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/v4l2-core/v4l2-dv-timings.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/media/v4l2-core/v4l2-dv-timings.c b/drivers/media/v4l2-core/v4l2-dv-timings.c index 48b20dfcc4d0..4ae54caadd03 100644 --- a/drivers/media/v4l2-core/v4l2-dv-timings.c +++ b/drivers/media/v4l2-core/v4l2-dv-timings.c @@ -131,6 +131,17 @@ const struct v4l2_dv_timings v4l2_dv_timings_presets[] = { V4L2_DV_BT_DMT_2560X1600P75, V4L2_DV_BT_DMT_2560X1600P85, V4L2_DV_BT_DMT_2560X1600P120_RB, + V4L2_DV_BT_CEA_3840X2160P24, + V4L2_DV_BT_CEA_3840X2160P25, + V4L2_DV_BT_CEA_3840X2160P30, + V4L2_DV_BT_CEA_3840X2160P50, + V4L2_DV_BT_CEA_3840X2160P60, + V4L2_DV_BT_CEA_4096X2160P24, + V4L2_DV_BT_CEA_4096X2160P25, + V4L2_DV_BT_CEA_4096X2160P30, + V4L2_DV_BT_CEA_4096X2160P50, + V4L2_DV_BT_DMT_4096X2160P59_94_RB, + V4L2_DV_BT_CEA_4096X2160P60, { } }; EXPORT_SYMBOL_GPL(v4l2_dv_timings_presets); -- cgit v1.2.3 From 412376a1532a9eb3eb66c9d07175f21cdbebdc09 Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Mon, 7 Apr 2014 08:44:56 -0300 Subject: [media] vb2: fix handling of data_offset and v4l2_plane.reserved[] The videobuf2-core did not zero the 'planes' array in __qbuf_userptr() and __qbuf_dmabuf(). That's now memset to 0. Without this the reserved array in struct v4l2_plane would be non-zero, causing v4l2-compliance errors. More serious is the fact that data_offset was not handled correctly: - for capture devices it was never zeroed, which meant that it was uninitialized. Unless the driver sets it it was a completely random number. With the memset above this is now fixed. - __qbuf_dmabuf had a completely incorrect length check that included data_offset. - in __fill_vb2_buffer in the DMABUF case the data_offset field was unconditionally copied from v4l2_buffer to v4l2_plane when this should only happen in the output case. - in the single-planar case data_offset was never correctly set to 0. The single-planar API doesn't support data_offset, so setting it to 0 is the right thing to do. This too is now solved by the memset. All these issues were found with v4l2-compliance. Signed-off-by: Hans Verkuil Acked-by: Pawel Osciak Acked-by: Sakari Ailus Signed-off-by: Mauro Carvalho Chehab --- drivers/media/v4l2-core/videobuf2-core.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/drivers/media/v4l2-core/videobuf2-core.c b/drivers/media/v4l2-core/videobuf2-core.c index 98ddeb6c05c1..b20e0fbc762a 100644 --- a/drivers/media/v4l2-core/videobuf2-core.c +++ b/drivers/media/v4l2-core/videobuf2-core.c @@ -1234,8 +1234,6 @@ static void __fill_vb2_buffer(struct vb2_buffer *vb, const struct v4l2_buffer *b b->m.planes[plane].m.fd; v4l2_planes[plane].length = b->m.planes[plane].length; - v4l2_planes[plane].data_offset = - b->m.planes[plane].data_offset; } } } else { @@ -1245,10 +1243,8 @@ static void __fill_vb2_buffer(struct vb2_buffer *vb, const struct v4l2_buffer *b * In videobuf we use our internal V4l2_planes struct for * single-planar buffers as well, for simplicity. */ - if (V4L2_TYPE_IS_OUTPUT(b->type)) { + if (V4L2_TYPE_IS_OUTPUT(b->type)) v4l2_planes[0].bytesused = b->bytesused; - v4l2_planes[0].data_offset = 0; - } if (b->memory == V4L2_MEMORY_USERPTR) { v4l2_planes[0].m.userptr = b->m.userptr; @@ -1258,9 +1254,7 @@ static void __fill_vb2_buffer(struct vb2_buffer *vb, const struct v4l2_buffer *b if (b->memory == V4L2_MEMORY_DMABUF) { v4l2_planes[0].m.fd = b->m.fd; v4l2_planes[0].length = b->length; - v4l2_planes[0].data_offset = 0; } - } /* Zero flags that the vb2 core handles */ @@ -1303,6 +1297,7 @@ static int __qbuf_userptr(struct vb2_buffer *vb, const struct v4l2_buffer *b) int write = !V4L2_TYPE_IS_OUTPUT(q->type); bool reacquired = vb->planes[0].mem_priv == NULL; + memset(planes, 0, sizeof(planes[0]) * vb->num_planes); /* Copy relevant information provided by the userspace */ __fill_vb2_buffer(vb, b, planes); @@ -1414,6 +1409,7 @@ static int __qbuf_dmabuf(struct vb2_buffer *vb, const struct v4l2_buffer *b) int write = !V4L2_TYPE_IS_OUTPUT(q->type); bool reacquired = vb->planes[0].mem_priv == NULL; + memset(planes, 0, sizeof(planes[0]) * vb->num_planes); /* Copy relevant information provided by the userspace */ __fill_vb2_buffer(vb, b, planes); @@ -1431,8 +1427,7 @@ static int __qbuf_dmabuf(struct vb2_buffer *vb, const struct v4l2_buffer *b) if (planes[plane].length == 0) planes[plane].length = dbuf->size; - if (planes[plane].length < planes[plane].data_offset + - q->plane_sizes[plane]) { + if (planes[plane].length < q->plane_sizes[plane]) { dprintk(1, "qbuf: invalid dmabuf length for plane %d\n", plane); ret = -EINVAL; -- cgit v1.2.3 From 61bd8fb37db948154ae01c8ed43a86633ae1d2be Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Mon, 7 Apr 2014 08:57:48 -0300 Subject: [media] vb2: if bytesused is 0, then fill with output buffer length The application should really always fill in bytesused for output buffers, unfortunately the vb2 framework never checked for that. So for single planar formats replace a bytesused of 0 by the length of the buffer, and for multiplanar format do the same if bytesused is 0 for ALL planes. This seems to be what the user really intended if v4l2_buffer was just memset to 0. I'm afraid that just checking for this and returning an error would break too many applications. Quite a few drivers never check for bytesused at all and just use the buffer length instead. Signed-off-by: Hans Verkuil Acked-by: Pawel Osciak Acked-by: Sakari Ailus Signed-off-by: Mauro Carvalho Chehab --- drivers/media/v4l2-core/videobuf2-core.c | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/drivers/media/v4l2-core/videobuf2-core.c b/drivers/media/v4l2-core/videobuf2-core.c index b20e0fbc762a..2e96f3535e2c 100644 --- a/drivers/media/v4l2-core/videobuf2-core.c +++ b/drivers/media/v4l2-core/videobuf2-core.c @@ -1208,15 +1208,30 @@ static void __fill_vb2_buffer(struct vb2_buffer *vb, const struct v4l2_buffer *b if (V4L2_TYPE_IS_MULTIPLANAR(b->type)) { /* Fill in driver-provided information for OUTPUT types */ if (V4L2_TYPE_IS_OUTPUT(b->type)) { + bool bytesused_is_used; + + /* Check if bytesused == 0 for all planes */ + for (plane = 0; plane < vb->num_planes; ++plane) + if (b->m.planes[plane].bytesused) + break; + bytesused_is_used = plane < vb->num_planes; + /* * Will have to go up to b->length when API starts * accepting variable number of planes. + * + * If bytesused_is_used is false, then fall back to the + * full buffer size. In that case userspace clearly + * never bothered to set it and it's a safe assumption + * that they really meant to use the full plane sizes. */ for (plane = 0; plane < vb->num_planes; ++plane) { - v4l2_planes[plane].bytesused = - b->m.planes[plane].bytesused; - v4l2_planes[plane].data_offset = - b->m.planes[plane].data_offset; + struct v4l2_plane *pdst = &v4l2_planes[plane]; + struct v4l2_plane *psrc = &b->m.planes[plane]; + + pdst->bytesused = bytesused_is_used ? + psrc->bytesused : psrc->length; + pdst->data_offset = psrc->data_offset; } } @@ -1242,9 +1257,15 @@ static void __fill_vb2_buffer(struct vb2_buffer *vb, const struct v4l2_buffer *b * so fill in relevant v4l2_buffer struct fields instead. * In videobuf we use our internal V4l2_planes struct for * single-planar buffers as well, for simplicity. + * + * If bytesused == 0, then fall back to the full buffer size + * as that's a sensible default. */ if (V4L2_TYPE_IS_OUTPUT(b->type)) - v4l2_planes[0].bytesused = b->bytesused; + v4l2_planes[0].bytesused = + b->bytesused ? b->bytesused : b->length; + else + v4l2_planes[0].bytesused = 0; if (b->memory == V4L2_MEMORY_USERPTR) { v4l2_planes[0].m.userptr = b->m.userptr; -- cgit v1.2.3 From fd4354cf528ab28322374b7fdbcaa2c9828e53f4 Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Mon, 7 Apr 2014 09:08:47 -0300 Subject: [media] vb2: use correct prefix Many dprintk's in vb2 use a hardcoded prefix with the function name. In many cases that is now outdated. To keep things consistent the dprintk macro has been changed to print the function name in addition to the "vb2:" prefix. Superfluous prefixes elsewhere in the code have been removed. Signed-off-by: Hans Verkuil Acked-by: Pawel Osciak Acked-by: Sakari Ailus Signed-off-by: Mauro Carvalho Chehab --- drivers/media/v4l2-core/videobuf2-core.c | 133 +++++++++++++++---------------- 1 file changed, 65 insertions(+), 68 deletions(-) diff --git a/drivers/media/v4l2-core/videobuf2-core.c b/drivers/media/v4l2-core/videobuf2-core.c index 2e96f3535e2c..58b97023ae6f 100644 --- a/drivers/media/v4l2-core/videobuf2-core.c +++ b/drivers/media/v4l2-core/videobuf2-core.c @@ -27,10 +27,10 @@ static int debug; module_param(debug, int, 0644); -#define dprintk(level, fmt, arg...) \ - do { \ - if (debug >= level) \ - printk(KERN_DEBUG "vb2: " fmt, ## arg); \ +#define dprintk(level, fmt, arg...) \ + do { \ + if (debug >= level) \ + pr_debug("vb2: %s: " fmt, __func__, ## arg); \ } while (0) #ifdef CONFIG_VIDEO_ADV_DEBUG @@ -444,7 +444,7 @@ static int __vb2_queue_free(struct vb2_queue *q, unsigned int buffers) if (q->bufs[buffer] == NULL) continue; if (q->bufs[buffer]->state == VB2_BUF_STATE_PREPARING) { - dprintk(1, "reqbufs: preparing buffers, cannot free\n"); + dprintk(1, "preparing buffers, cannot free\n"); return -EAGAIN; } } @@ -729,12 +729,12 @@ int vb2_querybuf(struct vb2_queue *q, struct v4l2_buffer *b) int ret; if (b->type != q->type) { - dprintk(1, "querybuf: wrong buffer type\n"); + dprintk(1, "wrong buffer type\n"); return -EINVAL; } if (b->index >= q->num_buffers) { - dprintk(1, "querybuf: buffer index out of range\n"); + dprintk(1, "buffer index out of range\n"); return -EINVAL; } vb = q->bufs[b->index]; @@ -794,12 +794,12 @@ static int __verify_memory_type(struct vb2_queue *q, { if (memory != V4L2_MEMORY_MMAP && memory != V4L2_MEMORY_USERPTR && memory != V4L2_MEMORY_DMABUF) { - dprintk(1, "reqbufs: unsupported memory type\n"); + dprintk(1, "unsupported memory type\n"); return -EINVAL; } if (type != q->type) { - dprintk(1, "reqbufs: requested type is incorrect\n"); + dprintk(1, "requested type is incorrect\n"); return -EINVAL; } @@ -808,17 +808,17 @@ static int __verify_memory_type(struct vb2_queue *q, * are available. */ if (memory == V4L2_MEMORY_MMAP && __verify_mmap_ops(q)) { - dprintk(1, "reqbufs: MMAP for current setup unsupported\n"); + dprintk(1, "MMAP for current setup unsupported\n"); return -EINVAL; } if (memory == V4L2_MEMORY_USERPTR && __verify_userptr_ops(q)) { - dprintk(1, "reqbufs: USERPTR for current setup unsupported\n"); + dprintk(1, "USERPTR for current setup unsupported\n"); return -EINVAL; } if (memory == V4L2_MEMORY_DMABUF && __verify_dmabuf_ops(q)) { - dprintk(1, "reqbufs: DMABUF for current setup unsupported\n"); + dprintk(1, "DMABUF for current setup unsupported\n"); return -EINVAL; } @@ -828,7 +828,7 @@ static int __verify_memory_type(struct vb2_queue *q, * do the memory and type validation. */ if (q->fileio) { - dprintk(1, "reqbufs: file io in progress\n"); + dprintk(1, "file io in progress\n"); return -EBUSY; } return 0; @@ -863,7 +863,7 @@ static int __reqbufs(struct vb2_queue *q, struct v4l2_requestbuffers *req) int ret; if (q->streaming) { - dprintk(1, "reqbufs: streaming active\n"); + dprintk(1, "streaming active\n"); return -EBUSY; } @@ -873,7 +873,7 @@ static int __reqbufs(struct vb2_queue *q, struct v4l2_requestbuffers *req) * are not in use and can be freed. */ if (q->memory == V4L2_MEMORY_MMAP && __buffers_in_use(q)) { - dprintk(1, "reqbufs: memory in use, cannot free\n"); + dprintk(1, "memory in use, cannot free\n"); return -EBUSY; } @@ -1000,8 +1000,7 @@ static int __create_bufs(struct vb2_queue *q, struct v4l2_create_buffers *create int ret; if (q->num_buffers == VIDEO_MAX_FRAME) { - dprintk(1, "%s(): maximum number of buffers already allocated\n", - __func__); + dprintk(1, "maximum number of buffers already allocated\n"); return -ENOBUFS; } @@ -1329,12 +1328,12 @@ static int __qbuf_userptr(struct vb2_buffer *vb, const struct v4l2_buffer *b) && vb->v4l2_planes[plane].length == planes[plane].length) continue; - dprintk(3, "qbuf: userspace address for plane %d changed, " + dprintk(3, "userspace address for plane %d changed, " "reacquiring memory\n", plane); /* Check if the provided plane buffer is large enough */ if (planes[plane].length < q->plane_sizes[plane]) { - dprintk(1, "qbuf: provided buffer size %u is less than " + dprintk(1, "provided buffer size %u is less than " "setup size %u for plane %d\n", planes[plane].length, q->plane_sizes[plane], plane); @@ -1359,7 +1358,7 @@ static int __qbuf_userptr(struct vb2_buffer *vb, const struct v4l2_buffer *b) planes[plane].m.userptr, planes[plane].length, write); if (IS_ERR_OR_NULL(mem_priv)) { - dprintk(1, "qbuf: failed acquiring userspace " + dprintk(1, "failed acquiring userspace " "memory for plane %d\n", plane); ret = mem_priv ? PTR_ERR(mem_priv) : -EINVAL; goto err; @@ -1382,14 +1381,14 @@ static int __qbuf_userptr(struct vb2_buffer *vb, const struct v4l2_buffer *b) */ ret = call_vb_qop(vb, buf_init, vb); if (ret) { - dprintk(1, "qbuf: buffer initialization failed\n"); + dprintk(1, "buffer initialization failed\n"); goto err; } } ret = call_vb_qop(vb, buf_prepare, vb); if (ret) { - dprintk(1, "qbuf: buffer preparation failed\n"); + dprintk(1, "buffer preparation failed\n"); call_void_vb_qop(vb, buf_cleanup, vb); goto err; } @@ -1438,7 +1437,7 @@ static int __qbuf_dmabuf(struct vb2_buffer *vb, const struct v4l2_buffer *b) struct dma_buf *dbuf = dma_buf_get(planes[plane].m.fd); if (IS_ERR_OR_NULL(dbuf)) { - dprintk(1, "qbuf: invalid dmabuf fd for plane %d\n", + dprintk(1, "invalid dmabuf fd for plane %d\n", plane); ret = -EINVAL; goto err; @@ -1449,7 +1448,7 @@ static int __qbuf_dmabuf(struct vb2_buffer *vb, const struct v4l2_buffer *b) planes[plane].length = dbuf->size; if (planes[plane].length < q->plane_sizes[plane]) { - dprintk(1, "qbuf: invalid dmabuf length for plane %d\n", + dprintk(1, "invalid dmabuf length for plane %d\n", plane); ret = -EINVAL; goto err; @@ -1462,7 +1461,7 @@ static int __qbuf_dmabuf(struct vb2_buffer *vb, const struct v4l2_buffer *b) continue; } - dprintk(1, "qbuf: buffer for plane %d changed\n", plane); + dprintk(1, "buffer for plane %d changed\n", plane); if (!reacquired) { reacquired = true; @@ -1477,7 +1476,7 @@ static int __qbuf_dmabuf(struct vb2_buffer *vb, const struct v4l2_buffer *b) mem_priv = call_ptr_memop(vb, attach_dmabuf, q->alloc_ctx[plane], dbuf, planes[plane].length, write); if (IS_ERR(mem_priv)) { - dprintk(1, "qbuf: failed to attach dmabuf\n"); + dprintk(1, "failed to attach dmabuf\n"); ret = PTR_ERR(mem_priv); dma_buf_put(dbuf); goto err; @@ -1494,7 +1493,7 @@ static int __qbuf_dmabuf(struct vb2_buffer *vb, const struct v4l2_buffer *b) for (plane = 0; plane < vb->num_planes; ++plane) { ret = call_memop(vb, map_dmabuf, vb->planes[plane].mem_priv); if (ret) { - dprintk(1, "qbuf: failed to map dmabuf for plane %d\n", + dprintk(1, "failed to map dmabuf for plane %d\n", plane); goto err; } @@ -1515,14 +1514,14 @@ static int __qbuf_dmabuf(struct vb2_buffer *vb, const struct v4l2_buffer *b) */ ret = call_vb_qop(vb, buf_init, vb); if (ret) { - dprintk(1, "qbuf: buffer initialization failed\n"); + dprintk(1, "buffer initialization failed\n"); goto err; } } ret = call_vb_qop(vb, buf_prepare, vb); if (ret) { - dprintk(1, "qbuf: buffer preparation failed\n"); + dprintk(1, "buffer preparation failed\n"); call_void_vb_qop(vb, buf_cleanup, vb); goto err; } @@ -1561,8 +1560,7 @@ static int __buf_prepare(struct vb2_buffer *vb, const struct v4l2_buffer *b) ret = __verify_length(vb, b); if (ret < 0) { - dprintk(1, "%s(): plane parameters verification failed: %d\n", - __func__, ret); + dprintk(1, "plane parameters verification failed: %d\n", ret); return ret; } @@ -1606,7 +1604,7 @@ static int __buf_prepare(struct vb2_buffer *vb, const struct v4l2_buffer *b) } if (ret) - dprintk(1, "qbuf: buffer preparation failed: %d\n", ret); + dprintk(1, "buffer preparation failed: %d\n", ret); vb->state = ret ? VB2_BUF_STATE_DEQUEUED : VB2_BUF_STATE_PREPARED; return ret; @@ -1616,23 +1614,23 @@ static int vb2_queue_or_prepare_buf(struct vb2_queue *q, struct v4l2_buffer *b, const char *opname) { if (b->type != q->type) { - dprintk(1, "%s(): invalid buffer type\n", opname); + dprintk(1, "%s: invalid buffer type\n", opname); return -EINVAL; } if (b->index >= q->num_buffers) { - dprintk(1, "%s(): buffer index out of range\n", opname); + dprintk(1, "%s: buffer index out of range\n", opname); return -EINVAL; } if (q->bufs[b->index] == NULL) { /* Should never happen */ - dprintk(1, "%s(): buffer is NULL\n", opname); + dprintk(1, "%s: buffer is NULL\n", opname); return -EINVAL; } if (b->memory != q->memory) { - dprintk(1, "%s(): invalid memory type\n", opname); + dprintk(1, "%s: invalid memory type\n", opname); return -EINVAL; } @@ -1660,7 +1658,7 @@ int vb2_prepare_buf(struct vb2_queue *q, struct v4l2_buffer *b) int ret; if (q->fileio) { - dprintk(1, "%s(): file io in progress\n", __func__); + dprintk(1, "file io in progress\n"); return -EBUSY; } @@ -1670,7 +1668,7 @@ int vb2_prepare_buf(struct vb2_queue *q, struct v4l2_buffer *b) vb = q->bufs[b->index]; if (vb->state != VB2_BUF_STATE_DEQUEUED) { - dprintk(1, "%s(): invalid buffer state %d\n", __func__, + dprintk(1, "invalid buffer state %d\n", vb->state); return -EINVAL; } @@ -1680,7 +1678,7 @@ int vb2_prepare_buf(struct vb2_queue *q, struct v4l2_buffer *b) /* Fill buffer information for the userspace */ __fill_v4l2_buffer(vb, b); - dprintk(1, "%s() of buffer %d succeeded\n", __func__, vb->v4l2_buf.index); + dprintk(1, "prepare of buffer %d succeeded\n", vb->v4l2_buf.index); } return ret; } @@ -1716,7 +1714,7 @@ static int vb2_start_streaming(struct vb2_queue *q) if (!ret) return 0; - dprintk(1, "qbuf: driver refused to start streaming\n"); + dprintk(1, "driver refused to start streaming\n"); if (WARN_ON(atomic_read(&q->owned_by_drv_count))) { unsigned i; @@ -1754,11 +1752,10 @@ static int vb2_internal_qbuf(struct vb2_queue *q, struct v4l2_buffer *b) case VB2_BUF_STATE_PREPARED: break; case VB2_BUF_STATE_PREPARING: - dprintk(1, "qbuf: buffer still being prepared\n"); + dprintk(1, "buffer still being prepared\n"); return -EINVAL; default: - dprintk(1, "%s(): invalid buffer state %d\n", __func__, - vb->state); + dprintk(1, "invalid buffer state %d\n", vb->state); return -EINVAL; } @@ -1805,7 +1802,7 @@ static int vb2_internal_qbuf(struct vb2_queue *q, struct v4l2_buffer *b) return ret; } - dprintk(1, "%s() of buffer %d succeeded\n", __func__, vb->v4l2_buf.index); + dprintk(1, "qbuf of buffer %d succeeded\n", vb->v4l2_buf.index); return 0; } @@ -1829,7 +1826,7 @@ static int vb2_internal_qbuf(struct vb2_queue *q, struct v4l2_buffer *b) int vb2_qbuf(struct vb2_queue *q, struct v4l2_buffer *b) { if (q->fileio) { - dprintk(1, "%s(): file io in progress\n", __func__); + dprintk(1, "file io in progress\n"); return -EBUSY; } @@ -1990,7 +1987,7 @@ static int vb2_internal_dqbuf(struct vb2_queue *q, struct v4l2_buffer *b, bool n int ret; if (b->type != q->type) { - dprintk(1, "dqbuf: invalid buffer type\n"); + dprintk(1, "invalid buffer type\n"); return -EINVAL; } ret = __vb2_get_done_vb(q, &vb, b, nonblocking); @@ -1999,13 +1996,13 @@ static int vb2_internal_dqbuf(struct vb2_queue *q, struct v4l2_buffer *b, bool n switch (vb->state) { case VB2_BUF_STATE_DONE: - dprintk(3, "dqbuf: Returning done buffer\n"); + dprintk(3, "Returning done buffer\n"); break; case VB2_BUF_STATE_ERROR: - dprintk(3, "dqbuf: Returning done buffer with errors\n"); + dprintk(3, "Returning done buffer with errors\n"); break; default: - dprintk(1, "dqbuf: Invalid buffer state\n"); + dprintk(1, "Invalid buffer state\n"); return -EINVAL; } @@ -2049,7 +2046,7 @@ static int vb2_internal_dqbuf(struct vb2_queue *q, struct v4l2_buffer *b, bool n int vb2_dqbuf(struct vb2_queue *q, struct v4l2_buffer *b, bool nonblocking) { if (q->fileio) { - dprintk(1, "dqbuf: file io in progress\n"); + dprintk(1, "file io in progress\n"); return -EBUSY; } return vb2_internal_dqbuf(q, b, nonblocking); @@ -2121,26 +2118,26 @@ static int vb2_internal_streamon(struct vb2_queue *q, enum v4l2_buf_type type) int ret; if (type != q->type) { - dprintk(1, "streamon: invalid stream type\n"); + dprintk(1, "invalid stream type\n"); return -EINVAL; } if (q->streaming) { - dprintk(3, "streamon successful: already streaming\n"); + dprintk(3, "already streaming\n"); return 0; } if (!q->num_buffers) { - dprintk(1, "streamon: no buffers have been allocated\n"); + dprintk(1, "no buffers have been allocated\n"); return -EINVAL; } if (!q->num_buffers) { - dprintk(1, "streamon: no buffers have been allocated\n"); + dprintk(1, "no buffers have been allocated\n"); return -EINVAL; } if (q->num_buffers < q->min_buffers_needed) { - dprintk(1, "streamon: need at least %u allocated buffers\n", + dprintk(1, "need at least %u allocated buffers\n", q->min_buffers_needed); return -EINVAL; } @@ -2159,7 +2156,7 @@ static int vb2_internal_streamon(struct vb2_queue *q, enum v4l2_buf_type type) q->streaming = 1; - dprintk(3, "Streamon successful\n"); + dprintk(3, "successful\n"); return 0; } @@ -2179,7 +2176,7 @@ static int vb2_internal_streamon(struct vb2_queue *q, enum v4l2_buf_type type) int vb2_streamon(struct vb2_queue *q, enum v4l2_buf_type type) { if (q->fileio) { - dprintk(1, "streamon: file io in progress\n"); + dprintk(1, "file io in progress\n"); return -EBUSY; } return vb2_internal_streamon(q, type); @@ -2189,7 +2186,7 @@ EXPORT_SYMBOL_GPL(vb2_streamon); static int vb2_internal_streamoff(struct vb2_queue *q, enum v4l2_buf_type type) { if (type != q->type) { - dprintk(1, "streamoff: invalid stream type\n"); + dprintk(1, "invalid stream type\n"); return -EINVAL; } @@ -2204,7 +2201,7 @@ static int vb2_internal_streamoff(struct vb2_queue *q, enum v4l2_buf_type type) */ __vb2_queue_cancel(q); - dprintk(3, "Streamoff successful\n"); + dprintk(3, "successful\n"); return 0; } @@ -2226,7 +2223,7 @@ static int vb2_internal_streamoff(struct vb2_queue *q, enum v4l2_buf_type type) int vb2_streamoff(struct vb2_queue *q, enum v4l2_buf_type type) { if (q->fileio) { - dprintk(1, "streamoff: file io in progress\n"); + dprintk(1, "file io in progress\n"); return -EBUSY; } return vb2_internal_streamoff(q, type); @@ -2294,7 +2291,7 @@ int vb2_expbuf(struct vb2_queue *q, struct v4l2_exportbuffer *eb) } if (eb->type != q->type) { - dprintk(1, "qbuf: invalid buffer type\n"); + dprintk(1, "invalid buffer type\n"); return -EINVAL; } @@ -2805,7 +2802,7 @@ static size_t __vb2_perform_fileio(struct vb2_queue *q, char __user *data, size_ struct vb2_fileio_buf *buf; int ret, index; - dprintk(3, "file io: mode %s, offset %ld, count %zd, %sblocking\n", + dprintk(3, "mode %s, offset %ld, count %zd, %sblocking\n", read ? "read" : "write", (long)*ppos, count, nonblock ? "non" : ""); @@ -2817,7 +2814,7 @@ static size_t __vb2_perform_fileio(struct vb2_queue *q, char __user *data, size_ */ if (!q->fileio) { ret = __vb2_init_fileio(q, read); - dprintk(3, "file io: vb2_init_fileio result: %d\n", ret); + dprintk(3, "vb2_init_fileio result: %d\n", ret); if (ret) return ret; } @@ -2835,7 +2832,7 @@ static size_t __vb2_perform_fileio(struct vb2_queue *q, char __user *data, size_ fileio->b.type = q->type; fileio->b.memory = q->memory; ret = vb2_internal_dqbuf(q, &fileio->b, nonblock); - dprintk(5, "file io: vb2_dqbuf result: %d\n", ret); + dprintk(5, "vb2_dqbuf result: %d\n", ret); if (ret) return ret; fileio->dq_count += 1; @@ -2865,14 +2862,14 @@ static size_t __vb2_perform_fileio(struct vb2_queue *q, char __user *data, size_ /* * Transfer data to userspace. */ - dprintk(3, "file io: copying %zd bytes - buffer %d, offset %u\n", + dprintk(3, "copying %zd bytes - buffer %d, offset %u\n", count, index, buf->pos); if (read) ret = copy_to_user(data, buf->vaddr + buf->pos, count); else ret = copy_from_user(buf->vaddr + buf->pos, data, count); if (ret) { - dprintk(3, "file io: error copying data\n"); + dprintk(3, "error copying data\n"); return -EFAULT; } @@ -2892,7 +2889,7 @@ static size_t __vb2_perform_fileio(struct vb2_queue *q, char __user *data, size_ */ if (read && (fileio->flags & VB2_FILEIO_READ_ONCE) && fileio->dq_count == 1) { - dprintk(3, "file io: read limit reached\n"); + dprintk(3, "read limit reached\n"); return __vb2_cleanup_fileio(q); } @@ -2905,7 +2902,7 @@ static size_t __vb2_perform_fileio(struct vb2_queue *q, char __user *data, size_ fileio->b.index = index; fileio->b.bytesused = buf->pos; ret = vb2_internal_qbuf(q, &fileio->b); - dprintk(5, "file io: vb2_dbuf result: %d\n", ret); + dprintk(5, "vb2_dbuf result: %d\n", ret); if (ret) return ret; -- cgit v1.2.3 From dcc2428a5e930aa7c0f40840a946b68a396ceae6 Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Mon, 10 Mar 2014 12:23:13 -0300 Subject: [media] vb2: move __qbuf_mmap before __qbuf_userptr __qbuf_mmap was sort of hidden in between the much larger __qbuf_userptr and __qbuf_dmabuf functions. Move it before __qbuf_userptr which is also conform the usual order these memory models are implemented: first mmap, then userptr, then dmabuf. Signed-off-by: Hans Verkuil Acked-by: Pawel Osciak Acked-by: Sakari Ailus Signed-off-by: Mauro Carvalho Chehab --- drivers/media/v4l2-core/videobuf2-core.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/media/v4l2-core/videobuf2-core.c b/drivers/media/v4l2-core/videobuf2-core.c index 58b97023ae6f..0f495f1d6946 100644 --- a/drivers/media/v4l2-core/videobuf2-core.c +++ b/drivers/media/v4l2-core/videobuf2-core.c @@ -1304,6 +1304,15 @@ static void __fill_vb2_buffer(struct vb2_buffer *vb, const struct v4l2_buffer *b } } +/** + * __qbuf_mmap() - handle qbuf of an MMAP buffer + */ +static int __qbuf_mmap(struct vb2_buffer *vb, const struct v4l2_buffer *b) +{ + __fill_vb2_buffer(vb, b, vb->v4l2_planes); + return call_vb_qop(vb, buf_prepare, vb); +} + /** * __qbuf_userptr() - handle qbuf of a USERPTR buffer */ @@ -1407,15 +1416,6 @@ err: return ret; } -/** - * __qbuf_mmap() - handle qbuf of an MMAP buffer - */ -static int __qbuf_mmap(struct vb2_buffer *vb, const struct v4l2_buffer *b) -{ - __fill_vb2_buffer(vb, b, vb->v4l2_planes); - return call_vb_qop(vb, buf_prepare, vb); -} - /** * __qbuf_dmabuf() - handle qbuf of a DMABUF buffer */ -- cgit v1.2.3 From ebd7c50510f4b56285bb9fb4ba56a501c9c8f7df Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Fri, 11 Apr 2014 04:36:57 -0300 Subject: [media] vb2: set timestamp when using write() When using write() to write data to an output video node the vb2 core should set timestamps if V4L2_BUF_FLAG_TIMESTAMP_COPY is set. Nobody else is able to provide this information with the write() operation. Signed-off-by: Hans Verkuil Acked-by: Pawel Osciak Acked-by: Sakari Ailus Signed-off-by: Mauro Carvalho Chehab --- drivers/media/v4l2-core/videobuf2-core.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/media/v4l2-core/videobuf2-core.c b/drivers/media/v4l2-core/videobuf2-core.c index 0f495f1d6946..07ab0677e259 100644 --- a/drivers/media/v4l2-core/videobuf2-core.c +++ b/drivers/media/v4l2-core/videobuf2-core.c @@ -22,6 +22,7 @@ #include #include #include +#include #include static int debug; @@ -2800,6 +2801,14 @@ static size_t __vb2_perform_fileio(struct vb2_queue *q, char __user *data, size_ { struct vb2_fileio_data *fileio; struct vb2_fileio_buf *buf; + /* + * When using write() to write data to an output video node the vb2 core + * should set timestamps if V4L2_BUF_FLAG_TIMESTAMP_COPY is set. Nobody + * else is able to provide this information with the write() operation. + */ + bool set_timestamp = !read && + (q->timestamp_flags & V4L2_BUF_FLAG_TIMESTAMP_MASK) == + V4L2_BUF_FLAG_TIMESTAMP_COPY; int ret, index; dprintk(3, "mode %s, offset %ld, count %zd, %sblocking\n", @@ -2901,6 +2910,8 @@ static size_t __vb2_perform_fileio(struct vb2_queue *q, char __user *data, size_ fileio->b.memory = q->memory; fileio->b.index = index; fileio->b.bytesused = buf->pos; + if (set_timestamp) + v4l2_get_timestamp(&fileio->b.timestamp); ret = vb2_internal_qbuf(q, &fileio->b); dprintk(5, "vb2_dbuf result: %d\n", ret); if (ret) -- cgit v1.2.3 From e35e41b57624b9a8c0014420cdfb24454e4773c5 Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Mon, 7 Apr 2014 09:20:39 -0300 Subject: [media] vb2: reject output buffers with V4L2_FIELD_ALTERNATE This is not allowed by the spec and does in fact not make any sense. Return -EINVAL if this is the case. Signed-off-by: Hans Verkuil Acked-by: Pawel Osciak Acked-by: Sakari Ailus Signed-off-by: Mauro Carvalho Chehab --- drivers/media/v4l2-core/videobuf2-core.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/drivers/media/v4l2-core/videobuf2-core.c b/drivers/media/v4l2-core/videobuf2-core.c index 07ab0677e259..2eef5ef93e93 100644 --- a/drivers/media/v4l2-core/videobuf2-core.c +++ b/drivers/media/v4l2-core/videobuf2-core.c @@ -1564,6 +1564,19 @@ static int __buf_prepare(struct vb2_buffer *vb, const struct v4l2_buffer *b) dprintk(1, "plane parameters verification failed: %d\n", ret); return ret; } + if (b->field == V4L2_FIELD_ALTERNATE && V4L2_TYPE_IS_OUTPUT(q->type)) { + /* + * If the format's field is ALTERNATE, then the buffer's field + * should be either TOP or BOTTOM, not ALTERNATE since that + * makes no sense. The driver has to know whether the + * buffer represents a top or a bottom field in order to + * program any DMA correctly. Using ALTERNATE is wrong, since + * that just says that it is either a top or a bottom field, + * but not which of the two it is. + */ + dprintk(1, "the field is incorrectly set to ALTERNATE for an output buffer\n"); + return -EINVAL; + } vb->state = VB2_BUF_STATE_PREPARING; vb->v4l2_buf.timestamp.tv_sec = 0; -- cgit v1.2.3 From 57394b72ef2b6dcf335999a7aebe69eb52142884 Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Mon, 24 Feb 2014 15:52:04 -0300 Subject: [media] vb2: simplify a confusing condition q->start_streaming_called is always true, so the WARN_ON check against it being false can be dropped. Signed-off-by: Hans Verkuil Acked-by: Pawel Osciak Acked-by: Sakari Ailus Signed-off-by: Mauro Carvalho Chehab --- drivers/media/v4l2-core/videobuf2-core.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/media/v4l2-core/videobuf2-core.c b/drivers/media/v4l2-core/videobuf2-core.c index 2eef5ef93e93..60fbb17cc913 100644 --- a/drivers/media/v4l2-core/videobuf2-core.c +++ b/drivers/media/v4l2-core/videobuf2-core.c @@ -1159,9 +1159,8 @@ void vb2_buffer_done(struct vb2_buffer *vb, enum vb2_buffer_state state) if (!q->start_streaming_called) { if (WARN_ON(state != VB2_BUF_STATE_QUEUED)) state = VB2_BUF_STATE_QUEUED; - } else if (!WARN_ON(!q->start_streaming_called)) { - if (WARN_ON(state != VB2_BUF_STATE_DONE && - state != VB2_BUF_STATE_ERROR)) + } else if (WARN_ON(state != VB2_BUF_STATE_DONE && + state != VB2_BUF_STATE_ERROR)) { state = VB2_BUF_STATE_ERROR; } -- cgit v1.2.3 From 74753cffa6fae399aef0f0a1a3315196e6e339cf Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Mon, 7 Apr 2014 09:23:50 -0300 Subject: [media] vb2: add vb2_fileio_is_active and check it more often Added a vb2_fileio_is_active inline function that returns true if fileio is in progress. Check for this too in mmap() (you don't want apps mmap()ing buffers used by fileio) and expbuf() (same reason). In addition drivers should be able to check for this in queue_setup() to return an error if an attempt is made to read() or write() with V4L2_FIELD_ALTERNATE being configured. This is illegal (there is no way to pass the TOP/BOTTOM information around using file I/O). However, in order to be able to check for this the init_fileio function needs to set q->fileio early on, before the buffers are allocated. So switch to using internal functions (__reqbufs, vb2_internal_qbuf and vb2_internal_streamon) to skip the fileio check. Well, that's why the internal functions were created... Signed-off-by: Hans Verkuil Acked-by: Pawel Osciak Acked-by: Sakari Ailus Signed-off-by: Mauro Carvalho Chehab --- drivers/media/v4l2-core/videobuf2-core.c | 39 ++++++++++++++++++++------------ include/media/videobuf2-core.h | 17 ++++++++++++++ 2 files changed, 41 insertions(+), 15 deletions(-) diff --git a/drivers/media/v4l2-core/videobuf2-core.c b/drivers/media/v4l2-core/videobuf2-core.c index 60fbb17cc913..b80fd24debfa 100644 --- a/drivers/media/v4l2-core/videobuf2-core.c +++ b/drivers/media/v4l2-core/videobuf2-core.c @@ -828,7 +828,7 @@ static int __verify_memory_type(struct vb2_queue *q, * create_bufs is called with count == 0, but count == 0 should still * do the memory and type validation. */ - if (q->fileio) { + if (vb2_fileio_is_active(q)) { dprintk(1, "file io in progress\n"); return -EBUSY; } @@ -1670,7 +1670,7 @@ int vb2_prepare_buf(struct vb2_queue *q, struct v4l2_buffer *b) struct vb2_buffer *vb; int ret; - if (q->fileio) { + if (vb2_fileio_is_active(q)) { dprintk(1, "file io in progress\n"); return -EBUSY; } @@ -1838,7 +1838,7 @@ static int vb2_internal_qbuf(struct vb2_queue *q, struct v4l2_buffer *b) */ int vb2_qbuf(struct vb2_queue *q, struct v4l2_buffer *b) { - if (q->fileio) { + if (vb2_fileio_is_active(q)) { dprintk(1, "file io in progress\n"); return -EBUSY; } @@ -2058,7 +2058,7 @@ static int vb2_internal_dqbuf(struct vb2_queue *q, struct v4l2_buffer *b, bool n */ int vb2_dqbuf(struct vb2_queue *q, struct v4l2_buffer *b, bool nonblocking) { - if (q->fileio) { + if (vb2_fileio_is_active(q)) { dprintk(1, "file io in progress\n"); return -EBUSY; } @@ -2188,7 +2188,7 @@ static int vb2_internal_streamon(struct vb2_queue *q, enum v4l2_buf_type type) */ int vb2_streamon(struct vb2_queue *q, enum v4l2_buf_type type) { - if (q->fileio) { + if (vb2_fileio_is_active(q)) { dprintk(1, "file io in progress\n"); return -EBUSY; } @@ -2235,7 +2235,7 @@ static int vb2_internal_streamoff(struct vb2_queue *q, enum v4l2_buf_type type) */ int vb2_streamoff(struct vb2_queue *q, enum v4l2_buf_type type) { - if (q->fileio) { + if (vb2_fileio_is_active(q)) { dprintk(1, "file io in progress\n"); return -EBUSY; } @@ -2320,6 +2320,11 @@ int vb2_expbuf(struct vb2_queue *q, struct v4l2_exportbuffer *eb) return -EINVAL; } + if (vb2_fileio_is_active(q)) { + dprintk(1, "expbuf: file io in progress\n"); + return -EBUSY; + } + vb_plane = &vb->planes[eb->plane]; dbuf = call_ptr_memop(vb, get_dmabuf, vb_plane->mem_priv, eb->flags & O_ACCMODE); @@ -2395,6 +2400,10 @@ int vb2_mmap(struct vb2_queue *q, struct vm_area_struct *vma) return -EINVAL; } } + if (vb2_fileio_is_active(q)) { + dprintk(1, "mmap: file io in progress\n"); + return -EBUSY; + } /* * Find the plane corresponding to the offset passed by userspace. @@ -2504,7 +2513,7 @@ unsigned int vb2_poll(struct vb2_queue *q, struct file *file, poll_table *wait) /* * Start file I/O emulator only if streaming API has not been used yet. */ - if (q->num_buffers == 0 && q->fileio == NULL) { + if (q->num_buffers == 0 && !vb2_fileio_is_active(q)) { if (!V4L2_TYPE_IS_OUTPUT(q->type) && (q->io_modes & VB2_READ) && (req_events & (POLLIN | POLLRDNORM))) { if (__vb2_init_fileio(q, 1)) @@ -2709,7 +2718,8 @@ static int __vb2_init_fileio(struct vb2_queue *q, int read) fileio->req.count = count; fileio->req.memory = V4L2_MEMORY_MMAP; fileio->req.type = q->type; - ret = vb2_reqbufs(q, &fileio->req); + q->fileio = fileio; + ret = __reqbufs(q, &fileio->req); if (ret) goto err_kfree; @@ -2747,7 +2757,7 @@ static int __vb2_init_fileio(struct vb2_queue *q, int read) b->type = q->type; b->memory = q->memory; b->index = i; - ret = vb2_qbuf(q, b); + ret = vb2_internal_qbuf(q, b); if (ret) goto err_reqbufs; fileio->bufs[i].queued = 1; @@ -2763,19 +2773,18 @@ static int __vb2_init_fileio(struct vb2_queue *q, int read) /* * Start streaming. */ - ret = vb2_streamon(q, q->type); + ret = vb2_internal_streamon(q, q->type); if (ret) goto err_reqbufs; - q->fileio = fileio; - return ret; err_reqbufs: fileio->req.count = 0; - vb2_reqbufs(q, &fileio->req); + __reqbufs(q, &fileio->req); err_kfree: + q->fileio = NULL; kfree(fileio); return ret; } @@ -2833,7 +2842,7 @@ static size_t __vb2_perform_fileio(struct vb2_queue *q, char __user *data, size_ /* * Initialize emulator on first call. */ - if (!q->fileio) { + if (!vb2_fileio_is_active(q)) { ret = __vb2_init_fileio(q, read); dprintk(3, "vb2_init_fileio result: %d\n", ret); if (ret) @@ -3201,7 +3210,7 @@ unsigned int vb2_fop_poll(struct file *file, poll_table *wait) /* Try to be smart: only lock if polling might start fileio, otherwise locking will only introduce unwanted delays. */ - if (q->num_buffers == 0 && q->fileio == NULL) { + if (q->num_buffers == 0 && !vb2_fileio_is_active(q)) { if (!V4L2_TYPE_IS_OUTPUT(q->type) && (q->io_modes & VB2_READ) && (req_events & (POLLIN | POLLRDNORM))) must_lock = true; diff --git a/include/media/videobuf2-core.h b/include/media/videobuf2-core.h index af4621109726..b1859f6953b2 100644 --- a/include/media/videobuf2-core.h +++ b/include/media/videobuf2-core.h @@ -471,6 +471,23 @@ static inline bool vb2_is_streaming(struct vb2_queue *q) return q->streaming; } +/** + * vb2_fileio_is_active() - return true if fileio is active. + * @q: videobuf queue + * + * This returns true if read() or write() is used to stream the data + * as opposed to stream I/O. This is almost never an important distinction, + * except in rare cases. One such case is that using read() or write() to + * stream a format using V4L2_FIELD_ALTERNATE is not allowed since there + * is no way you can pass the field information of each buffer to/from + * userspace. A driver that supports this field format should check for + * this in the queue_setup op and reject it if this function returns true. + */ +static inline bool vb2_fileio_is_active(struct vb2_queue *q) +{ + return q->fileio; +} + /** * vb2_is_busy() - return busy status of the queue * @q: videobuf queue -- cgit v1.2.3 From 7bb6edd37fc2e56297231cc854d7a17e336590db Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Fri, 11 Apr 2014 04:40:03 -0300 Subject: [media] vb2: allow read/write as long as the format is single planar It was impossible to read() or write() a frame if the queue type was multiplanar. Even if the current format is single planar. Change this to just check whether the number of planes is 1 or more. Signed-off-by: Hans Verkuil Acked-by: Sakari Ailus Signed-off-by: Mauro Carvalho Chehab --- drivers/media/v4l2-core/videobuf2-core.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/drivers/media/v4l2-core/videobuf2-core.c b/drivers/media/v4l2-core/videobuf2-core.c index b80fd24debfa..4a635c6bb6e1 100644 --- a/drivers/media/v4l2-core/videobuf2-core.c +++ b/drivers/media/v4l2-core/videobuf2-core.c @@ -2658,6 +2658,7 @@ struct vb2_fileio_buf { */ struct vb2_fileio_data { struct v4l2_requestbuffers req; + struct v4l2_plane p; struct v4l2_buffer b; struct vb2_fileio_buf bufs[VIDEO_MAX_FRAME]; unsigned int cur_index; @@ -2748,13 +2749,21 @@ static int __vb2_init_fileio(struct vb2_queue *q, int read) * Read mode requires pre queuing of all buffers. */ if (read) { + bool is_multiplanar = V4L2_TYPE_IS_MULTIPLANAR(q->type); + /* * Queue all buffers. */ for (i = 0; i < q->num_buffers; i++) { struct v4l2_buffer *b = &fileio->b; + memset(b, 0, sizeof(*b)); b->type = q->type; + if (is_multiplanar) { + memset(&fileio->p, 0, sizeof(fileio->p)); + b->m.planes = &fileio->p; + b->length = 1; + } b->memory = q->memory; b->index = i; ret = vb2_internal_qbuf(q, b); @@ -2822,6 +2831,7 @@ static size_t __vb2_perform_fileio(struct vb2_queue *q, char __user *data, size_ { struct vb2_fileio_data *fileio; struct vb2_fileio_buf *buf; + bool is_multiplanar = V4L2_TYPE_IS_MULTIPLANAR(q->type); /* * When using write() to write data to an output video node the vb2 core * should set timestamps if V4L2_BUF_FLAG_TIMESTAMP_COPY is set. Nobody @@ -2861,6 +2871,11 @@ static size_t __vb2_perform_fileio(struct vb2_queue *q, char __user *data, size_ memset(&fileio->b, 0, sizeof(fileio->b)); fileio->b.type = q->type; fileio->b.memory = q->memory; + if (is_multiplanar) { + memset(&fileio->p, 0, sizeof(fileio->p)); + fileio->b.m.planes = &fileio->p; + fileio->b.length = 1; + } ret = vb2_internal_dqbuf(q, &fileio->b, nonblock); dprintk(5, "vb2_dqbuf result: %d\n", ret); if (ret) @@ -2931,6 +2946,12 @@ static size_t __vb2_perform_fileio(struct vb2_queue *q, char __user *data, size_ fileio->b.memory = q->memory; fileio->b.index = index; fileio->b.bytesused = buf->pos; + if (is_multiplanar) { + memset(&fileio->p, 0, sizeof(fileio->p)); + fileio->p.bytesused = buf->pos; + fileio->b.m.planes = &fileio->p; + fileio->b.length = 1; + } if (set_timestamp) v4l2_get_timestamp(&fileio->b.timestamp); ret = vb2_internal_qbuf(q, &fileio->b); -- cgit v1.2.3 From 3050040b4ed95a8e3fa243d57f78a1d7fb1ab77b Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Mon, 7 Apr 2014 09:13:22 -0300 Subject: [media] vb2: start messages with a lower-case for consistency The kernel debug messages produced by vb2 started either with a lower or an upper case character. Switched all to use lower-case which seemed to be what was used in the majority of the messages. Signed-off-by: Hans Verkuil Acked-by: Pawel Osciak Acked-by: Sakari Ailus Signed-off-by: Mauro Carvalho Chehab --- drivers/media/v4l2-core/videobuf2-core.c | 58 ++++++++++++++++---------------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/drivers/media/v4l2-core/videobuf2-core.c b/drivers/media/v4l2-core/videobuf2-core.c index 4a635c6bb6e1..2075bac748c0 100644 --- a/drivers/media/v4l2-core/videobuf2-core.c +++ b/drivers/media/v4l2-core/videobuf2-core.c @@ -225,7 +225,7 @@ static void __vb2_buf_mem_free(struct vb2_buffer *vb) for (plane = 0; plane < vb->num_planes; ++plane) { call_void_memop(vb, put, vb->planes[plane].mem_priv); vb->planes[plane].mem_priv = NULL; - dprintk(3, "Freed plane %d of buffer %d\n", plane, + dprintk(3, "freed plane %d of buffer %d\n", plane, vb->v4l2_buf.index); } } @@ -320,7 +320,7 @@ static void __setup_offsets(struct vb2_queue *q, unsigned int n) for (plane = 0; plane < vb->num_planes; ++plane) { vb->v4l2_planes[plane].m.mem_offset = off; - dprintk(3, "Buffer %d, plane %d offset 0x%08lx\n", + dprintk(3, "buffer %d, plane %d offset 0x%08lx\n", buffer, plane, off); off += vb->v4l2_planes[plane].length; @@ -347,7 +347,7 @@ static int __vb2_queue_alloc(struct vb2_queue *q, enum v4l2_memory memory, /* Allocate videobuf buffer structures */ vb = kzalloc(q->buf_struct_size, GFP_KERNEL); if (!vb) { - dprintk(1, "Memory alloc for buffer struct failed\n"); + dprintk(1, "memory alloc for buffer struct failed\n"); break; } @@ -366,7 +366,7 @@ static int __vb2_queue_alloc(struct vb2_queue *q, enum v4l2_memory memory, if (memory == V4L2_MEMORY_MMAP) { ret = __vb2_buf_mem_alloc(vb); if (ret) { - dprintk(1, "Failed allocating memory for " + dprintk(1, "failed allocating memory for " "buffer %d\n", buffer); kfree(vb); break; @@ -378,7 +378,7 @@ static int __vb2_queue_alloc(struct vb2_queue *q, enum v4l2_memory memory, */ ret = call_vb_qop(vb, buf_init, vb); if (ret) { - dprintk(1, "Buffer %d %p initialization" + dprintk(1, "buffer %d %p initialization" " failed\n", buffer, vb); __vb2_buf_mem_free(vb); kfree(vb); @@ -393,7 +393,7 @@ static int __vb2_queue_alloc(struct vb2_queue *q, enum v4l2_memory memory, if (memory == V4L2_MEMORY_MMAP) __setup_offsets(q, buffer); - dprintk(1, "Allocated %d buffers, %d plane(s) each\n", + dprintk(1, "allocated %d buffers, %d plane(s) each\n", buffer, num_planes); return buffer; @@ -550,13 +550,13 @@ static int __verify_planes_array(struct vb2_buffer *vb, const struct v4l2_buffer /* Is memory for copying plane information present? */ if (NULL == b->m.planes) { - dprintk(1, "Multi-planar buffer passed but " + dprintk(1, "multi-planar buffer passed but " "planes array not provided\n"); return -EINVAL; } if (b->length < vb->num_planes || b->length > VIDEO_MAX_PLANES) { - dprintk(1, "Incorrect planes array length, " + dprintk(1, "incorrect planes array length, " "expected %d, got %d\n", vb->num_planes, b->length); return -EINVAL; } @@ -917,7 +917,7 @@ static int __reqbufs(struct vb2_queue *q, struct v4l2_requestbuffers *req) /* Finally, allocate buffers and video memory */ allocated_buffers = __vb2_queue_alloc(q, req->memory, num_buffers, num_planes); if (allocated_buffers == 0) { - dprintk(1, "Memory allocation failed\n"); + dprintk(1, "memory allocation failed\n"); return -ENOMEM; } @@ -1026,7 +1026,7 @@ static int __create_bufs(struct vb2_queue *q, struct v4l2_create_buffers *create allocated_buffers = __vb2_queue_alloc(q, create->memory, num_buffers, num_planes); if (allocated_buffers == 0) { - dprintk(1, "Memory allocation failed\n"); + dprintk(1, "memory allocation failed\n"); return -ENOMEM; } @@ -1171,7 +1171,7 @@ void vb2_buffer_done(struct vb2_buffer *vb, enum vb2_buffer_state state) */ vb->cnt_buf_done++; #endif - dprintk(4, "Done processing on buffer %d, state: %d\n", + dprintk(4, "done processing on buffer %d, state: %d\n", vb->v4l2_buf.index, state); /* sync buffers */ @@ -1868,7 +1868,7 @@ static int __vb2_wait_for_done_vb(struct vb2_queue *q, int nonblocking) int ret; if (!q->streaming) { - dprintk(1, "Streaming off, will not wait for buffers\n"); + dprintk(1, "streaming off, will not wait for buffers\n"); return -EINVAL; } @@ -1880,7 +1880,7 @@ static int __vb2_wait_for_done_vb(struct vb2_queue *q, int nonblocking) } if (nonblocking) { - dprintk(1, "Nonblocking and no buffers to dequeue, " + dprintk(1, "nonblocking and no buffers to dequeue, " "will not wait\n"); return -EAGAIN; } @@ -1895,7 +1895,7 @@ static int __vb2_wait_for_done_vb(struct vb2_queue *q, int nonblocking) /* * All locks have been released, it is safe to sleep now. */ - dprintk(3, "Will sleep waiting for buffers\n"); + dprintk(3, "will sleep waiting for buffers\n"); ret = wait_event_interruptible(q->done_wq, !list_empty(&q->done_list) || !q->streaming); @@ -1905,7 +1905,7 @@ static int __vb2_wait_for_done_vb(struct vb2_queue *q, int nonblocking) */ call_void_qop(q, wait_finish, q); if (ret) { - dprintk(1, "Sleep was interrupted\n"); + dprintk(1, "sleep was interrupted\n"); return ret; } } @@ -1960,7 +1960,7 @@ static int __vb2_get_done_vb(struct vb2_queue *q, struct vb2_buffer **vb, int vb2_wait_for_all_buffers(struct vb2_queue *q) { if (!q->streaming) { - dprintk(1, "Streaming off, will not wait for buffers\n"); + dprintk(1, "streaming off, will not wait for buffers\n"); return -EINVAL; } @@ -2009,13 +2009,13 @@ static int vb2_internal_dqbuf(struct vb2_queue *q, struct v4l2_buffer *b, bool n switch (vb->state) { case VB2_BUF_STATE_DONE: - dprintk(3, "Returning done buffer\n"); + dprintk(3, "returning done buffer\n"); break; case VB2_BUF_STATE_ERROR: - dprintk(3, "Returning done buffer with errors\n"); + dprintk(3, "returning done buffer with errors\n"); break; default: - dprintk(1, "Invalid buffer state\n"); + dprintk(1, "invalid buffer state\n"); return -EINVAL; } @@ -2289,17 +2289,17 @@ int vb2_expbuf(struct vb2_queue *q, struct v4l2_exportbuffer *eb) struct dma_buf *dbuf; if (q->memory != V4L2_MEMORY_MMAP) { - dprintk(1, "Queue is not currently set up for mmap\n"); + dprintk(1, "queue is not currently set up for mmap\n"); return -EINVAL; } if (!q->mem_ops->get_dmabuf) { - dprintk(1, "Queue does not support DMA buffer exporting\n"); + dprintk(1, "queue does not support DMA buffer exporting\n"); return -EINVAL; } if (eb->flags & ~(O_CLOEXEC | O_ACCMODE)) { - dprintk(1, "Queue does support only O_CLOEXEC and access mode flags\n"); + dprintk(1, "queue does support only O_CLOEXEC and access mode flags\n"); return -EINVAL; } @@ -2329,7 +2329,7 @@ int vb2_expbuf(struct vb2_queue *q, struct v4l2_exportbuffer *eb) dbuf = call_ptr_memop(vb, get_dmabuf, vb_plane->mem_priv, eb->flags & O_ACCMODE); if (IS_ERR_OR_NULL(dbuf)) { - dprintk(1, "Failed to export buffer %d, plane %d\n", + dprintk(1, "failed to export buffer %d, plane %d\n", eb->index, eb->plane); return -EINVAL; } @@ -2378,7 +2378,7 @@ int vb2_mmap(struct vb2_queue *q, struct vm_area_struct *vma) unsigned long length; if (q->memory != V4L2_MEMORY_MMAP) { - dprintk(1, "Queue is not currently set up for mmap\n"); + dprintk(1, "queue is not currently set up for mmap\n"); return -EINVAL; } @@ -2386,17 +2386,17 @@ int vb2_mmap(struct vb2_queue *q, struct vm_area_struct *vma) * Check memory area access mode. */ if (!(vma->vm_flags & VM_SHARED)) { - dprintk(1, "Invalid vma flags, VM_SHARED needed\n"); + dprintk(1, "invalid vma flags, VM_SHARED needed\n"); return -EINVAL; } if (V4L2_TYPE_IS_OUTPUT(q->type)) { if (!(vma->vm_flags & VM_WRITE)) { - dprintk(1, "Invalid vma flags, VM_WRITE needed\n"); + dprintk(1, "invalid vma flags, VM_WRITE needed\n"); return -EINVAL; } } else { if (!(vma->vm_flags & VM_READ)) { - dprintk(1, "Invalid vma flags, VM_READ needed\n"); + dprintk(1, "invalid vma flags, VM_READ needed\n"); return -EINVAL; } } @@ -2430,7 +2430,7 @@ int vb2_mmap(struct vb2_queue *q, struct vm_area_struct *vma) if (ret) return ret; - dprintk(3, "Buffer %d, plane %d successfully mapped\n", buffer, plane); + dprintk(3, "buffer %d, plane %d successfully mapped\n", buffer, plane); return 0; } EXPORT_SYMBOL_GPL(vb2_mmap); @@ -2448,7 +2448,7 @@ unsigned long vb2_get_unmapped_area(struct vb2_queue *q, int ret; if (q->memory != V4L2_MEMORY_MMAP) { - dprintk(1, "Queue is not currently set up for mmap\n"); + dprintk(1, "queue is not currently set up for mmap\n"); return -EINVAL; } -- cgit v1.2.3 From b050b29e071a0b11262ad513700ab073f58c45b2 Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Mon, 7 Apr 2014 10:01:28 -0300 Subject: [media] DocBook media: update bytesused field description For output buffers the application has to set the bytesused field. In reality applications often do not set this since drivers that deal with fix image sizes just override it anyway. The vb2 framework will replace this field with the length field if bytesused was set to 0 by the application, which is what happens in practice. Document this behavior. Signed-off-by: Hans Verkuil Acked-by: Sakari Ailus Signed-off-by: Mauro Carvalho Chehab --- Documentation/DocBook/media/v4l/io.xml | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/Documentation/DocBook/media/v4l/io.xml b/Documentation/DocBook/media/v4l/io.xml index 97a69bf6f3eb..188e6211abd1 100644 --- a/Documentation/DocBook/media/v4l/io.xml +++ b/Documentation/DocBook/media/v4l/io.xml @@ -699,7 +699,12 @@ linkend="v4l2-buf-type" /> buffer. It depends on the negotiated data format and may change with each buffer for compressed variable size data like JPEG images. Drivers must set this field when type -refers to an input stream, applications when it refers to an output stream. +refers to an input stream, applications when it refers to an output stream. +If the application sets this to 0 for an output stream, then +bytesused will be set to the size of the +buffer (see the length field of this struct) by +the driver. For multiplanar formats this field is ignored and the +planes pointer is used instead. __u32 @@ -861,7 +866,11 @@ should set this to 0. The number of bytes occupied by data in the plane (its payload). Drivers must set this field when type - refers to an input stream, applications when it refers to an output stream. + refers to an input stream, applications when it refers to an output stream. + If the application sets this to 0 for an output stream, then + bytesused will be set to the size of the + plane (see the length field of this struct) + by the driver. __u32 -- cgit v1.2.3 From 5f26f2501b81190b60a0b72d611668fb6a59dd24 Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Fri, 11 Apr 2014 05:02:29 -0300 Subject: [media] v4l2-pci-skeleton.c: fix alternate field handling For interlaced HDTV timings the correct field setting is FIELD_ALTERNATE, not INTERLACED. Update this template driver accordingly: - add check for the invalid combination of read() and FIELD_ALTERNATE. - in the interrupt handler set v4l2_buffer field to alternating TOP and BOTTOM. Signed-off-by: Hans Verkuil Acked-by: Sakari Ailus Signed-off-by: Mauro Carvalho Chehab --- Documentation/video4linux/v4l2-pci-skeleton.c | 39 +++++++++++++++++++-------- 1 file changed, 28 insertions(+), 11 deletions(-) diff --git a/Documentation/video4linux/v4l2-pci-skeleton.c b/Documentation/video4linux/v4l2-pci-skeleton.c index 3a1c0d2dafce..80251dc2c6cf 100644 --- a/Documentation/video4linux/v4l2-pci-skeleton.c +++ b/Documentation/video4linux/v4l2-pci-skeleton.c @@ -77,7 +77,8 @@ struct skeleton { spinlock_t qlock; struct list_head buf_list; - unsigned int sequence; + unsigned field; + unsigned sequence; }; struct skel_buffer { @@ -124,7 +125,7 @@ static const struct v4l2_dv_timings_cap skel_timings_cap = { * Interrupt handler: typically interrupts happen after a new frame has been * captured. It is the job of the handler to remove the new frame from the * internal list and give it back to the vb2 framework, updating the sequence - * counter and timestamp at the same time. + * counter, field and timestamp at the same time. */ static irqreturn_t skeleton_irq(int irq, void *dev_id) { @@ -139,8 +140,15 @@ static irqreturn_t skeleton_irq(int irq, void *dev_id) spin_lock(&skel->qlock); list_del(&new_buf->list); spin_unlock(&skel->qlock); - new_buf->vb.v4l2_buf.sequence = skel->sequence++; v4l2_get_timestamp(&new_buf->vb.v4l2_buf.timestamp); + new_buf->vb.v4l2_buf.sequence = skel->sequence++; + new_buf->vb.v4l2_buf.field = skel->field; + if (skel->format.field == V4L2_FIELD_ALTERNATE) { + if (skel->field == V4L2_FIELD_BOTTOM) + skel->field = V4L2_FIELD_TOP; + else if (skel->field == V4L2_FIELD_TOP) + skel->field = V4L2_FIELD_BOTTOM; + } vb2_buffer_done(&new_buf->vb, VB2_BUF_STATE_DONE); } #endif @@ -160,6 +168,17 @@ static int queue_setup(struct vb2_queue *vq, const struct v4l2_format *fmt, { struct skeleton *skel = vb2_get_drv_priv(vq); + skel->field = skel->format.field; + if (skel->field == V4L2_FIELD_ALTERNATE) { + /* + * You cannot use read() with FIELD_ALTERNATE since the field + * information (TOP/BOTTOM) cannot be passed back to the user. + */ + if (vb2_fileio_is_active(q)) + return -EINVAL; + skel->field = V4L2_FIELD_TOP; + } + if (vq->num_buffers + *nbuffers < 3) *nbuffers = 3 - vq->num_buffers; @@ -173,10 +192,7 @@ static int queue_setup(struct vb2_queue *vq, const struct v4l2_format *fmt, /* * Prepare the buffer for queueing to the DMA engine: check and set the - * payload size and fill in the field. Note: if the format's field is - * V4L2_FIELD_ALTERNATE, then vb->v4l2_buf.field should be set in the - * interrupt handler since that's usually where you know if the TOP or - * BOTTOM field has been captured. + * payload size. */ static int buffer_prepare(struct vb2_buffer *vb) { @@ -190,7 +206,6 @@ static int buffer_prepare(struct vb2_buffer *vb) } vb2_set_plane_payload(vb, 0, size); - vb->v4l2_buf.field = skel->format.field; return 0; } @@ -319,10 +334,12 @@ static void skeleton_fill_pix_format(struct skeleton *skel, /* HDMI input */ pix->width = skel->timings.bt.width; pix->height = skel->timings.bt.height; - if (skel->timings.bt.interlaced) - pix->field = V4L2_FIELD_INTERLACED; - else + if (skel->timings.bt.interlaced) { + pix->field = V4L2_FIELD_ALTERNATE; + pix->height /= 2; + } else { pix->field = V4L2_FIELD_NONE; + } pix->colorspace = V4L2_COLORSPACE_REC709; } -- cgit v1.2.3 From 3415a89f48dce655ae353bc70a8e292764e8e931 Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Mon, 14 Apr 2014 07:33:00 -0300 Subject: [media] vb2: add thread support In order to implement vb2 DVB support you need to be able to start a kernel thread that queues and dequeues buffers, calling a callback function for every buffer. This patch adds support for that. It's based on drivers/media/v4l2-core/videobuf-dvb.c, but with all the DVB specific stuff stripped out, thus making it much more generic. Signed-off-by: Hans Verkuil Acked-by: Laurent Pinchart Signed-off-by: Mauro Carvalho Chehab --- drivers/media/v4l2-core/videobuf2-core.c | 146 +++++++++++++++++++++++++++++++ include/media/videobuf2-core.h | 32 +++++++ 2 files changed, 178 insertions(+) diff --git a/drivers/media/v4l2-core/videobuf2-core.c b/drivers/media/v4l2-core/videobuf2-core.c index 2075bac748c0..3f0cdb150dfd 100644 --- a/drivers/media/v4l2-core/videobuf2-core.c +++ b/drivers/media/v4l2-core/videobuf2-core.c @@ -6,6 +6,9 @@ * Author: Pawel Osciak * Marek Szyprowski * + * The vb2_thread implementation was based on code from videobuf-dvb.c: + * (c) 2004 Gerd Knorr [SUSE Labs] + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation. @@ -18,6 +21,8 @@ #include #include #include +#include +#include #include #include @@ -3005,6 +3010,147 @@ size_t vb2_write(struct vb2_queue *q, const char __user *data, size_t count, } EXPORT_SYMBOL_GPL(vb2_write); +struct vb2_threadio_data { + struct task_struct *thread; + vb2_thread_fnc fnc; + void *priv; + bool stop; +}; + +static int vb2_thread(void *data) +{ + struct vb2_queue *q = data; + struct vb2_threadio_data *threadio = q->threadio; + struct vb2_fileio_data *fileio = q->fileio; + bool set_timestamp = false; + int prequeue = 0; + int index = 0; + int ret = 0; + + if (V4L2_TYPE_IS_OUTPUT(q->type)) { + prequeue = q->num_buffers; + set_timestamp = + (q->timestamp_flags & V4L2_BUF_FLAG_TIMESTAMP_MASK) == + V4L2_BUF_FLAG_TIMESTAMP_COPY; + } + + set_freezable(); + + for (;;) { + struct vb2_buffer *vb; + + /* + * Call vb2_dqbuf to get buffer back. + */ + memset(&fileio->b, 0, sizeof(fileio->b)); + fileio->b.type = q->type; + fileio->b.memory = q->memory; + if (prequeue) { + fileio->b.index = index++; + prequeue--; + } else { + call_void_qop(q, wait_finish, q); + ret = vb2_internal_dqbuf(q, &fileio->b, 0); + call_void_qop(q, wait_prepare, q); + dprintk(5, "file io: vb2_dqbuf result: %d\n", ret); + } + if (threadio->stop) + break; + if (ret) + break; + try_to_freeze(); + + vb = q->bufs[fileio->b.index]; + if (!(fileio->b.flags & V4L2_BUF_FLAG_ERROR)) + ret = threadio->fnc(vb, threadio->priv); + if (ret) + break; + call_void_qop(q, wait_finish, q); + if (set_timestamp) + v4l2_get_timestamp(&fileio->b.timestamp); + ret = vb2_internal_qbuf(q, &fileio->b); + call_void_qop(q, wait_prepare, q); + if (ret) + break; + } + + /* Hmm, linux becomes *very* unhappy without this ... */ + while (!kthread_should_stop()) { + set_current_state(TASK_INTERRUPTIBLE); + schedule(); + } + return 0; +} + +/* + * This function should not be used for anything else but the videobuf2-dvb + * support. If you think you have another good use-case for this, then please + * contact the linux-media mailinglist first. + */ +int vb2_thread_start(struct vb2_queue *q, vb2_thread_fnc fnc, void *priv, + const char *thread_name) +{ + struct vb2_threadio_data *threadio; + int ret = 0; + + if (q->threadio) + return -EBUSY; + if (vb2_is_busy(q)) + return -EBUSY; + if (WARN_ON(q->fileio)) + return -EBUSY; + + threadio = kzalloc(sizeof(*threadio), GFP_KERNEL); + if (threadio == NULL) + return -ENOMEM; + threadio->fnc = fnc; + threadio->priv = priv; + + ret = __vb2_init_fileio(q, !V4L2_TYPE_IS_OUTPUT(q->type)); + dprintk(3, "file io: vb2_init_fileio result: %d\n", ret); + if (ret) + goto nomem; + q->threadio = threadio; + threadio->thread = kthread_run(vb2_thread, q, "vb2-%s", thread_name); + if (IS_ERR(threadio->thread)) { + ret = PTR_ERR(threadio->thread); + threadio->thread = NULL; + goto nothread; + } + return 0; + +nothread: + __vb2_cleanup_fileio(q); +nomem: + kfree(threadio); + return ret; +} +EXPORT_SYMBOL_GPL(vb2_thread_start); + +int vb2_thread_stop(struct vb2_queue *q) +{ + struct vb2_threadio_data *threadio = q->threadio; + struct vb2_fileio_data *fileio = q->fileio; + int err; + + if (threadio == NULL) + return 0; + call_void_qop(q, wait_finish, q); + threadio->stop = true; + vb2_internal_streamoff(q, q->type); + call_void_qop(q, wait_prepare, q); + q->fileio = NULL; + fileio->req.count = 0; + vb2_reqbufs(q, &fileio->req); + kfree(fileio); + err = kthread_stop(threadio->thread); + threadio->thread = NULL; + kfree(threadio); + q->fileio = NULL; + q->threadio = NULL; + return err; +} +EXPORT_SYMBOL_GPL(vb2_thread_stop); /* * The following functions are not part of the vb2 core API, but are helper diff --git a/include/media/videobuf2-core.h b/include/media/videobuf2-core.h index b1859f6953b2..46e76096c22a 100644 --- a/include/media/videobuf2-core.h +++ b/include/media/videobuf2-core.h @@ -20,6 +20,7 @@ struct vb2_alloc_ctx; struct vb2_fileio_data; +struct vb2_threadio_data; /** * struct vb2_mem_ops - memory handling/memory allocator operations @@ -375,6 +376,7 @@ struct v4l2_fh; * @start_streaming_called: start_streaming() was called successfully and we * started streaming. * @fileio: file io emulator internal data, used only if emulator is active + * @threadio: thread io internal data, used only if thread is active */ struct vb2_queue { enum v4l2_buf_type type; @@ -411,6 +413,7 @@ struct vb2_queue { unsigned int start_streaming_called:1; struct vb2_fileio_data *fileio; + struct vb2_threadio_data *threadio; #ifdef CONFIG_VIDEO_ADV_DEBUG /* @@ -461,6 +464,35 @@ size_t vb2_read(struct vb2_queue *q, char __user *data, size_t count, loff_t *ppos, int nonblock); size_t vb2_write(struct vb2_queue *q, const char __user *data, size_t count, loff_t *ppos, int nonblock); +/** + * vb2_thread_fnc - callback function for use with vb2_thread + * + * This is called whenever a buffer is dequeued in the thread. + */ +typedef int (*vb2_thread_fnc)(struct vb2_buffer *vb, void *priv); + +/** + * vb2_thread_start() - start a thread for the given queue. + * @q: videobuf queue + * @fnc: callback function + * @priv: priv pointer passed to the callback function + * @thread_name:the name of the thread. This will be prefixed with "vb2-". + * + * This starts a thread that will queue and dequeue until an error occurs + * or @vb2_thread_stop is called. + * + * This function should not be used for anything else but the videobuf2-dvb + * support. If you think you have another good use-case for this, then please + * contact the linux-media mailinglist first. + */ +int vb2_thread_start(struct vb2_queue *q, vb2_thread_fnc fnc, void *priv, + const char *thread_name); + +/** + * vb2_thread_stop() - stop the thread for the given queue. + * @q: videobuf queue + */ +int vb2_thread_stop(struct vb2_queue *q); /** * vb2_is_streaming() - return streaming status of the queue -- cgit v1.2.3 From cd9ae5fe47dfb9820976c3c38c70f4b07a5a1c36 Mon Sep 17 00:00:00 2001 From: Nadav Amit Date: Fri, 4 Apr 2014 06:31:04 +0300 Subject: KVM: x86: Fix page-tables reserved bits KVM does not handle the reserved bits of x86 page tables correctly: In PAE, bits 5:8 are reserved in the PDPTE. In IA-32e, bit 8 is not reserved. Signed-off-by: Nadav Amit Signed-off-by: Marcelo Tosatti --- arch/x86/kvm/mmu.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c index 813d31038b93..668ae5916de9 100644 --- a/arch/x86/kvm/mmu.c +++ b/arch/x86/kvm/mmu.c @@ -3538,7 +3538,7 @@ static void reset_rsvds_bits_mask(struct kvm_vcpu *vcpu, case PT32E_ROOT_LEVEL: context->rsvd_bits_mask[0][2] = rsvd_bits(maxphyaddr, 63) | - rsvd_bits(7, 8) | rsvd_bits(1, 2); /* PDPTE */ + rsvd_bits(5, 8) | rsvd_bits(1, 2); /* PDPTE */ context->rsvd_bits_mask[0][1] = exb_bit_rsvd | rsvd_bits(maxphyaddr, 62); /* PDE */ context->rsvd_bits_mask[0][0] = exb_bit_rsvd | @@ -3550,9 +3550,9 @@ static void reset_rsvds_bits_mask(struct kvm_vcpu *vcpu, break; case PT64_ROOT_LEVEL: context->rsvd_bits_mask[0][3] = exb_bit_rsvd | - rsvd_bits(maxphyaddr, 51) | rsvd_bits(7, 8); + rsvd_bits(maxphyaddr, 51) | rsvd_bits(7, 7); context->rsvd_bits_mask[0][2] = exb_bit_rsvd | - rsvd_bits(maxphyaddr, 51) | rsvd_bits(7, 8); + rsvd_bits(maxphyaddr, 51) | rsvd_bits(7, 7); context->rsvd_bits_mask[0][1] = exb_bit_rsvd | rsvd_bits(maxphyaddr, 51); context->rsvd_bits_mask[0][0] = exb_bit_rsvd | -- cgit v1.2.3 From 701b57ee3387b8e3749845b02310b5625fbd8da0 Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Wed, 9 Oct 2013 08:01:05 -0300 Subject: [media] vb2: Add videobuf2-dvb support With the new vb2_thread_start/stop core code it is very easy to implement videobuf2-dvb. This should simplify converting existing videobuf drivers to vb2. Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/v4l2-core/Kconfig | 4 + drivers/media/v4l2-core/Makefile | 1 + drivers/media/v4l2-core/videobuf2-dvb.c | 336 ++++++++++++++++++++++++++++++++ include/media/videobuf2-dvb.h | 58 ++++++ 4 files changed, 399 insertions(+) create mode 100644 drivers/media/v4l2-core/videobuf2-dvb.c create mode 100644 include/media/videobuf2-dvb.h diff --git a/drivers/media/v4l2-core/Kconfig b/drivers/media/v4l2-core/Kconfig index 2189bfb2e828..9ca0f8d59a14 100644 --- a/drivers/media/v4l2-core/Kconfig +++ b/drivers/media/v4l2-core/Kconfig @@ -83,3 +83,7 @@ config VIDEOBUF2_DMA_SG #depends on HAS_DMA select VIDEOBUF2_CORE select VIDEOBUF2_MEMOPS + +config VIDEOBUF2_DVB + tristate + select VIDEOBUF2_CORE diff --git a/drivers/media/v4l2-core/Makefile b/drivers/media/v4l2-core/Makefile index c6ae7bad951e..63d29f27538c 100644 --- a/drivers/media/v4l2-core/Makefile +++ b/drivers/media/v4l2-core/Makefile @@ -33,6 +33,7 @@ obj-$(CONFIG_VIDEOBUF2_MEMOPS) += videobuf2-memops.o obj-$(CONFIG_VIDEOBUF2_VMALLOC) += videobuf2-vmalloc.o obj-$(CONFIG_VIDEOBUF2_DMA_CONTIG) += videobuf2-dma-contig.o obj-$(CONFIG_VIDEOBUF2_DMA_SG) += videobuf2-dma-sg.o +obj-$(CONFIG_VIDEOBUF2_DVB) += videobuf2-dvb.o ccflags-y += -I$(srctree)/drivers/media/dvb-core ccflags-y += -I$(srctree)/drivers/media/dvb-frontends diff --git a/drivers/media/v4l2-core/videobuf2-dvb.c b/drivers/media/v4l2-core/videobuf2-dvb.c new file mode 100644 index 000000000000..d09269846b7e --- /dev/null +++ b/drivers/media/v4l2-core/videobuf2-dvb.c @@ -0,0 +1,336 @@ +/* + * + * some helper function for simple DVB cards which simply DMA the + * complete transport stream and let the computer sort everything else + * (i.e. we are using the software demux, ...). Also uses the + * video-buf to manage DMA buffers. + * + * (c) 2004 Gerd Knorr [SUSE Labs] + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + */ + +#include +#include +#include +#include + +#include + +/* ------------------------------------------------------------------ */ + +MODULE_AUTHOR("Gerd Knorr [SuSE Labs]"); +MODULE_LICENSE("GPL"); + +/* ------------------------------------------------------------------ */ + +static int dvb_fnc(struct vb2_buffer *vb, void *priv) +{ + struct vb2_dvb *dvb = priv; + + dvb_dmx_swfilter(&dvb->demux, vb2_plane_vaddr(vb, 0), + vb2_get_plane_payload(vb, 0)); + return 0; +} + +static int vb2_dvb_start_feed(struct dvb_demux_feed *feed) +{ + struct dvb_demux *demux = feed->demux; + struct vb2_dvb *dvb = demux->priv; + int rc = 0; + + if (!demux->dmx.frontend) + return -EINVAL; + + mutex_lock(&dvb->lock); + dvb->nfeeds++; + + if (!dvb->dvbq.threadio) { + rc = vb2_thread_start(&dvb->dvbq, dvb_fnc, dvb, dvb->name); + if (rc) + dvb->nfeeds--; + } + if (!rc) + rc = dvb->nfeeds; + mutex_unlock(&dvb->lock); + return rc; +} + +static int vb2_dvb_stop_feed(struct dvb_demux_feed *feed) +{ + struct dvb_demux *demux = feed->demux; + struct vb2_dvb *dvb = demux->priv; + int err = 0; + + mutex_lock(&dvb->lock); + dvb->nfeeds--; + if (0 == dvb->nfeeds) + err = vb2_thread_stop(&dvb->dvbq); + mutex_unlock(&dvb->lock); + return err; +} + +static int vb2_dvb_register_adapter(struct vb2_dvb_frontends *fe, + struct module *module, + void *adapter_priv, + struct device *device, + char *adapter_name, + short *adapter_nr, + int mfe_shared) +{ + int result; + + mutex_init(&fe->lock); + + /* register adapter */ + result = dvb_register_adapter(&fe->adapter, adapter_name, module, + device, adapter_nr); + if (result < 0) { + pr_warn("%s: dvb_register_adapter failed (errno = %d)\n", + adapter_name, result); + } + fe->adapter.priv = adapter_priv; + fe->adapter.mfe_shared = mfe_shared; + + return result; +} + +static int vb2_dvb_register_frontend(struct dvb_adapter *adapter, + struct vb2_dvb *dvb) +{ + int result; + + /* register frontend */ + result = dvb_register_frontend(adapter, dvb->frontend); + if (result < 0) { + pr_warn("%s: dvb_register_frontend failed (errno = %d)\n", + dvb->name, result); + goto fail_frontend; + } + + /* register demux stuff */ + dvb->demux.dmx.capabilities = + DMX_TS_FILTERING | DMX_SECTION_FILTERING | + DMX_MEMORY_BASED_FILTERING; + dvb->demux.priv = dvb; + dvb->demux.filternum = 256; + dvb->demux.feednum = 256; + dvb->demux.start_feed = vb2_dvb_start_feed; + dvb->demux.stop_feed = vb2_dvb_stop_feed; + result = dvb_dmx_init(&dvb->demux); + if (result < 0) { + pr_warn("%s: dvb_dmx_init failed (errno = %d)\n", + dvb->name, result); + goto fail_dmx; + } + + dvb->dmxdev.filternum = 256; + dvb->dmxdev.demux = &dvb->demux.dmx; + dvb->dmxdev.capabilities = 0; + result = dvb_dmxdev_init(&dvb->dmxdev, adapter); + + if (result < 0) { + pr_warn("%s: dvb_dmxdev_init failed (errno = %d)\n", + dvb->name, result); + goto fail_dmxdev; + } + + dvb->fe_hw.source = DMX_FRONTEND_0; + result = dvb->demux.dmx.add_frontend(&dvb->demux.dmx, &dvb->fe_hw); + if (result < 0) { + pr_warn("%s: add_frontend failed (DMX_FRONTEND_0, errno = %d)\n", + dvb->name, result); + goto fail_fe_hw; + } + + dvb->fe_mem.source = DMX_MEMORY_FE; + result = dvb->demux.dmx.add_frontend(&dvb->demux.dmx, &dvb->fe_mem); + if (result < 0) { + pr_warn("%s: add_frontend failed (DMX_MEMORY_FE, errno = %d)\n", + dvb->name, result); + goto fail_fe_mem; + } + + result = dvb->demux.dmx.connect_frontend(&dvb->demux.dmx, &dvb->fe_hw); + if (result < 0) { + pr_warn("%s: connect_frontend failed (errno = %d)\n", + dvb->name, result); + goto fail_fe_conn; + } + + /* register network adapter */ + result = dvb_net_init(adapter, &dvb->net, &dvb->demux.dmx); + if (result < 0) { + pr_warn("%s: dvb_net_init failed (errno = %d)\n", + dvb->name, result); + goto fail_fe_conn; + } + return 0; + +fail_fe_conn: + dvb->demux.dmx.remove_frontend(&dvb->demux.dmx, &dvb->fe_mem); +fail_fe_mem: + dvb->demux.dmx.remove_frontend(&dvb->demux.dmx, &dvb->fe_hw); +fail_fe_hw: + dvb_dmxdev_release(&dvb->dmxdev); +fail_dmxdev: + dvb_dmx_release(&dvb->demux); +fail_dmx: + dvb_unregister_frontend(dvb->frontend); +fail_frontend: + dvb_frontend_detach(dvb->frontend); + dvb->frontend = NULL; + + return result; +} + +/* ------------------------------------------------------------------ */ +/* Register a single adapter and one or more frontends */ +int vb2_dvb_register_bus(struct vb2_dvb_frontends *f, + struct module *module, + void *adapter_priv, + struct device *device, + short *adapter_nr, + int mfe_shared) +{ + struct list_head *list, *q; + struct vb2_dvb_frontend *fe; + int res; + + fe = vb2_dvb_get_frontend(f, 1); + if (!fe) { + pr_warn("Unable to register the adapter which has no frontends\n"); + return -EINVAL; + } + + /* Bring up the adapter */ + res = vb2_dvb_register_adapter(f, module, adapter_priv, device, + fe->dvb.name, adapter_nr, mfe_shared); + if (res < 0) { + pr_warn("vb2_dvb_register_adapter failed (errno = %d)\n", res); + return res; + } + + /* Attach all of the frontends to the adapter */ + mutex_lock(&f->lock); + list_for_each_safe(list, q, &f->felist) { + fe = list_entry(list, struct vb2_dvb_frontend, felist); + res = vb2_dvb_register_frontend(&f->adapter, &fe->dvb); + if (res < 0) { + pr_warn("%s: vb2_dvb_register_frontend failed (errno = %d)\n", + fe->dvb.name, res); + goto err; + } + } + mutex_unlock(&f->lock); + return 0; + +err: + mutex_unlock(&f->lock); + vb2_dvb_unregister_bus(f); + return res; +} +EXPORT_SYMBOL(vb2_dvb_register_bus); + +void vb2_dvb_unregister_bus(struct vb2_dvb_frontends *f) +{ + vb2_dvb_dealloc_frontends(f); + + dvb_unregister_adapter(&f->adapter); +} +EXPORT_SYMBOL(vb2_dvb_unregister_bus); + +struct vb2_dvb_frontend *vb2_dvb_get_frontend( + struct vb2_dvb_frontends *f, int id) +{ + struct list_head *list, *q; + struct vb2_dvb_frontend *fe, *ret = NULL; + + mutex_lock(&f->lock); + + list_for_each_safe(list, q, &f->felist) { + fe = list_entry(list, struct vb2_dvb_frontend, felist); + if (fe->id == id) { + ret = fe; + break; + } + } + + mutex_unlock(&f->lock); + + return ret; +} +EXPORT_SYMBOL(vb2_dvb_get_frontend); + +int vb2_dvb_find_frontend(struct vb2_dvb_frontends *f, + struct dvb_frontend *p) +{ + struct list_head *list, *q; + struct vb2_dvb_frontend *fe = NULL; + int ret = 0; + + mutex_lock(&f->lock); + + list_for_each_safe(list, q, &f->felist) { + fe = list_entry(list, struct vb2_dvb_frontend, felist); + if (fe->dvb.frontend == p) { + ret = fe->id; + break; + } + } + + mutex_unlock(&f->lock); + + return ret; +} +EXPORT_SYMBOL(vb2_dvb_find_frontend); + +struct vb2_dvb_frontend *vb2_dvb_alloc_frontend( + struct vb2_dvb_frontends *f, int id) +{ + struct vb2_dvb_frontend *fe; + + fe = kzalloc(sizeof(struct vb2_dvb_frontend), GFP_KERNEL); + if (fe == NULL) + return NULL; + + fe->id = id; + mutex_init(&fe->dvb.lock); + + mutex_lock(&f->lock); + list_add_tail(&fe->felist, &f->felist); + mutex_unlock(&f->lock); + return fe; +} +EXPORT_SYMBOL(vb2_dvb_alloc_frontend); + +void vb2_dvb_dealloc_frontends(struct vb2_dvb_frontends *f) +{ + struct list_head *list, *q; + struct vb2_dvb_frontend *fe; + + mutex_lock(&f->lock); + list_for_each_safe(list, q, &f->felist) { + fe = list_entry(list, struct vb2_dvb_frontend, felist); + if (fe->dvb.net.dvbdev) { + dvb_net_release(&fe->dvb.net); + fe->dvb.demux.dmx.remove_frontend(&fe->dvb.demux.dmx, + &fe->dvb.fe_mem); + fe->dvb.demux.dmx.remove_frontend(&fe->dvb.demux.dmx, + &fe->dvb.fe_hw); + dvb_dmxdev_release(&fe->dvb.dmxdev); + dvb_dmx_release(&fe->dvb.demux); + dvb_unregister_frontend(fe->dvb.frontend); + } + if (fe->dvb.frontend) + /* always allocated, may have been reset */ + dvb_frontend_detach(fe->dvb.frontend); + list_del(list); /* remove list entry */ + kfree(fe); /* free frontend allocation */ + } + mutex_unlock(&f->lock); +} +EXPORT_SYMBOL(vb2_dvb_dealloc_frontends); diff --git a/include/media/videobuf2-dvb.h b/include/media/videobuf2-dvb.h new file mode 100644 index 000000000000..8f61456f1394 --- /dev/null +++ b/include/media/videobuf2-dvb.h @@ -0,0 +1,58 @@ +#ifndef _VIDEOBUF2_DVB_H_ +#define _VIDEOBUF2_DVB_H_ + +#include +#include +#include +#include +#include +#include + +struct vb2_dvb { + /* filling that the job of the driver */ + char *name; + struct dvb_frontend *frontend; + struct vb2_queue dvbq; + + /* video-buf-dvb state info */ + struct mutex lock; + int nfeeds; + + /* vb2_dvb_(un)register manages this */ + struct dvb_demux demux; + struct dmxdev dmxdev; + struct dmx_frontend fe_hw; + struct dmx_frontend fe_mem; + struct dvb_net net; +}; + +struct vb2_dvb_frontend { + struct list_head felist; + int id; + struct vb2_dvb dvb; +}; + +struct vb2_dvb_frontends { + struct list_head felist; + struct mutex lock; + struct dvb_adapter adapter; + int active_fe_id; /* Indicates which frontend in the felist is in use */ + int gate; /* Frontend with gate control 0=!MFE,1=fe0,2=fe1 etc */ +}; + +int vb2_dvb_register_bus(struct vb2_dvb_frontends *f, + struct module *module, + void *adapter_priv, + struct device *device, + short *adapter_nr, + int mfe_shared); + +void vb2_dvb_unregister_bus(struct vb2_dvb_frontends *f); + +struct vb2_dvb_frontend *vb2_dvb_alloc_frontend(struct vb2_dvb_frontends *f, int id); +void vb2_dvb_dealloc_frontends(struct vb2_dvb_frontends *f); + +struct vb2_dvb_frontend *vb2_dvb_get_frontend(struct vb2_dvb_frontends *f, int id); +int vb2_dvb_find_frontend(struct vb2_dvb_frontends *f, struct dvb_frontend *p); + +#endif /* _VIDEOBUF2_DVB_H_ */ -- cgit v1.2.3 From 9260764cb3daea8738ae308f8a8ecb31507c0d6f Mon Sep 17 00:00:00 2001 From: Stephen Warren Date: Wed, 16 Apr 2014 10:34:18 -0600 Subject: ARM: tegra: fix Jetson TK1 SD card supply Regulator vddio_sdmmc3 provides the Tegra<->SD IO voltage, not the card core supply voltage. That is, it provides vqmmc, not vmmc. Fix the DT to correctly reflect this. Reported-by: Andrew Bresticker Signed-off-by: Stephen Warren --- arch/arm/boot/dts/tegra124-jetson-tk1.dts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm/boot/dts/tegra124-jetson-tk1.dts b/arch/arm/boot/dts/tegra124-jetson-tk1.dts index ae5c750dc515..dd3076d94727 100644 --- a/arch/arm/boot/dts/tegra124-jetson-tk1.dts +++ b/arch/arm/boot/dts/tegra124-jetson-tk1.dts @@ -1611,7 +1611,7 @@ cd-gpios = <&gpio TEGRA_GPIO(V, 2) GPIO_ACTIVE_LOW>; power-gpios = <&gpio TEGRA_GPIO(R, 0) GPIO_ACTIVE_HIGH>; bus-width = <4>; - vmmc-supply = <&vddio_sdmmc3>; + vqmmc-supply = <&vddio_sdmmc3>; }; /* eMMC */ -- cgit v1.2.3 From c7fe76721eb546d13fd5576cf135c414136ae4ff Mon Sep 17 00:00:00 2001 From: Stephen Warren Date: Tue, 15 Apr 2014 16:27:01 -0600 Subject: ARM: tegra: make Venice's +3.3V_RUN regulator always on This regulator supplies power to pretty much everything on the board, so it doesn't make sense to allow it to turn off. Mark it boot-on and always-on so it doesn't get turned off. Without this, I see issues with the eMMC device; it can't be correctly detected during boot. Signed-off-by: Stephen Warren --- arch/arm/boot/dts/tegra124-venice2.dts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/arm/boot/dts/tegra124-venice2.dts b/arch/arm/boot/dts/tegra124-venice2.dts index c17283c04598..87537f499875 100644 --- a/arch/arm/boot/dts/tegra124-venice2.dts +++ b/arch/arm/boot/dts/tegra124-venice2.dts @@ -1060,6 +1060,8 @@ regulator-name = "+3.3V_RUN"; regulator-min-microvolt = <3300000>; regulator-max-microvolt = <3300000>; + regulator-always-on; + regulator-boot-on; gpio = <&pmic 1 GPIO_ACTIVE_HIGH>; enable-active-high; vin-supply = <&vdd_3v3_sys>; -- cgit v1.2.3 From 49228caee067854656778978c633f37815f0538e Mon Sep 17 00:00:00 2001 From: Andrew Bresticker Date: Wed, 16 Apr 2014 16:08:39 -0700 Subject: ARM: tegra: fix Venice2 SD card VQMMC supply VDDIO_SDMMC3 is the VQMMC (I/O) supply, not the VMMC (core) supply, for the SD slot on Venice2. Signed-off-by: Andrew Bresticker Signed-off-by: Stephen Warren --- arch/arm/boot/dts/tegra124-venice2.dts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm/boot/dts/tegra124-venice2.dts b/arch/arm/boot/dts/tegra124-venice2.dts index 87537f499875..6770e2bdf226 100644 --- a/arch/arm/boot/dts/tegra124-venice2.dts +++ b/arch/arm/boot/dts/tegra124-venice2.dts @@ -933,7 +933,7 @@ power-gpios = <&gpio TEGRA_GPIO(R, 0) GPIO_ACTIVE_HIGH>; status = "okay"; bus-width = <4>; - vmmc-supply = <&vddio_sdmmc3>; + vqmmc-supply = <&vddio_sdmmc3>; }; sdhci@0,700b0600 { -- cgit v1.2.3 From 67c20cfbce53cf6df28681939d9a9621d2a85dfc Mon Sep 17 00:00:00 2001 From: Kristina MartÅ¡enko Date: Tue, 25 Mar 2014 01:45:09 +0200 Subject: staging: goldfish: switch from spinlock to mutex MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use a mutex instead of a spinlock in goldfish_nand.c, as suggested by the TODO list. Signed-off-by: Kristina MartÅ¡enko Reviewed-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/goldfish/README | 1 - drivers/staging/goldfish/goldfish_nand.c | 15 +++++++-------- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/drivers/staging/goldfish/README b/drivers/staging/goldfish/README index 93d65b0f0f83..183af0053234 100644 --- a/drivers/staging/goldfish/README +++ b/drivers/staging/goldfish/README @@ -5,7 +5,6 @@ Audio NAND ---- -- Switch from spinlock to mutex - Remove excess checking of parameters in calls - Use dma coherent memory not kmalloc/__pa for the memory (this is just a cleanliness issue not a correctness one) diff --git a/drivers/staging/goldfish/goldfish_nand.c b/drivers/staging/goldfish/goldfish_nand.c index eca0873098cd..7f606f7dec69 100644 --- a/drivers/staging/goldfish/goldfish_nand.c +++ b/drivers/staging/goldfish/goldfish_nand.c @@ -24,13 +24,14 @@ #include #include #include +#include #include #include "goldfish_nand_reg.h" struct goldfish_nand { - spinlock_t lock; + struct mutex lock; unsigned char __iomem *base; struct cmd_params *cmd_params; size_t mtd_count; @@ -77,10 +78,9 @@ static u32 goldfish_nand_cmd(struct mtd_info *mtd, enum nand_cmd cmd, { struct goldfish_nand *nand = mtd->priv; u32 rv; - unsigned long irq_flags; unsigned char __iomem *base = nand->base; - spin_lock_irqsave(&nand->lock, irq_flags); + mutex_lock(&nand->lock); if (goldfish_nand_cmd_with_params(mtd, cmd, addr, len, ptr, &rv)) { writel(mtd - nand->mtd, base + NAND_DEV); writel((u32)(addr >> 32), base + NAND_ADDR_HIGH); @@ -90,7 +90,7 @@ static u32 goldfish_nand_cmd(struct mtd_info *mtd, enum nand_cmd cmd, writel(cmd, base + NAND_COMMAND); rv = readl(base + NAND_RESULT); } - spin_unlock_irqrestore(&nand->lock, irq_flags); + mutex_unlock(&nand->lock); return rv; } @@ -307,12 +307,11 @@ static int goldfish_nand_init_device(struct platform_device *pdev, u32 name_len; u32 result; u32 flags; - unsigned long irq_flags; unsigned char __iomem *base = nand->base; struct mtd_info *mtd = &nand->mtd[id]; char *name; - spin_lock_irqsave(&nand->lock, irq_flags); + mutex_lock(&nand->lock); writel(id, base + NAND_DEV); flags = readl(base + NAND_DEV_FLAGS); name_len = readl(base + NAND_DEV_NAME_LEN); @@ -329,7 +328,7 @@ static int goldfish_nand_init_device(struct platform_device *pdev, "goldfish nand dev%d: size %llx, page %d, extra %d, erase %d\n", id, mtd->size, mtd->writesize, mtd->oobsize, mtd->erasesize); - spin_unlock_irqrestore(&nand->lock, irq_flags); + mutex_unlock(&nand->lock); mtd->priv = nand; @@ -405,7 +404,7 @@ static int goldfish_nand_probe(struct platform_device *pdev) if (nand == NULL) return -ENOMEM; - spin_lock_init(&nand->lock); + mutex_init(&nand->lock); nand->base = base; nand->mtd_count = num_dev; platform_set_drvdata(pdev, nand); -- cgit v1.2.3 From ef323812c9cfd5837afab13dde846bf208eb4cc3 Mon Sep 17 00:00:00 2001 From: Garret Kelly Date: Sun, 6 Apr 2014 23:47:31 -0400 Subject: staging: goldfish: Fix missing blank lines Fix two instances of the following checkpatch warning: WARNING: Missing a blank line after declarations Signed-off-by: Garret Kelly Signed-off-by: Greg Kroah-Hartman --- drivers/staging/goldfish/goldfish_audio.c | 1 + drivers/staging/goldfish/goldfish_nand.c | 1 + 2 files changed, 2 insertions(+) diff --git a/drivers/staging/goldfish/goldfish_audio.c b/drivers/staging/goldfish/goldfish_audio.c index f96dcec740ae..aca980ec3696 100644 --- a/drivers/staging/goldfish/goldfish_audio.c +++ b/drivers/staging/goldfish/goldfish_audio.c @@ -147,6 +147,7 @@ static ssize_t goldfish_audio_write(struct file *fp, const char __user *buf, while (count > 0) { ssize_t copy = count; + if (copy > WRITE_BUFFER_SIZE) copy = WRITE_BUFFER_SIZE; wait_event_interruptible(data->wait, (data->buffer_status & diff --git a/drivers/staging/goldfish/goldfish_nand.c b/drivers/staging/goldfish/goldfish_nand.c index 7f606f7dec69..2a292df71e7c 100644 --- a/drivers/staging/goldfish/goldfish_nand.c +++ b/drivers/staging/goldfish/goldfish_nand.c @@ -424,6 +424,7 @@ static int goldfish_nand_remove(struct platform_device *pdev) { struct goldfish_nand *nand = platform_get_drvdata(pdev); int i; + for (i = 0; i < nand->mtd_count; i++) { if (nand->mtd[i].name) mtd_device_unregister(&nand->mtd[i]); -- cgit v1.2.3 From 53d719f6a907ad7e2ca449fdaf9c9e175a623350 Mon Sep 17 00:00:00 2001 From: Seunghun Lee Date: Thu, 17 Apr 2014 00:39:44 +0900 Subject: staging: android: uapi: fix coding style This patch fix checkpatch.pl warning and errors. Signed-off-by: Seunghun Lee Signed-off-by: Greg Kroah-Hartman --- drivers/staging/android/uapi/ion.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/staging/android/uapi/ion.h b/drivers/staging/android/uapi/ion.h index f09e7c154d69..6aa495673370 100644 --- a/drivers/staging/android/uapi/ion.h +++ b/drivers/staging/android/uapi/ion.h @@ -27,12 +27,12 @@ typedef int ion_user_handle_t; * @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 + * 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 + * is used to identify the heaps, so only 32 + * total heap types are supported */ enum ion_heap_type { ION_HEAP_TYPE_SYSTEM, @@ -50,7 +50,7 @@ enum ion_heap_type { #define ION_HEAP_CARVEOUT_MASK (1 << ION_HEAP_TYPE_CARVEOUT) #define ION_HEAP_TYPE_DMA_MASK (1 << ION_HEAP_TYPE_DMA) -#define ION_NUM_HEAP_IDS sizeof(unsigned int) * 8 +#define ION_NUM_HEAP_IDS (sizeof(unsigned int) * 8) /** * allocation flags - the lower 16 bits are used by core ion, the upper 16 @@ -78,7 +78,7 @@ enum ion_heap_type { * @align: required alignment 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 + * @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 -- cgit v1.2.3 From 36c89c0a6bebafdde13099229dfe541380ce7612 Mon Sep 17 00:00:00 2001 From: Mathieu Maret Date: Tue, 15 Apr 2014 12:03:05 +0200 Subject: staging: binder: add __user annotation in binder.c Add __user to binder_version to correct sparse warning. Reduce line size to fit to coding style. Signed-off-by: Mathieu Maret Signed-off-by: Greg Kroah-Hartman --- drivers/staging/android/binder.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/staging/android/binder.c b/drivers/staging/android/binder.c index cfe4bc8f05cb..1f5e2499ac1b 100644 --- a/drivers/staging/android/binder.c +++ b/drivers/staging/android/binder.c @@ -2683,16 +2683,20 @@ static long binder_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) binder_free_thread(proc, thread); thread = NULL; break; - case BINDER_VERSION: + case BINDER_VERSION: { + struct binder_version __user *ver = ubuf; + if (size != sizeof(struct binder_version)) { ret = -EINVAL; goto err; } - if (put_user(BINDER_CURRENT_PROTOCOL_VERSION, &((struct binder_version *)ubuf)->protocol_version)) { + if (put_user(BINDER_CURRENT_PROTOCOL_VERSION, + &ver->protocol_version)) { ret = -EINVAL; goto err; } break; + } default: ret = -EINVAL; goto err; -- cgit v1.2.3 From 22bfe7e89c9d070d9a8497ae239d4ef76045ff08 Mon Sep 17 00:00:00 2001 From: Julian Gindi Date: Sun, 13 Apr 2014 18:38:31 -0400 Subject: bcm: Fixing a few checkpatch issues in InterfaceMisc.h Just cleaned up a few issues presented by checkpatch in InterfaceMisc.h. I converted some spaces to tabs, and removed unnecessary whitespace. The kernel version I am using linux-next-20140411. Signed-off-by: Julian Gindi Signed-off-by: Greg Kroah-Hartman --- drivers/staging/bcm/InterfaceMisc.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/staging/bcm/InterfaceMisc.h b/drivers/staging/bcm/InterfaceMisc.h index bce6869a7478..efb686046153 100644 --- a/drivers/staging/bcm/InterfaceMisc.h +++ b/drivers/staging/bcm/InterfaceMisc.h @@ -14,13 +14,13 @@ InterfaceWRM(struct bcm_interface_adapter *psIntfAdapter, INT len); -int InterfaceFileDownload( PVOID psIntfAdapter, - struct file *flp, - unsigned int on_chip_loc); +int InterfaceFileDownload(PVOID psIntfAdapter, + struct file *flp, + unsigned int on_chip_loc); -int InterfaceFileReadbackFromChip( PVOID psIntfAdapter, - struct file *flp, - unsigned int on_chip_loc); +int InterfaceFileReadbackFromChip(PVOID psIntfAdapter, + struct file *flp, + unsigned int on_chip_loc); int BcmRDM(PVOID arg, -- cgit v1.2.3 From d766b4b50ae0c8156783089c69821072ef3c2f2d Mon Sep 17 00:00:00 2001 From: Masanari Iida Date: Fri, 21 Mar 2014 23:42:52 +0900 Subject: staging: lustre: Fix typo in lustre/include Fix spelling typo in comments within lustre/include. Signed-off-by: Masanari Iida Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/include/linux/libcfs/libcfs_cpu.h | 4 ++-- drivers/staging/lustre/include/linux/libcfs/libcfs_crypto.h | 2 +- drivers/staging/lustre/include/linux/libcfs/libcfs_hash.h | 8 ++++---- drivers/staging/lustre/include/linux/lnet/lib-lnet.h | 2 +- drivers/staging/lustre/include/linux/lnet/lib-types.h | 6 +++--- drivers/staging/lustre/include/linux/lnet/lnetst.h | 2 +- drivers/staging/lustre/include/linux/lnet/types.h | 2 +- 7 files changed, 13 insertions(+), 13 deletions(-) diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_cpu.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_cpu.h index c87efb49ebc2..d116fdfc5c41 100644 --- a/drivers/staging/lustre/include/linux/libcfs/libcfs_cpu.h +++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_cpu.h @@ -128,7 +128,7 @@ struct cfs_cpt_table *cfs_cpt_table_alloc(unsigned int ncpt); int cfs_cpt_number(struct cfs_cpt_table *cptab); /** - * return number of HW cores or hypter-threadings in a CPU partition \a cpt + * return number of HW cores or hyper-threadings in a CPU partition \a cpt */ int cfs_cpt_weight(struct cfs_cpt_table *cptab, int cpt); /** @@ -152,7 +152,7 @@ int cfs_cpt_of_cpu(struct cfs_cpt_table *cptab, int cpu); */ int cfs_cpt_bind(struct cfs_cpt_table *cptab, int cpt); /** - * add \a cpu to CPU partion @cpt of \a cptab, return 1 for success, + * add \a cpu to CPU partition @cpt of \a cptab, return 1 for success, * otherwise 0 is returned */ int cfs_cpt_set_cpu(struct cfs_cpt_table *cptab, int cpt, int cpu); diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_crypto.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_crypto.h index 776e9c0e48c1..9e610a9ce51f 100644 --- a/drivers/staging/lustre/include/linux/libcfs/libcfs_crypto.h +++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_crypto.h @@ -31,7 +31,7 @@ struct cfs_crypto_hash_type { char *cht_name; /**< hash algorithm name, equal to * format name for crypto api */ - unsigned int cht_key; /**< init key by default (vaild for + unsigned int cht_key; /**< init key by default (valid for * 4 bytes context like crc32, adler */ unsigned int cht_size; /**< hash digest size */ }; diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_hash.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_hash.h index e5d5db255622..954164361ca4 100644 --- a/drivers/staging/lustre/include/linux/libcfs/libcfs_hash.h +++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_hash.h @@ -59,8 +59,8 @@ /* * Ideally we would use HAVE_HASH_LONG for this, but on linux we configure * the linux kernel and user space at the same time, so we need to differentiate - * between them explicitely. If this is not needed on other architectures, then - * we'll need to move the functions to archi specific headers. + * between them explicitly. If this is not needed on other architectures, then + * we'll need to move the functions to architecture specific headers. */ #include @@ -86,7 +86,7 @@ union cfs_hash_lock { /** * cfs_hash_bucket is a container of: - * - lock, couter ... + * - lock, counter ... * - array of hash-head starting from hsb_head[0], hash-head can be one of * . cfs_hash_head_t * . cfs_hash_head_dep_t @@ -136,7 +136,7 @@ enum cfs_hash_tag { CFS_HASH_NO_BKTLOCK = 1 << 1, /** rwlock to protect bucket */ CFS_HASH_RW_BKTLOCK = 1 << 2, - /** spinlcok to protect bucket */ + /** spinlock to protect bucket */ CFS_HASH_SPIN_BKTLOCK = 1 << 3, /** always add new item to tail */ CFS_HASH_ADD_TAIL = 1 << 4, diff --git a/drivers/staging/lustre/include/linux/lnet/lib-lnet.h b/drivers/staging/lustre/include/linux/lnet/lib-lnet.h index 856fcfaafafa..06ff463e4af6 100644 --- a/drivers/staging/lustre/include/linux/lnet/lib-lnet.h +++ b/drivers/staging/lustre/include/linux/lnet/lib-lnet.h @@ -181,7 +181,7 @@ lnet_net_lock_current(void) #define MAX_PORTALS 64 /* these are only used by code with LNET_USE_LIB_FREELIST, but we still - * exported them to !LNET_USE_LIB_FREELIST for easy implemetation */ + * exported them to !LNET_USE_LIB_FREELIST for easy implementation */ #define LNET_FL_MAX_MES 2048 #define LNET_FL_MAX_MDS 2048 #define LNET_FL_MAX_EQS 512 diff --git a/drivers/staging/lustre/include/linux/lnet/lib-types.h b/drivers/staging/lustre/include/linux/lnet/lib-types.h index 1c13ef7df80e..a63654b660de 100644 --- a/drivers/staging/lustre/include/linux/lnet/lib-types.h +++ b/drivers/staging/lustre/include/linux/lnet/lib-types.h @@ -204,7 +204,7 @@ typedef struct lnet_msg { unsigned int msg_receiving:1; /* being received */ unsigned int msg_txcredit:1; /* taken an NI send credit */ unsigned int msg_peertxcredit:1; /* taken a peer send credit */ - unsigned int msg_rtrcredit:1; /* taken a globel router credit */ + unsigned int msg_rtrcredit:1; /* taken a global router credit */ unsigned int msg_peerrtrcredit:1; /* taken a peer router credit */ unsigned int msg_onactivelist:1; /* on the activelist */ @@ -342,7 +342,7 @@ typedef struct lnet_lnd { /* Start receiving 'mlen' bytes of payload data, skipping the following * 'rlen' - 'mlen' bytes. 'private' is the 'private' passed to - * lnet_parse(). Return non-zero for immedaite failure, otherwise + * lnet_parse(). Return non-zero for immediate failure, otherwise * complete later with lnet_finalize(). This also gives back a receive * credit if the LND does flow control. */ int (*lnd_recv)(struct lnet_ni *ni, void *private, lnet_msg_t *msg, @@ -594,7 +594,7 @@ struct lnet_match_table { unsigned int mt_cpt; unsigned int mt_portal; /* portal index */ /* match table is set as "enabled" if there's non-exhausted MD - * attached on mt_mhash, it's only valide for wildcard portal */ + * attached on mt_mhash, it's only valid for wildcard portal */ unsigned int mt_enabled; /* bitmap to flag whether MEs on mt_hash are exhausted or not */ __u64 mt_exhausted[LNET_MT_EXHAUSTED_BMAP]; diff --git a/drivers/staging/lustre/include/linux/lnet/lnetst.h b/drivers/staging/lustre/include/linux/lnet/lnetst.h index e060599314d5..87fe9ac76a6c 100644 --- a/drivers/staging/lustre/include/linux/lnet/lnetst.h +++ b/drivers/staging/lustre/include/linux/lnet/lnetst.h @@ -402,7 +402,7 @@ typedef struct { /* add stat in session */ typedef struct { int lstio_sta_key; /* IN: session key */ - int lstio_sta_timeout; /* IN: timeout for stat requst */ + int lstio_sta_timeout; /* IN: timeout for stat request */ int lstio_sta_nmlen; /* IN: group name length */ char *lstio_sta_namep; /* IN: group name */ int lstio_sta_count; /* IN: # of pid */ diff --git a/drivers/staging/lustre/include/linux/lnet/types.h b/drivers/staging/lustre/include/linux/lnet/types.h index c833ce8544d3..b19d98809b57 100644 --- a/drivers/staging/lustre/include/linux/lnet/types.h +++ b/drivers/staging/lustre/include/linux/lnet/types.h @@ -181,7 +181,7 @@ typedef struct { * address of an array of lnet_kiov_t and the length field specifies * the number of entries in the array. The length can't be bigger * than LNET_MAX_IOV. The lnet_kiov_t is used to describe page-based - * fragments that are not necessarily mapped in virtal memory. + * fragments that are not necessarily mapped in virtual memory. * - LNET_MD_IOVEC bit set: The start field points to the starting * address of an array of struct iovec and the length field specifies * the number of entries in the array. The length can't be bigger -- cgit v1.2.3 From f5e8269b5afacccf9a0262e9143097c31d9c1b57 Mon Sep 17 00:00:00 2001 From: John de la Garza Date: Mon, 24 Mar 2014 13:58:02 -0700 Subject: drivers:staging:lustre Fixed sparse warning: plain integer as NULL pointer Fixes these sparse warnings: drivers/staging/lustre/lustre/lmv/lproc_lmv.c:202:51: warning: Using plain integer as NULL pointer drivers/staging/lustre/lustre/lmv/lproc_lmv.c:203:51: warning: Using plain integer as NULL pointer drivers/staging/lustre/lustre/lmv/lproc_lmv.c:204:51: warning: Using plain integer as NULL pointer drivers/staging/lustre/lustre/lmv/lproc_lmv.c:205:51: warning: Using plain integer as NULL pointer drivers/staging/lustre/lustre/lmv/lproc_lmv.c:206:51: warning: Using plain integer as NULL pointer drivers/staging/lustre/lustre/lmv/lproc_lmv.c:207:11: warning: Using plain integer as NULL pointer drivers/staging/lustre/lustre/lmv/lproc_lmv.c:213:47: warning: Using plain integer as NULL pointer drivers/staging/lustre/lustre/lmv/lproc_lmv.c:214:11: warning: Using plain integer as NULL pointer Signed-off-by: John de la Garza Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/lmv/lproc_lmv.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/staging/lustre/lustre/lmv/lproc_lmv.c b/drivers/staging/lustre/lustre/lmv/lproc_lmv.c index 5d5c3081c467..ae73c82ce499 100644 --- a/drivers/staging/lustre/lustre/lmv/lproc_lmv.c +++ b/drivers/staging/lustre/lustre/lmv/lproc_lmv.c @@ -200,19 +200,19 @@ static int lmv_target_seq_open(struct inode *inode, struct file *file) LPROC_SEQ_FOPS_RO_TYPE(lmv, uuid); struct lprocfs_vars lprocfs_lmv_obd_vars[] = { - { "numobd", &lmv_numobd_fops, 0, 0 }, - { "placement", &lmv_placement_fops, 0, 0 }, - { "activeobd", &lmv_activeobd_fops, 0, 0 }, - { "uuid", &lmv_uuid_fops, 0, 0 }, - { "desc_uuid", &lmv_desc_uuid_fops, 0, 0 }, - { 0 } + { "numobd", &lmv_numobd_fops, NULL, 0 }, + { "placement", &lmv_placement_fops, NULL, 0 }, + { "activeobd", &lmv_activeobd_fops, NULL, 0 }, + { "uuid", &lmv_uuid_fops, NULL, 0 }, + { "desc_uuid", &lmv_desc_uuid_fops, NULL, 0 }, + { NULL } }; LPROC_SEQ_FOPS_RO_TYPE(lmv, numrefs); static struct lprocfs_vars lprocfs_lmv_module_vars[] = { - { "num_refs", &lmv_numrefs_fops, 0, 0 }, - { 0 } + { "num_refs", &lmv_numrefs_fops, NULL, 0 }, + { NULL } }; struct file_operations lmv_proc_target_fops = { -- cgit v1.2.3 From f9bd9c1a08f852cd6ba6102d15ad94db2d6b595f Mon Sep 17 00:00:00 2001 From: Christoph Jaeger Date: Fri, 28 Mar 2014 00:21:07 +0100 Subject: staging: lustre: use __func__ instead of __FUNCTION__ __FUNCTION__ is gcc specific; use __func__ instead. Signed-off-by: Christoph Jaeger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/include/linux/libcfs/libcfs_debug.h | 4 ++-- drivers/staging/lustre/lustre/include/linux/obd.h | 2 +- drivers/staging/lustre/lustre/include/lu_ref.h | 4 ++-- drivers/staging/lustre/lustre/include/lustre_dlm.h | 4 ++-- drivers/staging/lustre/lustre/obdclass/cl_lock.c | 2 +- drivers/staging/lustre/lustre/obdclass/genops.c | 4 ++-- drivers/staging/lustre/lustre/obdclass/linux/linux-module.c | 4 ++-- drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c | 4 ++-- 8 files changed, 14 insertions(+), 14 deletions(-) diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_debug.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_debug.h index 2bd4885ce06c..b270d84def98 100644 --- a/drivers/staging/lustre/include/linux/libcfs/libcfs_debug.h +++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_debug.h @@ -183,7 +183,7 @@ struct libcfs_debug_msg_data { do { \ (data)->msg_subsys = DEBUG_SUBSYSTEM; \ (data)->msg_file = __FILE__; \ - (data)->msg_fn = __FUNCTION__; \ + (data)->msg_fn = __func__; \ (data)->msg_line = __LINE__; \ (data)->msg_cdls = (cdls); \ (data)->msg_mask = (mask); \ @@ -193,7 +193,7 @@ do { \ static struct libcfs_debug_msg_data dataname = { \ .msg_subsys = DEBUG_SUBSYSTEM, \ .msg_file = __FILE__, \ - .msg_fn = __FUNCTION__, \ + .msg_fn = __func__, \ .msg_line = __LINE__, \ .msg_cdls = (cdls) }; \ dataname.msg_mask = (mask); diff --git a/drivers/staging/lustre/lustre/include/linux/obd.h b/drivers/staging/lustre/lustre/include/linux/obd.h index dc36f75eb635..fea7e6cd44c3 100644 --- a/drivers/staging/lustre/lustre/include/linux/obd.h +++ b/drivers/staging/lustre/lustre/include/linux/obd.h @@ -104,7 +104,7 @@ static inline void __client_obd_list_lock(client_obd_lock_t *lock, } #define client_obd_list_lock(lock) \ - __client_obd_list_lock(lock, __FUNCTION__, __LINE__) + __client_obd_list_lock(lock, __func__, __LINE__) static inline void client_obd_list_unlock(client_obd_lock_t *lock) { diff --git a/drivers/staging/lustre/lustre/include/lu_ref.h b/drivers/staging/lustre/lustre/include/lu_ref.h index 50a2a7f786dc..b451a888ca3a 100644 --- a/drivers/staging/lustre/lustre/include/lu_ref.h +++ b/drivers/staging/lustre/lustre/include/lu_ref.h @@ -69,12 +69,12 @@ * * // current thread acquired a temporary reference to foo. * foo_get(foo); - * lu_ref_add(&foo->reference, __FUNCTION__, current); + * lu_ref_add(&foo->reference, __func__, current); * * ... * * // temporary reference is released. - * lu_ref_del(&foo->reference, __FUNCTION__, current); + * lu_ref_del(&foo->reference, __func__, current); * foo_put(foo); * \endcode * diff --git a/drivers/staging/lustre/lustre/include/lustre_dlm.h b/drivers/staging/lustre/lustre/include/lustre_dlm.h index 3e25f001c07d..ed103133165e 100644 --- a/drivers/staging/lustre/lustre/include/lustre_dlm.h +++ b/drivers/staging/lustre/lustre/include/lustre_dlm.h @@ -1312,11 +1312,11 @@ int ldlm_lock_change_resource(struct ldlm_namespace *, struct ldlm_lock *, const struct ldlm_res_id *); #define LDLM_RESOURCE_ADDREF(res) do { \ - lu_ref_add_atomic(&(res)->lr_reference, __FUNCTION__, current); \ + lu_ref_add_atomic(&(res)->lr_reference, __func__, current); \ } while (0) #define LDLM_RESOURCE_DELREF(res) do { \ - lu_ref_del(&(res)->lr_reference, __FUNCTION__, current); \ + lu_ref_del(&(res)->lr_reference, __func__, current); \ } while (0) /* ldlm_request.c */ diff --git a/drivers/staging/lustre/lustre/obdclass/cl_lock.c b/drivers/staging/lustre/lustre/obdclass/cl_lock.c index d795cef3f164..8eb1785645ba 100644 --- a/drivers/staging/lustre/lustre/obdclass/cl_lock.c +++ b/drivers/staging/lustre/lustre/obdclass/cl_lock.c @@ -139,7 +139,7 @@ static void cl_lock_trace0(int level, const struct lu_env *env, func, line); } #define cl_lock_trace(level, env, prefix, lock) \ - cl_lock_trace0(level, env, prefix, lock, __FUNCTION__, __LINE__) + cl_lock_trace0(level, env, prefix, lock, __func__, __LINE__) #define RETIP ((unsigned long)__builtin_return_address(0)) diff --git a/drivers/staging/lustre/lustre/obdclass/genops.c b/drivers/staging/lustre/lustre/obdclass/genops.c index f2bdea33041d..350b6f079d92 100644 --- a/drivers/staging/lustre/lustre/obdclass/genops.c +++ b/drivers/staging/lustre/lustre/obdclass/genops.c @@ -615,13 +615,13 @@ int class_notify_sptlrpc_conf(const char *fsname, int namelen) if (strncmp(obd->obd_name, fsname, namelen)) continue; - class_incref(obd, __FUNCTION__, obd); + class_incref(obd, __func__, obd); read_unlock(&obd_dev_lock); rc2 = obd_set_info_async(NULL, obd->obd_self_export, sizeof(KEY_SPTLRPC_CONF), KEY_SPTLRPC_CONF, 0, NULL, NULL); rc = rc ? rc : rc2; - class_decref(obd, __FUNCTION__, obd); + class_decref(obd, __func__, obd); read_lock(&obd_dev_lock); } read_unlock(&obd_dev_lock); diff --git a/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c b/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c index ba20776ebfa1..e4e94cc1713d 100644 --- a/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c +++ b/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c @@ -244,7 +244,7 @@ static int obd_proc_health_seq_show(struct seq_file *m, void *v) if (obd->obd_stopping) continue; - class_incref(obd, __FUNCTION__, current); + class_incref(obd, __func__, current); read_unlock(&obd_dev_lock); if (obd_health_check(NULL, obd)) { @@ -252,7 +252,7 @@ static int obd_proc_health_seq_show(struct seq_file *m, void *v) obd->obd_name); rc++; } - class_decref(obd, __FUNCTION__, current); + class_decref(obd, __func__, current); read_lock(&obd_dev_lock); } read_unlock(&obd_dev_lock); diff --git a/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c b/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c index 58f1c8bf25b0..7a422ff759bf 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c +++ b/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c @@ -1190,7 +1190,7 @@ int lprocfs_wr_evict_client(struct file *file, const char *buffer, * the proc entries under the being destroyed export{}, so I have * to drop the lock at first here. * - jay, jxiong@clusterfs.com */ - class_incref(obd, __FUNCTION__, current); + class_incref(obd, __func__, current); if (strncmp(tmpbuf, "nid:", 4) == 0) obd_export_evict_by_nid(obd, tmpbuf + 4); @@ -1199,7 +1199,7 @@ int lprocfs_wr_evict_client(struct file *file, const char *buffer, else obd_export_evict_by_uuid(obd, tmpbuf); - class_decref(obd, __FUNCTION__, current); + class_decref(obd, __func__, current); out: OBD_FREE(kbuf, BUFLEN); -- cgit v1.2.3 From f51d7657cb62fe1457aa430cdfd3cddfe6272abb Mon Sep 17 00:00:00 2001 From: Joshua Baldock Date: Wed, 2 Apr 2014 19:12:57 +1100 Subject: Staging: lustre: Fixed errors reported by checkpatch.pl script for file ptllnd.h Added space after ',' as reported as error by checkpatch.pl script. Signed-off-by: Joshua Baldock Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/include/linux/lnet/ptllnd.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/lustre/include/linux/lnet/ptllnd.h b/drivers/staging/lustre/include/linux/lnet/ptllnd.h index 564f5d3a9b4d..313442a7ed3e 100644 --- a/drivers/staging/lustre/include/linux/lnet/ptllnd.h +++ b/drivers/staging/lustre/include/linux/lnet/ptllnd.h @@ -66,7 +66,7 @@ /*#define PTL_MD_LUSTRE_COMPLETION_SEMANTICS */ /* Can compare handles directly on Cray Portals */ -#define PtlHandleIsEqual(a,b) ((a) == (b)) +#define PtlHandleIsEqual(a, b) ((a) == (b)) /* Different error types on Cray Portals*/ #define ptl_err_t ptl_ni_fail_t -- cgit v1.2.3 From f0bd2c4695264f4660190761739dce6393c981b5 Mon Sep 17 00:00:00 2001 From: Joshua Baldock Date: Wed, 2 Apr 2014 19:12:58 +1100 Subject: Staging: lustre: Corrected styling errors reported by checkpatch.pl script on file ptllnd_wire.h Moved '{' from new line to same line as struct as advised by checkpatch.pl script. Signed-off-by: Joshua Baldock Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/include/linux/lnet/ptllnd_wire.h | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/drivers/staging/lustre/include/linux/lnet/ptllnd_wire.h b/drivers/staging/lustre/include/linux/lnet/ptllnd_wire.h index 7d12b3a23a96..0d3ec5be0a00 100644 --- a/drivers/staging/lustre/include/linux/lnet/ptllnd_wire.h +++ b/drivers/staging/lustre/include/linux/lnet/ptllnd_wire.h @@ -64,26 +64,22 @@ * above is for bulk data transfer */ #define LNET_MSG_MATCHBITS 0 /* the value for the message channel */ -typedef struct -{ +typedef struct { lnet_hdr_t kptlim_hdr; /* portals header */ char kptlim_payload[0]; /* piggy-backed payload */ } WIRE_ATTR kptl_immediate_msg_t; -typedef struct -{ +typedef struct { lnet_hdr_t kptlrm_hdr; /* portals header */ __u64 kptlrm_matchbits; /* matchbits */ } WIRE_ATTR kptl_rdma_msg_t; -typedef struct -{ +typedef struct { __u64 kptlhm_matchbits; /* matchbits */ __u32 kptlhm_max_msg_size; /* max message size */ } WIRE_ATTR kptl_hello_msg_t; -typedef struct -{ +typedef struct { /* First 2 fields fixed FOR ALL TIME */ __u32 ptlm_magic; /* I'm a Portals LND message */ __u16 ptlm_version; /* this is my version number */ @@ -107,7 +103,7 @@ typedef struct } kptl_msg_t; /* kptl_msg_t::ptlm_credits is only a __u8 */ -#define PTLLND_MSG_MAX_CREDITS ((typeof(((kptl_msg_t*) 0)->ptlm_credits)) -1) +#define PTLLND_MSG_MAX_CREDITS ((typeof(((kptl_msg_t*) 0)->ptlm_credits)) - 1) #define PTLLND_MSG_MAGIC LNET_PROTO_PTL_MAGIC #define PTLLND_MSG_VERSION 0x04 -- cgit v1.2.3 From e4422943832a416cc63a1eee59f2adff42ed56ac Mon Sep 17 00:00:00 2001 From: Joshua Baldock Date: Wed, 2 Apr 2014 19:12:59 +1100 Subject: Staging: lustre: Fixed syntax errors reported by checkpatch.pl script for file types.h Added space after ',' and moved '{' to same line as struct as instructed by checkpatch.pl script. Signed-off-by: Joshua Baldock Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/include/linux/lnet/types.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/lustre/include/linux/lnet/types.h b/drivers/staging/lustre/include/linux/lnet/types.h index b19d98809b57..2add7976b3b2 100644 --- a/drivers/staging/lustre/include/linux/lnet/types.h +++ b/drivers/staging/lustre/include/linux/lnet/types.h @@ -112,7 +112,7 @@ static inline void LNetInvalidateHandle(lnet_handle_any_t *h) */ static inline int LNetHandleIsEqual (lnet_handle_any_t h1, lnet_handle_any_t h2) { - return (h1.cookie == h2.cookie); + return h1.cookie == h2.cookie; } /** @@ -122,7 +122,7 @@ static inline int LNetHandleIsEqual (lnet_handle_any_t h1, lnet_handle_any_t h2) */ static inline int LNetHandleIsInvalid(lnet_handle_any_t h) { - return (LNET_WIRE_HANDLE_COOKIE_NONE == h.cookie); + return LNET_WIRE_HANDLE_COOKIE_NONE == h.cookie; } /** @@ -381,7 +381,7 @@ typedef enum { #define LNET_SEQ_BASETYPE long typedef unsigned LNET_SEQ_BASETYPE lnet_seq_t; -#define LNET_SEQ_GT(a,b) (((signed LNET_SEQ_BASETYPE)((a) - (b))) > 0) +#define LNET_SEQ_GT(a, b) (((signed LNET_SEQ_BASETYPE)((a) - (b))) > 0) /** * Information about an event on a MD. -- cgit v1.2.3 From 81fb955d029927213ddd082bbf57e82f8ba20bd0 Mon Sep 17 00:00:00 2001 From: Denis Pithon Date: Mon, 14 Apr 2014 18:25:30 +0200 Subject: staging/lustre: fix sparse warning Fix sparse complaint: "Using plain integer as NULL pointer" Signed-off-by: Denis Pithon Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/ptlrpc/sec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec.c b/drivers/staging/lustre/lustre/ptlrpc/sec.c index d80418057f29..b0a1c5a0d5cc 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/sec.c +++ b/drivers/staging/lustre/lustre/ptlrpc/sec.c @@ -354,7 +354,7 @@ static int import_sec_check_expire(struct obd_import *imp) return 0; CDEBUG(D_SEC, "found delayed sec adapt expired, do it now\n"); - return sptlrpc_import_sec_adapt(imp, NULL, 0); + return sptlrpc_import_sec_adapt(imp, NULL, NULL); } static int import_sec_validate_get(struct obd_import *imp, -- cgit v1.2.3 From df3c9577f41c90a718616bb83b91fbd30f0eeeb5 Mon Sep 17 00:00:00 2001 From: Daeseok Youn Date: Mon, 7 Apr 2014 11:47:17 +0900 Subject: staging: lustre: use NULL instead of 0 for pointer Signed-off-by: Daeseok Youn Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/obdclass/obd_mount.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/drivers/staging/lustre/lustre/obdclass/obd_mount.c b/drivers/staging/lustre/lustre/obdclass/obd_mount.c index 6f8ba54e9667..419a32361359 100644 --- a/drivers/staging/lustre/lustre/obdclass/obd_mount.c +++ b/drivers/staging/lustre/lustre/obdclass/obd_mount.c @@ -187,7 +187,7 @@ int lustre_start_simple(char *obdname, char *type, char *uuid, int rc; CDEBUG(D_MOUNT, "Starting obd %s (typ=%s)\n", obdname, type); - rc = do_lcfg(obdname, 0, LCFG_ATTACH, type, uuid, 0, 0); + rc = do_lcfg(obdname, 0, LCFG_ATTACH, type, uuid, NULL, NULL); if (rc) { CERROR("%s attach error %d\n", obdname, rc); return rc; @@ -195,7 +195,7 @@ int lustre_start_simple(char *obdname, char *type, char *uuid, rc = do_lcfg(obdname, 0, LCFG_SETUP, s1, s2, s3, s4); if (rc) { CERROR("%s setup error %d\n", obdname, rc); - do_lcfg(obdname, 0, LCFG_DETACH, 0, 0, 0, 0); + do_lcfg(obdname, 0, LCFG_DETACH, NULL, NULL, NULL, NULL); } return rc; } @@ -337,7 +337,8 @@ int lustre_start_mgc(struct super_block *sb) lnet_process_id_t id; while ((rc = LNetGetId(i++, &id)) != -ENOENT) { rc = do_lcfg(mgcname, id.nid, - LCFG_ADD_UUID, niduuid, 0,0,0); + LCFG_ADD_UUID, niduuid, + NULL, NULL, NULL); } } else { /* Use mgsnode= nids */ @@ -351,7 +352,8 @@ int lustre_start_mgc(struct super_block *sb) } while (class_parse_nid(ptr, &nid, &ptr) == 0) { rc = do_lcfg(mgcname, nid, - LCFG_ADD_UUID, niduuid, 0,0,0); + LCFG_ADD_UUID, niduuid, + NULL, NULL, NULL); i++; } } @@ -360,7 +362,7 @@ int lustre_start_mgc(struct super_block *sb) ptr = lsi->lsi_lmd->lmd_dev; while (class_parse_nid(ptr, &nid, &ptr) == 0) { rc = do_lcfg(mgcname, nid, - LCFG_ADD_UUID, niduuid, 0,0,0); + LCFG_ADD_UUID, niduuid, NULL, NULL, NULL); i++; /* Stop at the first failover nid */ if (*ptr == ':') @@ -396,13 +398,13 @@ int lustre_start_mgc(struct super_block *sb) while (class_parse_nid_quiet(ptr, &nid, &ptr) == 0) { j++; rc = do_lcfg(mgcname, nid, - LCFG_ADD_UUID, niduuid, 0,0,0); + LCFG_ADD_UUID, niduuid, NULL, NULL, NULL); if (*ptr == ':') break; } if (j > 0) { rc = do_lcfg(mgcname, 0, LCFG_ADD_CONN, - niduuid, 0, 0, 0); + niduuid, NULL, NULL, NULL); i++; } else { /* at ":/fsname" */ @@ -532,7 +534,7 @@ static int lustre_stop_mgc(struct super_block *sb) for (i = 0; i < lsi->lsi_lmd->lmd_mgs_failnodes; i++) { sprintf(ptr, "_%x", i); rc = do_lcfg(LUSTRE_MGC_OBDNAME, 0, LCFG_DEL_UUID, - niduuid, 0, 0, 0); + niduuid, NULL, NULL, NULL); if (rc) CERROR("del MDC UUID %s failed: rc = %d\n", niduuid, rc); -- cgit v1.2.3 From d130c00069f53651edf9067baa713fb5044b9b0a Mon Sep 17 00:00:00 2001 From: Mike Sampson Date: Sat, 5 Apr 2014 09:01:25 +1100 Subject: Staging: lustre: mark a variable static in workitem.c This fixes a sparse warning: warning: symbol 'cfs_wi_data' was not declared. Should it be static? Signed-off-by: Mike Sampson Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/libcfs/workitem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/lustre/lustre/libcfs/workitem.c b/drivers/staging/lustre/lustre/libcfs/workitem.c index ba16fd5db704..0a03bf7ba3eb 100644 --- a/drivers/staging/lustre/lustre/libcfs/workitem.c +++ b/drivers/staging/lustre/lustre/libcfs/workitem.c @@ -75,7 +75,7 @@ typedef struct cfs_wi_sched { char ws_name[CFS_WS_NAME_LEN]; } cfs_wi_sched_t; -struct cfs_workitem_data { +static struct cfs_workitem_data { /** serialize */ spinlock_t wi_glock; /** list of all schedulers */ -- cgit v1.2.3 From a6b4699dbfe995cc8e5e6f07d61227a6a36bd5df Mon Sep 17 00:00:00 2001 From: Fabian Mewes Date: Mon, 24 Mar 2014 23:46:31 +0100 Subject: staging: line6: Add blank lines after declarations Use the more common kernel coding style. Signed-off-by: Fabian Mewes Reviewed-by: Stefan Hajnoczi Signed-off-by: Greg Kroah-Hartman --- drivers/staging/line6/driver.c | 1 + drivers/staging/line6/playback.c | 5 +++++ drivers/staging/line6/toneport.c | 1 + 3 files changed, 7 insertions(+) diff --git a/drivers/staging/line6/driver.c b/drivers/staging/line6/driver.c index 77f1b421e957..ef511c76a6e3 100644 --- a/drivers/staging/line6/driver.c +++ b/drivers/staging/line6/driver.c @@ -124,6 +124,7 @@ static int line6_send_raw_message_async_part(struct message *msg, static int line6_start_listen(struct usb_line6 *line6) { int err; + usb_fill_int_urb(line6->urb_listen, line6->usbdev, usb_rcvintpipe(line6->usbdev, line6->ep_control_read), line6->buffer_listen, LINE6_BUFSIZE_LISTEN, diff --git a/drivers/staging/line6/playback.c b/drivers/staging/line6/playback.c index 41869caf19a7..0f72db5665fe 100644 --- a/drivers/staging/line6/playback.c +++ b/drivers/staging/line6/playback.c @@ -34,6 +34,7 @@ static void change_volume(struct urb *urb_out, int volume[], if (bytes_per_frame == 4) { short *p, *buf_end; + p = (short *)urb_out->transfer_buffer; buf_end = p + urb_out->transfer_buffer_length / sizeof(*p); @@ -48,6 +49,7 @@ static void change_volume(struct urb *urb_out, int volume[], for (; p < buf_end; p += 3) { int val; + val = p[0] + (p[1] << 8) + ((signed char)p[2] << 16); val = (val * volume[chn & 1]) >> 8; p[0] = val; @@ -116,6 +118,7 @@ static void add_monitor_signal(struct urb *urb_out, unsigned char *signal, if (bytes_per_frame == 4) { short *pi, *po, *buf_end; + pi = (short *)signal; po = (short *)urb_out->transfer_buffer; buf_end = po + urb_out->transfer_buffer_length / sizeof(*po); @@ -171,6 +174,7 @@ static int submit_audio_out_urb(struct snd_line6_pcm *line6pcm) if (fsize == 0) { int n; + line6pcm->count_out += frame_increment; n = line6pcm->count_out / frame_factor; line6pcm->count_out -= n * frame_factor; @@ -207,6 +211,7 @@ static int submit_audio_out_urb(struct snd_line6_pcm *line6pcm) copy the data to the temp buffer. */ int len; + len = runtime->buffer_size - line6pcm->pos_out; if (len > 0) { diff --git a/drivers/staging/line6/toneport.c b/drivers/staging/line6/toneport.c index af2e7e50c135..dcab6478a3b3 100644 --- a/drivers/staging/line6/toneport.c +++ b/drivers/staging/line6/toneport.c @@ -213,6 +213,7 @@ static int snd_toneport_source_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { const int size = ARRAY_SIZE(toneport_source_info); + uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; uinfo->count = 1; uinfo->value.enumerated.items = size; -- cgit v1.2.3 From 5565c59e9b1b329f58e7b4a3e307a2bc7c12605c Mon Sep 17 00:00:00 2001 From: "L. Alberto Giménez" Date: Mon, 7 Apr 2014 00:12:30 +0200 Subject: staging/line6: Fix kzalloc coding style issue MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Pass the actual variable to sizeof instead of a type definition. Signed-off-by: L. Alberto Giménez Acked-by: Takashi Iwai Signed-off-by: Greg Kroah-Hartman --- drivers/staging/line6/pcm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/line6/pcm.c b/drivers/staging/line6/pcm.c index 661080b3c39d..a3136b189ee5 100644 --- a/drivers/staging/line6/pcm.c +++ b/drivers/staging/line6/pcm.c @@ -475,7 +475,7 @@ int line6_init_pcm(struct usb_line6 *line6, MISSING_CASE; } - line6pcm = kzalloc(sizeof(struct snd_line6_pcm), GFP_KERNEL); + line6pcm = kzalloc(sizeof(*line6pcm), GFP_KERNEL); if (line6pcm == NULL) return -ENOMEM; -- cgit v1.2.3 From dc4a93078b8a6a10d2dcaba76ab488d6dbe73922 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Wed, 16 Apr 2014 21:37:30 -0600 Subject: sd/skd: stuff discard page in request->completion_data Store the pointer to the page there, so we can always safely reference it from end_io context where ->bio may have been cleared. Signed-off-by: Jens Axboe --- drivers/block/skd_main.c | 4 ++-- drivers/scsi/sd.c | 7 +++---- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/block/skd_main.c b/drivers/block/skd_main.c index 36bcedfd930c..c48d9084c965 100644 --- a/drivers/block/skd_main.c +++ b/drivers/block/skd_main.c @@ -743,6 +743,7 @@ static void skd_request_fn(struct request_queue *q) break; } skreq->discard_page = 1; + req->completion_data = page; skd_prep_discard_cdb(scsi_req, skreq, page, lba, count); } else if (flush == SKD_FLUSH_ZERO_SIZE_FIRST) { @@ -855,10 +856,9 @@ static void skd_end_request(struct skd_device *skdev, if ((io_flags & REQ_DISCARD) && (skreq->discard_page == 1)) { - struct bio *bio = req->bio; pr_debug("%s:%s:%d, free the page!", skdev->name, __func__, __LINE__); - __free_page(bio->bi_io_vec->bv_page); + __free_page(req->completion_data); } if (unlikely(error)) { diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index 06d154d20faa..96af195224f2 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -737,6 +737,7 @@ static int sd_setup_discard_cmnd(struct scsi_device *sdp, struct request *rq) goto out; } + rq->completion_data = page; blk_add_request_payload(rq, page, len); ret = scsi_setup_blk_pc_cmnd(sdp, rq); rq->__data_len = nr_bytes; @@ -839,11 +840,9 @@ static void sd_unprep_fn(struct request_queue *q, struct request *rq) { struct scsi_cmnd *SCpnt = rq->special; - if (rq->cmd_flags & REQ_DISCARD) { - struct bio *bio = rq->bio; + if (rq->cmd_flags & REQ_DISCARD) + __free_page(rq->completion_data); - __free_page(bio->bi_io_vec->bv_page); - } if (SCpnt->cmnd != rq->cmd) { mempool_free(SCpnt->cmnd, sd_cdb_pool); SCpnt->cmnd = NULL; -- cgit v1.2.3 From 991deec8193a20cf5a79a4c4bc01ba1a51c9ba5f Mon Sep 17 00:00:00 2001 From: Abhi Das Date: Thu, 17 Apr 2014 00:55:04 -0500 Subject: GFS2: quotas not being refreshed in gfs2_adjust_quota Old values of user quota limits were being used and could allow users to exceed their allotted quotas. This patch refreshes the limits to the latest values so that quotas are enforced correctly. Resolves: rhbz#1077463 Signed-off-by: Abhi Das Signed-off-by: Steven Whitehouse --- fs/gfs2/quota.c | 1 + 1 file changed, 1 insertion(+) diff --git a/fs/gfs2/quota.c b/fs/gfs2/quota.c index c4effff7cf55..619389649d03 100644 --- a/fs/gfs2/quota.c +++ b/fs/gfs2/quota.c @@ -778,6 +778,7 @@ get_a_page: i_size_write(inode, size); inode->i_mtime = inode->i_atime = CURRENT_TIME; mark_inode_dirty(inode); + set_bit(QDF_REFRESH, &qd->qd_flags); return 0; unlock_out: -- cgit v1.2.3 From ac1ef1fed3d2c1cd4902ecb92876cb239c97a870 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Fri, 21 Feb 2014 16:54:53 +0100 Subject: iommu/shmobile: Don't ignore the ipmmu_iommu_init() return value The function can fail, don't ignore its error value. Signed-off-by: Laurent Pinchart --- drivers/iommu/shmobile-ipmmu.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/iommu/shmobile-ipmmu.c b/drivers/iommu/shmobile-ipmmu.c index e3bc2e19b6dd..6ba611002c6f 100644 --- a/drivers/iommu/shmobile-ipmmu.c +++ b/drivers/iommu/shmobile-ipmmu.c @@ -117,8 +117,7 @@ static int ipmmu_probe(struct platform_device *pdev) platform_set_drvdata(pdev, ipmmu); ipmmu_reg_write(ipmmu, IMCTR1, 0x0); /* disable TLB */ ipmmu_reg_write(ipmmu, IMCTR2, 0x0); /* disable PMB */ - ipmmu_iommu_init(ipmmu); - return 0; + return ipmmu_iommu_init(ipmmu); } static struct platform_driver ipmmu_driver = { -- cgit v1.2.3 From b11762f8431b3a5cf1c156876e79efab7d7f80c4 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Fri, 21 Feb 2014 16:54:53 +0100 Subject: iommu/shmobile: Use devm_ioremap_resource() Replace the devm_ioremap_nocache() call with devm_ioremap_resource(). This simplifies error checking. Signed-off-by: Laurent Pinchart --- drivers/iommu/shmobile-ipmmu.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/drivers/iommu/shmobile-ipmmu.c b/drivers/iommu/shmobile-ipmmu.c index 6ba611002c6f..bd97adecb1fd 100644 --- a/drivers/iommu/shmobile-ipmmu.c +++ b/drivers/iommu/shmobile-ipmmu.c @@ -94,11 +94,6 @@ static int ipmmu_probe(struct platform_device *pdev) struct resource *res; struct shmobile_ipmmu_platform_data *pdata = pdev->dev.platform_data; - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - if (!res) { - dev_err(&pdev->dev, "cannot get platform resources\n"); - return -ENOENT; - } ipmmu = devm_kzalloc(&pdev->dev, sizeof(*ipmmu), GFP_KERNEL); if (!ipmmu) { dev_err(&pdev->dev, "cannot allocate device data\n"); @@ -106,12 +101,12 @@ static int ipmmu_probe(struct platform_device *pdev) } spin_lock_init(&ipmmu->flush_lock); ipmmu->dev = &pdev->dev; - ipmmu->ipmmu_base = devm_ioremap_nocache(&pdev->dev, res->start, - resource_size(res)); - if (!ipmmu->ipmmu_base) { - dev_err(&pdev->dev, "ioremap_nocache failed\n"); - return -ENOMEM; - } + + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + ipmmu->ipmmu_base = devm_ioremap_resource(&pdev->dev, res); + if (IS_ERR(ipmmu->ipmmu_base)) + return PTR_ERR(ipmmu->ipmmu_base); + ipmmu->dev_names = pdata->dev_names; ipmmu->num_dev_names = pdata->num_dev_names; platform_set_drvdata(pdev, ipmmu); -- cgit v1.2.3 From 9bb40191e88d23563fd0467ac195debf5f6daaf9 Mon Sep 17 00:00:00 2001 From: Roy Franz Date: Tue, 28 Jan 2014 10:41:28 -0800 Subject: efi: Add get_dram_base() helper function Add the get_dram_base() function, shared by arm/arm64. Signed-off-by: Roy Franz Signed-off-by: Leif Lindholm Signed-off-by: Matt Fleming --- drivers/firmware/efi/efi-stub-helper.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/drivers/firmware/efi/efi-stub-helper.c b/drivers/firmware/efi/efi-stub-helper.c index 1bf439be9138..a168dd20511f 100644 --- a/drivers/firmware/efi/efi-stub-helper.c +++ b/drivers/firmware/efi/efi-stub-helper.c @@ -11,6 +11,10 @@ */ #define EFI_READ_CHUNK_SIZE (1024 * 1024) +/* error code which can't be mistaken for valid address */ +#define EFI_ERROR (~0UL) + + struct file_info { efi_file_handle_t *handle; u64 size; @@ -83,6 +87,32 @@ fail: return status; } + +static unsigned long __init get_dram_base(efi_system_table_t *sys_table_arg) +{ + efi_status_t status; + unsigned long map_size; + unsigned long membase = EFI_ERROR; + struct efi_memory_map map; + efi_memory_desc_t *md; + + status = efi_get_memory_map(sys_table_arg, (efi_memory_desc_t **)&map.map, + &map_size, &map.desc_size, NULL, NULL); + if (status != EFI_SUCCESS) + return membase; + + map.map_end = map.map + map_size; + + for_each_efi_memory_desc(&map, md) + if (md->attribute & EFI_MEMORY_WB) + if (membase > md->phys_addr) + membase = md->phys_addr; + + efi_call_early(free_pool, map.map); + + return membase; +} + /* * Allocate at the highest possible address that is not above 'max'. */ -- cgit v1.2.3 From c625d1c203941fad755eb4eb729db1f65d6e9836 Mon Sep 17 00:00:00 2001 From: "H. Peter Anvin" Date: Fri, 20 Sep 2013 09:55:39 -0500 Subject: efi: x86: Handle arbitrary Unicode characters Instead of truncating UTF-16 assuming all characters is ASCII, properly convert it to UTF-8. Signed-off-by: H. Peter Anvin [ Bug and style fixes. ] Signed-off-by: Roy Franz Signed-off-by: Leif Lindholm Signed-off-by: Matt Fleming --- arch/x86/boot/compressed/eboot.c | 3 +- drivers/firmware/efi/efi-stub-helper.c | 87 ++++++++++++++++++++++++++-------- 2 files changed, 68 insertions(+), 22 deletions(-) diff --git a/arch/x86/boot/compressed/eboot.c b/arch/x86/boot/compressed/eboot.c index 4703a6c4b8e3..0331d765c2bb 100644 --- a/arch/x86/boot/compressed/eboot.c +++ b/arch/x86/boot/compressed/eboot.c @@ -1087,8 +1087,7 @@ struct boot_params *make_boot_params(struct efi_config *c) hdr->type_of_loader = 0x21; /* Convert unicode cmdline to ascii */ - cmdline_ptr = efi_convert_cmdline_to_ascii(sys_table, image, - &options_size); + cmdline_ptr = efi_convert_cmdline(sys_table, image, &options_size); if (!cmdline_ptr) goto fail; hdr->cmd_line_ptr = (unsigned long)cmdline_ptr; diff --git a/drivers/firmware/efi/efi-stub-helper.c b/drivers/firmware/efi/efi-stub-helper.c index a168dd20511f..eb6d4be9e722 100644 --- a/drivers/firmware/efi/efi-stub-helper.c +++ b/drivers/firmware/efi/efi-stub-helper.c @@ -535,53 +535,100 @@ static efi_status_t efi_relocate_kernel(efi_system_table_t *sys_table_arg, return status; } +/* + * Get the number of UTF-8 bytes corresponding to an UTF-16 character. + * This overestimates for surrogates, but that is okay. + */ +static int efi_utf8_bytes(u16 c) +{ + return 1 + (c >= 0x80) + (c >= 0x800); +} + +/* + * Convert an UTF-16 string, not necessarily null terminated, to UTF-8. + */ +static u8 *efi_utf16_to_utf8(u8 *dst, const u16 *src, int n) +{ + unsigned int c; + + while (n--) { + c = *src++; + if (n && c >= 0xd800 && c <= 0xdbff && + *src >= 0xdc00 && *src <= 0xdfff) { + c = 0x10000 + ((c & 0x3ff) << 10) + (*src & 0x3ff); + src++; + n--; + } + if (c >= 0xd800 && c <= 0xdfff) + c = 0xfffd; /* Unmatched surrogate */ + if (c < 0x80) { + *dst++ = c; + continue; + } + if (c < 0x800) { + *dst++ = 0xc0 + (c >> 6); + goto t1; + } + if (c < 0x10000) { + *dst++ = 0xe0 + (c >> 12); + goto t2; + } + *dst++ = 0xf0 + (c >> 18); + *dst++ = 0x80 + ((c >> 12) & 0x3f); + t2: + *dst++ = 0x80 + ((c >> 6) & 0x3f); + t1: + *dst++ = 0x80 + (c & 0x3f); + } + + return dst; +} + /* * Convert the unicode UEFI command line to ASCII to pass to kernel. * Size of memory allocated return in *cmd_line_len. * Returns NULL on error. */ -static char *efi_convert_cmdline_to_ascii(efi_system_table_t *sys_table_arg, - efi_loaded_image_t *image, - int *cmd_line_len) +static char *efi_convert_cmdline(efi_system_table_t *sys_table_arg, + efi_loaded_image_t *image, + int *cmd_line_len) { - u16 *s2; + const u16 *s2; u8 *s1 = NULL; unsigned long cmdline_addr = 0; - int load_options_size = image->load_options_size / 2; /* ASCII */ - void *options = image->load_options; - int options_size = 0; + int load_options_chars = image->load_options_size / 2; /* UTF-16 */ + const u16 *options = image->load_options; + int options_bytes = 0; /* UTF-8 bytes */ + int options_chars = 0; /* UTF-16 chars */ efi_status_t status; - int i; u16 zero = 0; if (options) { s2 = options; - while (*s2 && *s2 != '\n' && options_size < load_options_size) { - s2++; - options_size++; + while (*s2 && *s2 != '\n' + && options_chars < load_options_chars) { + options_bytes += efi_utf8_bytes(*s2++); + options_chars++; } } - if (options_size == 0) { + if (!options_chars) { /* No command line options, so return empty string*/ - options_size = 1; options = &zero; } - options_size++; /* NUL termination */ + options_bytes++; /* NUL termination */ - status = efi_low_alloc(sys_table_arg, options_size, 0, &cmdline_addr); + status = efi_low_alloc(sys_table_arg, options_bytes, 0, &cmdline_addr); if (status != EFI_SUCCESS) return NULL; s1 = (u8 *)cmdline_addr; - s2 = (u16 *)options; - - for (i = 0; i < options_size - 1; i++) - *s1++ = *s2++; + s2 = (const u16 *)options; + s1 = efi_utf16_to_utf8(s1, s2, options_chars); *s1 = '\0'; - *cmd_line_len = options_size; + *cmd_line_len = options_bytes; return (char *)cmdline_addr; } -- cgit v1.2.3 From 62fa6e69a436f662090f3996538adb9e568817f6 Mon Sep 17 00:00:00 2001 From: Matt Fleming Date: Thu, 27 Mar 2014 15:10:39 -0700 Subject: x86/efi: Delete most of the efi_call* macros We really only need one phys and one virt function call, and then only one assembly function to make firmware calls. Since we are not using the C type system anyway, we're not really losing much by deleting the macros apart from no longer having a check that we are passing the correct number of parameters. The lack of duplicated code seems like a worthwhile trade-off. Cc: Ricardo Neri Cc: Borislav Petkov Signed-off-by: Matt Fleming --- arch/x86/boot/compressed/head_64.S | 2 +- arch/x86/include/asm/efi.h | 74 ++++----------------------------- arch/x86/platform/efi/efi.c | 48 +++++++++++----------- arch/x86/platform/efi/efi_stub_64.S | 81 +------------------------------------ arch/x86/platform/uv/bios_uv.c | 2 +- 5 files changed, 35 insertions(+), 172 deletions(-) diff --git a/arch/x86/boot/compressed/head_64.S b/arch/x86/boot/compressed/head_64.S index 0d558ee899ae..2884e0c3e8a5 100644 --- a/arch/x86/boot/compressed/head_64.S +++ b/arch/x86/boot/compressed/head_64.S @@ -452,7 +452,7 @@ efi32_config: .global efi64_config efi64_config: .fill 11,8,0 - .quad efi_call6 + .quad efi_call .byte 1 #endif /* CONFIG_EFI_STUB */ diff --git a/arch/x86/include/asm/efi.h b/arch/x86/include/asm/efi.h index 0869434eaf72..e3975597b289 100644 --- a/arch/x86/include/asm/efi.h +++ b/arch/x86/include/asm/efi.h @@ -27,16 +27,6 @@ extern unsigned long asmlinkage efi_call_phys(void *, ...); -#define efi_call_phys0(f) efi_call_phys(f) -#define efi_call_phys1(f, a1) efi_call_phys(f, a1) -#define efi_call_phys2(f, a1, a2) efi_call_phys(f, a1, a2) -#define efi_call_phys3(f, a1, a2, a3) efi_call_phys(f, a1, a2, a3) -#define efi_call_phys4(f, a1, a2, a3, a4) \ - efi_call_phys(f, a1, a2, a3, a4) -#define efi_call_phys5(f, a1, a2, a3, a4, a5) \ - efi_call_phys(f, a1, a2, a3, a4, a5) -#define efi_call_phys6(f, a1, a2, a3, a4, a5, a6) \ - efi_call_phys(f, a1, a2, a3, a4, a5, a6) /* * Wrap all the virtual calls in a way that forces the parameters on the stack. */ @@ -44,75 +34,27 @@ extern unsigned long asmlinkage efi_call_phys(void *, ...); #define efi_call_virt(f, args...) \ ((efi_##f##_t __attribute__((regparm(0)))*)efi.systab->runtime->f)(args) -#define efi_call_virt0(f) efi_call_virt(f) -#define efi_call_virt1(f, a1) efi_call_virt(f, a1) -#define efi_call_virt2(f, a1, a2) efi_call_virt(f, a1, a2) -#define efi_call_virt3(f, a1, a2, a3) efi_call_virt(f, a1, a2, a3) -#define efi_call_virt4(f, a1, a2, a3, a4) \ - efi_call_virt(f, a1, a2, a3, a4) -#define efi_call_virt5(f, a1, a2, a3, a4, a5) \ - efi_call_virt(f, a1, a2, a3, a4, a5) -#define efi_call_virt6(f, a1, a2, a3, a4, a5, a6) \ - efi_call_virt(f, a1, a2, a3, a4, a5, a6) - #define efi_ioremap(addr, size, type, attr) ioremap_cache(addr, size) #else /* !CONFIG_X86_32 */ -extern u64 efi_call0(void *fp); -extern u64 efi_call1(void *fp, u64 arg1); -extern u64 efi_call2(void *fp, u64 arg1, u64 arg2); -extern u64 efi_call3(void *fp, u64 arg1, u64 arg2, u64 arg3); -extern u64 efi_call4(void *fp, u64 arg1, u64 arg2, u64 arg3, u64 arg4); -extern u64 efi_call5(void *fp, u64 arg1, u64 arg2, u64 arg3, - u64 arg4, u64 arg5); -extern u64 efi_call6(void *fp, u64 arg1, u64 arg2, u64 arg3, - u64 arg4, u64 arg5, u64 arg6); - -#define efi_call_phys0(f) \ - efi_call0((f)) -#define efi_call_phys1(f, a1) \ - efi_call1((f), (u64)(a1)) -#define efi_call_phys2(f, a1, a2) \ - efi_call2((f), (u64)(a1), (u64)(a2)) -#define efi_call_phys3(f, a1, a2, a3) \ - efi_call3((f), (u64)(a1), (u64)(a2), (u64)(a3)) -#define efi_call_phys4(f, a1, a2, a3, a4) \ - efi_call4((f), (u64)(a1), (u64)(a2), (u64)(a3), \ - (u64)(a4)) -#define efi_call_phys5(f, a1, a2, a3, a4, a5) \ - efi_call5((f), (u64)(a1), (u64)(a2), (u64)(a3), \ - (u64)(a4), (u64)(a5)) -#define efi_call_phys6(f, a1, a2, a3, a4, a5, a6) \ - efi_call6((f), (u64)(a1), (u64)(a2), (u64)(a3), \ - (u64)(a4), (u64)(a5), (u64)(a6)) - -#define _efi_call_virtX(x, f, ...) \ +#define EFI_LOADER_SIGNATURE "EL64" + +extern u64 asmlinkage efi_call(void *fp, ...); + +#define efi_call_phys(f, args...) efi_call((f), args) + +#define efi_call_virt(f, ...) \ ({ \ efi_status_t __s; \ \ efi_sync_low_kernel_mappings(); \ preempt_disable(); \ - __s = efi_call##x((void *)efi.systab->runtime->f, __VA_ARGS__); \ + __s = efi_call((void *)efi.systab->runtime->f, __VA_ARGS__); \ preempt_enable(); \ __s; \ }) -#define efi_call_virt0(f) \ - _efi_call_virtX(0, f) -#define efi_call_virt1(f, a1) \ - _efi_call_virtX(1, f, (u64)(a1)) -#define efi_call_virt2(f, a1, a2) \ - _efi_call_virtX(2, f, (u64)(a1), (u64)(a2)) -#define efi_call_virt3(f, a1, a2, a3) \ - _efi_call_virtX(3, f, (u64)(a1), (u64)(a2), (u64)(a3)) -#define efi_call_virt4(f, a1, a2, a3, a4) \ - _efi_call_virtX(4, f, (u64)(a1), (u64)(a2), (u64)(a3), (u64)(a4)) -#define efi_call_virt5(f, a1, a2, a3, a4, a5) \ - _efi_call_virtX(5, f, (u64)(a1), (u64)(a2), (u64)(a3), (u64)(a4), (u64)(a5)) -#define efi_call_virt6(f, a1, a2, a3, a4, a5, a6) \ - _efi_call_virtX(6, f, (u64)(a1), (u64)(a2), (u64)(a3), (u64)(a4), (u64)(a5), (u64)(a6)) - extern void __iomem *efi_ioremap(unsigned long addr, unsigned long size, u32 type, u64 attribute); diff --git a/arch/x86/platform/efi/efi.c b/arch/x86/platform/efi/efi.c index 3781dd39e8bd..8f6531e8d32f 100644 --- a/arch/x86/platform/efi/efi.c +++ b/arch/x86/platform/efi/efi.c @@ -110,7 +110,7 @@ static efi_status_t virt_efi_get_time(efi_time_t *tm, efi_time_cap_t *tc) efi_status_t status; spin_lock_irqsave(&rtc_lock, flags); - status = efi_call_virt2(get_time, tm, tc); + status = efi_call_virt(get_time, tm, tc); spin_unlock_irqrestore(&rtc_lock, flags); return status; } @@ -121,7 +121,7 @@ static efi_status_t virt_efi_set_time(efi_time_t *tm) efi_status_t status; spin_lock_irqsave(&rtc_lock, flags); - status = efi_call_virt1(set_time, tm); + status = efi_call_virt(set_time, tm); spin_unlock_irqrestore(&rtc_lock, flags); return status; } @@ -134,8 +134,7 @@ static efi_status_t virt_efi_get_wakeup_time(efi_bool_t *enabled, efi_status_t status; spin_lock_irqsave(&rtc_lock, flags); - status = efi_call_virt3(get_wakeup_time, - enabled, pending, tm); + status = efi_call_virt(get_wakeup_time, enabled, pending, tm); spin_unlock_irqrestore(&rtc_lock, flags); return status; } @@ -146,8 +145,7 @@ static efi_status_t virt_efi_set_wakeup_time(efi_bool_t enabled, efi_time_t *tm) efi_status_t status; spin_lock_irqsave(&rtc_lock, flags); - status = efi_call_virt2(set_wakeup_time, - enabled, tm); + status = efi_call_virt(set_wakeup_time, enabled, tm); spin_unlock_irqrestore(&rtc_lock, flags); return status; } @@ -158,17 +156,17 @@ static efi_status_t virt_efi_get_variable(efi_char16_t *name, unsigned long *data_size, void *data) { - return efi_call_virt5(get_variable, - name, vendor, attr, - data_size, data); + return efi_call_virt(get_variable, + name, vendor, attr, + data_size, data); } static efi_status_t virt_efi_get_next_variable(unsigned long *name_size, efi_char16_t *name, efi_guid_t *vendor) { - return efi_call_virt3(get_next_variable, - name_size, name, vendor); + return efi_call_virt(get_next_variable, + name_size, name, vendor); } static efi_status_t virt_efi_set_variable(efi_char16_t *name, @@ -177,9 +175,9 @@ static efi_status_t virt_efi_set_variable(efi_char16_t *name, unsigned long data_size, void *data) { - return efi_call_virt5(set_variable, - name, vendor, attr, - data_size, data); + return efi_call_virt(set_variable, + name, vendor, attr, + data_size, data); } static efi_status_t virt_efi_query_variable_info(u32 attr, @@ -190,13 +188,13 @@ static efi_status_t virt_efi_query_variable_info(u32 attr, if (efi.runtime_version < EFI_2_00_SYSTEM_TABLE_REVISION) return EFI_UNSUPPORTED; - return efi_call_virt4(query_variable_info, attr, storage_space, - remaining_space, max_variable_size); + return efi_call_virt(query_variable_info, attr, storage_space, + remaining_space, max_variable_size); } static efi_status_t virt_efi_get_next_high_mono_count(u32 *count) { - return efi_call_virt1(get_next_high_mono_count, count); + return efi_call_virt(get_next_high_mono_count, count); } static void virt_efi_reset_system(int reset_type, @@ -204,8 +202,8 @@ static void virt_efi_reset_system(int reset_type, unsigned long data_size, efi_char16_t *data) { - efi_call_virt4(reset_system, reset_type, status, - data_size, data); + efi_call_virt(reset_system, reset_type, status, + data_size, data); } static efi_status_t virt_efi_update_capsule(efi_capsule_header_t **capsules, @@ -215,7 +213,7 @@ static efi_status_t virt_efi_update_capsule(efi_capsule_header_t **capsules, if (efi.runtime_version < EFI_2_00_SYSTEM_TABLE_REVISION) return EFI_UNSUPPORTED; - return efi_call_virt3(update_capsule, capsules, count, sg_list); + return efi_call_virt(update_capsule, capsules, count, sg_list); } static efi_status_t virt_efi_query_capsule_caps(efi_capsule_header_t **capsules, @@ -226,8 +224,8 @@ static efi_status_t virt_efi_query_capsule_caps(efi_capsule_header_t **capsules, if (efi.runtime_version < EFI_2_00_SYSTEM_TABLE_REVISION) return EFI_UNSUPPORTED; - return efi_call_virt4(query_capsule_caps, capsules, count, max_size, - reset_type); + return efi_call_virt(query_capsule_caps, capsules, count, max_size, + reset_type); } static efi_status_t __init phys_efi_set_virtual_address_map( @@ -239,9 +237,9 @@ static efi_status_t __init phys_efi_set_virtual_address_map( efi_status_t status; efi_call_phys_prelog(); - status = efi_call_phys4(efi_phys.set_virtual_address_map, - memory_map_size, descriptor_size, - descriptor_version, virtual_map); + status = efi_call_phys(efi_phys.set_virtual_address_map, + memory_map_size, descriptor_size, + descriptor_version, virtual_map); efi_call_phys_epilog(); return status; } diff --git a/arch/x86/platform/efi/efi_stub_64.S b/arch/x86/platform/efi/efi_stub_64.S index e0984ef0374b..5fcda7272550 100644 --- a/arch/x86/platform/efi/efi_stub_64.S +++ b/arch/x86/platform/efi/efi_stub_64.S @@ -73,84 +73,7 @@ 2: .endm -ENTRY(efi_call0) - SAVE_XMM - subq $32, %rsp - SWITCH_PGT - call *%rdi - RESTORE_PGT - addq $32, %rsp - RESTORE_XMM - ret -ENDPROC(efi_call0) - -ENTRY(efi_call1) - SAVE_XMM - subq $32, %rsp - mov %rsi, %rcx - SWITCH_PGT - call *%rdi - RESTORE_PGT - addq $32, %rsp - RESTORE_XMM - ret -ENDPROC(efi_call1) - -ENTRY(efi_call2) - SAVE_XMM - subq $32, %rsp - mov %rsi, %rcx - SWITCH_PGT - call *%rdi - RESTORE_PGT - addq $32, %rsp - RESTORE_XMM - ret -ENDPROC(efi_call2) - -ENTRY(efi_call3) - SAVE_XMM - subq $32, %rsp - mov %rcx, %r8 - mov %rsi, %rcx - SWITCH_PGT - call *%rdi - RESTORE_PGT - addq $32, %rsp - RESTORE_XMM - ret -ENDPROC(efi_call3) - -ENTRY(efi_call4) - SAVE_XMM - subq $32, %rsp - mov %r8, %r9 - mov %rcx, %r8 - mov %rsi, %rcx - SWITCH_PGT - call *%rdi - RESTORE_PGT - addq $32, %rsp - RESTORE_XMM - ret -ENDPROC(efi_call4) - -ENTRY(efi_call5) - SAVE_XMM - subq $48, %rsp - mov %r9, 32(%rsp) - mov %r8, %r9 - mov %rcx, %r8 - mov %rsi, %rcx - SWITCH_PGT - call *%rdi - RESTORE_PGT - addq $48, %rsp - RESTORE_XMM - ret -ENDPROC(efi_call5) - -ENTRY(efi_call6) +ENTRY(efi_call) SAVE_XMM mov (%rsp), %rax mov 8(%rax), %rax @@ -166,7 +89,7 @@ ENTRY(efi_call6) addq $48, %rsp RESTORE_XMM ret -ENDPROC(efi_call6) +ENDPROC(efi_call) #ifdef CONFIG_EFI_MIXED diff --git a/arch/x86/platform/uv/bios_uv.c b/arch/x86/platform/uv/bios_uv.c index 766612137a62..1584cbed0dce 100644 --- a/arch/x86/platform/uv/bios_uv.c +++ b/arch/x86/platform/uv/bios_uv.c @@ -39,7 +39,7 @@ s64 uv_bios_call(enum uv_bios_cmd which, u64 a1, u64 a2, u64 a3, u64 a4, u64 a5) */ return BIOS_STATUS_UNIMPLEMENTED; - ret = efi_call6((void *)__va(tab->function), (u64)which, + ret = efi_call((void *)__va(tab->function), (u64)which, a1, a2, a3, a4, a5); return ret; } -- cgit v1.2.3 From c6b406919288a617815f710175da20f3fca72065 Mon Sep 17 00:00:00 2001 From: Matt Fleming Date: Thu, 27 Mar 2014 15:10:40 -0700 Subject: x86, fpu: Extend the use of static_cpu_has_safe It may be necessary to save and restore the FPU context during EFI runtime system services calls. However, this may happen during boot and before alternatives have run. Thus, we need to use static_cpu_has_safe instead. The rationale behind the use of static_cpu_has_safe is the same as in commit 5f8c4218148822fde6ee ("x86, fpu: Use static_cpu_has_safe before alternatives") by Borislav Petkov. Signed-off-by: Matt Fleming Signed-off-by: Ricardo Neri Cc: Borislav Petkov --- arch/x86/include/asm/fpu-internal.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/arch/x86/include/asm/fpu-internal.h b/arch/x86/include/asm/fpu-internal.h index cea1c76d49bf..115e3689cd53 100644 --- a/arch/x86/include/asm/fpu-internal.h +++ b/arch/x86/include/asm/fpu-internal.h @@ -87,22 +87,22 @@ static inline int is_x32_frame(void) static __always_inline __pure bool use_eager_fpu(void) { - return static_cpu_has(X86_FEATURE_EAGER_FPU); + return static_cpu_has_safe(X86_FEATURE_EAGER_FPU); } static __always_inline __pure bool use_xsaveopt(void) { - return static_cpu_has(X86_FEATURE_XSAVEOPT); + return static_cpu_has_safe(X86_FEATURE_XSAVEOPT); } static __always_inline __pure bool use_xsave(void) { - return static_cpu_has(X86_FEATURE_XSAVE); + return static_cpu_has_safe(X86_FEATURE_XSAVE); } static __always_inline __pure bool use_fxsr(void) { - return static_cpu_has(X86_FEATURE_FXSR); + return static_cpu_has_safe(X86_FEATURE_FXSR); } static inline void fx_finit(struct i387_fxsave_struct *fx) @@ -293,7 +293,7 @@ static inline int restore_fpu_checking(struct task_struct *tsk) /* AMD K7/K8 CPUs don't save/restore FDP/FIP/FOP unless an exception is pending. Clear the x87 state here by setting it to fixed values. "m" is a random variable that should be in L1 */ - if (unlikely(static_cpu_has(X86_FEATURE_FXSAVE_LEAK))) { + if (unlikely(static_cpu_has_safe(X86_FEATURE_FXSAVE_LEAK))) { asm volatile( "fnclex\n\t" "emms\n\t" -- cgit v1.2.3 From 982e239cd2c73d2c70e14615a42c0c7391415a44 Mon Sep 17 00:00:00 2001 From: Ricardo Neri Date: Thu, 27 Mar 2014 15:10:41 -0700 Subject: x86/efi: Implement a __efi_call_virt macro For i386, all the EFI system runtime services functions return efi_status_t except efi_reset_system_system. Therefore, not all functions can be covered by the same macro in case the macro needs to do more than calling the function (i.e., return a value). The purpose of the __efi_call_virt macro is to be used when no return value is expected. For x86_64, this macro would not be needed as all the runtime services return u64. However, the same code is used for both x86_64 and i386. Thus, the macro __efi_call_virt is also defined to not break compilation. Signed-off-by: Ricardo Neri Cc: Borislav Petkov Signed-off-by: Matt Fleming --- arch/x86/include/asm/efi.h | 10 ++++++++++ arch/x86/platform/efi/efi.c | 4 ++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/arch/x86/include/asm/efi.h b/arch/x86/include/asm/efi.h index e3975597b289..19292e7cae58 100644 --- a/arch/x86/include/asm/efi.h +++ b/arch/x86/include/asm/efi.h @@ -31,9 +31,13 @@ extern unsigned long asmlinkage efi_call_phys(void *, ...); * Wrap all the virtual calls in a way that forces the parameters on the stack. */ +/* Use this macro if your virtual returns a non-void value */ #define efi_call_virt(f, args...) \ ((efi_##f##_t __attribute__((regparm(0)))*)efi.systab->runtime->f)(args) +/* Use this macro if your virtual call does not return any value */ +#define __efi_call_virt(f, args...) efi_call_virt(f, args) + #define efi_ioremap(addr, size, type, attr) ioremap_cache(addr, size) #else /* !CONFIG_X86_32 */ @@ -55,6 +59,12 @@ extern u64 asmlinkage efi_call(void *fp, ...); __s; \ }) +/* + * All X86_64 virt calls return non-void values. Thus, use non-void call for + * virt calls that would be void on X86_32. + */ +#define __efi_call_virt(f, args...) efi_call_virt(f, args) + extern void __iomem *efi_ioremap(unsigned long addr, unsigned long size, u32 type, u64 attribute); diff --git a/arch/x86/platform/efi/efi.c b/arch/x86/platform/efi/efi.c index 8f6531e8d32f..835b24820eaa 100644 --- a/arch/x86/platform/efi/efi.c +++ b/arch/x86/platform/efi/efi.c @@ -202,8 +202,8 @@ static void virt_efi_reset_system(int reset_type, unsigned long data_size, efi_char16_t *data) { - efi_call_virt(reset_system, reset_type, status, - data_size, data); + __efi_call_virt(reset_system, reset_type, status, + data_size, data); } static efi_status_t virt_efi_update_capsule(efi_capsule_header_t **capsules, -- cgit v1.2.3 From de05764e0b2a3d9559e099a2e134f8cef4500fdd Mon Sep 17 00:00:00 2001 From: Ricardo Neri Date: Thu, 27 Mar 2014 15:10:42 -0700 Subject: x86/efi: Save and restore FPU context around efi_calls (x86_64) Do a complete FPU context save/restore around the EFI calls. This required as runtime EFI firmware may potentially use the FPU. This change covers only the x86_64 configuration. Signed-off-by: Ricardo Neri Cc: Borislav Petkov Signed-off-by: Matt Fleming --- arch/x86/include/asm/efi.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/arch/x86/include/asm/efi.h b/arch/x86/include/asm/efi.h index 19292e7cae58..0b19187cc882 100644 --- a/arch/x86/include/asm/efi.h +++ b/arch/x86/include/asm/efi.h @@ -1,6 +1,7 @@ #ifndef _ASM_X86_EFI_H #define _ASM_X86_EFI_H +#include /* * We map the EFI regions needed for runtime services non-contiguously, * with preserved alignment on virtual addresses starting from -4G down @@ -54,7 +55,9 @@ extern u64 asmlinkage efi_call(void *fp, ...); \ efi_sync_low_kernel_mappings(); \ preempt_disable(); \ + __kernel_fpu_begin(); \ __s = efi_call((void *)efi.systab->runtime->f, __VA_ARGS__); \ + __kernel_fpu_end(); \ preempt_enable(); \ __s; \ }) -- cgit v1.2.3 From b738c6ea49b4e98e6ca0651da82a610f996a16ae Mon Sep 17 00:00:00 2001 From: Ricardo Neri Date: Thu, 27 Mar 2014 15:10:43 -0700 Subject: x86/efi: Save and restore FPU context around efi_calls (i386) Do a complete FPU context save/restore around the EFI calls. This required as runtime EFI firmware may potentially use the FPU. This change covers only the i386 configuration. Signed-off-by: Ricardo Neri Cc: Borislav Petkov Signed-off-by: Matt Fleming --- arch/x86/include/asm/efi.h | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/arch/x86/include/asm/efi.h b/arch/x86/include/asm/efi.h index 0b19187cc882..1eb5f6433ad8 100644 --- a/arch/x86/include/asm/efi.h +++ b/arch/x86/include/asm/efi.h @@ -34,10 +34,23 @@ extern unsigned long asmlinkage efi_call_phys(void *, ...); /* Use this macro if your virtual returns a non-void value */ #define efi_call_virt(f, args...) \ - ((efi_##f##_t __attribute__((regparm(0)))*)efi.systab->runtime->f)(args) +({ \ + efi_status_t __s; \ + kernel_fpu_begin(); \ + __s = ((efi_##f##_t __attribute__((regparm(0)))*) \ + efi.systab->runtime->f)(args); \ + kernel_fpu_end(); \ + __s; \ +}) /* Use this macro if your virtual call does not return any value */ -#define __efi_call_virt(f, args...) efi_call_virt(f, args) +#define __efi_call_virt(f, args...) \ +({ \ + kernel_fpu_begin(); \ + ((efi_##f##_t __attribute__((regparm(0)))*) \ + efi.systab->runtime->f)(args); \ + kernel_fpu_end(); \ +}) #define efi_ioremap(addr, size, type, attr) ioremap_cache(addr, size) -- cgit v1.2.3 From bafc84d539c0ffa916037840df54428623abc3e6 Mon Sep 17 00:00:00 2001 From: Matt Fleming Date: Sun, 16 Mar 2014 12:14:49 +0000 Subject: efivars: Use local variables instead of a pointer dereference In order to support a compat interface we need to stop passing pointers to structures around, since the type of structure is going to depend on whether the current task is a compat task. Cc: Mike Waychison Signed-off-by: Matt Fleming --- drivers/firmware/efi/efivars.c | 48 ++++++++++++++++++++++++++++++------------ 1 file changed, 35 insertions(+), 13 deletions(-) diff --git a/drivers/firmware/efi/efivars.c b/drivers/firmware/efi/efivars.c index 50ea412a25e6..06ec6ee1c58a 100644 --- a/drivers/firmware/efi/efivars.c +++ b/drivers/firmware/efi/efivars.c @@ -197,37 +197,48 @@ static ssize_t efivar_store_raw(struct efivar_entry *entry, const char *buf, size_t count) { struct efi_variable *new_var, *var = &entry->var; + efi_char16_t *name; + unsigned long size; + efi_guid_t vendor; + u32 attributes; + u8 *data; int err; if (count != sizeof(struct efi_variable)) return -EINVAL; new_var = (struct efi_variable *)buf; + + attributes = new_var->Attributes; + vendor = new_var->VendorGuid; + name = new_var->VariableName; + size = new_var->DataSize; + data = new_var->Data; + /* * If only updating the variable data, then the name * and guid should remain the same */ - if (memcmp(new_var->VariableName, var->VariableName, sizeof(var->VariableName)) || - efi_guidcmp(new_var->VendorGuid, var->VendorGuid)) { + if (memcmp(name, var->VariableName, sizeof(var->VariableName)) || + efi_guidcmp(vendor, var->VendorGuid)) { printk(KERN_ERR "efivars: Cannot edit the wrong variable!\n"); return -EINVAL; } - if ((new_var->DataSize <= 0) || (new_var->Attributes == 0)){ + if ((size <= 0) || (attributes == 0)){ printk(KERN_ERR "efivars: DataSize & Attributes must be valid!\n"); return -EINVAL; } - if ((new_var->Attributes & ~EFI_VARIABLE_MASK) != 0 || - efivar_validate(new_var, new_var->Data, new_var->DataSize) == false) { + if ((attributes & ~EFI_VARIABLE_MASK) != 0 || + efivar_validate(new_var, data, size) == false) { printk(KERN_ERR "efivars: Malformed variable content\n"); return -EINVAL; } memcpy(&entry->var, new_var, count); - err = efivar_entry_set(entry, new_var->Attributes, - new_var->DataSize, new_var->Data, NULL); + err = efivar_entry_set(entry, attributes, size, data, NULL); if (err) { printk(KERN_WARNING "efivars: set_variable() failed: status=%d\n", err); return -EIO; @@ -328,13 +339,20 @@ static ssize_t efivar_create(struct file *filp, struct kobject *kobj, { struct efi_variable *new_var = (struct efi_variable *)buf; struct efivar_entry *new_entry; + unsigned long size; + u32 attributes; + u8 *data; int err; if (!capable(CAP_SYS_ADMIN)) return -EACCES; - if ((new_var->Attributes & ~EFI_VARIABLE_MASK) != 0 || - efivar_validate(new_var, new_var->Data, new_var->DataSize) == false) { + attributes = new_var->Attributes; + size = new_var->DataSize; + data = new_var->Data; + + if ((attributes & ~EFI_VARIABLE_MASK) != 0 || + efivar_validate(new_var, data, size) == false) { printk(KERN_ERR "efivars: Malformed variable content\n"); return -EINVAL; } @@ -345,8 +363,8 @@ static ssize_t efivar_create(struct file *filp, struct kobject *kobj, memcpy(&new_entry->var, new_var, sizeof(*new_var)); - err = efivar_entry_set(new_entry, new_var->Attributes, new_var->DataSize, - new_var->Data, &efivar_sysfs_list); + err = efivar_entry_set(new_entry, attributes, size, + data, &efivar_sysfs_list); if (err) { if (err == -EEXIST) err = -EINVAL; @@ -370,14 +388,18 @@ static ssize_t efivar_delete(struct file *filp, struct kobject *kobj, { struct efi_variable *del_var = (struct efi_variable *)buf; struct efivar_entry *entry; + efi_char16_t *name; + efi_guid_t vendor; int err = 0; if (!capable(CAP_SYS_ADMIN)) return -EACCES; + name = del_var->VariableName; + vendor = del_var->VendorGuid; + efivar_entry_iter_begin(); - entry = efivar_entry_find(del_var->VariableName, del_var->VendorGuid, - &efivar_sysfs_list, true); + entry = efivar_entry_find(name, vendor, &efivar_sysfs_list, true); if (!entry) err = -EINVAL; else if (__efivar_entry_delete(entry)) -- cgit v1.2.3 From e003bbee2a6a19a4c733335989284caf1b179e0d Mon Sep 17 00:00:00 2001 From: Matt Fleming Date: Mon, 17 Mar 2014 09:17:28 +0000 Subject: efivars: Check size of user object Unbelieavably there are no checks to see whether the data structure passed to 'new_var' and 'del_var' is the size that we expect. Let's add some for better robustness. Cc: Mike Waychison Signed-off-by: Matt Fleming --- drivers/firmware/efi/efivars.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/firmware/efi/efivars.c b/drivers/firmware/efi/efivars.c index 06ec6ee1c58a..2c21cccc2572 100644 --- a/drivers/firmware/efi/efivars.c +++ b/drivers/firmware/efi/efivars.c @@ -347,6 +347,9 @@ static ssize_t efivar_create(struct file *filp, struct kobject *kobj, if (!capable(CAP_SYS_ADMIN)) return -EACCES; + if (count != sizeof(*new_var)) + return -EINVAL; + attributes = new_var->Attributes; size = new_var->DataSize; data = new_var->Data; @@ -395,6 +398,9 @@ static ssize_t efivar_delete(struct file *filp, struct kobject *kobj, if (!capable(CAP_SYS_ADMIN)) return -EACCES; + if (count != sizeof(*del_var)) + return -EINVAL; + name = del_var->VariableName; vendor = del_var->VendorGuid; -- cgit v1.2.3 From a5d92ad32dad94fd8f3f61778561d532bb3a2f77 Mon Sep 17 00:00:00 2001 From: Matt Fleming Date: Mon, 17 Mar 2014 10:57:00 +0000 Subject: efivars: Stop passing a struct argument to efivar_validate() In preparation for compat support, we can't assume that user variable object is represented by a 'struct efi_variable'. Convert the validation functions to take the variable name as an argument, which is the only piece of the struct that was ever used anyway. Cc: Mike Waychison Signed-off-by: Matt Fleming --- drivers/firmware/efi/efivars.c | 6 ++++-- drivers/firmware/efi/vars.c | 30 +++++++++++++++--------------- include/linux/efi.h | 6 ++++-- 3 files changed, 23 insertions(+), 19 deletions(-) diff --git a/drivers/firmware/efi/efivars.c b/drivers/firmware/efi/efivars.c index 2c21cccc2572..5ee2cfb96698 100644 --- a/drivers/firmware/efi/efivars.c +++ b/drivers/firmware/efi/efivars.c @@ -231,7 +231,7 @@ efivar_store_raw(struct efivar_entry *entry, const char *buf, size_t count) } if ((attributes & ~EFI_VARIABLE_MASK) != 0 || - efivar_validate(new_var, data, size) == false) { + efivar_validate(name, data, size) == false) { printk(KERN_ERR "efivars: Malformed variable content\n"); return -EINVAL; } @@ -339,6 +339,7 @@ static ssize_t efivar_create(struct file *filp, struct kobject *kobj, { struct efi_variable *new_var = (struct efi_variable *)buf; struct efivar_entry *new_entry; + efi_char16_t *name; unsigned long size; u32 attributes; u8 *data; @@ -351,11 +352,12 @@ static ssize_t efivar_create(struct file *filp, struct kobject *kobj, return -EINVAL; attributes = new_var->Attributes; + name = new_var->VariableName; size = new_var->DataSize; data = new_var->Data; if ((attributes & ~EFI_VARIABLE_MASK) != 0 || - efivar_validate(new_var, data, size) == false) { + efivar_validate(name, data, size) == false) { printk(KERN_ERR "efivars: Malformed variable content\n"); return -EINVAL; } diff --git a/drivers/firmware/efi/vars.c b/drivers/firmware/efi/vars.c index b22659cccca4..f0a43646a2f3 100644 --- a/drivers/firmware/efi/vars.c +++ b/drivers/firmware/efi/vars.c @@ -42,7 +42,7 @@ DECLARE_WORK(efivar_work, NULL); EXPORT_SYMBOL_GPL(efivar_work); static bool -validate_device_path(struct efi_variable *var, int match, u8 *buffer, +validate_device_path(efi_char16_t *var_name, int match, u8 *buffer, unsigned long len) { struct efi_generic_dev_path *node; @@ -75,7 +75,7 @@ validate_device_path(struct efi_variable *var, int match, u8 *buffer, } static bool -validate_boot_order(struct efi_variable *var, int match, u8 *buffer, +validate_boot_order(efi_char16_t *var_name, int match, u8 *buffer, unsigned long len) { /* An array of 16-bit integers */ @@ -86,18 +86,18 @@ validate_boot_order(struct efi_variable *var, int match, u8 *buffer, } static bool -validate_load_option(struct efi_variable *var, int match, u8 *buffer, +validate_load_option(efi_char16_t *var_name, int match, u8 *buffer, unsigned long len) { u16 filepathlength; int i, desclength = 0, namelen; - namelen = ucs2_strnlen(var->VariableName, sizeof(var->VariableName)); + namelen = ucs2_strnlen(var_name, EFI_VAR_NAME_LEN); /* Either "Boot" or "Driver" followed by four digits of hex */ for (i = match; i < match+4; i++) { - if (var->VariableName[i] > 127 || - hex_to_bin(var->VariableName[i] & 0xff) < 0) + if (var_name[i] > 127 || + hex_to_bin(var_name[i] & 0xff) < 0) return true; } @@ -132,12 +132,12 @@ validate_load_option(struct efi_variable *var, int match, u8 *buffer, /* * And, finally, check the filepath */ - return validate_device_path(var, match, buffer + desclength + 6, + return validate_device_path(var_name, match, buffer + desclength + 6, filepathlength); } static bool -validate_uint16(struct efi_variable *var, int match, u8 *buffer, +validate_uint16(efi_char16_t *var_name, int match, u8 *buffer, unsigned long len) { /* A single 16-bit integer */ @@ -148,7 +148,7 @@ validate_uint16(struct efi_variable *var, int match, u8 *buffer, } static bool -validate_ascii_string(struct efi_variable *var, int match, u8 *buffer, +validate_ascii_string(efi_char16_t *var_name, int match, u8 *buffer, unsigned long len) { int i; @@ -166,7 +166,7 @@ validate_ascii_string(struct efi_variable *var, int match, u8 *buffer, struct variable_validate { char *name; - bool (*validate)(struct efi_variable *var, int match, u8 *data, + bool (*validate)(efi_char16_t *var_name, int match, u8 *data, unsigned long len); }; @@ -189,10 +189,10 @@ static const struct variable_validate variable_validate[] = { }; bool -efivar_validate(struct efi_variable *var, u8 *data, unsigned long len) +efivar_validate(efi_char16_t *var_name, u8 *data, unsigned long len) { int i; - u16 *unicode_name = var->VariableName; + u16 *unicode_name = var_name; for (i = 0; variable_validate[i].validate != NULL; i++) { const char *name = variable_validate[i].name; @@ -208,7 +208,7 @@ efivar_validate(struct efi_variable *var, u8 *data, unsigned long len) /* Wildcard in the matching name means we've matched */ if (c == '*') - return variable_validate[i].validate(var, + return variable_validate[i].validate(var_name, match, data, len); /* Case sensitive match */ @@ -217,7 +217,7 @@ efivar_validate(struct efi_variable *var, u8 *data, unsigned long len) /* Reached the end of the string while matching */ if (!c) - return variable_validate[i].validate(var, + return variable_validate[i].validate(var_name, match, data, len); } } @@ -805,7 +805,7 @@ int efivar_entry_set_get_size(struct efivar_entry *entry, u32 attributes, *set = false; - if (efivar_validate(&entry->var, data, *size) == false) + if (efivar_validate(name, data, *size) == false) return -EINVAL; /* diff --git a/include/linux/efi.h b/include/linux/efi.h index 82d0abb2b19f..6a4d8e27d1d7 100644 --- a/include/linux/efi.h +++ b/include/linux/efi.h @@ -1039,8 +1039,10 @@ struct efivars { * and we use a page for reading/writing. */ +#define EFI_VAR_NAME_LEN 1024 + struct efi_variable { - efi_char16_t VariableName[1024/sizeof(efi_char16_t)]; + efi_char16_t VariableName[EFI_VAR_NAME_LEN/sizeof(efi_char16_t)]; efi_guid_t VendorGuid; unsigned long DataSize; __u8 Data[1024]; @@ -1122,7 +1124,7 @@ int efivar_entry_iter(int (*func)(struct efivar_entry *, void *), struct efivar_entry *efivar_entry_find(efi_char16_t *name, efi_guid_t guid, struct list_head *head, bool remove); -bool efivar_validate(struct efi_variable *var, u8 *data, unsigned long len); +bool efivar_validate(efi_char16_t *var_name, u8 *data, unsigned long len); extern struct work_struct efivar_work; void efivar_run_worker(void); -- cgit v1.2.3 From 54d2fbfb0c9d341c891926100ed0e5d4c4b0c987 Mon Sep 17 00:00:00 2001 From: Matt Fleming Date: Mon, 17 Mar 2014 15:08:34 +0000 Subject: efivars: Refactor sanity checking code into separate function Move a large chunk of code that checks the validity of efi_variable into a new function, because we'll also need to use it for the compat code. Cc: Mike Waychison Signed-off-by: Matt Fleming --- drivers/firmware/efi/efivars.c | 52 ++++++++++++++++++++++++++---------------- 1 file changed, 32 insertions(+), 20 deletions(-) diff --git a/drivers/firmware/efi/efivars.c b/drivers/firmware/efi/efivars.c index 5ee2cfb96698..a44310c6a8ba 100644 --- a/drivers/firmware/efi/efivars.c +++ b/drivers/firmware/efi/efivars.c @@ -189,6 +189,35 @@ efivar_data_read(struct efivar_entry *entry, char *buf) memcpy(buf, var->Data, var->DataSize); return var->DataSize; } + +static inline int +sanity_check(struct efi_variable *var, efi_char16_t *name, efi_guid_t vendor, + unsigned long size, u32 attributes, u8 *data) +{ + /* + * If only updating the variable data, then the name + * and guid should remain the same + */ + if (memcmp(name, var->VariableName, sizeof(var->VariableName)) || + efi_guidcmp(vendor, var->VendorGuid)) { + printk(KERN_ERR "efivars: Cannot edit the wrong variable!\n"); + return -EINVAL; + } + + if ((size <= 0) || (attributes == 0)){ + printk(KERN_ERR "efivars: DataSize & Attributes must be valid!\n"); + return -EINVAL; + } + + if ((attributes & ~EFI_VARIABLE_MASK) != 0 || + efivar_validate(name, data, size) == false) { + printk(KERN_ERR "efivars: Malformed variable content\n"); + return -EINVAL; + } + + return 0; +} + /* * We allow each variable to be edited via rewriting the * entire efi variable structure. @@ -215,26 +244,9 @@ efivar_store_raw(struct efivar_entry *entry, const char *buf, size_t count) size = new_var->DataSize; data = new_var->Data; - /* - * If only updating the variable data, then the name - * and guid should remain the same - */ - if (memcmp(name, var->VariableName, sizeof(var->VariableName)) || - efi_guidcmp(vendor, var->VendorGuid)) { - printk(KERN_ERR "efivars: Cannot edit the wrong variable!\n"); - return -EINVAL; - } - - if ((size <= 0) || (attributes == 0)){ - printk(KERN_ERR "efivars: DataSize & Attributes must be valid!\n"); - return -EINVAL; - } - - if ((attributes & ~EFI_VARIABLE_MASK) != 0 || - efivar_validate(name, data, size) == false) { - printk(KERN_ERR "efivars: Malformed variable content\n"); - return -EINVAL; - } + err = sanity_check(var, name, vendor, size, attributes, data); + if (err) + return err; memcpy(&entry->var, new_var, count); -- cgit v1.2.3 From e33655a386ed3b26ad36fb97a47ebb1c2ca1e928 Mon Sep 17 00:00:00 2001 From: Matt Fleming Date: Mon, 17 Mar 2014 15:36:37 +0000 Subject: efivars: Add compatibility code for compat tasks It seems people are using 32-bit efibootmgr on top of 64-bit kernels, which will currently fail horribly when using the efivars interface, which is the traditional efibootmgr backend (the other being efivarfs). Since there is no versioning info in the data structure, figure out when we need to munge the structure data via judicious use of is_compat_task(). Cc: Mike Waychison Signed-off-by: Matt Fleming --- drivers/firmware/efi/efivars.c | 142 +++++++++++++++++++++++++++++++++-------- 1 file changed, 116 insertions(+), 26 deletions(-) diff --git a/drivers/firmware/efi/efivars.c b/drivers/firmware/efi/efivars.c index a44310c6a8ba..463c56545ae8 100644 --- a/drivers/firmware/efi/efivars.c +++ b/drivers/firmware/efi/efivars.c @@ -69,6 +69,7 @@ #include #include #include +#include #define EFIVARS_VERSION "0.08" #define EFIVARS_DATE "2004-May-17" @@ -86,6 +87,15 @@ static struct kset *efivars_kset; static struct bin_attribute *efivars_new_var; static struct bin_attribute *efivars_del_var; +struct compat_efi_variable { + efi_char16_t VariableName[EFI_VAR_NAME_LEN/sizeof(efi_char16_t)]; + efi_guid_t VendorGuid; + __u32 DataSize; + __u8 Data[1024]; + __u32 Status; + __u32 Attributes; +} __packed; + struct efivar_attribute { struct attribute attr; ssize_t (*show) (struct efivar_entry *entry, char *buf); @@ -218,6 +228,25 @@ sanity_check(struct efi_variable *var, efi_char16_t *name, efi_guid_t vendor, return 0; } +static inline bool is_compat(void) +{ + if (IS_ENABLED(CONFIG_COMPAT) && is_compat_task()) + return true; + + return false; +} + +static void +copy_out_compat(struct efi_variable *dst, struct compat_efi_variable *src) +{ + memcpy(dst->VariableName, src->VariableName, EFI_VAR_NAME_LEN); + memcpy(dst->Data, src->Data, sizeof(src->Data)); + + dst->VendorGuid = src->VendorGuid; + dst->DataSize = src->DataSize; + dst->Attributes = src->Attributes; +} + /* * We allow each variable to be edited via rewriting the * entire efi variable structure. @@ -233,22 +262,42 @@ efivar_store_raw(struct efivar_entry *entry, const char *buf, size_t count) u8 *data; int err; - if (count != sizeof(struct efi_variable)) - return -EINVAL; + if (is_compat()) { + struct compat_efi_variable *compat; - new_var = (struct efi_variable *)buf; + if (count != sizeof(*compat)) + return -EINVAL; - attributes = new_var->Attributes; - vendor = new_var->VendorGuid; - name = new_var->VariableName; - size = new_var->DataSize; - data = new_var->Data; + compat = (struct compat_efi_variable *)buf; + attributes = compat->Attributes; + vendor = compat->VendorGuid; + name = compat->VariableName; + size = compat->DataSize; + data = compat->Data; - err = sanity_check(var, name, vendor, size, attributes, data); - if (err) - return err; + err = sanity_check(var, name, vendor, size, attributes, data); + if (err) + return err; + + copy_out_compat(&entry->var, compat); + } else { + if (count != sizeof(struct efi_variable)) + return -EINVAL; + + new_var = (struct efi_variable *)buf; - memcpy(&entry->var, new_var, count); + attributes = new_var->Attributes; + vendor = new_var->VendorGuid; + name = new_var->VariableName; + size = new_var->DataSize; + data = new_var->Data; + + err = sanity_check(var, name, vendor, size, attributes, data); + if (err) + return err; + + memcpy(&entry->var, new_var, count); + } err = efivar_entry_set(entry, attributes, size, data, NULL); if (err) { @@ -263,6 +312,8 @@ static ssize_t efivar_show_raw(struct efivar_entry *entry, char *buf) { struct efi_variable *var = &entry->var; + struct compat_efi_variable *compat; + size_t size; if (!entry || !buf) return 0; @@ -272,9 +323,23 @@ efivar_show_raw(struct efivar_entry *entry, char *buf) &entry->var.DataSize, entry->var.Data)) return -EIO; - memcpy(buf, var, sizeof(*var)); + if (is_compat()) { + compat = (struct compat_efi_variable *)buf; + + size = sizeof(*compat); + memcpy(compat->VariableName, var->VariableName, + EFI_VAR_NAME_LEN); + memcpy(compat->Data, var->Data, sizeof(compat->Data)); + + compat->VendorGuid = var->VendorGuid; + compat->DataSize = var->DataSize; + compat->Attributes = var->Attributes; + } else { + size = sizeof(*var); + memcpy(buf, var, size); + } - return sizeof(*var); + return size; } /* @@ -349,8 +414,10 @@ static ssize_t efivar_create(struct file *filp, struct kobject *kobj, struct bin_attribute *bin_attr, char *buf, loff_t pos, size_t count) { + struct compat_efi_variable *compat = (struct compat_efi_variable *)buf; struct efi_variable *new_var = (struct efi_variable *)buf; struct efivar_entry *new_entry; + bool need_compat = is_compat(); efi_char16_t *name; unsigned long size; u32 attributes; @@ -360,13 +427,23 @@ static ssize_t efivar_create(struct file *filp, struct kobject *kobj, if (!capable(CAP_SYS_ADMIN)) return -EACCES; - if (count != sizeof(*new_var)) - return -EINVAL; - - attributes = new_var->Attributes; - name = new_var->VariableName; - size = new_var->DataSize; - data = new_var->Data; + if (need_compat) { + if (count != sizeof(*compat)) + return -EINVAL; + + attributes = compat->Attributes; + name = compat->VariableName; + size = compat->DataSize; + data = compat->Data; + } else { + if (count != sizeof(*new_var)) + return -EINVAL; + + attributes = new_var->Attributes; + name = new_var->VariableName; + size = new_var->DataSize; + data = new_var->Data; + } if ((attributes & ~EFI_VARIABLE_MASK) != 0 || efivar_validate(name, data, size) == false) { @@ -378,7 +455,10 @@ static ssize_t efivar_create(struct file *filp, struct kobject *kobj, if (!new_entry) return -ENOMEM; - memcpy(&new_entry->var, new_var, sizeof(*new_var)); + if (need_compat) + copy_out_compat(&new_entry->var, compat); + else + memcpy(&new_entry->var, new_var, sizeof(*new_var)); err = efivar_entry_set(new_entry, attributes, size, data, &efivar_sysfs_list); @@ -404,6 +484,7 @@ static ssize_t efivar_delete(struct file *filp, struct kobject *kobj, char *buf, loff_t pos, size_t count) { struct efi_variable *del_var = (struct efi_variable *)buf; + struct compat_efi_variable *compat; struct efivar_entry *entry; efi_char16_t *name; efi_guid_t vendor; @@ -412,11 +493,20 @@ static ssize_t efivar_delete(struct file *filp, struct kobject *kobj, if (!capable(CAP_SYS_ADMIN)) return -EACCES; - if (count != sizeof(*del_var)) - return -EINVAL; + if (is_compat()) { + if (count != sizeof(*compat)) + return -EINVAL; + + compat = (struct compat_efi_variable *)buf; + name = compat->VariableName; + vendor = compat->VendorGuid; + } else { + if (count != sizeof(*del_var)) + return -EINVAL; - name = del_var->VariableName; - vendor = del_var->VendorGuid; + name = del_var->VariableName; + vendor = del_var->VendorGuid; + } efivar_entry_iter_begin(); entry = efivar_entry_find(name, vendor, &efivar_sysfs_list, true); -- cgit v1.2.3 From f848a5a8dcb655553423f77cc98909a04e64173d Mon Sep 17 00:00:00 2001 From: "Michael S. Tsirkin" Date: Mon, 31 Mar 2014 21:50:38 +0300 Subject: KVM: support any-length wildcard ioeventfd It is sometimes benefitial to ignore IO size, and only match on address. In hindsight this would have been a better default than matching length when KVM_IOEVENTFD_FLAG_DATAMATCH is not set, In particular, this kind of access can be optimized on VMX: there no need to do page lookups. This can currently be done with many ioeventfds but in a suboptimal way. However we can't change kernel/userspace ABI without risk of breaking some applications. Use len = 0 to mean "ignore length for matching" in a more optimal way. Signed-off-by: Michael S. Tsirkin Signed-off-by: Marcelo Tosatti --- arch/x86/kvm/x86.c | 1 + include/uapi/linux/kvm.h | 3 ++- virt/kvm/eventfd.c | 27 ++++++++++++++++++++++----- 3 files changed, 25 insertions(+), 6 deletions(-) diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 8b8fc0b792ba..bc4aaf68190c 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -2644,6 +2644,7 @@ int kvm_dev_ioctl_check_extension(long ext) case KVM_CAP_IRQ_INJECT_STATUS: case KVM_CAP_IRQFD: case KVM_CAP_IOEVENTFD: + case KVM_CAP_IOEVENTFD_NO_LENGTH: case KVM_CAP_PIT2: case KVM_CAP_PIT_STATE2: case KVM_CAP_SET_IDENTITY_MAP_ADDR: diff --git a/include/uapi/linux/kvm.h b/include/uapi/linux/kvm.h index a8f4ee5d2e82..39098a61f41c 100644 --- a/include/uapi/linux/kvm.h +++ b/include/uapi/linux/kvm.h @@ -529,7 +529,7 @@ enum { struct kvm_ioeventfd { __u64 datamatch; __u64 addr; /* legal pio/mmio address */ - __u32 len; /* 1, 2, 4, or 8 bytes */ + __u32 len; /* 1, 2, 4, or 8 bytes; or 0 to ignore length */ __s32 fd; __u32 flags; __u8 pad[36]; @@ -743,6 +743,7 @@ struct kvm_ppc_smmu_info { #define KVM_CAP_IOAPIC_POLARITY_IGNORED 97 #define KVM_CAP_ENABLE_CAP_VM 98 #define KVM_CAP_S390_IRQCHIP 99 +#define KVM_CAP_IOEVENTFD_NO_LENGTH 100 #ifdef KVM_CAP_IRQ_ROUTING diff --git a/virt/kvm/eventfd.c b/virt/kvm/eventfd.c index 29c2a04e036e..2721996bb9c2 100644 --- a/virt/kvm/eventfd.c +++ b/virt/kvm/eventfd.c @@ -600,7 +600,15 @@ ioeventfd_in_range(struct _ioeventfd *p, gpa_t addr, int len, const void *val) { u64 _val; - if (!(addr == p->addr && len == p->length)) + if (addr != p->addr) + /* address must be precise for a hit */ + return false; + + if (!p->length) + /* length = 0 means only look at the address, so always a hit */ + return true; + + if (len != p->length) /* address-range must be precise for a hit */ return false; @@ -671,9 +679,11 @@ ioeventfd_check_collision(struct kvm *kvm, struct _ioeventfd *p) list_for_each_entry(_p, &kvm->ioeventfds, list) if (_p->bus_idx == p->bus_idx && - _p->addr == p->addr && _p->length == p->length && - (_p->wildcard || p->wildcard || - _p->datamatch == p->datamatch)) + _p->addr == p->addr && + (!_p->length || !p->length || + (_p->length == p->length && + (_p->wildcard || p->wildcard || + _p->datamatch == p->datamatch)))) return true; return false; @@ -697,8 +707,9 @@ kvm_assign_ioeventfd(struct kvm *kvm, struct kvm_ioeventfd *args) int ret; bus_idx = ioeventfd_bus_from_flags(args->flags); - /* must be natural-word sized */ + /* must be natural-word sized, or 0 to ignore length */ switch (args->len) { + case 0: case 1: case 2: case 4: @@ -716,6 +727,12 @@ kvm_assign_ioeventfd(struct kvm *kvm, struct kvm_ioeventfd *args) if (args->flags & ~KVM_IOEVENTFD_VALID_FLAG_MASK) return -EINVAL; + /* ioeventfd with no length can't be combined with DATAMATCH */ + if (!args->len && + args->flags & (KVM_IOEVENTFD_FLAG_PIO | + KVM_IOEVENTFD_FLAG_DATAMATCH)) + return -EINVAL; + eventfd = eventfd_ctx_fdget(args->fd); if (IS_ERR(eventfd)) return PTR_ERR(eventfd); -- cgit v1.2.3 From 68c3b4d1676d870f0453c31d5a52e7e65c7448ae Mon Sep 17 00:00:00 2001 From: "Michael S. Tsirkin" Date: Mon, 31 Mar 2014 21:50:44 +0300 Subject: KVM: VMX: speed up wildcard MMIO EVENTFD With KVM, MMIO is much slower than PIO, due to the need to do page walk and emulation. But with EPT, it does not have to be: we know the address from the VMCS so if the address is unique, we can look up the eventfd directly, bypassing emulation. Unfortunately, this only works if userspace does not need to match on access length and data. The implementation adds a separate FAST_MMIO bus internally. This serves two purposes: - minimize overhead for old userspace that does not use eventfd with lengtth = 0 - minimize disruption in other code (since we don't know the length, devices on the MMIO bus only get a valid address in write, this way we don't need to touch all devices to teach them to handle an invalid length) At the moment, this optimization only has effect for EPT on x86. It will be possible to speed up MMIO for NPT and MMU using the same idea in the future. With this patch applied, on VMX MMIO EVENTFD is essentially as fast as PIO. I was unable to detect any measureable slowdown to non-eventfd MMIO. Making MMIO faster is important for the upcoming virtio 1.0 which includes an MMIO signalling capability. The idea was suggested by Peter Anvin. Lots of thanks to Gleb for pre-review and suggestions. Signed-off-by: Michael S. Tsirkin Signed-off-by: Marcelo Tosatti --- arch/x86/kvm/vmx.c | 4 ++++ include/linux/kvm_host.h | 1 + include/uapi/linux/kvm.h | 1 + virt/kvm/eventfd.c | 16 ++++++++++++++++ virt/kvm/kvm_main.c | 1 + 5 files changed, 23 insertions(+) diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index 1f68c5831924..eb3f2b1b764c 100644 --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c @@ -5528,6 +5528,10 @@ static int handle_ept_misconfig(struct kvm_vcpu *vcpu) gpa_t gpa; gpa = vmcs_read64(GUEST_PHYSICAL_ADDRESS); + if (!kvm_io_bus_write(vcpu->kvm, KVM_FAST_MMIO_BUS, gpa, 0, NULL)) { + skip_emulated_instruction(vcpu); + return 1; + } ret = handle_mmio_page_fault_common(vcpu, gpa, true); if (likely(ret == RET_MMIO_PF_EMULATE)) diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h index 7d21cf9f4380..6c3c2eb96d06 100644 --- a/include/linux/kvm_host.h +++ b/include/linux/kvm_host.h @@ -163,6 +163,7 @@ enum kvm_bus { KVM_MMIO_BUS, KVM_PIO_BUS, KVM_VIRTIO_CCW_NOTIFY_BUS, + KVM_FAST_MMIO_BUS, KVM_NR_BUSES }; diff --git a/include/uapi/linux/kvm.h b/include/uapi/linux/kvm.h index 39098a61f41c..d8a6ce4c2a83 100644 --- a/include/uapi/linux/kvm.h +++ b/include/uapi/linux/kvm.h @@ -515,6 +515,7 @@ enum { kvm_ioeventfd_flag_nr_pio, kvm_ioeventfd_flag_nr_deassign, kvm_ioeventfd_flag_nr_virtio_ccw_notify, + kvm_ioeventfd_flag_nr_fast_mmio, kvm_ioeventfd_flag_nr_max, }; diff --git a/virt/kvm/eventfd.c b/virt/kvm/eventfd.c index 2721996bb9c2..912ec5a95e2c 100644 --- a/virt/kvm/eventfd.c +++ b/virt/kvm/eventfd.c @@ -770,6 +770,16 @@ kvm_assign_ioeventfd(struct kvm *kvm, struct kvm_ioeventfd *args) if (ret < 0) goto unlock_fail; + /* When length is ignored, MMIO is also put on a separate bus, for + * faster lookups. + */ + if (!args->len && !(args->flags & KVM_IOEVENTFD_FLAG_PIO)) { + ret = kvm_io_bus_register_dev(kvm, KVM_FAST_MMIO_BUS, + p->addr, 0, &p->dev); + if (ret < 0) + goto register_fail; + } + kvm->buses[bus_idx]->ioeventfd_count++; list_add_tail(&p->list, &kvm->ioeventfds); @@ -777,6 +787,8 @@ kvm_assign_ioeventfd(struct kvm *kvm, struct kvm_ioeventfd *args) return 0; +register_fail: + kvm_io_bus_unregister_dev(kvm, bus_idx, &p->dev); unlock_fail: mutex_unlock(&kvm->slots_lock); @@ -816,6 +828,10 @@ kvm_deassign_ioeventfd(struct kvm *kvm, struct kvm_ioeventfd *args) continue; kvm_io_bus_unregister_dev(kvm, bus_idx, &p->dev); + if (!p->length) { + kvm_io_bus_unregister_dev(kvm, KVM_FAST_MMIO_BUS, + &p->dev); + } kvm->buses[bus_idx]->ioeventfd_count--; ioeventfd_release(p); ret = 0; diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index 56baae8c2f56..96456ac888ba 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -2922,6 +2922,7 @@ static int __kvm_io_bus_read(struct kvm_io_bus *bus, struct kvm_io_range *range, return -EOPNOTSUPP; } +EXPORT_SYMBOL_GPL(kvm_io_bus_write); /* kvm_io_bus_read - called under kvm->slots_lock */ int kvm_io_bus_read(struct kvm *kvm, enum kvm_bus bus_idx, gpa_t addr, -- cgit v1.2.3 From 8a6b173287bb94b3ef8360119020e856afb1c934 Mon Sep 17 00:00:00 2001 From: Oleg Nesterov Date: Sun, 30 Mar 2014 18:56:22 +0200 Subject: uprobes: Kill UPROBE_SKIP_SSTEP and can_skip_sstep() UPROBE_COPY_INSN, UPROBE_SKIP_SSTEP, and uprobe->flags must die. This patch kills UPROBE_SKIP_SSTEP. I never understood why it was added; not only it doesn't help, it harms. It can only help to avoid arch_uprobe_skip_sstep() if it was already called before and failed. But this is ugly, if we want to know whether we can emulate this instruction or not we should do this analysis in arch_uprobe_analyze_insn(), not when we hit this probe for the first time. And in fact this logic is simply wrong. arch_uprobe_skip_sstep() can fail or not depending on the task/register state, if this insn can be emulated but, say, put_user() fails we need to xol it this time, but this doesn't mean we shouldn't try to emulate it when this or another thread hits this bp next time. And this is the actual reason for this change. We need to emulate the "call" insn, but push(return-address) can obviously fail. Per-arch notes: x86: __skip_sstep() can only emulate "rep;nop". With this change it will be called every time and most probably for no reason. This will be fixed by the next changes. We need to change this suboptimal code anyway. arm: Should not be affected. It has its own "bool simulate" flag checked in arch_uprobe_skip_sstep(). ppc: Looks like, it can emulate almost everything. Does it actually need to record the fact that emulate_step() failed? Hopefully not. But if yes, it can add the ppc- specific flag into arch_uprobe. TODO: rename arch_uprobe_skip_sstep() to arch_uprobe_emulate_insn(), Signed-off-by: Oleg Nesterov Reviewed-by: Masami Hiramatsu Reviewed-by: David A. Long Reviewed-by: Jim Keniston Acked-by: Srikar Dronamraju --- kernel/events/uprobes.c | 23 ++--------------------- 1 file changed, 2 insertions(+), 21 deletions(-) diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c index 04709b66369d..ea2a7c0728bb 100644 --- a/kernel/events/uprobes.c +++ b/kernel/events/uprobes.c @@ -60,8 +60,6 @@ static struct percpu_rw_semaphore dup_mmap_sem; /* Have a copy of original instruction */ #define UPROBE_COPY_INSN 0 -/* Can skip singlestep */ -#define UPROBE_SKIP_SSTEP 1 struct uprobe { struct rb_node rb_node; /* node in the rb tree */ @@ -491,12 +489,9 @@ static struct uprobe *alloc_uprobe(struct inode *inode, loff_t offset) uprobe->offset = offset; init_rwsem(&uprobe->register_rwsem); init_rwsem(&uprobe->consumer_rwsem); - /* For now assume that the instruction need not be single-stepped */ - __set_bit(UPROBE_SKIP_SSTEP, &uprobe->flags); /* add to uprobes_tree, sorted on inode:offset */ cur_uprobe = insert_uprobe(uprobe); - /* a uprobe exists for this inode:offset combination */ if (cur_uprobe) { kfree(uprobe); @@ -1628,20 +1623,6 @@ bool uprobe_deny_signal(void) return true; } -/* - * Avoid singlestepping the original instruction if the original instruction - * is a NOP or can be emulated. - */ -static bool can_skip_sstep(struct uprobe *uprobe, struct pt_regs *regs) -{ - if (test_bit(UPROBE_SKIP_SSTEP, &uprobe->flags)) { - if (arch_uprobe_skip_sstep(&uprobe->arch, regs)) - return true; - clear_bit(UPROBE_SKIP_SSTEP, &uprobe->flags); - } - return false; -} - static void mmf_recalc_uprobes(struct mm_struct *mm) { struct vm_area_struct *vma; @@ -1868,13 +1849,13 @@ static void handle_swbp(struct pt_regs *regs) handler_chain(uprobe, regs); - if (can_skip_sstep(uprobe, regs)) + if (arch_uprobe_skip_sstep(&uprobe->arch, regs)) goto out; if (!pre_ssout(uprobe, regs, bp_vaddr)) return; - /* can_skip_sstep() succeeded, or restart if can't singlestep */ + /* arch_uprobe_skip_sstep() succeeded, or restart if can't singlestep */ out: put_uprobe(uprobe); } -- cgit v1.2.3 From ddb69f276c4af8bb47ad4f24a72f72ddf58c228a Mon Sep 17 00:00:00 2001 From: Oleg Nesterov Date: Mon, 31 Mar 2014 15:16:22 +0200 Subject: uprobes/x86: Fold prepare_fixups() into arch_uprobe_analyze_insn() No functional changes, preparation. Shift the code from prepare_fixups() to arch_uprobe_analyze_insn() with the following modifications: - Do not call insn_get_opcode() again, it was already called by validate_insn_bits(). - Move "case 0xea" up. This way "case 0xff" can fall through to default case. - change "case 0xff" to use the nested "switch (MODRM_REG)", this way the code looks a bit simpler. - Make the comments look consistent. While at it, kill the initialization of rip_rela_target_address and ->fixups, we can rely on kzalloc(). We will add the new members into arch_uprobe, it would be better to assume that everything is zero by default. TODO: cleanup/fix the mess in validate_insn_bits() paths: - validate_insn_64bits() and validate_insn_32bits() should be unified. - "ifdef" is not used consistently; if good_insns_64 depends on CONFIG_X86_64, then probably good_insns_32 should depend on CONFIG_X86_32/EMULATION - the usage of mm->context.ia32_compat looks wrong if the task is TIF_X32. Signed-off-by: Oleg Nesterov Reviewed-by: Masami Hiramatsu Reviewed-by: Jim Keniston Acked-by: Srikar Dronamraju --- arch/x86/kernel/uprobes.c | 110 ++++++++++++++++++++-------------------------- 1 file changed, 47 insertions(+), 63 deletions(-) diff --git a/arch/x86/kernel/uprobes.c b/arch/x86/kernel/uprobes.c index 2ed845928b5f..098e56ec7954 100644 --- a/arch/x86/kernel/uprobes.c +++ b/arch/x86/kernel/uprobes.c @@ -53,7 +53,7 @@ #define OPCODE1(insn) ((insn)->opcode.bytes[0]) #define OPCODE2(insn) ((insn)->opcode.bytes[1]) #define OPCODE3(insn) ((insn)->opcode.bytes[2]) -#define MODRM_REG(insn) X86_MODRM_REG(insn->modrm.value) +#define MODRM_REG(insn) X86_MODRM_REG((insn)->modrm.value) #define W(row, b0, b1, b2, b3, b4, b5, b6, b7, b8, b9, ba, bb, bc, bd, be, bf)\ (((b0##UL << 0x0)|(b1##UL << 0x1)|(b2##UL << 0x2)|(b3##UL << 0x3) | \ @@ -229,63 +229,6 @@ static int validate_insn_32bits(struct arch_uprobe *auprobe, struct insn *insn) return -ENOTSUPP; } -/* - * Figure out which fixups arch_uprobe_post_xol() will need to perform, and - * annotate arch_uprobe->fixups accordingly. To start with, - * arch_uprobe->fixups is either zero or it reflects rip-related fixups. - */ -static void prepare_fixups(struct arch_uprobe *auprobe, struct insn *insn) -{ - bool fix_ip = true, fix_call = false; /* defaults */ - int reg; - - insn_get_opcode(insn); /* should be a nop */ - - switch (OPCODE1(insn)) { - case 0x9d: - /* popf */ - auprobe->fixups |= UPROBE_FIX_SETF; - break; - case 0xc3: /* ret/lret */ - case 0xcb: - case 0xc2: - case 0xca: - /* ip is correct */ - fix_ip = false; - break; - case 0xe8: /* call relative - Fix return addr */ - fix_call = true; - break; - case 0x9a: /* call absolute - Fix return addr, not ip */ - fix_call = true; - fix_ip = false; - break; - case 0xff: - insn_get_modrm(insn); - reg = MODRM_REG(insn); - if (reg == 2 || reg == 3) { - /* call or lcall, indirect */ - /* Fix return addr; ip is correct. */ - fix_call = true; - fix_ip = false; - } else if (reg == 4 || reg == 5) { - /* jmp or ljmp, indirect */ - /* ip is correct. */ - fix_ip = false; - } - break; - case 0xea: /* jmp absolute -- ip is correct */ - fix_ip = false; - break; - default: - break; - } - if (fix_ip) - auprobe->fixups |= UPROBE_FIX_IP; - if (fix_call) - auprobe->fixups |= UPROBE_FIX_CALL; -} - #ifdef CONFIG_X86_64 /* * If arch_uprobe->insn doesn't use rip-relative addressing, return @@ -318,7 +261,6 @@ handle_riprel_insn(struct arch_uprobe *auprobe, struct mm_struct *mm, struct ins if (mm->context.ia32_compat) return; - auprobe->rip_rela_target_address = 0x0; if (!insn_rip_relative(insn)) return; @@ -421,16 +363,58 @@ static int validate_insn_bits(struct arch_uprobe *auprobe, struct mm_struct *mm, */ int arch_uprobe_analyze_insn(struct arch_uprobe *auprobe, struct mm_struct *mm, unsigned long addr) { - int ret; struct insn insn; + bool fix_ip = true, fix_call = false; + int ret; - auprobe->fixups = 0; ret = validate_insn_bits(auprobe, mm, &insn); - if (ret != 0) + if (ret) return ret; + /* + * Figure out which fixups arch_uprobe_post_xol() will need to perform, + * and annotate arch_uprobe->fixups accordingly. To start with, ->fixups + * is either zero or it reflects rip-related fixups. + */ handle_riprel_insn(auprobe, mm, &insn); - prepare_fixups(auprobe, &insn); + + switch (OPCODE1(&insn)) { + case 0x9d: /* popf */ + auprobe->fixups |= UPROBE_FIX_SETF; + break; + case 0xc3: /* ret or lret -- ip is correct */ + case 0xcb: + case 0xc2: + case 0xca: + fix_ip = false; + break; + case 0xe8: /* call relative - Fix return addr */ + fix_call = true; + break; + case 0x9a: /* call absolute - Fix return addr, not ip */ + fix_call = true; + fix_ip = false; + break; + case 0xea: /* jmp absolute -- ip is correct */ + fix_ip = false; + break; + case 0xff: + insn_get_modrm(&insn); + switch (MODRM_REG(&insn)) { + case 2: case 3: /* call or lcall, indirect */ + fix_call = true; + case 4: case 5: /* jmp or ljmp, indirect */ + fix_ip = false; + } + break; + default: + break; + } + + if (fix_ip) + auprobe->fixups |= UPROBE_FIX_IP; + if (fix_call) + auprobe->fixups |= UPROBE_FIX_CALL; return 0; } -- cgit v1.2.3 From 59078d4b96bb548f97d9fb429b929a289e4884d9 Mon Sep 17 00:00:00 2001 From: Oleg Nesterov Date: Mon, 31 Mar 2014 18:09:36 +0200 Subject: uprobes/x86: Kill the "ia32_compat" check in handle_riprel_insn(), remove "mm" arg Kill the "mm->context.ia32_compat" check in handle_riprel_insn(), if it is true insn_rip_relative() must return false. validate_insn_bits() passed "ia32_compat" as !x86_64 to insn_init(), and insn_rip_relative() checks insn->x86_64. Also, remove the no longer needed "struct mm_struct *mm" argument and the unnecessary "return" at the end. Signed-off-by: Oleg Nesterov Reviewed-by: Masami Hiramatsu Reviewed-by: Jim Keniston Acked-by: Srikar Dronamraju --- arch/x86/kernel/uprobes.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/arch/x86/kernel/uprobes.c b/arch/x86/kernel/uprobes.c index 098e56ec7954..963c121c0307 100644 --- a/arch/x86/kernel/uprobes.c +++ b/arch/x86/kernel/uprobes.c @@ -253,14 +253,11 @@ static int validate_insn_32bits(struct arch_uprobe *auprobe, struct insn *insn) * - The displacement is always 4 bytes. */ static void -handle_riprel_insn(struct arch_uprobe *auprobe, struct mm_struct *mm, struct insn *insn) +handle_riprel_insn(struct arch_uprobe *auprobe, struct insn *insn) { u8 *cursor; u8 reg; - if (mm->context.ia32_compat) - return; - if (!insn_rip_relative(insn)) return; @@ -314,7 +311,6 @@ handle_riprel_insn(struct arch_uprobe *auprobe, struct mm_struct *mm, struct ins cursor++; memmove(cursor, cursor + insn->displacement.nbytes, insn->immediate.nbytes); } - return; } static int validate_insn_64bits(struct arch_uprobe *auprobe, struct insn *insn) @@ -343,7 +339,7 @@ static int validate_insn_bits(struct arch_uprobe *auprobe, struct mm_struct *mm, return validate_insn_64bits(auprobe, insn); } #else /* 32-bit: */ -static void handle_riprel_insn(struct arch_uprobe *auprobe, struct mm_struct *mm, struct insn *insn) +static void handle_riprel_insn(struct arch_uprobe *auprobe, struct insn *insn) { /* No RIP-relative addressing on 32-bit */ } @@ -376,7 +372,7 @@ int arch_uprobe_analyze_insn(struct arch_uprobe *auprobe, struct mm_struct *mm, * and annotate arch_uprobe->fixups accordingly. To start with, ->fixups * is either zero or it reflects rip-related fixups. */ - handle_riprel_insn(auprobe, mm, &insn); + handle_riprel_insn(auprobe, &insn); switch (OPCODE1(&insn)) { case 0x9d: /* popf */ -- cgit v1.2.3 From d20737c07a1063d681fe9fb86f3da369da1edab7 Mon Sep 17 00:00:00 2001 From: Oleg Nesterov Date: Mon, 31 Mar 2014 18:35:09 +0200 Subject: uprobes/x86: Gather "riprel" functions together Cosmetic. Move pre_xol_rip_insn() and handle_riprel_post_xol() up to the closely related handle_riprel_insn(). This way it is simpler to read and understand this code, and this lessens the number of ifdef's. While at it, update the comment in handle_riprel_post_xol() as Jim suggested. TODO: rename them somehow to make the naming consistent. Signed-off-by: Oleg Nesterov Reviewed-by: Masami Hiramatsu Reviewed-by: Jim Keniston --- arch/x86/kernel/uprobes.c | 118 +++++++++++++++++++++------------------------- 1 file changed, 53 insertions(+), 65 deletions(-) diff --git a/arch/x86/kernel/uprobes.c b/arch/x86/kernel/uprobes.c index 963c121c0307..c52c30fa7871 100644 --- a/arch/x86/kernel/uprobes.c +++ b/arch/x86/kernel/uprobes.c @@ -313,6 +313,48 @@ handle_riprel_insn(struct arch_uprobe *auprobe, struct insn *insn) } } +/* + * If we're emulating a rip-relative instruction, save the contents + * of the scratch register and store the target address in that register. + */ +static void +pre_xol_rip_insn(struct arch_uprobe *auprobe, struct pt_regs *regs, + struct arch_uprobe_task *autask) +{ + if (auprobe->fixups & UPROBE_FIX_RIP_AX) { + autask->saved_scratch_register = regs->ax; + regs->ax = current->utask->vaddr; + regs->ax += auprobe->rip_rela_target_address; + } else if (auprobe->fixups & UPROBE_FIX_RIP_CX) { + autask->saved_scratch_register = regs->cx; + regs->cx = current->utask->vaddr; + regs->cx += auprobe->rip_rela_target_address; + } +} + +static void +handle_riprel_post_xol(struct arch_uprobe *auprobe, struct pt_regs *regs, long *correction) +{ + if (auprobe->fixups & (UPROBE_FIX_RIP_AX | UPROBE_FIX_RIP_CX)) { + struct arch_uprobe_task *autask; + + autask = ¤t->utask->autask; + if (auprobe->fixups & UPROBE_FIX_RIP_AX) + regs->ax = autask->saved_scratch_register; + else + regs->cx = autask->saved_scratch_register; + + /* + * The original instruction includes a displacement, and so + * is 4 bytes longer than what we've just single-stepped. + * Caller may need to apply other fixups to handle stuff + * like "jmpq *...(%rip)" and "callq *...(%rip)". + */ + if (correction) + *correction += 4; + } +} + static int validate_insn_64bits(struct arch_uprobe *auprobe, struct insn *insn) { insn_init(insn, auprobe->insn, true); @@ -339,9 +381,19 @@ static int validate_insn_bits(struct arch_uprobe *auprobe, struct mm_struct *mm, return validate_insn_64bits(auprobe, insn); } #else /* 32-bit: */ +/* + * No RIP-relative addressing on 32-bit + */ static void handle_riprel_insn(struct arch_uprobe *auprobe, struct insn *insn) { - /* No RIP-relative addressing on 32-bit */ +} +static void pre_xol_rip_insn(struct arch_uprobe *auprobe, struct pt_regs *regs, + struct arch_uprobe_task *autask) +{ +} +static void handle_riprel_post_xol(struct arch_uprobe *auprobe, struct pt_regs *regs, + long *correction) +{ } static int validate_insn_bits(struct arch_uprobe *auprobe, struct mm_struct *mm, struct insn *insn) @@ -415,34 +467,6 @@ int arch_uprobe_analyze_insn(struct arch_uprobe *auprobe, struct mm_struct *mm, return 0; } -#ifdef CONFIG_X86_64 -/* - * If we're emulating a rip-relative instruction, save the contents - * of the scratch register and store the target address in that register. - */ -static void -pre_xol_rip_insn(struct arch_uprobe *auprobe, struct pt_regs *regs, - struct arch_uprobe_task *autask) -{ - if (auprobe->fixups & UPROBE_FIX_RIP_AX) { - autask->saved_scratch_register = regs->ax; - regs->ax = current->utask->vaddr; - regs->ax += auprobe->rip_rela_target_address; - } else if (auprobe->fixups & UPROBE_FIX_RIP_CX) { - autask->saved_scratch_register = regs->cx; - regs->cx = current->utask->vaddr; - regs->cx += auprobe->rip_rela_target_address; - } -} -#else -static void -pre_xol_rip_insn(struct arch_uprobe *auprobe, struct pt_regs *regs, - struct arch_uprobe_task *autask) -{ - /* No RIP-relative addressing on 32-bit */ -} -#endif - /* * arch_uprobe_pre_xol - prepare to execute out of line. * @auprobe: the probepoint information. @@ -492,42 +516,6 @@ static int adjust_ret_addr(unsigned long sp, long correction) return 0; } -#ifdef CONFIG_X86_64 -static bool is_riprel_insn(struct arch_uprobe *auprobe) -{ - return ((auprobe->fixups & (UPROBE_FIX_RIP_AX | UPROBE_FIX_RIP_CX)) != 0); -} - -static void -handle_riprel_post_xol(struct arch_uprobe *auprobe, struct pt_regs *regs, long *correction) -{ - if (is_riprel_insn(auprobe)) { - struct arch_uprobe_task *autask; - - autask = ¤t->utask->autask; - if (auprobe->fixups & UPROBE_FIX_RIP_AX) - regs->ax = autask->saved_scratch_register; - else - regs->cx = autask->saved_scratch_register; - - /* - * The original instruction includes a displacement, and so - * is 4 bytes longer than what we've just single-stepped. - * Fall through to handle stuff like "jmpq *...(%rip)" and - * "callq *...(%rip)". - */ - if (correction) - *correction += 4; - } -} -#else -static void -handle_riprel_post_xol(struct arch_uprobe *auprobe, struct pt_regs *regs, long *correction) -{ - /* No RIP-relative addressing on 32-bit */ -} -#endif - /* * If xol insn itself traps and generates a signal(Say, * SIGILL/SIGSEGV/etc), then detect the case where a singlestepped -- cgit v1.2.3 From 34e7317d6ae8f6111ac449444f22e14f4a14ebfd Mon Sep 17 00:00:00 2001 From: Oleg Nesterov Date: Mon, 31 Mar 2014 19:38:09 +0200 Subject: uprobes/x86: move the UPROBE_FIX_{RIP,IP,CALL} code at the end of pre/post hooks No functional changes. Preparation to simplify the review of the next change. Just reorder the code in arch_uprobe_pre/post_xol() functions so that UPROBE_FIX_{RIP_*,IP,CALL} logic goes to the end. Also change arch_uprobe_pre_xol() to use utask instead of autask, to make the code more symmetrical with arch_uprobe_post_xol(). Signed-off-by: Oleg Nesterov Reviewed-by: Masami Hiramatsu Reviewed-by: Jim Keniston Acked-by: Srikar Dronamraju --- arch/x86/kernel/uprobes.c | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/arch/x86/kernel/uprobes.c b/arch/x86/kernel/uprobes.c index c52c30fa7871..3bb4198aa588 100644 --- a/arch/x86/kernel/uprobes.c +++ b/arch/x86/kernel/uprobes.c @@ -474,19 +474,18 @@ int arch_uprobe_analyze_insn(struct arch_uprobe *auprobe, struct mm_struct *mm, */ int arch_uprobe_pre_xol(struct arch_uprobe *auprobe, struct pt_regs *regs) { - struct arch_uprobe_task *autask; + struct uprobe_task *utask = current->utask; - autask = ¤t->utask->autask; - autask->saved_trap_nr = current->thread.trap_nr; + regs->ip = utask->xol_vaddr; + utask->autask.saved_trap_nr = current->thread.trap_nr; current->thread.trap_nr = UPROBE_TRAP_NR; - regs->ip = current->utask->xol_vaddr; - pre_xol_rip_insn(auprobe, regs, autask); - autask->saved_tf = !!(regs->flags & X86_EFLAGS_TF); + utask->autask.saved_tf = !!(regs->flags & X86_EFLAGS_TF); regs->flags |= X86_EFLAGS_TF; if (test_tsk_thread_flag(current, TIF_BLOCKSTEP)) set_task_blockstep(current, false); + pre_xol_rip_insn(auprobe, regs, &utask->autask); return 0; } @@ -560,22 +559,13 @@ bool arch_uprobe_xol_was_trapped(struct task_struct *t) */ int arch_uprobe_post_xol(struct arch_uprobe *auprobe, struct pt_regs *regs) { - struct uprobe_task *utask; + struct uprobe_task *utask = current->utask; long correction; int result = 0; WARN_ON_ONCE(current->thread.trap_nr != UPROBE_TRAP_NR); - utask = current->utask; current->thread.trap_nr = utask->autask.saved_trap_nr; - correction = (long)(utask->vaddr - utask->xol_vaddr); - handle_riprel_post_xol(auprobe, regs, &correction); - if (auprobe->fixups & UPROBE_FIX_IP) - regs->ip += correction; - - if (auprobe->fixups & UPROBE_FIX_CALL) - result = adjust_ret_addr(regs->sp, correction); - /* * arch_uprobe_pre_xol() doesn't save the state of TIF_BLOCKSTEP * so we can get an extra SIGTRAP if we do not clear TF. We need @@ -586,6 +576,14 @@ int arch_uprobe_post_xol(struct arch_uprobe *auprobe, struct pt_regs *regs) else if (!(auprobe->fixups & UPROBE_FIX_SETF)) regs->flags &= ~X86_EFLAGS_TF; + correction = (long)(utask->vaddr - utask->xol_vaddr); + handle_riprel_post_xol(auprobe, regs, &correction); + if (auprobe->fixups & UPROBE_FIX_IP) + regs->ip += correction; + + if (auprobe->fixups & UPROBE_FIX_CALL) + result = adjust_ret_addr(regs->sp, correction); + return result; } -- cgit v1.2.3 From 8ad8e9d3fd64f101eed6652964670672d699e563 Mon Sep 17 00:00:00 2001 From: Oleg Nesterov Date: Mon, 31 Mar 2014 21:01:31 +0200 Subject: uprobes/x86: Introduce uprobe_xol_ops and arch_uprobe->ops Introduce arch_uprobe->ops pointing to the "struct uprobe_xol_ops", move the current UPROBE_FIX_{RIP*,IP,CALL} code into the default set of methods and change arch_uprobe_pre/post_xol() accordingly. This way we can add the new uprobe_xol_ops's to handle the insns which need the special processing (rip-relative jmp/call at least). Signed-off-by: Oleg Nesterov Reviewed-by: Jim Keniston Reviewed-by: Masami Hiramatsu --- arch/x86/include/asm/uprobes.h | 7 ++- arch/x86/kernel/uprobes.c | 107 ++++++++++++++++++++++++++--------------- 2 files changed, 74 insertions(+), 40 deletions(-) diff --git a/arch/x86/include/asm/uprobes.h b/arch/x86/include/asm/uprobes.h index 3087ea9c5f2e..9f8210bcbb49 100644 --- a/arch/x86/include/asm/uprobes.h +++ b/arch/x86/include/asm/uprobes.h @@ -33,12 +33,17 @@ typedef u8 uprobe_opcode_t; #define UPROBE_SWBP_INSN 0xcc #define UPROBE_SWBP_INSN_SIZE 1 +struct uprobe_xol_ops; + struct arch_uprobe { - u16 fixups; union { u8 insn[MAX_UINSN_BYTES]; u8 ixol[MAX_UINSN_BYTES]; }; + + u16 fixups; + const struct uprobe_xol_ops *ops; + #ifdef CONFIG_X86_64 unsigned long rip_rela_target_address; #endif diff --git a/arch/x86/kernel/uprobes.c b/arch/x86/kernel/uprobes.c index 3bb4198aa588..13ad8a38c2d9 100644 --- a/arch/x86/kernel/uprobes.c +++ b/arch/x86/kernel/uprobes.c @@ -402,6 +402,64 @@ static int validate_insn_bits(struct arch_uprobe *auprobe, struct mm_struct *mm, } #endif /* CONFIG_X86_64 */ +struct uprobe_xol_ops { + bool (*emulate)(struct arch_uprobe *, struct pt_regs *); + int (*pre_xol)(struct arch_uprobe *, struct pt_regs *); + int (*post_xol)(struct arch_uprobe *, struct pt_regs *); +}; + +static int default_pre_xol_op(struct arch_uprobe *auprobe, struct pt_regs *regs) +{ + pre_xol_rip_insn(auprobe, regs, ¤t->utask->autask); + return 0; +} + +/* + * Adjust the return address pushed by a call insn executed out of line. + */ +static int adjust_ret_addr(unsigned long sp, long correction) +{ + int rasize, ncopied; + long ra = 0; + + if (is_ia32_task()) + rasize = 4; + else + rasize = 8; + + ncopied = copy_from_user(&ra, (void __user *)sp, rasize); + if (unlikely(ncopied)) + return -EFAULT; + + ra += correction; + ncopied = copy_to_user((void __user *)sp, &ra, rasize); + if (unlikely(ncopied)) + return -EFAULT; + + return 0; +} + +static int default_post_xol_op(struct arch_uprobe *auprobe, struct pt_regs *regs) +{ + struct uprobe_task *utask = current->utask; + long correction = (long)(utask->vaddr - utask->xol_vaddr); + int ret = 0; + + handle_riprel_post_xol(auprobe, regs, &correction); + if (auprobe->fixups & UPROBE_FIX_IP) + regs->ip += correction; + + if (auprobe->fixups & UPROBE_FIX_CALL) + ret = adjust_ret_addr(regs->sp, correction); + + return ret; +} + +static struct uprobe_xol_ops default_xol_ops = { + .pre_xol = default_pre_xol_op, + .post_xol = default_post_xol_op, +}; + /** * arch_uprobe_analyze_insn - instruction analysis including validity and fixups. * @mm: the probed address space. @@ -464,6 +522,7 @@ int arch_uprobe_analyze_insn(struct arch_uprobe *auprobe, struct mm_struct *mm, if (fix_call) auprobe->fixups |= UPROBE_FIX_CALL; + auprobe->ops = &default_xol_ops; return 0; } @@ -485,33 +544,8 @@ int arch_uprobe_pre_xol(struct arch_uprobe *auprobe, struct pt_regs *regs) if (test_tsk_thread_flag(current, TIF_BLOCKSTEP)) set_task_blockstep(current, false); - pre_xol_rip_insn(auprobe, regs, &utask->autask); - return 0; -} - -/* - * This function is called by arch_uprobe_post_xol() to adjust the return - * address pushed by a call instruction executed out of line. - */ -static int adjust_ret_addr(unsigned long sp, long correction) -{ - int rasize, ncopied; - long ra = 0; - - if (is_ia32_task()) - rasize = 4; - else - rasize = 8; - - ncopied = copy_from_user(&ra, (void __user *)sp, rasize); - if (unlikely(ncopied)) - return -EFAULT; - - ra += correction; - ncopied = copy_to_user((void __user *)sp, &ra, rasize); - if (unlikely(ncopied)) - return -EFAULT; - + if (auprobe->ops->pre_xol) + return auprobe->ops->pre_xol(auprobe, regs); return 0; } @@ -560,11 +594,8 @@ bool arch_uprobe_xol_was_trapped(struct task_struct *t) int arch_uprobe_post_xol(struct arch_uprobe *auprobe, struct pt_regs *regs) { struct uprobe_task *utask = current->utask; - long correction; - int result = 0; WARN_ON_ONCE(current->thread.trap_nr != UPROBE_TRAP_NR); - current->thread.trap_nr = utask->autask.saved_trap_nr; /* * arch_uprobe_pre_xol() doesn't save the state of TIF_BLOCKSTEP @@ -576,15 +607,9 @@ int arch_uprobe_post_xol(struct arch_uprobe *auprobe, struct pt_regs *regs) else if (!(auprobe->fixups & UPROBE_FIX_SETF)) regs->flags &= ~X86_EFLAGS_TF; - correction = (long)(utask->vaddr - utask->xol_vaddr); - handle_riprel_post_xol(auprobe, regs, &correction); - if (auprobe->fixups & UPROBE_FIX_IP) - regs->ip += correction; - - if (auprobe->fixups & UPROBE_FIX_CALL) - result = adjust_ret_addr(regs->sp, correction); - - return result; + if (auprobe->ops->post_xol) + return auprobe->ops->post_xol(auprobe, regs); + return 0; } /* callback routine for handling exceptions. */ @@ -642,6 +667,10 @@ static bool __skip_sstep(struct arch_uprobe *auprobe, struct pt_regs *regs) { int i; + if (auprobe->ops->emulate) + return auprobe->ops->emulate(auprobe, regs); + + /* TODO: move this code into ->emulate() hook */ for (i = 0; i < MAX_UINSN_BYTES; i++) { if (auprobe->insn[i] == 0x66) continue; -- cgit v1.2.3 From e55848a4f8ee52465771983e144f0c3337776eda Mon Sep 17 00:00:00 2001 From: Oleg Nesterov Date: Mon, 31 Mar 2014 17:24:14 +0200 Subject: uprobes/x86: Conditionalize the usage of handle_riprel_insn() arch_uprobe_analyze_insn() calls handle_riprel_insn() at the start, but only "0xff" and "default" cases need the UPROBE_FIX_RIP_ logic. Move the callsite into "default" case and change the "0xff" case to fall-through. We are going to add the various hooks to handle the rip-relative jmp/call instructions (and more), we need this change to enforce the fact that the new code can not conflict with is_riprel_insn() logic which, after this change, can only be used by default_xol_ops. Note: arch_uprobe_abort_xol() still calls handle_riprel_post_xol() directly. This is fine unless another _xol_ops we may add later will need to reuse "UPROBE_FIX_RIP_AX|UPROBE_FIX_RIP_CX" bits in ->fixup. In this case we can add uprobe_xol_ops->abort() hook, which (perhaps) we will need anyway in the long term. Signed-off-by: Oleg Nesterov Reviewed-by: Jim Keniston Reviewed-by: Masami Hiramatsu --- arch/x86/kernel/uprobes.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/arch/x86/kernel/uprobes.c b/arch/x86/kernel/uprobes.c index 13ad8a38c2d9..08cdb82815fe 100644 --- a/arch/x86/kernel/uprobes.c +++ b/arch/x86/kernel/uprobes.c @@ -482,8 +482,6 @@ int arch_uprobe_analyze_insn(struct arch_uprobe *auprobe, struct mm_struct *mm, * and annotate arch_uprobe->fixups accordingly. To start with, ->fixups * is either zero or it reflects rip-related fixups. */ - handle_riprel_insn(auprobe, &insn); - switch (OPCODE1(&insn)) { case 0x9d: /* popf */ auprobe->fixups |= UPROBE_FIX_SETF; @@ -512,9 +510,9 @@ int arch_uprobe_analyze_insn(struct arch_uprobe *auprobe, struct mm_struct *mm, case 4: case 5: /* jmp or ljmp, indirect */ fix_ip = false; } - break; + /* fall through */ default: - break; + handle_riprel_insn(auprobe, &insn); } if (fix_ip) -- cgit v1.2.3 From 014940bad8e46ca7bd0483f760f9cba60088a3d4 Mon Sep 17 00:00:00 2001 From: Oleg Nesterov Date: Thu, 3 Apr 2014 20:20:10 +0200 Subject: uprobes/x86: Send SIGILL if arch_uprobe_post_xol() fails Currently the error from arch_uprobe_post_xol() is silently ignored. This doesn't look good and this can lead to the hard-to-debug problems. 1. Change handle_singlestep() to loudly complain and send SIGILL. Note: this only affects x86, ppc/arm can't fail. 2. Change arch_uprobe_post_xol() to call arch_uprobe_abort_xol() and avoid TF games if it is going to return an error. This can help to to analyze the problem, if nothing else we should not report ->ip = xol_slot in the core-file. Note: this means that handle_riprel_post_xol() can be called twice, but this is fine because it is idempotent. Signed-off-by: Oleg Nesterov Reviewed-by: Masami Hiramatsu Reviewed-by: Jim Keniston --- arch/x86/kernel/uprobes.c | 16 ++++++++++++---- kernel/events/uprobes.c | 8 +++++++- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/arch/x86/kernel/uprobes.c b/arch/x86/kernel/uprobes.c index 08cdb82815fe..e72903eacd43 100644 --- a/arch/x86/kernel/uprobes.c +++ b/arch/x86/kernel/uprobes.c @@ -594,6 +594,15 @@ int arch_uprobe_post_xol(struct arch_uprobe *auprobe, struct pt_regs *regs) struct uprobe_task *utask = current->utask; WARN_ON_ONCE(current->thread.trap_nr != UPROBE_TRAP_NR); + + if (auprobe->ops->post_xol) { + int err = auprobe->ops->post_xol(auprobe, regs); + if (err) { + arch_uprobe_abort_xol(auprobe, regs); + return err; + } + } + current->thread.trap_nr = utask->autask.saved_trap_nr; /* * arch_uprobe_pre_xol() doesn't save the state of TIF_BLOCKSTEP @@ -605,8 +614,6 @@ int arch_uprobe_post_xol(struct arch_uprobe *auprobe, struct pt_regs *regs) else if (!(auprobe->fixups & UPROBE_FIX_SETF)) regs->flags &= ~X86_EFLAGS_TF; - if (auprobe->ops->post_xol) - return auprobe->ops->post_xol(auprobe, regs); return 0; } @@ -641,8 +648,9 @@ int arch_uprobe_exception_notify(struct notifier_block *self, unsigned long val, /* * This function gets called when XOL instruction either gets trapped or - * the thread has a fatal signal, so reset the instruction pointer to its - * probed address. + * the thread has a fatal signal, or if arch_uprobe_post_xol() failed. + * Reset the instruction pointer to its probed address for the potential + * restart or for post mortem analysis. */ void arch_uprobe_abort_xol(struct arch_uprobe *auprobe, struct pt_regs *regs) { diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c index ea2a7c0728bb..d1edc5e6fd03 100644 --- a/kernel/events/uprobes.c +++ b/kernel/events/uprobes.c @@ -1867,10 +1867,11 @@ out: static void handle_singlestep(struct uprobe_task *utask, struct pt_regs *regs) { struct uprobe *uprobe; + int err = 0; uprobe = utask->active_uprobe; if (utask->state == UTASK_SSTEP_ACK) - arch_uprobe_post_xol(&uprobe->arch, regs); + err = arch_uprobe_post_xol(&uprobe->arch, regs); else if (utask->state == UTASK_SSTEP_TRAPPED) arch_uprobe_abort_xol(&uprobe->arch, regs); else @@ -1884,6 +1885,11 @@ static void handle_singlestep(struct uprobe_task *utask, struct pt_regs *regs) spin_lock_irq(¤t->sighand->siglock); recalc_sigpending(); /* see uprobe_deny_signal() */ spin_unlock_irq(¤t->sighand->siglock); + + if (unlikely(err)) { + uprobe_warn(current, "execute the probed insn, sending SIGILL."); + force_sig_info(SIGILL, SEND_SIG_FORCED, current); + } } /* -- cgit v1.2.3 From 75f9ef0b7f1aae33b7be7ba8d9c23c8cb48c2212 Mon Sep 17 00:00:00 2001 From: Oleg Nesterov Date: Thu, 3 Apr 2014 20:52:19 +0200 Subject: uprobes/x86: Teach arch_uprobe_post_xol() to restart if possible SIGILL after the failed arch_uprobe_post_xol() should only be used as a last resort, we should try to restart the probed insn if possible. Currently only adjust_ret_addr() can fail, and this can only happen if another thread unmapped our stack after we executed "call" out-of-line. Most probably the application if buggy, but even in this case it can have a handler for SIGSEGV/etc. And in theory it can be even correct and do something non-trivial with its memory. Of course we can't restart unconditionally, so arch_uprobe_post_xol() does this only if ->post_xol() returns -ERESTART even if currently this is the only possible error. default_post_xol_op(UPROBE_FIX_CALL) can always restart, but as Jim pointed out it should not forget to pop off the return address pushed by this insn executed out-of-line. Note: this is not "perfect", we do not want the extra handler_chain() after restart, but I think this is the best solution we can realistically do without too much uglifications. Signed-off-by: Oleg Nesterov Reviewed-by: Masami Hiramatsu Reviewed-by: Jim Keniston --- arch/x86/kernel/uprobes.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/arch/x86/kernel/uprobes.c b/arch/x86/kernel/uprobes.c index e72903eacd43..cdd6909affcb 100644 --- a/arch/x86/kernel/uprobes.c +++ b/arch/x86/kernel/uprobes.c @@ -443,16 +443,22 @@ static int default_post_xol_op(struct arch_uprobe *auprobe, struct pt_regs *regs { struct uprobe_task *utask = current->utask; long correction = (long)(utask->vaddr - utask->xol_vaddr); - int ret = 0; handle_riprel_post_xol(auprobe, regs, &correction); if (auprobe->fixups & UPROBE_FIX_IP) regs->ip += correction; - if (auprobe->fixups & UPROBE_FIX_CALL) - ret = adjust_ret_addr(regs->sp, correction); + if (auprobe->fixups & UPROBE_FIX_CALL) { + if (adjust_ret_addr(regs->sp, correction)) { + if (is_ia32_task()) + regs->sp += 4; + else + regs->sp += 8; + return -ERESTART; + } + } - return ret; + return 0; } static struct uprobe_xol_ops default_xol_ops = { @@ -599,6 +605,12 @@ int arch_uprobe_post_xol(struct arch_uprobe *auprobe, struct pt_regs *regs) int err = auprobe->ops->post_xol(auprobe, regs); if (err) { arch_uprobe_abort_xol(auprobe, regs); + /* + * Restart the probed insn. ->post_xol() must ensure + * this is really possible if it returns -ERESTART. + */ + if (err == -ERESTART) + return 0; return err; } } -- cgit v1.2.3 From 8faaed1b9f500d6cf32702716733a645c9b0727a Mon Sep 17 00:00:00 2001 From: Oleg Nesterov Date: Sun, 6 Apr 2014 17:16:10 +0200 Subject: uprobes/x86: Introduce sizeof_long(), cleanup adjust_ret_addr() and arch_uretprobe_hijack_return_addr() 1. Add the trivial sizeof_long() helper and change other callers of is_ia32_task() to use it. TODO: is_ia32_task() is not what we actually want, TS_COMPAT does not necessarily mean 32bit. Fortunately syscall-like insns can't be probed so it actually works, but it would be better to rename and use is_ia32_frame(). 2. As Jim pointed out "ncopied" in arch_uretprobe_hijack_return_addr() and adjust_ret_addr() should be named "nleft". And in fact only the last copy_to_user() in arch_uretprobe_hijack_return_addr() actually needs to inspect the non-zero error code. TODO: adjust_ret_addr() should die. We can always calculate the value we need to write into *regs->sp, just UPROBE_FIX_CALL should record insn->length. Signed-off-by: Oleg Nesterov Reviewed-by: Jim Keniston --- arch/x86/kernel/uprobes.c | 37 +++++++++++++++---------------------- 1 file changed, 15 insertions(+), 22 deletions(-) diff --git a/arch/x86/kernel/uprobes.c b/arch/x86/kernel/uprobes.c index cdd6909affcb..aecc22054384 100644 --- a/arch/x86/kernel/uprobes.c +++ b/arch/x86/kernel/uprobes.c @@ -408,6 +408,11 @@ struct uprobe_xol_ops { int (*post_xol)(struct arch_uprobe *, struct pt_regs *); }; +static inline int sizeof_long(void) +{ + return is_ia32_task() ? 4 : 8; +} + static int default_pre_xol_op(struct arch_uprobe *auprobe, struct pt_regs *regs) { pre_xol_rip_insn(auprobe, regs, ¤t->utask->autask); @@ -419,21 +424,14 @@ static int default_pre_xol_op(struct arch_uprobe *auprobe, struct pt_regs *regs) */ static int adjust_ret_addr(unsigned long sp, long correction) { - int rasize, ncopied; - long ra = 0; - - if (is_ia32_task()) - rasize = 4; - else - rasize = 8; + int rasize = sizeof_long(); + long ra; - ncopied = copy_from_user(&ra, (void __user *)sp, rasize); - if (unlikely(ncopied)) + if (copy_from_user(&ra, (void __user *)sp, rasize)) return -EFAULT; ra += correction; - ncopied = copy_to_user((void __user *)sp, &ra, rasize); - if (unlikely(ncopied)) + if (copy_to_user((void __user *)sp, &ra, rasize)) return -EFAULT; return 0; @@ -450,10 +448,7 @@ static int default_post_xol_op(struct arch_uprobe *auprobe, struct pt_regs *regs if (auprobe->fixups & UPROBE_FIX_CALL) { if (adjust_ret_addr(regs->sp, correction)) { - if (is_ia32_task()) - regs->sp += 4; - else - regs->sp += 8; + regs->sp += sizeof_long(); return -ERESTART; } } @@ -714,23 +709,21 @@ bool arch_uprobe_skip_sstep(struct arch_uprobe *auprobe, struct pt_regs *regs) unsigned long arch_uretprobe_hijack_return_addr(unsigned long trampoline_vaddr, struct pt_regs *regs) { - int rasize, ncopied; + int rasize = sizeof_long(), nleft; unsigned long orig_ret_vaddr = 0; /* clear high bits for 32-bit apps */ - rasize = is_ia32_task() ? 4 : 8; - ncopied = copy_from_user(&orig_ret_vaddr, (void __user *)regs->sp, rasize); - if (unlikely(ncopied)) + if (copy_from_user(&orig_ret_vaddr, (void __user *)regs->sp, rasize)) return -1; /* check whether address has been already hijacked */ if (orig_ret_vaddr == trampoline_vaddr) return orig_ret_vaddr; - ncopied = copy_to_user((void __user *)regs->sp, &trampoline_vaddr, rasize); - if (likely(!ncopied)) + nleft = copy_to_user((void __user *)regs->sp, &trampoline_vaddr, rasize); + if (likely(!nleft)) return orig_ret_vaddr; - if (ncopied != rasize) { + if (nleft != rasize) { pr_err("uprobe: return address clobbered: pid=%d, %%sp=%#lx, " "%%ip=%#lx\n", current->pid, regs->sp, regs->ip); -- cgit v1.2.3 From 7ba6db2d688bdf83049a18c8e55b2d1e58e8b0bc Mon Sep 17 00:00:00 2001 From: Oleg Nesterov Date: Sat, 5 Apr 2014 20:05:02 +0200 Subject: uprobes/x86: Emulate unconditional relative jmp's Currently we always execute all insns out-of-line, including relative jmp's and call's. This assumes that even if regs->ip points to nowhere after the single-step, default_post_xol_op(UPROBE_FIX_IP) logic will update it correctly. However, this doesn't work if this regs->ip == xol_vaddr + insn_offset is not canonical. In this case CPU generates #GP and general_protection() kills the task which tries to execute this insn out-of-line. Now that we have uprobe_xol_ops we can teach uprobes to emulate these insns and solve the problem. This patch adds branch_xol_ops which has a single branch_emulate_op() hook, so far it can only handle rel8/32 relative jmp's. TODO: move ->fixup into the union along with rip_rela_target_address. Signed-off-by: Oleg Nesterov Reported-by: Jonathan Lebon Reviewed-by: Jim Keniston --- arch/x86/include/asm/uprobes.h | 8 +++++++- arch/x86/kernel/uprobes.c | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+), 1 deletion(-) diff --git a/arch/x86/include/asm/uprobes.h b/arch/x86/include/asm/uprobes.h index 9f8210bcbb49..e9fd4d5537ed 100644 --- a/arch/x86/include/asm/uprobes.h +++ b/arch/x86/include/asm/uprobes.h @@ -44,9 +44,15 @@ struct arch_uprobe { u16 fixups; const struct uprobe_xol_ops *ops; + union { #ifdef CONFIG_X86_64 - unsigned long rip_rela_target_address; + unsigned long rip_rela_target_address; #endif + struct { + s32 offs; + u8 ilen; + } branch; + }; }; struct arch_uprobe_task { diff --git a/arch/x86/kernel/uprobes.c b/arch/x86/kernel/uprobes.c index aecc22054384..c3baeaacf1b6 100644 --- a/arch/x86/kernel/uprobes.c +++ b/arch/x86/kernel/uprobes.c @@ -461,6 +461,40 @@ static struct uprobe_xol_ops default_xol_ops = { .post_xol = default_post_xol_op, }; +static bool branch_emulate_op(struct arch_uprobe *auprobe, struct pt_regs *regs) +{ + regs->ip += auprobe->branch.ilen + auprobe->branch.offs; + return true; +} + +static struct uprobe_xol_ops branch_xol_ops = { + .emulate = branch_emulate_op, +}; + +/* Returns -ENOSYS if branch_xol_ops doesn't handle this insn */ +static int branch_setup_xol_ops(struct arch_uprobe *auprobe, struct insn *insn) +{ + + switch (OPCODE1(insn)) { + case 0xeb: /* jmp 8 */ + case 0xe9: /* jmp 32 */ + break; + default: + return -ENOSYS; + } + + /* has the side-effect of processing the entire instruction */ + insn_get_length(insn); + if (WARN_ON_ONCE(!insn_complete(insn))) + return -ENOEXEC; + + auprobe->branch.ilen = insn->length; + auprobe->branch.offs = insn->immediate.value; + + auprobe->ops = &branch_xol_ops; + return 0; +} + /** * arch_uprobe_analyze_insn - instruction analysis including validity and fixups. * @mm: the probed address space. @@ -478,6 +512,10 @@ int arch_uprobe_analyze_insn(struct arch_uprobe *auprobe, struct mm_struct *mm, if (ret) return ret; + ret = branch_setup_xol_ops(auprobe, &insn); + if (ret != -ENOSYS) + return ret; + /* * Figure out which fixups arch_uprobe_post_xol() will need to perform, * and annotate arch_uprobe->fixups accordingly. To start with, ->fixups -- cgit v1.2.3 From d241006354c550c7d22f304e2fdf90137fb8eaab Mon Sep 17 00:00:00 2001 From: Oleg Nesterov Date: Sat, 5 Apr 2014 21:06:10 +0200 Subject: uprobes/x86: Emulate nop's using ops->emulate() Finally we can kill the ugly (and very limited) code in __skip_sstep(). Just change branch_setup_xol_ops() to treat "nop" as jmp to the next insn. Thanks to lib/insn.c, it is clever enough. OPCODE1() == 0x90 includes "(rep;)+ nop;" at least, and (afaics) much more. Signed-off-by: Oleg Nesterov Reviewed-by: Jim Keniston --- arch/x86/kernel/uprobes.c | 20 +------------------- 1 file changed, 1 insertion(+), 19 deletions(-) diff --git a/arch/x86/kernel/uprobes.c b/arch/x86/kernel/uprobes.c index c3baeaacf1b6..f3c4212f3819 100644 --- a/arch/x86/kernel/uprobes.c +++ b/arch/x86/kernel/uprobes.c @@ -478,6 +478,7 @@ static int branch_setup_xol_ops(struct arch_uprobe *auprobe, struct insn *insn) switch (OPCODE1(insn)) { case 0xeb: /* jmp 8 */ case 0xe9: /* jmp 32 */ + case 0x90: /* prefix* + nop; same as jmp with .offs = 0 */ break; default: return -ENOSYS; @@ -710,29 +711,10 @@ void arch_uprobe_abort_xol(struct arch_uprobe *auprobe, struct pt_regs *regs) regs->flags &= ~X86_EFLAGS_TF; } -/* - * Skip these instructions as per the currently known x86 ISA. - * rep=0x66*; nop=0x90 - */ static bool __skip_sstep(struct arch_uprobe *auprobe, struct pt_regs *regs) { - int i; - if (auprobe->ops->emulate) return auprobe->ops->emulate(auprobe, regs); - - /* TODO: move this code into ->emulate() hook */ - for (i = 0; i < MAX_UINSN_BYTES; i++) { - if (auprobe->insn[i] == 0x66) - continue; - - if (auprobe->insn[i] == 0x90) { - regs->ip += i + 1; - return true; - } - - break; - } return false; } -- cgit v1.2.3 From 8e89c0be171b1a9ed2ba67168733ca811bb45d5c Mon Sep 17 00:00:00 2001 From: Oleg Nesterov Date: Sun, 6 Apr 2014 18:11:02 +0200 Subject: uprobes/x86: Emulate relative call's See the previous "Emulate unconditional relative jmp's" which explains why we can not execute "jmp" out-of-line, the same applies to "call". Emulating of rip-relative call is trivial, we only need to additionally push the ret-address. If this fails, we execute this instruction out of line and this should trigger the trap, the probed application should die or the same insn will be restarted if a signal handler expands the stack. We do not even need ->post_xol() for this case. But there is a corner (and almost theoretical) case: another thread can expand the stack right before we execute this insn out of line. In this case it hit the same problem we are trying to solve. So we simply turn the probed insn into "call 1f; 1:" and add ->post_xol() which restores ->sp and restarts. Many thanks to Jonathan who finally found the standalone reproducer, otherwise I would never resolve the "random SIGSEGV's under systemtap" bug-report. Now that the problem is clear we can write the simplified test-case: void probe_func(void), callee(void); int failed = 1; asm ( ".text\n" ".align 4096\n" ".globl probe_func\n" "probe_func:\n" "call callee\n" "ret" ); /* * This assumes that: * * - &probe_func = 0x401000 + a_bit, aligned = 0x402000 * * - xol_vma->vm_start = TASK_SIZE_MAX - PAGE_SIZE = 0x7fffffffe000 * as xol_add_vma() asks; the 1st slot = 0x7fffffffe080 * * so we can target the non-canonical address from xol_vma using * the simple math below, 100 * 4096 is just the random offset */ asm (".org . + 0x800000000000 - 0x7fffffffe080 - 5 - 1 + 100 * 4096\n"); void callee(void) { failed = 0; } int main(void) { probe_func(); return failed; } It SIGSEGV's if you probe "probe_func" (although this is not very reliable, randomize_va_space/etc can change the placement of xol area). Note: as Denys Vlasenko pointed out, amd and intel treat "callw" (0x66 0xe8) differently. This patch relies on lib/insn.c and thus implements the intel's behaviour: 0x66 is simply ignored. Fortunately nothing sane should ever use this insn, so we postpone the fix until we decide what should we do; emulate or not, support or not, etc. Reported-by: Jonathan Lebon Signed-off-by: Oleg Nesterov Reviewed-by: Jim Keniston --- arch/x86/include/asm/uprobes.h | 1 + arch/x86/kernel/uprobes.c | 80 ++++++++++++++++++++++++++++++++++++------ 2 files changed, 71 insertions(+), 10 deletions(-) diff --git a/arch/x86/include/asm/uprobes.h b/arch/x86/include/asm/uprobes.h index e9fd4d5537ed..93bee7b93854 100644 --- a/arch/x86/include/asm/uprobes.h +++ b/arch/x86/include/asm/uprobes.h @@ -51,6 +51,7 @@ struct arch_uprobe { struct { s32 offs; u8 ilen; + u8 opc1; } branch; }; }; diff --git a/arch/x86/kernel/uprobes.c b/arch/x86/kernel/uprobes.c index f3c4212f3819..0914435001f5 100644 --- a/arch/x86/kernel/uprobes.c +++ b/arch/x86/kernel/uprobes.c @@ -461,34 +461,97 @@ static struct uprobe_xol_ops default_xol_ops = { .post_xol = default_post_xol_op, }; +static bool branch_is_call(struct arch_uprobe *auprobe) +{ + return auprobe->branch.opc1 == 0xe8; +} + static bool branch_emulate_op(struct arch_uprobe *auprobe, struct pt_regs *regs) { - regs->ip += auprobe->branch.ilen + auprobe->branch.offs; + unsigned long new_ip = regs->ip += auprobe->branch.ilen; + + if (branch_is_call(auprobe)) { + unsigned long new_sp = regs->sp - sizeof_long(); + /* + * If it fails we execute this (mangled, see the comment in + * branch_clear_offset) insn out-of-line. In the likely case + * this should trigger the trap, and the probed application + * should die or restart the same insn after it handles the + * signal, arch_uprobe_post_xol() won't be even called. + * + * But there is corner case, see the comment in ->post_xol(). + */ + if (copy_to_user((void __user *)new_sp, &new_ip, sizeof_long())) + return false; + regs->sp = new_sp; + } + + regs->ip = new_ip + auprobe->branch.offs; return true; } +static int branch_post_xol_op(struct arch_uprobe *auprobe, struct pt_regs *regs) +{ + BUG_ON(!branch_is_call(auprobe)); + /* + * We can only get here if branch_emulate_op() failed to push the ret + * address _and_ another thread expanded our stack before the (mangled) + * "call" insn was executed out-of-line. Just restore ->sp and restart. + * We could also restore ->ip and try to call branch_emulate_op() again. + */ + regs->sp += sizeof_long(); + return -ERESTART; +} + +static void branch_clear_offset(struct arch_uprobe *auprobe, struct insn *insn) +{ + /* + * Turn this insn into "call 1f; 1:", this is what we will execute + * out-of-line if ->emulate() fails. We only need this to generate + * a trap, so that the probed task receives the correct signal with + * the properly filled siginfo. + * + * But see the comment in ->post_xol(), in the unlikely case it can + * succeed. So we need to ensure that the new ->ip can not fall into + * the non-canonical area and trigger #GP. + * + * We could turn it into (say) "pushf", but then we would need to + * divorce ->insn[] and ->ixol[]. We need to preserve the 1st byte + * of ->insn[] for set_orig_insn(). + */ + memset(auprobe->insn + insn_offset_immediate(insn), + 0, insn->immediate.nbytes); +} + static struct uprobe_xol_ops branch_xol_ops = { .emulate = branch_emulate_op, + .post_xol = branch_post_xol_op, }; /* Returns -ENOSYS if branch_xol_ops doesn't handle this insn */ static int branch_setup_xol_ops(struct arch_uprobe *auprobe, struct insn *insn) { + u8 opc1 = OPCODE1(insn); + + /* has the side-effect of processing the entire instruction */ + insn_get_length(insn); + if (WARN_ON_ONCE(!insn_complete(insn))) + return -ENOEXEC; - switch (OPCODE1(insn)) { + switch (opc1) { case 0xeb: /* jmp 8 */ case 0xe9: /* jmp 32 */ case 0x90: /* prefix* + nop; same as jmp with .offs = 0 */ break; + + case 0xe8: /* call relative */ + branch_clear_offset(auprobe, insn); + break; default: return -ENOSYS; } - /* has the side-effect of processing the entire instruction */ - insn_get_length(insn); - if (WARN_ON_ONCE(!insn_complete(insn))) - return -ENOEXEC; - + auprobe->branch.opc1 = opc1; auprobe->branch.ilen = insn->length; auprobe->branch.offs = insn->immediate.value; @@ -532,9 +595,6 @@ int arch_uprobe_analyze_insn(struct arch_uprobe *auprobe, struct mm_struct *mm, case 0xca: fix_ip = false; break; - case 0xe8: /* call relative - Fix return addr */ - fix_call = true; - break; case 0x9a: /* call absolute - Fix return addr, not ip */ fix_call = true; fix_ip = false; -- cgit v1.2.3 From 8f95505bc18a026ef7d3dfdbce4e5b31b3e4fc1b Mon Sep 17 00:00:00 2001 From: Oleg Nesterov Date: Sun, 6 Apr 2014 21:53:47 +0200 Subject: uprobes/x86: Emulate relative conditional "short" jmp's Teach branch_emulate_op() to emulate the conditional "short" jmp's which check regs->flags. Note: this doesn't support jcxz/jcexz, loope/loopz, and loopne/loopnz. They all are rel8 and thus they can't trigger the problem, but perhaps we will add the support in future just for completeness. Reported-by: Jonathan Lebon Signed-off-by: Oleg Nesterov Reviewed-by: Jim Keniston --- arch/x86/kernel/uprobes.c | 57 +++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 55 insertions(+), 2 deletions(-) diff --git a/arch/x86/kernel/uprobes.c b/arch/x86/kernel/uprobes.c index 0914435001f5..0460d04f0acc 100644 --- a/arch/x86/kernel/uprobes.c +++ b/arch/x86/kernel/uprobes.c @@ -466,9 +466,58 @@ static bool branch_is_call(struct arch_uprobe *auprobe) return auprobe->branch.opc1 == 0xe8; } +#define CASE_COND \ + COND(70, 71, XF(OF)) \ + COND(72, 73, XF(CF)) \ + COND(74, 75, XF(ZF)) \ + COND(78, 79, XF(SF)) \ + COND(7a, 7b, XF(PF)) \ + COND(76, 77, XF(CF) || XF(ZF)) \ + COND(7c, 7d, XF(SF) != XF(OF)) \ + COND(7e, 7f, XF(ZF) || XF(SF) != XF(OF)) + +#define COND(op_y, op_n, expr) \ + case 0x ## op_y: DO((expr) != 0) \ + case 0x ## op_n: DO((expr) == 0) + +#define XF(xf) (!!(flags & X86_EFLAGS_ ## xf)) + +static bool is_cond_jmp_opcode(u8 opcode) +{ + switch (opcode) { + #define DO(expr) \ + return true; + CASE_COND + #undef DO + + default: + return false; + } +} + +static bool check_jmp_cond(struct arch_uprobe *auprobe, struct pt_regs *regs) +{ + unsigned long flags = regs->flags; + + switch (auprobe->branch.opc1) { + #define DO(expr) \ + return expr; + CASE_COND + #undef DO + + default: /* not a conditional jmp */ + return true; + } +} + +#undef XF +#undef COND +#undef CASE_COND + static bool branch_emulate_op(struct arch_uprobe *auprobe, struct pt_regs *regs) { unsigned long new_ip = regs->ip += auprobe->branch.ilen; + unsigned long offs = (long)auprobe->branch.offs; if (branch_is_call(auprobe)) { unsigned long new_sp = regs->sp - sizeof_long(); @@ -484,9 +533,11 @@ static bool branch_emulate_op(struct arch_uprobe *auprobe, struct pt_regs *regs) if (copy_to_user((void __user *)new_sp, &new_ip, sizeof_long())) return false; regs->sp = new_sp; + } else if (!check_jmp_cond(auprobe, regs)) { + offs = 0; } - regs->ip = new_ip + auprobe->branch.offs; + regs->ip = new_ip + offs; return true; } @@ -547,8 +598,10 @@ static int branch_setup_xol_ops(struct arch_uprobe *auprobe, struct insn *insn) case 0xe8: /* call relative */ branch_clear_offset(auprobe, insn); break; + default: - return -ENOSYS; + if (!is_cond_jmp_opcode(opc1)) + return -ENOSYS; } auprobe->branch.opc1 = opc1; -- cgit v1.2.3 From 6cc5e7ff2c38641060f20786a5caf2815edbca5f Mon Sep 17 00:00:00 2001 From: Oleg Nesterov Date: Mon, 7 Apr 2014 16:22:58 +0200 Subject: uprobes/x86: Emulate relative conditional "near" jmp's Change branch_setup_xol_ops() to simply use opc1 = OPCODE2(insn) - 0x10 if OPCODE1() == 0x0f; this matches the "short" jmp which checks the same condition. Thanks to lib/insn.c, it does the rest correctly. branch->ilen/offs are correct no matter if this jmp is "near" or "short". Reported-by: Jonathan Lebon Signed-off-by: Oleg Nesterov Reviewed-by: Jim Keniston --- arch/x86/kernel/uprobes.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/arch/x86/kernel/uprobes.c b/arch/x86/kernel/uprobes.c index 0460d04f0acc..ace22916ade3 100644 --- a/arch/x86/kernel/uprobes.c +++ b/arch/x86/kernel/uprobes.c @@ -599,6 +599,14 @@ static int branch_setup_xol_ops(struct arch_uprobe *auprobe, struct insn *insn) branch_clear_offset(auprobe, insn); break; + case 0x0f: + if (insn->opcode.nbytes != 2) + return -ENOSYS; + /* + * If it is a "near" conditional jmp, OPCODE2() - 0x10 matches + * OPCODE1() of the "short" jmp which checks the same condition. + */ + opc1 = OPCODE2(insn) - 0x10; default: if (!is_cond_jmp_opcode(opc1)) return -ENOSYS; -- cgit v1.2.3 From 7b3b302615c3ab9c111d0238107d741146dda701 Mon Sep 17 00:00:00 2001 From: Maxime Ripard Date: Thu, 17 Apr 2014 11:51:16 +0200 Subject: ALSA: lx_core: Remove unused defines Commit f9367f3fbe3c ("ALSA: lx6464es: Remove unused function in pci/lx6464es/lx_core.c") removed the lx_dsp_es_check_pipeline function that was the only user of these defines. Since they're useless now, simply remove them. Signed-off-by: Maxime Ripard Signed-off-by: Takashi Iwai --- sound/pci/lx6464es/lx_core.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/sound/pci/lx6464es/lx_core.c b/sound/pci/lx6464es/lx_core.c index 2d8e95e9fbe5..6a1d90a308ea 100644 --- a/sound/pci/lx6464es/lx_core.c +++ b/sound/pci/lx6464es/lx_core.c @@ -429,11 +429,6 @@ int lx_dsp_read_async_events(struct lx6464es *chip, u32 *data) return ret; } -#define CSES_TIMEOUT 100 /* microseconds */ -#define CSES_CE 0x0001 -#define CSES_BROADCAST 0x0002 -#define CSES_UPDATE_LDSV 0x0004 - #define PIPE_INFO_TO_CMD(capture, pipe) \ ((u32)((u32)(pipe) | ((capture) ? ID_IS_CAPTURE : 0L)) << ID_OFFSET) -- cgit v1.2.3 From c546ca95f58b53839e9eb9dbdf25b369605e5077 Mon Sep 17 00:00:00 2001 From: Maxime Ripard Date: Thu, 17 Apr 2014 11:51:17 +0200 Subject: ALSA: lx_core: Switch to using BIT macro Move to using the BIT macro for a few defines. It also allows to discard the french comment that was saying exactly what the BIT macro is now pointing out. Signed-off-by: Maxime Ripard Signed-off-by: Takashi Iwai --- sound/pci/lx6464es/lx_core.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/sound/pci/lx6464es/lx_core.c b/sound/pci/lx6464es/lx_core.c index 6a1d90a308ea..652f6dfc7e1a 100644 --- a/sound/pci/lx6464es/lx_core.c +++ b/sound/pci/lx6464es/lx_core.c @@ -24,6 +24,7 @@ /* #define RMH_DEBUG 1 */ +#include #include #include #include @@ -966,9 +967,9 @@ int lx_level_peaks(struct lx6464es *chip, int is_capture, int channels, /* interrupt handling */ #define PCX_IRQ_NONE 0 -#define IRQCS_ACTIVE_PCIDB 0x00002000L /* Bit nø 13 */ -#define IRQCS_ENABLE_PCIIRQ 0x00000100L /* Bit nø 08 */ -#define IRQCS_ENABLE_PCIDB 0x00000200L /* Bit nø 09 */ +#define IRQCS_ACTIVE_PCIDB BIT(13) +#define IRQCS_ENABLE_PCIIRQ BIT(8) +#define IRQCS_ENABLE_PCIDB BIT(9) static u32 lx_interrupt_test_ack(struct lx6464es *chip) { -- cgit v1.2.3 From 68e440bb48a35c65756471e3cb952ed7fb7cef5b Mon Sep 17 00:00:00 2001 From: Maxime Ripard Date: Thu, 17 Apr 2014 11:51:18 +0200 Subject: ALSA: lx_core: Fix dev_dbg typo Commit be4e6d3c0fa0 ("ALSA: lx6464es: Use standard printk helpers") converted the custom printk helpers that were used before to standard dev_* functions. One of the dev_dbg calls had a typo, that was hidden away by an #if 0 .. #endif Signed-off-by: Maxime Ripard Signed-off-by: Takashi Iwai --- sound/pci/lx6464es/lx_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/pci/lx6464es/lx_core.c b/sound/pci/lx6464es/lx_core.c index 652f6dfc7e1a..9e0acba82751 100644 --- a/sound/pci/lx6464es/lx_core.c +++ b/sound/pci/lx6464es/lx_core.c @@ -1197,7 +1197,7 @@ irqreturn_t lx_interrupt(int irq, void *dev_id) #if 0 if (irqsrc & MASK_SYS_STATUS_EOBI) - dev_dgg(chip->card->dev, "interrupt: EOBI\n"); + dev_dbg(chip->card->dev, "interrupt: EOBI\n"); if (irqsrc & MASK_SYS_STATUS_EOBO) dev_dbg(chip->card->dev, "interrupt: EOBO\n"); -- cgit v1.2.3 From 4899210263a010b34d492d781e0d4fea82655c48 Mon Sep 17 00:00:00 2001 From: Maxime Ripard Date: Thu, 17 Apr 2014 11:51:19 +0200 Subject: ALSA: lx_core: Remove dead code Some code was never compiled because hidden between an #if 0 .. #endif structure, and even when removing these, it was never actually used elsewhere. Remove it entirely. Signed-off-by: Maxime Ripard Signed-off-by: Takashi Iwai --- sound/pci/lx6464es/lx_core.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/sound/pci/lx6464es/lx_core.c b/sound/pci/lx6464es/lx_core.c index 9e0acba82751..0ad6358b5fe2 100644 --- a/sound/pci/lx6464es/lx_core.c +++ b/sound/pci/lx6464es/lx_core.c @@ -1041,10 +1041,6 @@ static int lx_interrupt_handle_async_events(struct lx6464es *chip, u32 irqsrc, u64 orun_mask; u64 urun_mask; -#if 0 - int has_underrun = (irqsrc & MASK_SYS_STATUS_URUN) ? 1 : 0; - int has_overrun = (irqsrc & MASK_SYS_STATUS_ORUN) ? 1 : 0; -#endif int eb_pending_out = (irqsrc & MASK_SYS_STATUS_EOBO) ? 1 : 0; int eb_pending_in = (irqsrc & MASK_SYS_STATUS_EOBI) ? 1 : 0; -- cgit v1.2.3 From 8e6320064c3350cd8610cd23d4ef5c6926e33e48 Mon Sep 17 00:00:00 2001 From: Maxime Ripard Date: Thu, 17 Apr 2014 11:51:20 +0200 Subject: ALSA: lx_core: Remove useless #if 0 .. #endif The code contained in these sections are only dev_dbg calls, that are already removed whenever DEBUG isn't defined. Remove the redundant constructs. Signed-off-by: Maxime Ripard Signed-off-by: Takashi Iwai --- sound/pci/lx6464es/lx_core.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/sound/pci/lx6464es/lx_core.c b/sound/pci/lx6464es/lx_core.c index 0ad6358b5fe2..7c070864dc62 100644 --- a/sound/pci/lx6464es/lx_core.c +++ b/sound/pci/lx6464es/lx_core.c @@ -515,7 +515,6 @@ int lx_buffer_ask(struct lx6464es *chip, u32 pipe, int is_capture, *r_needed += 1; } -#if 0 dev_dbg(chip->card->dev, "CMD_08_ASK_BUFFERS: needed %d, freed %d\n", *r_needed, *r_freed); @@ -526,7 +525,6 @@ int lx_buffer_ask(struct lx6464es *chip, u32 pipe, int is_capture, chip->rmh.stat[i], chip->rmh.stat[i] & MASK_DATA_SIZE); } -#endif } spin_unlock_irqrestore(&chip->msg_lock, flags); @@ -1191,7 +1189,6 @@ irqreturn_t lx_interrupt(int irq, void *dev_id) if (irqsrc & MASK_SYS_STATUS_CMD_DONE) goto exit; -#if 0 if (irqsrc & MASK_SYS_STATUS_EOBI) dev_dbg(chip->card->dev, "interrupt: EOBI\n"); @@ -1203,7 +1200,6 @@ irqreturn_t lx_interrupt(int irq, void *dev_id) if (irqsrc & MASK_SYS_STATUS_ORUN) dev_dbg(chip->card->dev, "interrupt: ORUN\n"); -#endif if (async_pending) { u64 notified_in_pipe_mask = 0; @@ -1230,7 +1226,6 @@ irqreturn_t lx_interrupt(int irq, void *dev_id) } if (async_escmd) { -#if 0 /* backdoor for ethersound commands * * for now, we do not need this @@ -1238,7 +1233,6 @@ irqreturn_t lx_interrupt(int irq, void *dev_id) * */ dev_dbg(chip->card->dev, "interrupt requests escmd handling\n"); -#endif } exit: -- cgit v1.2.3 From 38137a064199a02630f136ce7bb1580d5d3fedeb Mon Sep 17 00:00:00 2001 From: Maxime Ripard Date: Thu, 17 Apr 2014 11:51:21 +0200 Subject: ALSA: lx_core: Translate comments from french to english For some reason, some of the comments were actually in poorly encoded french. Translate them in english like they should have been in the first place. Signed-off-by: Maxime Ripard Signed-off-by: Takashi Iwai --- sound/pci/lx6464es/lx_core.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/sound/pci/lx6464es/lx_core.c b/sound/pci/lx6464es/lx_core.c index 7c070864dc62..e8f38e5df10a 100644 --- a/sound/pci/lx6464es/lx_core.c +++ b/sound/pci/lx6464es/lx_core.c @@ -1024,17 +1024,17 @@ static int lx_interrupt_handle_async_events(struct lx6464es *chip, u32 irqsrc, int err; u32 stat[9]; /* answer from CMD_04_GET_EVENT */ - /* On peut optimiser pour ne pas lire les evenements vides - * les mots de réponse sont dans l'ordre suivant : - * Stat[0] mot de status général - * Stat[1] fin de buffer OUT pF - * Stat[2] fin de buffer OUT pf - * Stat[3] fin de buffer IN pF - * Stat[4] fin de buffer IN pf - * Stat[5] underrun poid fort - * Stat[6] underrun poid faible - * Stat[7] overrun poid fort - * Stat[8] overrun poid faible + /* We can optimize this to not read dumb events. + * Answer words are in the following order: + * Stat[0] general status + * Stat[1] end of buffer OUT pF + * Stat[2] end of buffer OUT pf + * Stat[3] end of buffer IN pF + * Stat[4] end of buffer IN pf + * Stat[5] MSB underrun + * Stat[6] LSB underrun + * Stat[7] MSB overrun + * Stat[8] LSB overrun * */ u64 orun_mask; -- cgit v1.2.3 From e4f9bfb3feaeaca55cf177dadb7e3313836b10f4 Mon Sep 17 00:00:00 2001 From: Peter Zijlstra Date: Tue, 4 Feb 2014 20:36:01 +0100 Subject: ia64: Fix up smp_mb__{before,after}_clear_bit() IA64 doesn't actually have acquire/release barriers, its a lie! Add a comment explaining this and fix up the bitop barriers. Signed-off-by: Peter Zijlstra Acked-by: Paul E. McKenney Link: http://lkml.kernel.org/n/tip-akevfh136um9dqvb1ohm55ca@git.kernel.org Cc: Akinobu Mita Cc: Fenghua Yu Cc: Linus Torvalds Cc: Tony Luck Cc: linux-ia64@vger.kernel.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Ingo Molnar --- arch/ia64/include/asm/bitops.h | 7 ++----- arch/ia64/include/uapi/asm/cmpxchg.h | 9 +++++++++ 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/arch/ia64/include/asm/bitops.h b/arch/ia64/include/asm/bitops.h index c27eccd33349..feb8117ed06a 100644 --- a/arch/ia64/include/asm/bitops.h +++ b/arch/ia64/include/asm/bitops.h @@ -65,11 +65,8 @@ __set_bit (int nr, volatile void *addr) *((__u32 *) addr + (nr >> 5)) |= (1 << (nr & 31)); } -/* - * clear_bit() has "acquire" semantics. - */ -#define smp_mb__before_clear_bit() smp_mb() -#define smp_mb__after_clear_bit() do { /* skip */; } while (0) +#define smp_mb__before_clear_bit() barrier(); +#define smp_mb__after_clear_bit() barrier(); /** * clear_bit - Clears a bit in memory diff --git a/arch/ia64/include/uapi/asm/cmpxchg.h b/arch/ia64/include/uapi/asm/cmpxchg.h index 4f37dbbb8640..f35109b1d907 100644 --- a/arch/ia64/include/uapi/asm/cmpxchg.h +++ b/arch/ia64/include/uapi/asm/cmpxchg.h @@ -118,6 +118,15 @@ extern long ia64_cmpxchg_called_with_bad_pointer(void); #define cmpxchg_rel(ptr, o, n) \ ia64_cmpxchg(rel, (ptr), (o), (n), sizeof(*(ptr))) +/* + * Worse still - early processor implementations actually just ignored + * the acquire/release and did a full fence all the time. Unfortunately + * this meant a lot of badly written code that used .acq when they really + * wanted .rel became legacy out in the wild - so when we made a cpu + * that strictly did the .acq or .rel ... all that code started breaking - so + * we had to back-pedal and keep the "legacy" behavior of a full fence :-( + */ + /* for compatibility with other platforms: */ #define cmpxchg(ptr, o, n) cmpxchg_acq((ptr), (o), (n)) #define cmpxchg64(ptr, o, n) cmpxchg_acq((ptr), (o), (n)) -- cgit v1.2.3 From 2ab08ee9f0a4eba27c7c4ce0b6d5118e8a18554b Mon Sep 17 00:00:00 2001 From: Peter Zijlstra Date: Thu, 6 Feb 2014 14:26:10 +0100 Subject: arc,hexagon: Delete asm/barrier.h Both already use asm-generic/barrier.h as per their include/asm/Kbuild. Remove the stale files. Signed-off-by: Peter Zijlstra Acked-by: Paul E. McKenney Link: http://lkml.kernel.org/n/tip-c7vlkshl3tblim0o8z2p70kt@git.kernel.org Cc: Linus Torvalds Cc: Richard Kuo Cc: Vineet Gupta Cc: linux-hexagon@vger.kernel.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Ingo Molnar --- arch/arc/include/asm/barrier.h | 37 ------------------------------------- arch/hexagon/include/asm/barrier.h | 37 ------------------------------------- 2 files changed, 74 deletions(-) delete mode 100644 arch/arc/include/asm/barrier.h delete mode 100644 arch/hexagon/include/asm/barrier.h diff --git a/arch/arc/include/asm/barrier.h b/arch/arc/include/asm/barrier.h deleted file mode 100644 index c32245c3d1e9..000000000000 --- a/arch/arc/include/asm/barrier.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - */ - -#ifndef __ASM_BARRIER_H -#define __ASM_BARRIER_H - -#ifndef __ASSEMBLY__ - -/* TODO-vineetg: Need to see what this does, don't we need sync anywhere */ -#define mb() __asm__ __volatile__ ("" : : : "memory") -#define rmb() mb() -#define wmb() mb() -#define set_mb(var, value) do { var = value; mb(); } while (0) -#define set_wmb(var, value) do { var = value; wmb(); } while (0) -#define read_barrier_depends() mb() - -/* TODO-vineetg verify the correctness of macros here */ -#ifdef CONFIG_SMP -#define smp_mb() mb() -#define smp_rmb() rmb() -#define smp_wmb() wmb() -#else -#define smp_mb() barrier() -#define smp_rmb() barrier() -#define smp_wmb() barrier() -#endif - -#define smp_read_barrier_depends() do { } while (0) - -#endif - -#endif diff --git a/arch/hexagon/include/asm/barrier.h b/arch/hexagon/include/asm/barrier.h deleted file mode 100644 index 4e863daea25b..000000000000 --- a/arch/hexagon/include/asm/barrier.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Memory barrier definitions for the Hexagon architecture - * - * Copyright (c) 2010-2011, The Linux Foundation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 and - * only version 2 as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - * 02110-1301, USA. - */ - -#ifndef _ASM_BARRIER_H -#define _ASM_BARRIER_H - -#define rmb() barrier() -#define read_barrier_depends() barrier() -#define wmb() barrier() -#define mb() barrier() -#define smp_rmb() barrier() -#define smp_read_barrier_depends() barrier() -#define smp_wmb() barrier() -#define smp_mb() barrier() - -/* Set a value and use a memory barrier. Used by the scheduler somewhere. */ -#define set_mb(var, value) \ - do { var = value; mb(); } while (0) - -#endif /* _ASM_BARRIER_H */ -- cgit v1.2.3 From febdbfe8a91ce0d11939d4940b592eb0dba8d663 Mon Sep 17 00:00:00 2001 From: Peter Zijlstra Date: Thu, 6 Feb 2014 18:16:07 +0100 Subject: arch: Prepare for smp_mb__{before,after}_atomic() Since the smp_mb__{before,after}*() ops are fundamentally dependent on how an arch can implement atomics it doesn't make sense to have 3 variants of them. They must all be the same. Furthermore, the 3 variants suggest they're only valid for those 3 atomic ops, while we have many more where they could be applied. So move away from smp_mb__{before,after}_{atomic,clear}_{dec,inc,bit}() and reduce the interface to just the two: smp_mb__{before,after}_atomic(). This patch prepares the way by introducing default implementations in asm-generic/barrier.h that default to a full barrier and providing __deprecated inlines for the previous 6 barriers if they're not provided by the arch. This should allow for a mostly painless transition (lots of deprecated warns in the interim). Signed-off-by: Peter Zijlstra Acked-by: Paul E. McKenney Link: http://lkml.kernel.org/n/tip-wr59327qdyi9mbzn6x937s4e@git.kernel.org Cc: Arnd Bergmann Cc: "Chen, Gong" Cc: John Sullivan Cc: Linus Torvalds Cc: Mauro Carvalho Chehab Cc: Srinivas Pandruvada Cc: "Theodore Ts'o" Cc: linux-arch@vger.kernel.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Ingo Molnar --- include/asm-generic/atomic.h | 7 +------ include/asm-generic/barrier.h | 8 ++++++++ include/asm-generic/bitops.h | 9 +-------- include/linux/atomic.h | 36 ++++++++++++++++++++++++++++++++++++ include/linux/bitops.h | 20 ++++++++++++++++++++ kernel/sched/core.c | 16 ++++++++++++++++ 6 files changed, 82 insertions(+), 14 deletions(-) diff --git a/include/asm-generic/atomic.h b/include/asm-generic/atomic.h index 33bd2de3bc1e..9c79e7603459 100644 --- a/include/asm-generic/atomic.h +++ b/include/asm-generic/atomic.h @@ -16,6 +16,7 @@ #define __ASM_GENERIC_ATOMIC_H #include +#include #ifdef CONFIG_SMP /* Force people to define core atomics */ @@ -182,11 +183,5 @@ static inline void atomic_set_mask(unsigned int mask, atomic_t *v) } #endif -/* Assume that atomic operations are already serializing */ -#define smp_mb__before_atomic_dec() barrier() -#define smp_mb__after_atomic_dec() barrier() -#define smp_mb__before_atomic_inc() barrier() -#define smp_mb__after_atomic_inc() barrier() - #endif /* __KERNEL__ */ #endif /* __ASM_GENERIC_ATOMIC_H */ diff --git a/include/asm-generic/barrier.h b/include/asm-generic/barrier.h index 6f692f8ac664..1402fa855388 100644 --- a/include/asm-generic/barrier.h +++ b/include/asm-generic/barrier.h @@ -62,6 +62,14 @@ #define set_mb(var, value) do { (var) = (value); mb(); } while (0) #endif +#ifndef smp_mb__before_atomic +#define smp_mb__before_atomic() smp_mb() +#endif + +#ifndef smp_mb__after_atomic +#define smp_mb__after_atomic() smp_mb() +#endif + #define smp_store_release(p, v) \ do { \ compiletime_assert_atomic_type(*p); \ diff --git a/include/asm-generic/bitops.h b/include/asm-generic/bitops.h index 280ca7a96f75..dcdcacf2fd2b 100644 --- a/include/asm-generic/bitops.h +++ b/include/asm-generic/bitops.h @@ -11,14 +11,7 @@ #include #include - -/* - * clear_bit may not imply a memory barrier - */ -#ifndef smp_mb__before_clear_bit -#define smp_mb__before_clear_bit() smp_mb() -#define smp_mb__after_clear_bit() smp_mb() -#endif +#include #include #include diff --git a/include/linux/atomic.h b/include/linux/atomic.h index 5b08a8540ecf..fef3a809e7cf 100644 --- a/include/linux/atomic.h +++ b/include/linux/atomic.h @@ -3,6 +3,42 @@ #define _LINUX_ATOMIC_H #include +/* + * Provide __deprecated wrappers for the new interface, avoid flag day changes. + * We need the ugly external functions to break header recursion hell. + */ +#ifndef smp_mb__before_atomic_inc +static inline void __deprecated smp_mb__before_atomic_inc(void) +{ + extern void __smp_mb__before_atomic(void); + __smp_mb__before_atomic(); +} +#endif + +#ifndef smp_mb__after_atomic_inc +static inline void __deprecated smp_mb__after_atomic_inc(void) +{ + extern void __smp_mb__after_atomic(void); + __smp_mb__after_atomic(); +} +#endif + +#ifndef smp_mb__before_atomic_dec +static inline void __deprecated smp_mb__before_atomic_dec(void) +{ + extern void __smp_mb__before_atomic(void); + __smp_mb__before_atomic(); +} +#endif + +#ifndef smp_mb__after_atomic_dec +static inline void __deprecated smp_mb__after_atomic_dec(void) +{ + extern void __smp_mb__after_atomic(void); + __smp_mb__after_atomic(); +} +#endif + /** * atomic_add_unless - add unless the number is already a given value * @v: pointer of type atomic_t diff --git a/include/linux/bitops.h b/include/linux/bitops.h index be5fd38bd5a0..cbc5833fb221 100644 --- a/include/linux/bitops.h +++ b/include/linux/bitops.h @@ -32,6 +32,26 @@ extern unsigned long __sw_hweight64(__u64 w); */ #include +/* + * Provide __deprecated wrappers for the new interface, avoid flag day changes. + * We need the ugly external functions to break header recursion hell. + */ +#ifndef smp_mb__before_clear_bit +static inline void __deprecated smp_mb__before_clear_bit(void) +{ + extern void __smp_mb__before_atomic(void); + __smp_mb__before_atomic(); +} +#endif + +#ifndef smp_mb__after_clear_bit +static inline void __deprecated smp_mb__after_clear_bit(void) +{ + extern void __smp_mb__after_atomic(void); + __smp_mb__after_atomic(); +} +#endif + #define for_each_set_bit(bit, addr, size) \ for ((bit) = find_first_bit((addr), (size)); \ (bit) < (size); \ diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 268a45ea238c..8a70ec091760 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -90,6 +90,22 @@ #define CREATE_TRACE_POINTS #include +#ifdef smp_mb__before_atomic +void __smp_mb__before_atomic(void) +{ + smp_mb__before_atomic(); +} +EXPORT_SYMBOL(__smp_mb__before_atomic); +#endif + +#ifdef smp_mb__after_atomic +void __smp_mb__after_atomic(void) +{ + smp_mb__after_atomic(); +} +EXPORT_SYMBOL(__smp_mb__after_atomic); +#endif + void start_bandwidth_timer(struct hrtimer *period_timer, ktime_t period) { unsigned long delta; -- cgit v1.2.3 From 6ae11028a62b2f82ee283392a84f33da599a81e7 Mon Sep 17 00:00:00 2001 From: Peter Zijlstra Date: Wed, 12 Mar 2014 17:11:00 +0100 Subject: arch,alpha: Convert smp_mb__*() to the asm-generic primitives The Alpha ll/sc primitives do not imply any sort of barrier; therefore the smp_mb__{before,after} should be a full barrier. This is the default from asm-generic/barrier.h and therefore just remove the current definitions. Signed-off-by: Peter Zijlstra Acked-by: Paul E. McKenney Link: http://lkml.kernel.org/n/tip-iacwfd15lq3ta2v7jut747r7@git.kernel.org Cc: Ivan Kokshaysky Cc: Linus Torvalds Cc: Matt Turner Cc: Richard Henderson Cc: linux-alpha@vger.kernel.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Ingo Molnar --- arch/alpha/include/asm/atomic.h | 5 ----- arch/alpha/include/asm/bitops.h | 3 --- 2 files changed, 8 deletions(-) diff --git a/arch/alpha/include/asm/atomic.h b/arch/alpha/include/asm/atomic.h index 78b03ef39f6f..ed60a1ee1ed3 100644 --- a/arch/alpha/include/asm/atomic.h +++ b/arch/alpha/include/asm/atomic.h @@ -292,9 +292,4 @@ static inline long atomic64_dec_if_positive(atomic64_t *v) #define atomic_dec(v) atomic_sub(1,(v)) #define atomic64_dec(v) atomic64_sub(1,(v)) -#define smp_mb__before_atomic_dec() smp_mb() -#define smp_mb__after_atomic_dec() smp_mb() -#define smp_mb__before_atomic_inc() smp_mb() -#define smp_mb__after_atomic_inc() smp_mb() - #endif /* _ALPHA_ATOMIC_H */ diff --git a/arch/alpha/include/asm/bitops.h b/arch/alpha/include/asm/bitops.h index a19ba5efea4c..4bdfbd444e63 100644 --- a/arch/alpha/include/asm/bitops.h +++ b/arch/alpha/include/asm/bitops.h @@ -53,9 +53,6 @@ __set_bit(unsigned long nr, volatile void * addr) *m |= 1 << (nr & 31); } -#define smp_mb__before_clear_bit() smp_mb() -#define smp_mb__after_clear_bit() smp_mb() - static inline void clear_bit(unsigned long nr, volatile void * addr) { -- cgit v1.2.3 From d594ffa94b7efdd8c6da5ee48aea8ae229809b55 Mon Sep 17 00:00:00 2001 From: Peter Zijlstra Date: Wed, 12 Mar 2014 17:11:00 +0100 Subject: arch,arc: Convert smp_mb__*() The arc mb() implementation is a compiler barrier(), therefore it all doesn't matter one way or the other. Simply remove the existing definitions and use whatever is generated by the defaults. Signed-off-by: Peter Zijlstra Acked-by: Paul E. McKenney Link: http://lkml.kernel.org/n/tip-ua48a59wri3ybz1rz8i7uvbr@git.kernel.org Cc: Linus Torvalds Cc: Vineet Gupta Cc: linux-kernel@vger.kernel.org Signed-off-by: Ingo Molnar --- arch/arc/include/asm/atomic.h | 5 ----- arch/arc/include/asm/bitops.h | 5 +---- 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/arch/arc/include/asm/atomic.h b/arch/arc/include/asm/atomic.h index 03e494f695d1..83f03ca6caf6 100644 --- a/arch/arc/include/asm/atomic.h +++ b/arch/arc/include/asm/atomic.h @@ -190,11 +190,6 @@ static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr) #endif /* !CONFIG_ARC_HAS_LLSC */ -#define smp_mb__before_atomic_dec() barrier() -#define smp_mb__after_atomic_dec() barrier() -#define smp_mb__before_atomic_inc() barrier() -#define smp_mb__after_atomic_inc() barrier() - /** * __atomic_add_unless - add unless the number is a given value * @v: pointer of type atomic_t diff --git a/arch/arc/include/asm/bitops.h b/arch/arc/include/asm/bitops.h index 647a83a8e756..ebc0cf3164dc 100644 --- a/arch/arc/include/asm/bitops.h +++ b/arch/arc/include/asm/bitops.h @@ -19,6 +19,7 @@ #include #include +#include /* * Hardware assisted read-modify-write using ARC700 LLOCK/SCOND insns. @@ -496,10 +497,6 @@ static inline __attribute__ ((const)) int __ffs(unsigned long word) */ #define ffz(x) __ffs(~(x)) -/* TODO does this affect uni-processor code */ -#define smp_mb__before_clear_bit() barrier() -#define smp_mb__after_clear_bit() barrier() - #include #include #include -- cgit v1.2.3 From 030d0178bdbd237c1f0577f03bbc1d7140a75044 Mon Sep 17 00:00:00 2001 From: Peter Zijlstra Date: Wed, 12 Mar 2014 17:11:00 +0100 Subject: arch,arm: Convert smp_mb__*() ARM uses ll/sc primitives that do not imply barriers for all regular atomic ops, therefore smp_mb__{before,after} need be a full barrier. Since ARM doesn't use asm-generic/barrier.h include the required definitions in its asm/barrier.h Signed-off-by: Peter Zijlstra Acked-by: Paul E. McKenney Link: http://lkml.kernel.org/n/tip-yijo7sglsl7uusbp13upcuvo@git.kernel.org Cc: Albin Tonnerre Cc: Catalin Marinas Cc: Chen Gang Cc: Linus Torvalds Cc: Nicolas Pitre Cc: Russell King Cc: Victor Kamensky Cc: Will Deacon Cc: linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Ingo Molnar --- arch/arm/include/asm/atomic.h | 5 ----- arch/arm/include/asm/barrier.h | 3 +++ arch/arm/include/asm/bitops.h | 4 +--- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/arch/arm/include/asm/atomic.h b/arch/arm/include/asm/atomic.h index 9a92fd7864a8..3040359094d9 100644 --- a/arch/arm/include/asm/atomic.h +++ b/arch/arm/include/asm/atomic.h @@ -241,11 +241,6 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u) #define atomic_add_negative(i,v) (atomic_add_return(i, v) < 0) -#define smp_mb__before_atomic_dec() smp_mb() -#define smp_mb__after_atomic_dec() smp_mb() -#define smp_mb__before_atomic_inc() smp_mb() -#define smp_mb__after_atomic_inc() smp_mb() - #ifndef CONFIG_GENERIC_ATOMIC64 typedef struct { long long counter; diff --git a/arch/arm/include/asm/barrier.h b/arch/arm/include/asm/barrier.h index 2f59f7443396..c6a3e73a6e24 100644 --- a/arch/arm/include/asm/barrier.h +++ b/arch/arm/include/asm/barrier.h @@ -79,5 +79,8 @@ do { \ #define set_mb(var, value) do { var = value; smp_mb(); } while (0) +#define smp_mb__before_atomic() smp_mb() +#define smp_mb__after_atomic() smp_mb() + #endif /* !__ASSEMBLY__ */ #endif /* __ASM_BARRIER_H */ diff --git a/arch/arm/include/asm/bitops.h b/arch/arm/include/asm/bitops.h index b2e298a90d76..56380995f4c3 100644 --- a/arch/arm/include/asm/bitops.h +++ b/arch/arm/include/asm/bitops.h @@ -25,9 +25,7 @@ #include #include - -#define smp_mb__before_clear_bit() smp_mb() -#define smp_mb__after_clear_bit() smp_mb() +#include /* * These functions are the basis of our bit ops. -- cgit v1.2.3 From 8715466b602729061394df18864ea64b97951589 Mon Sep 17 00:00:00 2001 From: Peter Zijlstra Date: Thu, 13 Mar 2014 19:00:37 +0100 Subject: arch,arm64: Convert smp_mb__*() AARGH64 uses ll/sc primitives that do not imply any barriers for the normal atomics, therefore smp_mb__{before,after} should be a full barrier. Since AARGH64 doesn't use asm-generic/barrier.h, add the required definitions to its asm/barrier.h. Signed-off-by: Peter Zijlstra Acked-by: Paul E. McKenney Link: http://lkml.kernel.org/n/tip-8p5iclqgy78al33kck3ht7nr@git.kernel.org Cc: Catalin Marinas Cc: Chen Gang Cc: Linus Torvalds Cc: Russell King Cc: Will Deacon Cc: linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Ingo Molnar --- arch/arm64/include/asm/atomic.h | 5 ----- arch/arm64/include/asm/barrier.h | 3 +++ arch/arm64/include/asm/bitops.h | 9 --------- 3 files changed, 3 insertions(+), 14 deletions(-) diff --git a/arch/arm64/include/asm/atomic.h b/arch/arm64/include/asm/atomic.h index 0237f0867e37..57e8cb49824c 100644 --- a/arch/arm64/include/asm/atomic.h +++ b/arch/arm64/include/asm/atomic.h @@ -152,11 +152,6 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u) #define atomic_add_negative(i,v) (atomic_add_return(i, v) < 0) -#define smp_mb__before_atomic_dec() smp_mb() -#define smp_mb__after_atomic_dec() smp_mb() -#define smp_mb__before_atomic_inc() smp_mb() -#define smp_mb__after_atomic_inc() smp_mb() - /* * 64-bit atomic operations. */ diff --git a/arch/arm64/include/asm/barrier.h b/arch/arm64/include/asm/barrier.h index 66eb7648043b..48b9e704af7c 100644 --- a/arch/arm64/include/asm/barrier.h +++ b/arch/arm64/include/asm/barrier.h @@ -98,6 +98,9 @@ do { \ #define set_mb(var, value) do { var = value; smp_mb(); } while (0) #define nop() asm volatile("nop"); +#define smp_mb__before_atomic() smp_mb() +#define smp_mb__after_atomic() smp_mb() + #endif /* __ASSEMBLY__ */ #endif /* __ASM_BARRIER_H */ diff --git a/arch/arm64/include/asm/bitops.h b/arch/arm64/include/asm/bitops.h index aa5b59d6ba43..9c19594ce7cb 100644 --- a/arch/arm64/include/asm/bitops.h +++ b/arch/arm64/include/asm/bitops.h @@ -17,17 +17,8 @@ #define __ASM_BITOPS_H #include - #include -/* - * clear_bit may not imply a memory barrier - */ -#ifndef smp_mb__before_clear_bit -#define smp_mb__before_clear_bit() smp_mb() -#define smp_mb__after_clear_bit() smp_mb() -#endif - #ifndef _LINUX_BITOPS_H #error only can be included directly #endif -- cgit v1.2.3 From 710adaa913169d7183cdf0de41c2a349101ff615 Mon Sep 17 00:00:00 2001 From: Peter Zijlstra Date: Thu, 13 Mar 2014 19:00:37 +0100 Subject: arch,avr32: Convert smp_mb__*() AVR32's mb() implementation is a compiler barrier(), therefore it all doesn't matter, fully rely on whatever asm-generic/barrier.h generates. Signed-off-by: Peter Zijlstra Acked-by: Paul E. McKenney Link: http://lkml.kernel.org/n/tip-8gow97a7mapmnec0pvf729pj@git.kernel.org Cc: Haavard Skinnemoen Cc: Hans-Christian Egtvedt Cc: Linus Torvalds Cc: linux-kernel@vger.kernel.org Signed-off-by: Ingo Molnar --- arch/avr32/include/asm/atomic.h | 5 ----- arch/avr32/include/asm/bitops.h | 9 ++------- 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/arch/avr32/include/asm/atomic.h b/arch/avr32/include/asm/atomic.h index 61407279208a..0780f3f2415b 100644 --- a/arch/avr32/include/asm/atomic.h +++ b/arch/avr32/include/asm/atomic.h @@ -183,9 +183,4 @@ static inline int atomic_sub_if_positive(int i, atomic_t *v) #define atomic_dec_if_positive(v) atomic_sub_if_positive(1, v) -#define smp_mb__before_atomic_dec() barrier() -#define smp_mb__after_atomic_dec() barrier() -#define smp_mb__before_atomic_inc() barrier() -#define smp_mb__after_atomic_inc() barrier() - #endif /* __ASM_AVR32_ATOMIC_H */ diff --git a/arch/avr32/include/asm/bitops.h b/arch/avr32/include/asm/bitops.h index ebe7ad3f490b..910d5374ce59 100644 --- a/arch/avr32/include/asm/bitops.h +++ b/arch/avr32/include/asm/bitops.h @@ -13,12 +13,7 @@ #endif #include - -/* - * clear_bit() doesn't provide any barrier for the compiler - */ -#define smp_mb__before_clear_bit() barrier() -#define smp_mb__after_clear_bit() barrier() +#include /* * set_bit - Atomically set a bit in memory @@ -67,7 +62,7 @@ static inline void set_bit(int nr, volatile void * addr) * * clear_bit() is atomic and may not be reordered. However, it does * not contain a memory barrier, so if it is used for locking purposes, - * you should call smp_mb__before_clear_bit() and/or smp_mb__after_clear_bit() + * you should call smp_mb__before_atomic() and/or smp_mb__after_atomic() * in order to ensure changes are visible on other processors. */ static inline void clear_bit(int nr, volatile void * addr) -- cgit v1.2.3 From b7bb7d9b28f6278625fbe7892b8c7799bb12a26a Mon Sep 17 00:00:00 2001 From: Peter Zijlstra Date: Thu, 13 Mar 2014 19:00:37 +0100 Subject: arch,blackfin: Convert smp_mb__*() Blackfin's atomic primitives do not imply a full barrier as whitnessed from its SMP smp_mb__{before,after}_clear_bit() implementations. However since !SMP smp_mb() reduces to barrier() remove everything and rely on the asm-generic/barrier.h implentation. Signed-off-by: Peter Zijlstra Acked-by: Paul E. McKenney Link: http://lkml.kernel.org/n/tip-1widdkdsb3c1titq8jez6g3g@git.kernel.org Cc: Geert Uytterhoeven Cc: Linus Torvalds Cc: Mathieu Desnoyers Cc: Steven Miao Cc: adi-buildroot-devel@lists.sourceforge.net Cc: linux-kernel@vger.kernel.org Signed-off-by: Ingo Molnar --- arch/blackfin/include/asm/barrier.h | 3 +++ arch/blackfin/include/asm/bitops.h | 14 ++------------ 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/arch/blackfin/include/asm/barrier.h b/arch/blackfin/include/asm/barrier.h index 19283a16ac08..420006877998 100644 --- a/arch/blackfin/include/asm/barrier.h +++ b/arch/blackfin/include/asm/barrier.h @@ -27,6 +27,9 @@ #endif /* !CONFIG_SMP */ +#define smp_mb__before_atomic() barrier() +#define smp_mb__after_atomic() barrier() + #include #endif /* _BLACKFIN_BARRIER_H */ diff --git a/arch/blackfin/include/asm/bitops.h b/arch/blackfin/include/asm/bitops.h index 0ca40dd44724..b298b654a26f 100644 --- a/arch/blackfin/include/asm/bitops.h +++ b/arch/blackfin/include/asm/bitops.h @@ -27,21 +27,17 @@ #include +#include + #ifndef CONFIG_SMP #include - /* * clear_bit may not imply a memory barrier */ -#ifndef smp_mb__before_clear_bit -#define smp_mb__before_clear_bit() smp_mb() -#define smp_mb__after_clear_bit() smp_mb() -#endif #include #include #else -#include #include /* swab32 */ #include @@ -101,12 +97,6 @@ static inline int test_and_change_bit(int nr, volatile unsigned long *addr) return __raw_bit_test_toggle_asm(a, nr & 0x1f); } -/* - * clear_bit() doesn't provide any barrier for the compiler. - */ -#define smp_mb__before_clear_bit() barrier() -#define smp_mb__after_clear_bit() barrier() - #define test_bit __skip_test_bit #include #undef test_bit -- cgit v1.2.3 From a8ec1516a74554992605f230859936d5d79c27ed Mon Sep 17 00:00:00 2001 From: Peter Zijlstra Date: Thu, 13 Mar 2014 19:00:37 +0100 Subject: arch,c6x: Convert smp_mb__*() c6x doesn't have a barrier.h and completely relies on asm-generic/barrier.h. Therefore its smp_mb() is barrier() and we can use the default versions that are smp_mb(). Signed-off-by: Peter Zijlstra Acked-by: Mark Salter Acked-by: Paul E. McKenney Link: http://lkml.kernel.org/n/tip-kl53k3pyj0rbd80jq8ralpf3@git.kernel.org Cc: Aurelien Jacquiot Cc: Linus Torvalds Cc: Mark Salter Cc: linux-c6x-dev@linux-c6x.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Ingo Molnar --- arch/c6x/include/asm/bitops.h | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/arch/c6x/include/asm/bitops.h b/arch/c6x/include/asm/bitops.h index 0bec7e5036a8..f0ab012401b6 100644 --- a/arch/c6x/include/asm/bitops.h +++ b/arch/c6x/include/asm/bitops.h @@ -14,14 +14,8 @@ #ifdef __KERNEL__ #include - #include - -/* - * clear_bit() doesn't provide any barrier for the compiler. - */ -#define smp_mb__before_clear_bit() barrier() -#define smp_mb__after_clear_bit() barrier() +#include /* * We are lucky, DSP is perfect for bitops: do it in 3 cycles -- cgit v1.2.3 From cadefd3d6cc914d95163ba1eda766bfe7ce1e5b7 Mon Sep 17 00:00:00 2001 From: Peter Zijlstra Date: Thu, 27 Feb 2014 10:40:35 +0100 Subject: sched: Make scale_rt_power() deal with backward clocks Mike reported that, while unlikely, its entirely possible for scale_rt_power() to see the time go backwards. This yields rather 'interesting' results. So like all other sites that deal with clocks; make this one ignore backward clock movement too. Reported-by: Mike Galbraith Signed-off-by: Peter Zijlstra Link: http://lkml.kernel.org/r/20140227094035.GZ9987@twins.programming.kicks-ass.net Cc: Linus Torvalds Cc: linux-kernel@vger.kernel.org Signed-off-by: Ingo Molnar --- kernel/sched/fair.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 7570dd969c28..5e157f157d85 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -5564,6 +5564,7 @@ static unsigned long scale_rt_power(int cpu) { struct rq *rq = cpu_rq(cpu); u64 total, available, age_stamp, avg; + s64 delta; /* * Since we're reading these variables without serialization make sure @@ -5572,7 +5573,11 @@ static unsigned long scale_rt_power(int cpu) age_stamp = ACCESS_ONCE(rq->age_stamp); avg = ACCESS_ONCE(rq->rt_avg); - total = sched_avg_period() + (rq_clock(rq) - age_stamp); + delta = rq_clock(rq) - age_stamp; + if (unlikely(delta < 0)) + delta = 0; + + total = sched_avg_period() + delta; if (unlikely(total < avg)) { /* Ensures that power won't end up being negative */ -- cgit v1.2.3 From 27e4f9d0012a9bb7011aade862f08679d2921ab0 Mon Sep 17 00:00:00 2001 From: Peter Zijlstra Date: Wed, 9 Apr 2014 12:50:34 +0200 Subject: sched/wait: Explain the shadowing and type inconsistencies Stick in a comment before someone else tries to fix the sparse warning this generates. Requested-by: Andrew Morton Signed-off-by: Peter Zijlstra Link: http://lkml.kernel.org/n/tip-o2ro6f3vkxklni0bc8f7m68s@git.kernel.org Cc: Linus Torvalds Cc: linux-kernel@vger.kernel.org Signed-off-by: Ingo Molnar --- include/linux/wait.h | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/include/linux/wait.h b/include/linux/wait.h index 559044c79232..2b563a15a77d 100644 --- a/include/linux/wait.h +++ b/include/linux/wait.h @@ -191,11 +191,23 @@ wait_queue_head_t *bit_waitqueue(void *, int); (!__builtin_constant_p(state) || \ state == TASK_INTERRUPTIBLE || state == TASK_KILLABLE) \ +/* + * The below macro ___wait_event() has an explicit shadow of the __ret + * variable when used from the wait_event_*() macros. + * + * This is so that both can use the ___wait_cond_timeout() construct + * to wrap the condition. + * + * The type inconsistency of the wait_event_*() __ret variable is also + * on purpose; we use long where we can return timeout values and int + * otherwise. + */ + #define ___wait_event(wq, condition, state, exclusive, ret, cmd) \ ({ \ __label__ __out; \ wait_queue_t __wait; \ - long __ret = ret; \ + long __ret = ret; /* explicit shadow */ \ \ INIT_LIST_HEAD(&__wait.task_list); \ if (exclusive) \ -- cgit v1.2.3 From 10447917551e0fffb8d1892d46e633c3e0a9c1ec Mon Sep 17 00:00:00 2001 From: Kirill V Tkhai Date: Wed, 12 Mar 2014 06:18:33 -0400 Subject: sched/rt: Do not try to push tasks if pinned task switches to RT Just switched pinned task is not able to be pushed. If the rq had had several RT tasks before they have already been considered as candidates to be pushed (or pulled). Signed-off-by: Kirill V Tkhai Acked-by: Steven Rostedt Signed-off-by: Peter Zijlstra Link: http://lkml.kernel.org/r/20140312061833.3a43aa64@gandalf.local.home Cc: linux-kernel@vger.kernel.org Signed-off-by: Ingo Molnar --- kernel/sched/rt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c index bd2267ad404f..1e4992eb5166 100644 --- a/kernel/sched/rt.c +++ b/kernel/sched/rt.c @@ -1892,9 +1892,9 @@ static void switched_to_rt(struct rq *rq, struct task_struct *p) */ if (p->on_rq && rq->curr != p) { #ifdef CONFIG_SMP - if (rq->rt.overloaded && push_rt_task(rq) && + if (p->nr_cpus_allowed > 1 && rq->rt.overloaded && /* Don't resched if we changed runqueues */ - rq != task_rq(p)) + push_rt_task(rq) && rq != task_rq(p)) check_resched = 0; #endif /* CONFIG_SMP */ if (check_resched && p->prio < rq->curr->prio) -- cgit v1.2.3 From 8698a745d800c59cd5a576398bdeccd578ac66f1 Mon Sep 17 00:00:00 2001 From: Dongsheng Yang Date: Tue, 11 Mar 2014 18:09:12 +0800 Subject: sched, treewide: Replace hardcoded nice values with MIN_NICE/MAX_NICE Replace various -20/+19 hardcoded nice values with MIN_NICE/MAX_NICE. Signed-off-by: Dongsheng Yang Acked-by: Tejun Heo Signed-off-by: Peter Zijlstra Link: http://lkml.kernel.org/r/ff13819fd09b7a5dba5ab5ae797f2e7019bdfa17.1394532288.git.yangds.fnst@cn.fujitsu.com Cc: devel@driverdev.osuosl.org Cc: devicetree@vger.kernel.org Cc: fcoe-devel@open-fcoe.org Cc: linux390@de.ibm.com Cc: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org Cc: linux-s390@vger.kernel.org Cc: linux-scsi@vger.kernel.org Cc: nbd-general@lists.sourceforge.net Cc: ocfs2-devel@oss.oracle.com Cc: openipmi-developer@lists.sourceforge.net Cc: qla2xxx-upstream@qlogic.com Cc: linux-arch@vger.kernel.org [ Consolidated the patches, twiddled the changelog. ] Signed-off-by: Ingo Molnar --- drivers/block/loop.c | 2 +- drivers/block/nbd.c | 2 +- drivers/block/pktcdvd.c | 2 +- drivers/char/ipmi/ipmi_si_intf.c | 2 +- drivers/s390/crypto/ap_bus.c | 2 +- drivers/scsi/bnx2fc/bnx2fc_fcoe.c | 4 ++-- drivers/scsi/bnx2i/bnx2i_hwi.c | 2 +- drivers/scsi/fcoe/fcoe.c | 2 +- drivers/scsi/ibmvscsi/ibmvfc.c | 2 +- drivers/scsi/ibmvscsi/ibmvscsi.c | 2 +- drivers/scsi/lpfc/lpfc_hbadisc.c | 2 +- drivers/scsi/qla2xxx/qla_os.c | 2 +- drivers/staging/android/binder.c | 2 +- drivers/staging/lustre/lustre/llite/lloop.c | 2 +- fs/ocfs2/cluster/heartbeat.c | 2 +- kernel/locking/locktorture.c | 2 +- kernel/workqueue.c | 6 +++--- mm/huge_memory.c | 2 +- 18 files changed, 21 insertions(+), 21 deletions(-) diff --git a/drivers/block/loop.c b/drivers/block/loop.c index 66e8c3b94ef3..c8bf270b7890 100644 --- a/drivers/block/loop.c +++ b/drivers/block/loop.c @@ -548,7 +548,7 @@ static int loop_thread(void *data) struct loop_device *lo = data; struct bio *bio; - set_user_nice(current, -20); + set_user_nice(current, MIN_NICE); while (!kthread_should_stop() || !bio_list_empty(&lo->lo_bio_list)) { diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c index 55298db36b2d..2a1f26bd6640 100644 --- a/drivers/block/nbd.c +++ b/drivers/block/nbd.c @@ -533,7 +533,7 @@ static int nbd_thread(void *data) struct nbd_device *nbd = data; struct request *req; - set_user_nice(current, -20); + set_user_nice(current, MIN_NICE); while (!kthread_should_stop() || !list_empty(&nbd->waiting_queue)) { /* wait for something to do */ wait_event_interruptible(nbd->waiting_wq, diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c index a2af73db187b..ef166ad2dbad 100644 --- a/drivers/block/pktcdvd.c +++ b/drivers/block/pktcdvd.c @@ -1463,7 +1463,7 @@ static int kcdrwd(void *foobar) struct packet_data *pkt; long min_sleep_time, residue; - set_user_nice(current, -20); + set_user_nice(current, MIN_NICE); set_freezable(); for (;;) { diff --git a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c index b7efd3c1a882..0f20d3646a46 100644 --- a/drivers/char/ipmi/ipmi_si_intf.c +++ b/drivers/char/ipmi/ipmi_si_intf.c @@ -998,7 +998,7 @@ static int ipmi_thread(void *data) struct timespec busy_until; ipmi_si_set_not_busy(&busy_until); - set_user_nice(current, 19); + set_user_nice(current, MAX_NICE); while (!kthread_should_stop()) { int busy_wait; diff --git a/drivers/s390/crypto/ap_bus.c b/drivers/s390/crypto/ap_bus.c index ab3baa7f9508..8eec1653c9cc 100644 --- a/drivers/s390/crypto/ap_bus.c +++ b/drivers/s390/crypto/ap_bus.c @@ -1803,7 +1803,7 @@ static int ap_poll_thread(void *data) int requests; struct ap_device *ap_dev; - set_user_nice(current, 19); + set_user_nice(current, MAX_NICE); while (1) { if (ap_suspend_flag) return 0; diff --git a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c index 6287f6a8b79d..3455cc5e4bfd 100644 --- a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c +++ b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c @@ -464,7 +464,7 @@ static int bnx2fc_l2_rcv_thread(void *arg) struct fcoe_percpu_s *bg = arg; struct sk_buff *skb; - set_user_nice(current, -20); + set_user_nice(current, MIN_NICE); set_current_state(TASK_INTERRUPTIBLE); while (!kthread_should_stop()) { schedule(); @@ -602,7 +602,7 @@ int bnx2fc_percpu_io_thread(void *arg) struct bnx2fc_work *work, *tmp; LIST_HEAD(work_list); - set_user_nice(current, -20); + set_user_nice(current, MIN_NICE); set_current_state(TASK_INTERRUPTIBLE); while (!kthread_should_stop()) { schedule(); diff --git a/drivers/scsi/bnx2i/bnx2i_hwi.c b/drivers/scsi/bnx2i/bnx2i_hwi.c index b5ffd280a1ae..d6d491c2f004 100644 --- a/drivers/scsi/bnx2i/bnx2i_hwi.c +++ b/drivers/scsi/bnx2i/bnx2i_hwi.c @@ -1870,7 +1870,7 @@ int bnx2i_percpu_io_thread(void *arg) struct bnx2i_work *work, *tmp; LIST_HEAD(work_list); - set_user_nice(current, -20); + set_user_nice(current, MIN_NICE); while (!kthread_should_stop()) { spin_lock_bh(&p->p_work_lock); diff --git a/drivers/scsi/fcoe/fcoe.c b/drivers/scsi/fcoe/fcoe.c index f3170008ae71..843a679d2a5e 100644 --- a/drivers/scsi/fcoe/fcoe.c +++ b/drivers/scsi/fcoe/fcoe.c @@ -1872,7 +1872,7 @@ static int fcoe_percpu_receive_thread(void *arg) skb_queue_head_init(&tmp); - set_user_nice(current, -20); + set_user_nice(current, MIN_NICE); retry: while (!kthread_should_stop()) { diff --git a/drivers/scsi/ibmvscsi/ibmvfc.c b/drivers/scsi/ibmvscsi/ibmvfc.c index 23f5ba5e6472..8dd47689d584 100644 --- a/drivers/scsi/ibmvscsi/ibmvfc.c +++ b/drivers/scsi/ibmvscsi/ibmvfc.c @@ -4515,7 +4515,7 @@ static int ibmvfc_work(void *data) struct ibmvfc_host *vhost = data; int rc; - set_user_nice(current, -20); + set_user_nice(current, MIN_NICE); while (1) { rc = wait_event_interruptible(vhost->work_wait_q, diff --git a/drivers/scsi/ibmvscsi/ibmvscsi.c b/drivers/scsi/ibmvscsi/ibmvscsi.c index fa764406df68..2ebfb2bb0f42 100644 --- a/drivers/scsi/ibmvscsi/ibmvscsi.c +++ b/drivers/scsi/ibmvscsi/ibmvscsi.c @@ -2213,7 +2213,7 @@ static int ibmvscsi_work(void *data) struct ibmvscsi_host_data *hostdata = data; int rc; - set_user_nice(current, -20); + set_user_nice(current, MIN_NICE); while (1) { rc = wait_event_interruptible(hostdata->work_wait_q, diff --git a/drivers/scsi/lpfc/lpfc_hbadisc.c b/drivers/scsi/lpfc/lpfc_hbadisc.c index 59b51c529ba0..294c072e9083 100644 --- a/drivers/scsi/lpfc/lpfc_hbadisc.c +++ b/drivers/scsi/lpfc/lpfc_hbadisc.c @@ -731,7 +731,7 @@ lpfc_do_work(void *p) struct lpfc_hba *phba = p; int rc; - set_user_nice(current, -20); + set_user_nice(current, MIN_NICE); current->flags |= PF_NOFREEZE; phba->data_flags = 0; diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c index 19e99cc33724..afc84814e9bb 100644 --- a/drivers/scsi/qla2xxx/qla_os.c +++ b/drivers/scsi/qla2xxx/qla_os.c @@ -4828,7 +4828,7 @@ qla2x00_do_dpc(void *data) ha = (struct qla_hw_data *)data; base_vha = pci_get_drvdata(ha->pdev); - set_user_nice(current, -20); + set_user_nice(current, MIN_NICE); set_current_state(TASK_INTERRUPTIBLE); while (!kthread_should_stop()) { diff --git a/drivers/staging/android/binder.c b/drivers/staging/android/binder.c index cfe4bc8f05cb..179b21b66504 100644 --- a/drivers/staging/android/binder.c +++ b/drivers/staging/android/binder.c @@ -441,7 +441,7 @@ static void binder_set_nice(long nice) "%d: nice value %ld not allowed use %ld instead\n", current->pid, nice, min_nice); set_user_nice(current, min_nice); - if (min_nice < 20) + if (min_nice <= MAX_NICE) return; binder_user_error("%d RLIMIT_NICE not set\n", current->pid); } diff --git a/drivers/staging/lustre/lustre/llite/lloop.c b/drivers/staging/lustre/lustre/llite/lloop.c index f78eda235c7a..d4c2cd91add4 100644 --- a/drivers/staging/lustre/lustre/llite/lloop.c +++ b/drivers/staging/lustre/lustre/llite/lloop.c @@ -407,7 +407,7 @@ static int loop_thread(void *data) int refcheck; int ret = 0; - set_user_nice(current, -20); + set_user_nice(current, MIN_NICE); lo->lo_state = LLOOP_BOUND; diff --git a/fs/ocfs2/cluster/heartbeat.c b/fs/ocfs2/cluster/heartbeat.c index bf482dfed14f..73039295d0d1 100644 --- a/fs/ocfs2/cluster/heartbeat.c +++ b/fs/ocfs2/cluster/heartbeat.c @@ -1107,7 +1107,7 @@ static int o2hb_thread(void *data) mlog(ML_HEARTBEAT|ML_KTHREAD, "hb thread running\n"); - set_user_nice(current, -20); + set_user_nice(current, MIN_NICE); /* Pin node */ o2nm_depend_this_node(); diff --git a/kernel/locking/locktorture.c b/kernel/locking/locktorture.c index f26b1a18e34e..23343be46e91 100644 --- a/kernel/locking/locktorture.c +++ b/kernel/locking/locktorture.c @@ -216,7 +216,7 @@ static int lock_torture_writer(void *arg) static DEFINE_TORTURE_RANDOM(rand); VERBOSE_TOROUT_STRING("lock_torture_writer task started"); - set_user_nice(current, 19); + set_user_nice(current, MAX_NICE); do { schedule_timeout_uninterruptible(1); diff --git a/kernel/workqueue.c b/kernel/workqueue.c index 0ee63af30bd1..c30c01b32ece 100644 --- a/kernel/workqueue.c +++ b/kernel/workqueue.c @@ -100,10 +100,10 @@ enum { /* * Rescue workers are used only on emergencies and shared by - * all cpus. Give -20. + * all cpus. Give MIN_NICE. */ - RESCUER_NICE_LEVEL = -20, - HIGHPRI_NICE_LEVEL = -20, + RESCUER_NICE_LEVEL = MIN_NICE, + HIGHPRI_NICE_LEVEL = MIN_NICE, WQ_NAME_LEN = 24, }; diff --git a/mm/huge_memory.c b/mm/huge_memory.c index 1546655a2d78..dcdb6f9adea1 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -2803,7 +2803,7 @@ static int khugepaged(void *none) struct mm_slot *mm_slot; set_freezable(); - set_user_nice(current, 19); + set_user_nice(current, MAX_NICE); while (!kthread_should_stop()) { khugepaged_do_scan(); -- cgit v1.2.3 From 22abdef37cebcdd4933c72339401a174b7d87768 Mon Sep 17 00:00:00 2001 From: Kirill Tkhai Date: Sat, 15 Mar 2014 02:14:49 +0400 Subject: sched/rt: Sum number of all children tasks in hierarhy at ->rt_nr_running {inc,dec}_rt_tasks() used to count entities which are directly queued on the rt_rq. If an entity was not a task (i.e., it is some queue), its children were not counted. There is no problem here, but now we want to count number of all tasks which are actually queued under the rt_rq in all the hierarchy (except throttled rt queues). Empty queues are not able to be queued and all of the places, which use ->rt_nr_running, just compare it with zero, so we do not break anything here. Signed-off-by: Kirill Tkhai Reviewed-by: Preeti U Murthy Signed-off-by: Peter Zijlstra Link: http://lkml.kernel.org/r/1394835289.18748.31.camel@HP-250-G1-Notebook-PC Cc: linux-kernel@vger.kernel.org [ Twiddled the changelog. ] Signed-off-by: Ingo Molnar --- kernel/sched/rt.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c index 1e4992eb5166..6892ed7d644b 100644 --- a/kernel/sched/rt.c +++ b/kernel/sched/rt.c @@ -1044,13 +1044,24 @@ void dec_rt_group(struct sched_rt_entity *rt_se, struct rt_rq *rt_rq) {} #endif /* CONFIG_RT_GROUP_SCHED */ +static inline +unsigned int rt_se_nr_running(struct sched_rt_entity *rt_se) +{ + struct rt_rq *group_rq = group_rt_rq(rt_se); + + if (group_rq) + return group_rq->rt_nr_running; + else + return 1; +} + static inline void inc_rt_tasks(struct sched_rt_entity *rt_se, struct rt_rq *rt_rq) { int prio = rt_se_prio(rt_se); WARN_ON(!rt_prio(prio)); - rt_rq->rt_nr_running++; + rt_rq->rt_nr_running += rt_se_nr_running(rt_se); inc_rt_prio(rt_rq, prio); inc_rt_migration(rt_se, rt_rq); @@ -1062,7 +1073,7 @@ void dec_rt_tasks(struct sched_rt_entity *rt_se, struct rt_rq *rt_rq) { WARN_ON(!rt_prio(rt_se_prio(rt_se))); WARN_ON(!rt_rq->rt_nr_running); - rt_rq->rt_nr_running--; + rt_rq->rt_nr_running -= rt_se_nr_running(rt_se); dec_rt_prio(rt_rq, rt_se_prio(rt_se)); dec_rt_migration(rt_se, rt_rq); -- cgit v1.2.3 From 653d07a6989a9a4166dcd1025aa252b3605737fd Mon Sep 17 00:00:00 2001 From: Kirill Tkhai Date: Sat, 15 Mar 2014 02:14:55 +0400 Subject: sched/rt: Add accessors rq_of_rt_se() Two accessors for RT_GROUP_SCHED and !RT_GROUP_SCHED cases. Signed-off-by: Kirill Tkhai Signed-off-by: Peter Zijlstra Link: http://lkml.kernel.org/r/1394835295.18748.32.camel@HP-250-G1-Notebook-PC Cc: linux-kernel@vger.kernel.org Signed-off-by: Ingo Molnar --- kernel/sched/rt.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c index 6892ed7d644b..f6aa3cdbee84 100644 --- a/kernel/sched/rt.c +++ b/kernel/sched/rt.c @@ -112,6 +112,13 @@ static inline struct rt_rq *rt_rq_of_se(struct sched_rt_entity *rt_se) return rt_se->rt_rq; } +static inline struct rq *rq_of_rt_se(struct sched_rt_entity *rt_se) +{ + struct rt_rq *rt_rq = rt_se->rt_rq; + + return rt_rq->rq; +} + void free_rt_sched_group(struct task_group *tg) { int i; @@ -211,10 +218,16 @@ static inline struct rq *rq_of_rt_rq(struct rt_rq *rt_rq) return container_of(rt_rq, struct rq, rt); } -static inline struct rt_rq *rt_rq_of_se(struct sched_rt_entity *rt_se) +static inline struct rq *rq_of_rt_se(struct sched_rt_entity *rt_se) { struct task_struct *p = rt_task_of(rt_se); - struct rq *rq = task_rq(p); + + return task_rq(p); +} + +static inline struct rt_rq *rt_rq_of_se(struct sched_rt_entity *rt_se) +{ + struct rq *rq = rq_of_rt_se(rt_se); return &rq->rt; } -- cgit v1.2.3 From f4ebcbc0d7e009783256c9daf76bc4b90e645c14 Mon Sep 17 00:00:00 2001 From: Kirill Tkhai Date: Sat, 15 Mar 2014 02:15:00 +0400 Subject: sched/rt: Substract number of tasks of throttled queues from rq->nr_running Now rq->rt becomes to be able to be in dequeued or enqueued state. We add new member rt_rq->rt_queued, which is used to indicate this. The member is used only for top queue rq->rt_rq. The goal is to fit generic scheme which is used in deadline and fair classes, i.e. throttled rt_rq's rt_nr_running is beeing substracted from rq->nr_running. Signed-off-by: Kirill Tkhai Signed-off-by: Peter Zijlstra Link: http://lkml.kernel.org/r/1394835300.18748.33.camel@HP-250-G1-Notebook-PC Cc: linux-kernel@vger.kernel.org Signed-off-by: Ingo Molnar --- kernel/sched/rt.c | 73 +++++++++++++++++++++++++++++++++++++++++++--------- kernel/sched/sched.h | 2 ++ 2 files changed, 63 insertions(+), 12 deletions(-) diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c index f6aa3cdbee84..2add019ddbd0 100644 --- a/kernel/sched/rt.c +++ b/kernel/sched/rt.c @@ -79,6 +79,8 @@ void init_rt_rq(struct rt_rq *rt_rq, struct rq *rq) rt_rq->overloaded = 0; plist_head_init(&rt_rq->pushable_tasks); #endif + /* We start is dequeued state, because no RT tasks are queued */ + rt_rq->rt_queued = 0; rt_rq->rt_time = 0; rt_rq->rt_throttled = 0; @@ -404,6 +406,9 @@ static inline void set_post_schedule(struct rq *rq) } #endif /* CONFIG_SMP */ +static void enqueue_top_rt_rq(struct rt_rq *rt_rq); +static void dequeue_top_rt_rq(struct rt_rq *rt_rq); + static inline int on_rt_rq(struct sched_rt_entity *rt_se) { return !list_empty(&rt_se->run_list); @@ -465,8 +470,11 @@ static void sched_rt_rq_enqueue(struct rt_rq *rt_rq) rt_se = rt_rq->tg->rt_se[cpu]; if (rt_rq->rt_nr_running) { - if (rt_se && !on_rt_rq(rt_se)) + if (!rt_se) + enqueue_top_rt_rq(rt_rq); + else if (!on_rt_rq(rt_se)) enqueue_rt_entity(rt_se, false); + if (rt_rq->highest_prio.curr < curr->prio) resched_task(curr); } @@ -479,7 +487,9 @@ static void sched_rt_rq_dequeue(struct rt_rq *rt_rq) rt_se = rt_rq->tg->rt_se[cpu]; - if (rt_se && on_rt_rq(rt_se)) + if (!rt_se) + dequeue_top_rt_rq(rt_rq); + else if (on_rt_rq(rt_se)) dequeue_rt_entity(rt_se); } @@ -545,12 +555,18 @@ static inline struct rt_rq *group_rt_rq(struct sched_rt_entity *rt_se) static inline void sched_rt_rq_enqueue(struct rt_rq *rt_rq) { - if (rt_rq->rt_nr_running) - resched_task(rq_of_rt_rq(rt_rq)->curr); + struct rq *rq = rq_of_rt_rq(rt_rq); + + if (!rt_rq->rt_nr_running) + return; + + enqueue_top_rt_rq(rt_rq); + resched_task(rq->curr); } static inline void sched_rt_rq_dequeue(struct rt_rq *rt_rq) { + dequeue_top_rt_rq(rt_rq); } static inline const struct cpumask *sched_rt_period_mask(void) @@ -935,6 +951,38 @@ static void update_curr_rt(struct rq *rq) } } +static void +dequeue_top_rt_rq(struct rt_rq *rt_rq) +{ + struct rq *rq = rq_of_rt_rq(rt_rq); + + BUG_ON(&rq->rt != rt_rq); + + if (!rt_rq->rt_queued) + return; + + BUG_ON(!rq->nr_running); + + rq->nr_running -= rt_rq->rt_nr_running; + rt_rq->rt_queued = 0; +} + +static void +enqueue_top_rt_rq(struct rt_rq *rt_rq) +{ + struct rq *rq = rq_of_rt_rq(rt_rq); + + BUG_ON(&rq->rt != rt_rq); + + if (rt_rq->rt_queued) + return; + if (rt_rq_throttled(rt_rq) || !rt_rq->rt_nr_running) + return; + + rq->nr_running += rt_rq->rt_nr_running; + rt_rq->rt_queued = 1; +} + #if defined CONFIG_SMP static void @@ -1143,6 +1191,8 @@ static void dequeue_rt_stack(struct sched_rt_entity *rt_se) back = rt_se; } + dequeue_top_rt_rq(rt_rq_of_se(back)); + for (rt_se = back; rt_se; rt_se = rt_se->back) { if (on_rt_rq(rt_se)) __dequeue_rt_entity(rt_se); @@ -1151,13 +1201,18 @@ static void dequeue_rt_stack(struct sched_rt_entity *rt_se) static void enqueue_rt_entity(struct sched_rt_entity *rt_se, bool head) { + struct rq *rq = rq_of_rt_se(rt_se); + dequeue_rt_stack(rt_se); for_each_sched_rt_entity(rt_se) __enqueue_rt_entity(rt_se, head); + enqueue_top_rt_rq(&rq->rt); } static void dequeue_rt_entity(struct sched_rt_entity *rt_se) { + struct rq *rq = rq_of_rt_se(rt_se); + dequeue_rt_stack(rt_se); for_each_sched_rt_entity(rt_se) { @@ -1166,6 +1221,7 @@ static void dequeue_rt_entity(struct sched_rt_entity *rt_se) if (rt_rq && rt_rq->rt_nr_running) __enqueue_rt_entity(rt_se, false); } + enqueue_top_rt_rq(&rq->rt); } /* @@ -1183,8 +1239,6 @@ enqueue_task_rt(struct rq *rq, struct task_struct *p, int flags) if (!task_current(rq, p) && p->nr_cpus_allowed > 1) enqueue_pushable_task(rq, p); - - inc_nr_running(rq); } static void dequeue_task_rt(struct rq *rq, struct task_struct *p, int flags) @@ -1195,8 +1249,6 @@ static void dequeue_task_rt(struct rq *rq, struct task_struct *p, int flags) dequeue_rt_entity(rt_se); dequeue_pushable_task(rq, p); - - dec_nr_running(rq); } /* @@ -1401,10 +1453,7 @@ pick_next_task_rt(struct rq *rq, struct task_struct *prev) if (prev->sched_class == &rt_sched_class) update_curr_rt(rq); - if (!rt_rq->rt_nr_running) - return NULL; - - if (rt_rq_throttled(rt_rq)) + if (!rt_rq->rt_queued) return NULL; put_prev_task(rq, prev); diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h index 456e492a3dca..c8d9ee418ca7 100644 --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h @@ -409,6 +409,8 @@ struct rt_rq { int overloaded; struct plist_head pushable_tasks; #endif + int rt_queued; + int rt_throttled; u64 rt_time; u64 rt_runtime; -- cgit v1.2.3 From 46383648b3c769fa74794ae6425ab993fc113bdb Mon Sep 17 00:00:00 2001 From: Kirill Tkhai Date: Sat, 15 Mar 2014 02:15:07 +0400 Subject: sched: Revert commit 4c6c4e38c4e9 ("sched/core: Fix endless loop in pick_next_task()") This reverts commit 4c6c4e38c4e9 ("sched/core: Fix endless loop in pick_next_task()"), which is not necessary after ("sched/rt: Substract number of tasks of throttled queues from rq->nr_running"). Signed-off-by: Kirill Tkhai Reviewed-by: Preeti U Murthy [conflict resolution with stop task checking patch] Signed-off-by: Peter Zijlstra Link: http://lkml.kernel.org/r/1394835307.18748.34.camel@HP-250-G1-Notebook-PC Cc: linux-kernel@vger.kernel.org Signed-off-by: Ingo Molnar --- kernel/sched/fair.c | 5 +---- kernel/sched/rt.c | 10 ++++++++++ kernel/sched/sched.h | 12 ------------ 3 files changed, 11 insertions(+), 16 deletions(-) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 5e157f157d85..43232b8bacde 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -6732,10 +6732,7 @@ static int idle_balance(struct rq *this_rq) out: /* Is there a task of a high priority class? */ - if (this_rq->nr_running != this_rq->cfs.h_nr_running && - ((this_rq->stop && this_rq->stop->on_rq) || - this_rq->dl.dl_nr_running || - (this_rq->rt.rt_nr_running && !rt_rq_throttled(&this_rq->rt)))) + if (this_rq->nr_running != this_rq->cfs.h_nr_running) pulled_task = -1; if (pulled_task) { diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c index 2add019ddbd0..7795e292f4c9 100644 --- a/kernel/sched/rt.c +++ b/kernel/sched/rt.c @@ -493,6 +493,11 @@ static void sched_rt_rq_dequeue(struct rt_rq *rt_rq) dequeue_rt_entity(rt_se); } +static inline int rt_rq_throttled(struct rt_rq *rt_rq) +{ + return rt_rq->rt_throttled && !rt_rq->rt_nr_boosted; +} + static int rt_se_boosted(struct sched_rt_entity *rt_se) { struct rt_rq *rt_rq = group_rt_rq(rt_se); @@ -569,6 +574,11 @@ static inline void sched_rt_rq_dequeue(struct rt_rq *rt_rq) dequeue_top_rt_rq(rt_rq); } +static inline int rt_rq_throttled(struct rt_rq *rt_rq) +{ + return rt_rq->rt_throttled; +} + static inline const struct cpumask *sched_rt_period_mask(void) { return cpu_online_mask; diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h index c8d9ee418ca7..b2cbe81308af 100644 --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h @@ -425,18 +425,6 @@ struct rt_rq { #endif }; -#ifdef CONFIG_RT_GROUP_SCHED -static inline int rt_rq_throttled(struct rt_rq *rt_rq) -{ - return rt_rq->rt_throttled && !rt_rq->rt_nr_boosted; -} -#else -static inline int rt_rq_throttled(struct rt_rq *rt_rq) -{ - return rt_rq->rt_throttled; -} -#endif - /* Deadline class' related fields in a runqueue */ struct dl_rq { /* runqueue is an rbtree, ordered by deadline */ -- cgit v1.2.3 From 08f8aeb55d7727d644dbbbbfb798fe937d47751d Mon Sep 17 00:00:00 2001 From: Peter Zijlstra Date: Tue, 8 Apr 2014 14:27:25 +0200 Subject: sched: Remove set_need_resched() The last user is gone now, so we can safely remove this function. Signed-off-by: Peter Zijlstra Cc: Mike Galbraith Cc: linux-kernel@vger.kernel.org Signed-off-by: Ingo Molnar --- include/linux/thread_info.h | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/include/linux/thread_info.h b/include/linux/thread_info.h index fddbe2023a5d..cb0cec94fda3 100644 --- a/include/linux/thread_info.h +++ b/include/linux/thread_info.h @@ -104,20 +104,6 @@ static inline int test_ti_thread_flag(struct thread_info *ti, int flag) #define test_thread_flag(flag) \ test_ti_thread_flag(current_thread_info(), flag) -static inline __deprecated void set_need_resched(void) -{ - /* - * Use of this function in deprecated. - * - * As of this writing there are only a few users in the DRM tree left - * all of which are wrong and can be removed without causing too much - * grief. - * - * The DRM people are aware and are working on removing the last few - * instances. - */ -} - #define tif_need_resched() test_thread_flag(TIF_NEED_RESCHED) #if defined TIF_RESTORE_SIGMASK && !defined HAVE_SET_RESTORE_SIGMASK -- cgit v1.2.3 From c464c76eec4be587604ca082e8cded7e6b89f3bf Mon Sep 17 00:00:00 2001 From: "Yan, Zheng" Date: Tue, 18 Mar 2014 16:56:41 +0800 Subject: perf: Allow building PMU drivers as modules This patch adds support for building PMU driver as module. It exports the functions perf_pmu_{register,unregister}() and adds reference tracking for the PMU driver module. When the PMU driver is built as a module, each active event of the PMU holds a reference to the driver module. Signed-off-by: Yan, Zheng Signed-off-by: Peter Zijlstra Link: http://lkml.kernel.org/r/1395133004-23205-1-git-send-email-zheng.z.yan@intel.com Cc: eranian@google.com Cc: Arnaldo Carvalho de Melo Cc: Linus Torvalds Cc: linux-kernel@vger.kernel.org Signed-off-by: Ingo Molnar --- include/linux/perf_event.h | 1 + kernel/events/core.c | 15 +++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h index 3356abcfff18..af6dcf1d9e47 100644 --- a/include/linux/perf_event.h +++ b/include/linux/perf_event.h @@ -172,6 +172,7 @@ struct perf_event; struct pmu { struct list_head entry; + struct module *module; struct device *dev; const struct attribute_group **attr_groups; const char *name; diff --git a/kernel/events/core.c b/kernel/events/core.c index f83a71a3e46d..5129b1201050 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c @@ -39,6 +39,7 @@ #include #include #include +#include #include "internal.h" @@ -3229,6 +3230,9 @@ static void __free_event(struct perf_event *event) if (event->ctx) put_ctx(event->ctx); + if (event->pmu) + module_put(event->pmu->module); + call_rcu(&event->rcu_head, free_event_rcu); } static void free_event(struct perf_event *event) @@ -6551,6 +6555,7 @@ free_pdc: free_percpu(pmu->pmu_disable_count); goto unlock; } +EXPORT_SYMBOL_GPL(perf_pmu_register); void perf_pmu_unregister(struct pmu *pmu) { @@ -6572,6 +6577,7 @@ void perf_pmu_unregister(struct pmu *pmu) put_device(pmu->dev); free_pmu_context(pmu); } +EXPORT_SYMBOL_GPL(perf_pmu_unregister); struct pmu *perf_init_event(struct perf_event *event) { @@ -6585,6 +6591,10 @@ struct pmu *perf_init_event(struct perf_event *event) pmu = idr_find(&pmu_idr, event->attr.type); rcu_read_unlock(); if (pmu) { + if (!try_module_get(pmu->module)) { + pmu = ERR_PTR(-ENODEV); + goto unlock; + } event->pmu = pmu; ret = pmu->event_init(event); if (ret) @@ -6593,6 +6603,10 @@ struct pmu *perf_init_event(struct perf_event *event) } list_for_each_entry_rcu(pmu, &pmus, entry) { + if (!try_module_get(pmu->module)) { + pmu = ERR_PTR(-ENODEV); + goto unlock; + } event->pmu = pmu; ret = pmu->event_init(event); if (!ret) @@ -6771,6 +6785,7 @@ perf_event_alloc(struct perf_event_attr *attr, int cpu, err_pmu: if (event->destroy) event->destroy(event); + module_put(pmu->module); err_ns: if (event->ns) put_pid_ns(event->ns); -- cgit v1.2.3 From 8588a2bbddc524325d84d1d6996758e9242e4ffc Mon Sep 17 00:00:00 2001 From: "Yan, Zheng" Date: Tue, 18 Mar 2014 16:56:42 +0800 Subject: hrtimer: Export __hrtimer_start_range_ns() Export __hrtimer_start_range_ns() to allow building perf Intel uncore driver as a module. Signed-off-by: Yan, Zheng Acked-by: Thomas Gleixner Signed-off-by: Peter Zijlstra Link: http://lkml.kernel.org/r/1395133004-23205-2-git-send-email-zheng.z.yan@intel.com Cc: eranian@google.com Cc: Linus Torvalds Cc: linux-kernel@vger.kernel.org Signed-off-by: Ingo Molnar --- kernel/hrtimer.c | 1 + 1 file changed, 1 insertion(+) diff --git a/kernel/hrtimer.c b/kernel/hrtimer.c index d55092ceee29..53d26829cd4d 100644 --- a/kernel/hrtimer.c +++ b/kernel/hrtimer.c @@ -1017,6 +1017,7 @@ int __hrtimer_start_range_ns(struct hrtimer *timer, ktime_t tim, return ret; } +EXPORT_SYMBOL_GPL(__hrtimer_start_range_ns); /** * hrtimer_start_range_ns - (re)start an hrtimer on the current CPU -- cgit v1.2.3 From 4a3dc121d3c370625575247bf714db3f601d83e9 Mon Sep 17 00:00:00 2001 From: "Yan, Zheng" Date: Tue, 18 Mar 2014 16:56:43 +0800 Subject: perf/x86: Export perf_assign_events() export perf_assign_events to allow building perf Intel uncore driver as module Signed-off-by: Yan, Zheng Signed-off-by: Peter Zijlstra Link: http://lkml.kernel.org/r/1395133004-23205-3-git-send-email-zheng.z.yan@intel.com Cc: Arnaldo Carvalho de Melo Cc: eranian@google.com Cc: Linus Torvalds Cc: linux-kernel@vger.kernel.org Signed-off-by: Ingo Molnar --- arch/x86/kernel/cpu/perf_event.c | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/x86/kernel/cpu/perf_event.c b/arch/x86/kernel/cpu/perf_event.c index ae407f7226c8..89f3b7c1af20 100644 --- a/arch/x86/kernel/cpu/perf_event.c +++ b/arch/x86/kernel/cpu/perf_event.c @@ -721,6 +721,7 @@ int perf_assign_events(struct perf_event **events, int n, return sched.state.unassigned; } +EXPORT_SYMBOL_GPL(perf_assign_events); int x86_schedule_events(struct cpu_hw_events *cpuc, int n, int *assign) { -- cgit v1.2.3 From 17b40213ab2b091fd5d2a9337eae62312608ad3d Mon Sep 17 00:00:00 2001 From: Peter Zijlstra Date: Thu, 13 Mar 2014 19:00:37 +0100 Subject: arch,cris: Convert smp_mb__*() Cris fully relies on asm-generic/barrier.h, therefore its smp_mb() is barrier(), thus we can use the default implementation that uses smp_mb(). (Include asm/system.h and asm/barrier.h to avoid header dependency hell.) Signed-off-by: Peter Zijlstra Acked-by: Jesper Nilsson Acked-by: Paul E. McKenney Link: http://lkml.kernel.org/n/tip-wvewbe8os3s1e4pt1cdotuee@git.kernel.org Cc: Andrew Morton Cc: Geert Uytterhoeven Cc: Jesper Nilsson Cc: Linus Torvalds Cc: Mikael Starvik Cc: linux-cris-kernel@axis.com Cc: linux-kernel@vger.kernel.org Signed-off-by: Ingo Molnar --- arch/cris/include/asm/atomic.h | 8 ++------ arch/cris/include/asm/bitops.h | 9 ++------- 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/arch/cris/include/asm/atomic.h b/arch/cris/include/asm/atomic.h index 1056a5dfe04f..aa429baebaf9 100644 --- a/arch/cris/include/asm/atomic.h +++ b/arch/cris/include/asm/atomic.h @@ -7,6 +7,8 @@ #include #include #include +#include +#include /* * Atomic operations that C can't guarantee us. Useful for @@ -151,10 +153,4 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u) return ret; } -/* Atomic operations are already serializing */ -#define smp_mb__before_atomic_dec() barrier() -#define smp_mb__after_atomic_dec() barrier() -#define smp_mb__before_atomic_inc() barrier() -#define smp_mb__after_atomic_inc() barrier() - #endif diff --git a/arch/cris/include/asm/bitops.h b/arch/cris/include/asm/bitops.h index 053c17b36559..bd49a546f4f5 100644 --- a/arch/cris/include/asm/bitops.h +++ b/arch/cris/include/asm/bitops.h @@ -21,6 +21,7 @@ #include #include #include +#include /* * set_bit - Atomically set a bit in memory @@ -42,7 +43,7 @@ * * clear_bit() is atomic and may not be reordered. However, it does * not contain a memory barrier, so if it is used for locking purposes, - * you should call smp_mb__before_clear_bit() and/or smp_mb__after_clear_bit() + * you should call smp_mb__before_atomic() and/or smp_mb__after_atomic() * in order to ensure changes are visible on other processors. */ @@ -84,12 +85,6 @@ static inline int test_and_set_bit(int nr, volatile unsigned long *addr) return retval; } -/* - * clear_bit() doesn't provide any barrier for the compiler. - */ -#define smp_mb__before_clear_bit() barrier() -#define smp_mb__after_clear_bit() barrier() - /** * test_and_clear_bit - Clear a bit and return its old value * @nr: Bit to clear -- cgit v1.2.3 From d038c0e8380fa8cae049bee8d81a5672cd159013 Mon Sep 17 00:00:00 2001 From: Peter Zijlstra Date: Thu, 13 Mar 2014 19:00:37 +0100 Subject: arch,frv: Convert smp_mb__*() Because: arch/frv/include/asm/smp.h:#error SMP not supported smp_mb() is barrier() and we can use the default implementation that uses smp_mb(). Signed-off-by: Peter Zijlstra Acked-by: Paul E. McKenney Link: http://lkml.kernel.org/n/tip-n296g51yzdu5ru1vp7mccxmf@git.kernel.org Cc: David Howells Cc: Linus Torvalds Cc: linux-kernel@vger.kernel.org Signed-off-by: Ingo Molnar --- arch/frv/include/asm/atomic.h | 7 +------ arch/frv/include/asm/bitops.h | 6 ------ 2 files changed, 1 insertion(+), 12 deletions(-) diff --git a/arch/frv/include/asm/atomic.h b/arch/frv/include/asm/atomic.h index b86329d0e316..f6c3a1690101 100644 --- a/arch/frv/include/asm/atomic.h +++ b/arch/frv/include/asm/atomic.h @@ -17,6 +17,7 @@ #include #include #include +#include #ifdef CONFIG_SMP #error not SMP safe @@ -29,12 +30,6 @@ * We do not have SMP systems, so we don't have to deal with that. */ -/* Atomic operations are already serializing */ -#define smp_mb__before_atomic_dec() barrier() -#define smp_mb__after_atomic_dec() barrier() -#define smp_mb__before_atomic_inc() barrier() -#define smp_mb__after_atomic_inc() barrier() - #define ATOMIC_INIT(i) { (i) } #define atomic_read(v) (*(volatile int *)&(v)->counter) #define atomic_set(v, i) (((v)->counter) = (i)) diff --git a/arch/frv/include/asm/bitops.h b/arch/frv/include/asm/bitops.h index 57bf85db893f..96de220ef131 100644 --- a/arch/frv/include/asm/bitops.h +++ b/arch/frv/include/asm/bitops.h @@ -25,12 +25,6 @@ #include -/* - * clear_bit() doesn't provide any barrier for the compiler. - */ -#define smp_mb__before_clear_bit() barrier() -#define smp_mb__after_clear_bit() barrier() - #ifndef CONFIG_FRV_OUTOFLINE_ATOMIC_OPS static inline unsigned long atomic_test_and_ANDNOT_mask(unsigned long mask, volatile unsigned long *v) -- cgit v1.2.3 From 94cf42f823bc904305b0ee93a09bcd51ba380497 Mon Sep 17 00:00:00 2001 From: Peter Zijlstra Date: Thu, 13 Mar 2014 19:00:36 +0100 Subject: arch,hexagon: Convert smp_mb__*() Hexagon uses asm-gemeric/barrier.h and its smp_mb() is barrier(). Therefore we can use the default implementation that uses smp_mb(). Signed-off-by: Peter Zijlstra Acked-by: Paul E. McKenney Link: http://lkml.kernel.org/n/tip-87irqrrbgizeojjfdqhypud3@git.kernel.org Cc: Linus Torvalds Cc: Richard Kuo Cc: Vineet Gupta Cc: linux-hexagon@vger.kernel.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Ingo Molnar --- arch/hexagon/include/asm/atomic.h | 6 +----- arch/hexagon/include/asm/bitops.h | 4 +--- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/arch/hexagon/include/asm/atomic.h b/arch/hexagon/include/asm/atomic.h index 17dc63780c06..de916b11bff5 100644 --- a/arch/hexagon/include/asm/atomic.h +++ b/arch/hexagon/include/asm/atomic.h @@ -24,6 +24,7 @@ #include #include +#include #define ATOMIC_INIT(i) { (i) } @@ -176,9 +177,4 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u) #define atomic_inc_return(v) (atomic_add_return(1, v)) #define atomic_dec_return(v) (atomic_sub_return(1, v)) -#define smp_mb__before_atomic_dec() barrier() -#define smp_mb__after_atomic_dec() barrier() -#define smp_mb__before_atomic_inc() barrier() -#define smp_mb__after_atomic_inc() barrier() - #endif diff --git a/arch/hexagon/include/asm/bitops.h b/arch/hexagon/include/asm/bitops.h index 9b1e4afbab3c..5e4a59b3ec1b 100644 --- a/arch/hexagon/include/asm/bitops.h +++ b/arch/hexagon/include/asm/bitops.h @@ -25,12 +25,10 @@ #include #include #include +#include #ifdef __KERNEL__ -#define smp_mb__before_clear_bit() barrier() -#define smp_mb__after_clear_bit() barrier() - /* * The offset calculations for these are based on BITS_PER_LONG == 32 * (i.e. I get to shift by #5-2 (32 bits per long, 4 bytes per access), -- cgit v1.2.3 From 0cd64efb61f1e68be26bd5121ccff3c779dc488b Mon Sep 17 00:00:00 2001 From: Peter Zijlstra Date: Thu, 13 Mar 2014 19:00:36 +0100 Subject: arch,ia64: Convert smp_mb__*() ia64 atomic ops are full barriers; implement the new smp_mb__{before,after}_atomic(). Signed-off-by: Peter Zijlstra Acked-by: Paul E. McKenney Link: http://lkml.kernel.org/n/tip-hyp7yj68cmqz1nqbfpr541ca@git.kernel.org Cc: Akinobu Mita Cc: Fenghua Yu Cc: Linus Torvalds Cc: Tony Luck Cc: Will Deacon Cc: linux-ia64@vger.kernel.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Ingo Molnar --- arch/ia64/include/asm/atomic.h | 7 +------ arch/ia64/include/asm/barrier.h | 3 +++ arch/ia64/include/asm/bitops.h | 6 ++---- 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/arch/ia64/include/asm/atomic.h b/arch/ia64/include/asm/atomic.h index 6e6fe1839f5d..0f8bf48dadf3 100644 --- a/arch/ia64/include/asm/atomic.h +++ b/arch/ia64/include/asm/atomic.h @@ -15,6 +15,7 @@ #include #include +#include #define ATOMIC_INIT(i) { (i) } @@ -208,10 +209,4 @@ atomic64_add_negative (__s64 i, atomic64_t *v) #define atomic64_inc(v) atomic64_add(1, (v)) #define atomic64_dec(v) atomic64_sub(1, (v)) -/* Atomic operations are already serializing */ -#define smp_mb__before_atomic_dec() barrier() -#define smp_mb__after_atomic_dec() barrier() -#define smp_mb__before_atomic_inc() barrier() -#define smp_mb__after_atomic_inc() barrier() - #endif /* _ASM_IA64_ATOMIC_H */ diff --git a/arch/ia64/include/asm/barrier.h b/arch/ia64/include/asm/barrier.h index d0a69aa35e27..a48957c7b445 100644 --- a/arch/ia64/include/asm/barrier.h +++ b/arch/ia64/include/asm/barrier.h @@ -55,6 +55,9 @@ #endif +#define smp_mb__before_atomic() barrier() +#define smp_mb__after_atomic() barrier() + /* * IA64 GCC turns volatile stores into st.rel and volatile loads into ld.acq no * need for asm trickery! diff --git a/arch/ia64/include/asm/bitops.h b/arch/ia64/include/asm/bitops.h index feb8117ed06a..71e8145243ee 100644 --- a/arch/ia64/include/asm/bitops.h +++ b/arch/ia64/include/asm/bitops.h @@ -16,6 +16,7 @@ #include #include #include +#include /** * set_bit - Atomically set a bit in memory @@ -65,9 +66,6 @@ __set_bit (int nr, volatile void *addr) *((__u32 *) addr + (nr >> 5)) |= (1 << (nr & 31)); } -#define smp_mb__before_clear_bit() barrier(); -#define smp_mb__after_clear_bit() barrier(); - /** * clear_bit - Clears a bit in memory * @nr: Bit to clear @@ -75,7 +73,7 @@ __set_bit (int nr, volatile void *addr) * * clear_bit() is atomic and may not be reordered. However, it does * not contain a memory barrier, so if it is used for locking purposes, - * you should call smp_mb__before_clear_bit() and/or smp_mb__after_clear_bit() + * you should call smp_mb__before_atomic() and/or smp_mb__after_atomic() * in order to ensure changes are visible on other processors. */ static __inline__ void -- cgit v1.2.3 From 89607d5e2928d49bb64669d6d1e30e933a33f817 Mon Sep 17 00:00:00 2001 From: Peter Zijlstra Date: Thu, 13 Mar 2014 19:00:36 +0100 Subject: arch,m32r: Convert smp_mb__*() M32r uses asm-generic/barrier.h and its smp_mb() is barrier(); therefore we can use the generic versions which default to smp_mb(). Signed-off-by: Peter Zijlstra Acked-by: Paul E. McKenney Link: http://lkml.kernel.org/n/tip-wh6xljltyvmpy9t0bc80k1fy@git.kernel.org Cc: Hirokazu Takata Cc: Linus Torvalds Cc: linux-kernel@vger.kernel.org Cc: linux-m32r-ja@ml.linux-m32r.org Cc: linux-m32r@ml.linux-m32r.org Signed-off-by: Ingo Molnar --- arch/m32r/include/asm/atomic.h | 7 +------ arch/m32r/include/asm/bitops.h | 6 ++---- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/arch/m32r/include/asm/atomic.h b/arch/m32r/include/asm/atomic.h index 0d81697c326c..8ad0ed4182a5 100644 --- a/arch/m32r/include/asm/atomic.h +++ b/arch/m32r/include/asm/atomic.h @@ -13,6 +13,7 @@ #include #include #include +#include /* * Atomic operations that C can't guarantee us. Useful for @@ -308,10 +309,4 @@ static __inline__ void atomic_set_mask(unsigned long mask, atomic_t *addr) local_irq_restore(flags); } -/* Atomic operations are already serializing on m32r */ -#define smp_mb__before_atomic_dec() barrier() -#define smp_mb__after_atomic_dec() barrier() -#define smp_mb__before_atomic_inc() barrier() -#define smp_mb__after_atomic_inc() barrier() - #endif /* _ASM_M32R_ATOMIC_H */ diff --git a/arch/m32r/include/asm/bitops.h b/arch/m32r/include/asm/bitops.h index d3dea9ac7d4e..86ba2b42a6cf 100644 --- a/arch/m32r/include/asm/bitops.h +++ b/arch/m32r/include/asm/bitops.h @@ -21,6 +21,7 @@ #include #include #include +#include /* * These have to be done with inline assembly: that way the bit-setting @@ -73,7 +74,7 @@ static __inline__ void set_bit(int nr, volatile void * addr) * * clear_bit() is atomic and may not be reordered. However, it does * not contain a memory barrier, so if it is used for locking purposes, - * you should call smp_mb__before_clear_bit() and/or smp_mb__after_clear_bit() + * you should call smp_mb__before_atomic() and/or smp_mb__after_atomic() * in order to ensure changes are visible on other processors. */ static __inline__ void clear_bit(int nr, volatile void * addr) @@ -103,9 +104,6 @@ static __inline__ void clear_bit(int nr, volatile void * addr) local_irq_restore(flags); } -#define smp_mb__before_clear_bit() barrier() -#define smp_mb__after_clear_bit() barrier() - /** * change_bit - Toggle a bit in memory * @nr: Bit to clear -- cgit v1.2.3 From 2db56e8606016e33903c64feaed989ffecd66a1b Mon Sep 17 00:00:00 2001 From: Peter Zijlstra Date: Thu, 13 Mar 2014 19:00:36 +0100 Subject: arch,m68k: Convert smp_mb__*() m68k uses asm-generic/barrier.h and its smp_mb() is barrier(), therefore we can use the generic versions that use smp_mb(). Signed-off-by: Peter Zijlstra Acked-by: Paul E. McKenney Link: http://lkml.kernel.org/n/tip-s5dvosrb7qhvpmtaffwfn0zg@git.kernel.org Cc: Geert Uytterhoeven Cc: Linus Torvalds Cc: linux-kernel@vger.kernel.org Cc: linux-m68k@lists.linux-m68k.org Signed-off-by: Ingo Molnar --- arch/m68k/include/asm/atomic.h | 8 +------- arch/m68k/include/asm/bitops.h | 7 +------ 2 files changed, 2 insertions(+), 13 deletions(-) diff --git a/arch/m68k/include/asm/atomic.h b/arch/m68k/include/asm/atomic.h index f4e32de263a7..55695212a2ae 100644 --- a/arch/m68k/include/asm/atomic.h +++ b/arch/m68k/include/asm/atomic.h @@ -4,6 +4,7 @@ #include #include #include +#include /* * Atomic operations that C can't guarantee us. Useful for @@ -209,11 +210,4 @@ static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u) return c; } - -/* Atomic operations are already serializing */ -#define smp_mb__before_atomic_dec() barrier() -#define smp_mb__after_atomic_dec() barrier() -#define smp_mb__before_atomic_inc() barrier() -#define smp_mb__after_atomic_inc() barrier() - #endif /* __ARCH_M68K_ATOMIC __ */ diff --git a/arch/m68k/include/asm/bitops.h b/arch/m68k/include/asm/bitops.h index c6baa913592a..b4a9b0d5928d 100644 --- a/arch/m68k/include/asm/bitops.h +++ b/arch/m68k/include/asm/bitops.h @@ -13,6 +13,7 @@ #endif #include +#include /* * Bit access functions vary across the ColdFire and 68k families. @@ -67,12 +68,6 @@ static inline void bfset_mem_set_bit(int nr, volatile unsigned long *vaddr) #define __set_bit(nr, vaddr) set_bit(nr, vaddr) -/* - * clear_bit() doesn't provide any barrier for the compiler. - */ -#define smp_mb__before_clear_bit() barrier() -#define smp_mb__after_clear_bit() barrier() - static inline void bclr_reg_clear_bit(int nr, volatile unsigned long *vaddr) { char *p = (char *)vaddr + (nr ^ 31) / 8; -- cgit v1.2.3 From 40074dece684fc61ab72cfc1689d564cba1c5f64 Mon Sep 17 00:00:00 2001 From: Peter Zijlstra Date: Thu, 13 Mar 2014 19:00:36 +0100 Subject: arch,metag: Convert smp_mb__*() Implement the new barriers; as per the old versions the metag atomic imply a full barrier. Signed-off-by: Peter Zijlstra Acked-by: Paul E. McKenney Link: http://lkml.kernel.org/n/tip-dqnyo215kq38wi4xcxnbpjw3@git.kernel.org Cc: James Hogan Cc: Linus Torvalds Cc: Will Deacon Cc: linux-kernel@vger.kernel.org Cc: linux-metag@vger.kernel.org Signed-off-by: Ingo Molnar --- arch/metag/include/asm/atomic.h | 6 +----- arch/metag/include/asm/barrier.h | 3 +++ arch/metag/include/asm/bitops.h | 6 ------ 3 files changed, 4 insertions(+), 11 deletions(-) diff --git a/arch/metag/include/asm/atomic.h b/arch/metag/include/asm/atomic.h index 307ecd2bd9a1..470e365f04ea 100644 --- a/arch/metag/include/asm/atomic.h +++ b/arch/metag/include/asm/atomic.h @@ -4,6 +4,7 @@ #include #include #include +#include #if defined(CONFIG_METAG_ATOMICITY_IRQSOFF) /* The simple UP case. */ @@ -39,11 +40,6 @@ #define atomic_inc_not_zero(v) atomic_add_unless((v), 1, 0) -#define smp_mb__before_atomic_dec() barrier() -#define smp_mb__after_atomic_dec() barrier() -#define smp_mb__before_atomic_inc() barrier() -#define smp_mb__after_atomic_inc() barrier() - #endif #define atomic_dec_if_positive(v) atomic_sub_if_positive(1, v) diff --git a/arch/metag/include/asm/barrier.h b/arch/metag/include/asm/barrier.h index 5d6b4b407dda..d1768c6f5b18 100644 --- a/arch/metag/include/asm/barrier.h +++ b/arch/metag/include/asm/barrier.h @@ -97,4 +97,7 @@ do { \ ___p1; \ }) +#define smp_mb__before_atomic() barrier() +#define smp_mb__after_atomic() barrier() + #endif /* _ASM_METAG_BARRIER_H */ diff --git a/arch/metag/include/asm/bitops.h b/arch/metag/include/asm/bitops.h index c0d0df0d1378..2671134ee745 100644 --- a/arch/metag/include/asm/bitops.h +++ b/arch/metag/include/asm/bitops.h @@ -5,12 +5,6 @@ #include #include -/* - * clear_bit() doesn't provide any barrier for the compiler. - */ -#define smp_mb__before_clear_bit() barrier() -#define smp_mb__after_clear_bit() barrier() - #ifdef CONFIG_SMP /* * These functions are the basis of our bit ops. -- cgit v1.2.3 From 91bbefe6b0fcd2968c34a5a566bda870477afc82 Mon Sep 17 00:00:00 2001 From: Peter Zijlstra Date: Thu, 13 Mar 2014 19:00:36 +0100 Subject: arch,mips: Convert smp_mb__*() MIPS is interesting and has hardware variants that reorder over ll/sc as well as those that do not. Implement the 2 new barrier functions as per the old barriers. Signed-off-by: Peter Zijlstra Acked-by: Paul E. McKenney Link: http://lkml.kernel.org/n/tip-9ph49jbae3hol9v721sbc2g6@git.kernel.org Cc: Linus Torvalds Cc: Maciej W. Rozycki" Cc: Ralf Baechle Cc: Will Deacon Cc: linux-kernel@vger.kernel.org Cc: linux-mips@linux-mips.org Signed-off-by: Ingo Molnar --- arch/mips/include/asm/atomic.h | 9 --------- arch/mips/include/asm/barrier.h | 3 +++ arch/mips/include/asm/bitops.h | 11 ++--------- arch/mips/kernel/irq.c | 4 ++-- 4 files changed, 7 insertions(+), 20 deletions(-) diff --git a/arch/mips/include/asm/atomic.h b/arch/mips/include/asm/atomic.h index e8eb3d53a241..37b2befe651a 100644 --- a/arch/mips/include/asm/atomic.h +++ b/arch/mips/include/asm/atomic.h @@ -761,13 +761,4 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u) #endif /* CONFIG_64BIT */ -/* - * atomic*_return operations are serializing but not the non-*_return - * versions. - */ -#define smp_mb__before_atomic_dec() smp_mb__before_llsc() -#define smp_mb__after_atomic_dec() smp_llsc_mb() -#define smp_mb__before_atomic_inc() smp_mb__before_llsc() -#define smp_mb__after_atomic_inc() smp_llsc_mb() - #endif /* _ASM_ATOMIC_H */ diff --git a/arch/mips/include/asm/barrier.h b/arch/mips/include/asm/barrier.h index e1aa4e4c2984..d0101dd0575e 100644 --- a/arch/mips/include/asm/barrier.h +++ b/arch/mips/include/asm/barrier.h @@ -195,4 +195,7 @@ do { \ ___p1; \ }) +#define smp_mb__before_atomic() smp_mb__before_llsc() +#define smp_mb__after_atomic() smp_llsc_mb() + #endif /* __ASM_BARRIER_H */ diff --git a/arch/mips/include/asm/bitops.h b/arch/mips/include/asm/bitops.h index 6a65d49e2c0d..7c8816f7b7c4 100644 --- a/arch/mips/include/asm/bitops.h +++ b/arch/mips/include/asm/bitops.h @@ -37,13 +37,6 @@ #define __EXT "dext " #endif -/* - * clear_bit() doesn't provide any barrier for the compiler. - */ -#define smp_mb__before_clear_bit() smp_mb__before_llsc() -#define smp_mb__after_clear_bit() smp_llsc_mb() - - /* * These are the "slower" versions of the functions and are in bitops.c. * These functions call raw_local_irq_{save,restore}(). @@ -120,7 +113,7 @@ static inline void set_bit(unsigned long nr, volatile unsigned long *addr) * * clear_bit() is atomic and may not be reordered. However, it does * not contain a memory barrier, so if it is used for locking purposes, - * you should call smp_mb__before_clear_bit() and/or smp_mb__after_clear_bit() + * you should call smp_mb__before_atomic() and/or smp_mb__after_atomic() * in order to ensure changes are visible on other processors. */ static inline void clear_bit(unsigned long nr, volatile unsigned long *addr) @@ -175,7 +168,7 @@ static inline void clear_bit(unsigned long nr, volatile unsigned long *addr) */ static inline void clear_bit_unlock(unsigned long nr, volatile unsigned long *addr) { - smp_mb__before_clear_bit(); + smp_mb__before_atomic(); clear_bit(nr, addr); } diff --git a/arch/mips/kernel/irq.c b/arch/mips/kernel/irq.c index d1fea7a054be..1818da4dbb85 100644 --- a/arch/mips/kernel/irq.c +++ b/arch/mips/kernel/irq.c @@ -62,9 +62,9 @@ void __init alloc_legacy_irqno(void) void free_irqno(unsigned int irq) { - smp_mb__before_clear_bit(); + smp_mb__before_atomic(); clear_bit(irq, irq_map); - smp_mb__after_clear_bit(); + smp_mb__after_atomic(); } /* -- cgit v1.2.3 From 9424cdf0fc7f768f20daef77980da9617a76679b Mon Sep 17 00:00:00 2001 From: Peter Zijlstra Date: Thu, 13 Mar 2014 19:00:36 +0100 Subject: arch,mn10300: Convert smp_mb__*() mn10300 fully relies on asm-generic/barrier.h and therefore its smp_mb() is barrier(). We can use the default implementation. Signed-off-by: Peter Zijlstra Acked-by: Paul E. McKenney Link: http://lkml.kernel.org/n/tip-wotyeoj99h1dpojjeest2jbk@git.kernel.org Cc: David Howells Cc: Koichi Yasutake Cc: Linus Torvalds Cc: linux-am33-list@redhat.com Cc: linux-kernel@vger.kernel.org Signed-off-by: Ingo Molnar --- arch/mn10300/include/asm/atomic.h | 7 +------ arch/mn10300/include/asm/bitops.h | 4 +--- arch/mn10300/mm/tlb-smp.c | 4 ++-- 3 files changed, 4 insertions(+), 11 deletions(-) diff --git a/arch/mn10300/include/asm/atomic.h b/arch/mn10300/include/asm/atomic.h index 975e1841ca64..cadeb1e2cdfc 100644 --- a/arch/mn10300/include/asm/atomic.h +++ b/arch/mn10300/include/asm/atomic.h @@ -13,6 +13,7 @@ #include #include +#include #ifndef CONFIG_SMP #include @@ -234,12 +235,6 @@ static inline void atomic_set_mask(unsigned long mask, unsigned long *addr) #endif } -/* Atomic operations are already serializing on MN10300??? */ -#define smp_mb__before_atomic_dec() barrier() -#define smp_mb__after_atomic_dec() barrier() -#define smp_mb__before_atomic_inc() barrier() -#define smp_mb__after_atomic_inc() barrier() - #endif /* __KERNEL__ */ #endif /* CONFIG_SMP */ #endif /* _ASM_ATOMIC_H */ diff --git a/arch/mn10300/include/asm/bitops.h b/arch/mn10300/include/asm/bitops.h index 596bb2706d81..fe6f8e2c3617 100644 --- a/arch/mn10300/include/asm/bitops.h +++ b/arch/mn10300/include/asm/bitops.h @@ -18,9 +18,7 @@ #define __ASM_BITOPS_H #include - -#define smp_mb__before_clear_bit() barrier() -#define smp_mb__after_clear_bit() barrier() +#include /* * set bit diff --git a/arch/mn10300/mm/tlb-smp.c b/arch/mn10300/mm/tlb-smp.c index 3e57faf04083..e5d0ef722bfa 100644 --- a/arch/mn10300/mm/tlb-smp.c +++ b/arch/mn10300/mm/tlb-smp.c @@ -78,9 +78,9 @@ void smp_flush_tlb(void *unused) else local_flush_tlb_page(flush_mm, flush_va); - smp_mb__before_clear_bit(); + smp_mb__before_atomic(); cpumask_clear_cpu(cpu_id, &flush_cpumask); - smp_mb__after_clear_bit(); + smp_mb__after_atomic(); out: put_cpu(); } -- cgit v1.2.3 From 0f5c6f9e18e14b4ebd83dd08e81ca8143d43de28 Mon Sep 17 00:00:00 2001 From: Peter Zijlstra Date: Thu, 13 Mar 2014 19:00:36 +0100 Subject: arch,openrisc: Convert smp_mb__*() Openrisc fully relies on asm-generic/barrier.h and therefore its smp_mb() is barrier(). Signed-off-by: Peter Zijlstra Acked-by: Paul E. McKenney Link: http://lkml.kernel.org/n/tip-sxgxgqag9tond4kji07d22oh@git.kernel.org Cc: Jonas Bonn Cc: Linus Torvalds Cc: linux-kernel@vger.kernel.org Cc: linux@lists.openrisc.net Signed-off-by: Ingo Molnar --- arch/openrisc/include/asm/bitops.h | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/arch/openrisc/include/asm/bitops.h b/arch/openrisc/include/asm/bitops.h index 2c64f2228dc7..3003cdad561b 100644 --- a/arch/openrisc/include/asm/bitops.h +++ b/arch/openrisc/include/asm/bitops.h @@ -27,14 +27,7 @@ #include #include - -/* - * clear_bit may not imply a memory barrier - */ -#ifndef smp_mb__before_clear_bit -#define smp_mb__before_clear_bit() smp_mb() -#define smp_mb__after_clear_bit() smp_mb() -#endif +#include #include #include -- cgit v1.2.3 From e4a65e9d395feee195f1219d708e9eb2a2d4b583 Mon Sep 17 00:00:00 2001 From: Peter Zijlstra Date: Thu, 13 Mar 2014 19:00:36 +0100 Subject: arch,parisc: Convert smp_mb__*() parisc fully relies on asm-generic/barrier.h, therefore its smp_mb() is barrier and the default implementation suffices. Signed-off-by: Peter Zijlstra Acked-by: Paul E. McKenney Link: http://lkml.kernel.org/n/tip-mxs4aubiyesi79v8xx53093q@git.kernel.org Cc: Helge Deller Cc: James E.J. Bottomley Cc: Linus Torvalds Cc: linux-kernel@vger.kernel.org Cc: linux-parisc@vger.kernel.org Signed-off-by: Ingo Molnar --- arch/parisc/include/asm/atomic.h | 6 +----- arch/parisc/include/asm/bitops.h | 4 +--- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/arch/parisc/include/asm/atomic.h b/arch/parisc/include/asm/atomic.h index 472886ceab1d..0be2db2c7d44 100644 --- a/arch/parisc/include/asm/atomic.h +++ b/arch/parisc/include/asm/atomic.h @@ -7,6 +7,7 @@ #include #include +#include /* * Atomic operations that C can't guarantee us. Useful for @@ -143,11 +144,6 @@ static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u) #define ATOMIC_INIT(i) { (i) } -#define smp_mb__before_atomic_dec() smp_mb() -#define smp_mb__after_atomic_dec() smp_mb() -#define smp_mb__before_atomic_inc() smp_mb() -#define smp_mb__after_atomic_inc() smp_mb() - #ifdef CONFIG_64BIT #define ATOMIC64_INIT(i) { (i) } diff --git a/arch/parisc/include/asm/bitops.h b/arch/parisc/include/asm/bitops.h index 8c9b631d2a78..3f9406d9b9d6 100644 --- a/arch/parisc/include/asm/bitops.h +++ b/arch/parisc/include/asm/bitops.h @@ -8,6 +8,7 @@ #include #include /* for BITS_PER_LONG/SHIFT_PER_LONG */ #include +#include #include /* @@ -19,9 +20,6 @@ #define CHOP_SHIFTCOUNT(x) (((unsigned long) (x)) & (BITS_PER_LONG - 1)) -#define smp_mb__before_clear_bit() smp_mb() -#define smp_mb__after_clear_bit() smp_mb() - /* See http://marc.theaimsgroup.com/?t=108826637900003 for discussion * on use of volatile and __*_bit() (set/clear/change): * *_bit() want use of volatile. -- cgit v1.2.3 From c645073f7e4f073e1ebcd0f0d91652c4468b8364 Mon Sep 17 00:00:00 2001 From: Peter Zijlstra Date: Thu, 13 Mar 2014 19:00:35 +0100 Subject: arch,powerpc: Convert smp_mb__*() Powerpc allows reordering over its ll/sc implementation. Implement the two new barriers as appropriate. Signed-off-by: Peter Zijlstra Acked-by: Paul E. McKenney Link: http://lkml.kernel.org/n/tip-gg2ffgq32sjgy9b8lj6m3hsc@git.kernel.org Cc: Benjamin Herrenschmidt Cc: Linus Torvalds Cc: Mahesh Salgaonkar Cc: Paul Gortmaker Cc: Paul Mackerras Cc: Will Deacon Cc: linux-kernel@vger.kernel.org Cc: linuxppc-dev@lists.ozlabs.org Signed-off-by: Ingo Molnar --- arch/powerpc/include/asm/atomic.h | 6 +----- arch/powerpc/include/asm/barrier.h | 3 +++ arch/powerpc/include/asm/bitops.h | 6 +----- arch/powerpc/kernel/crash.c | 2 +- 4 files changed, 6 insertions(+), 11 deletions(-) diff --git a/arch/powerpc/include/asm/atomic.h b/arch/powerpc/include/asm/atomic.h index e3b1d41c89be..28992d012926 100644 --- a/arch/powerpc/include/asm/atomic.h +++ b/arch/powerpc/include/asm/atomic.h @@ -8,6 +8,7 @@ #ifdef __KERNEL__ #include #include +#include #define ATOMIC_INIT(i) { (i) } @@ -270,11 +271,6 @@ static __inline__ int atomic_dec_if_positive(atomic_t *v) } #define atomic_dec_if_positive atomic_dec_if_positive -#define smp_mb__before_atomic_dec() smp_mb() -#define smp_mb__after_atomic_dec() smp_mb() -#define smp_mb__before_atomic_inc() smp_mb() -#define smp_mb__after_atomic_inc() smp_mb() - #ifdef __powerpc64__ #define ATOMIC64_INIT(i) { (i) } diff --git a/arch/powerpc/include/asm/barrier.h b/arch/powerpc/include/asm/barrier.h index f89da808ce31..bab79a110c7b 100644 --- a/arch/powerpc/include/asm/barrier.h +++ b/arch/powerpc/include/asm/barrier.h @@ -84,4 +84,7 @@ do { \ ___p1; \ }) +#define smp_mb__before_atomic() smp_mb() +#define smp_mb__after_atomic() smp_mb() + #endif /* _ASM_POWERPC_BARRIER_H */ diff --git a/arch/powerpc/include/asm/bitops.h b/arch/powerpc/include/asm/bitops.h index a5e9a7d494d8..bd3bd573d0ae 100644 --- a/arch/powerpc/include/asm/bitops.h +++ b/arch/powerpc/include/asm/bitops.h @@ -51,11 +51,7 @@ #define PPC_BIT(bit) (1UL << PPC_BITLSHIFT(bit)) #define PPC_BITMASK(bs, be) ((PPC_BIT(bs) - PPC_BIT(be)) | PPC_BIT(bs)) -/* - * clear_bit doesn't imply a memory barrier - */ -#define smp_mb__before_clear_bit() smp_mb() -#define smp_mb__after_clear_bit() smp_mb() +#include /* Macro for generating the ***_bits() functions */ #define DEFINE_BITOP(fn, op, prefix) \ diff --git a/arch/powerpc/kernel/crash.c b/arch/powerpc/kernel/crash.c index 18d7c80ddeb9..51dbace3269b 100644 --- a/arch/powerpc/kernel/crash.c +++ b/arch/powerpc/kernel/crash.c @@ -81,7 +81,7 @@ void crash_ipi_callback(struct pt_regs *regs) } atomic_inc(&cpus_in_crash); - smp_mb__after_atomic_inc(); + smp_mb__after_atomic(); /* * Starting the kdump boot. -- cgit v1.2.3 From 0e530747c69f1e191f101a925bb4051894e5c7b0 Mon Sep 17 00:00:00 2001 From: Peter Zijlstra Date: Thu, 13 Mar 2014 19:00:35 +0100 Subject: arch,s390: Convert smp_mb__*() As per the existing implementation; implement the new one using smp_mb(). AFAICT the s390 compare-and-swap does imply a barrier, however there are some immediate ops that seem to be singly-copy atomic and do not imply a barrier. One such is the "ni" op (which would be and-immediate) which is used for the constant clear_bit implementation. Therefore s390 needs full barriers for the {before,after} atomic ops. Signed-off-by: Peter Zijlstra Acked-by: Paul E. McKenney Link: http://lkml.kernel.org/n/tip-kme5dz5hcobpnufnnkh1ech2@git.kernel.org Cc: Chen Gang Cc: Heiko Carstens Cc: Linus Torvalds Cc: Martin Schwidefsky Cc: Will Deacon Cc: linux390@de.ibm.com Cc: linux-kernel@vger.kernel.org Cc: linux-s390@vger.kernel.org Signed-off-by: Ingo Molnar --- arch/s390/include/asm/atomic.h | 5 ----- arch/s390/include/asm/barrier.h | 5 +++-- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/arch/s390/include/asm/atomic.h b/arch/s390/include/asm/atomic.h index 1d4706114a45..fa934fe080c1 100644 --- a/arch/s390/include/asm/atomic.h +++ b/arch/s390/include/asm/atomic.h @@ -412,9 +412,4 @@ static inline long long atomic64_dec_if_positive(atomic64_t *v) #define atomic64_dec_and_test(_v) (atomic64_sub_return(1, _v) == 0) #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0) -#define smp_mb__before_atomic_dec() smp_mb() -#define smp_mb__after_atomic_dec() smp_mb() -#define smp_mb__before_atomic_inc() smp_mb() -#define smp_mb__after_atomic_inc() smp_mb() - #endif /* __ARCH_S390_ATOMIC__ */ diff --git a/arch/s390/include/asm/barrier.h b/arch/s390/include/asm/barrier.h index 578680f6207a..19ff956b752b 100644 --- a/arch/s390/include/asm/barrier.h +++ b/arch/s390/include/asm/barrier.h @@ -27,8 +27,9 @@ #define smp_rmb() rmb() #define smp_wmb() wmb() #define smp_read_barrier_depends() read_barrier_depends() -#define smp_mb__before_clear_bit() smp_mb() -#define smp_mb__after_clear_bit() smp_mb() + +#define smp_mb__before_atomic() smp_mb() +#define smp_mb__after_atomic() smp_mb() #define set_mb(var, value) do { var = value; mb(); } while (0) -- cgit v1.2.3 From 57aa6a76864dfbb5450728199c37c02f401586ec Mon Sep 17 00:00:00 2001 From: Peter Zijlstra Date: Thu, 13 Mar 2014 19:00:35 +0100 Subject: arch,score: Convert smp_mb__*() score fully relies on asm-generic/barrier.h, so it can use its default implementation. Signed-off-by: Peter Zijlstra Acked-by: Paul E. McKenney Acked-by: Lennox Wu Link: http://lkml.kernel.org/n/tip-4mv9svf28lnotjpfuza8urh8@git.kernel.org Cc: Chen Liqin Cc: Linus Torvalds Cc: linux-kernel@vger.kernel.org Signed-off-by: Ingo Molnar --- arch/score/include/asm/bitops.h | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/arch/score/include/asm/bitops.h b/arch/score/include/asm/bitops.h index a304096b1894..c1bf8d6d0fb0 100644 --- a/arch/score/include/asm/bitops.h +++ b/arch/score/include/asm/bitops.h @@ -2,12 +2,7 @@ #define _ASM_SCORE_BITOPS_H #include /* swab32 */ - -/* - * clear_bit() doesn't provide any barrier for the compiler. - */ -#define smp_mb__before_clear_bit() barrier() -#define smp_mb__after_clear_bit() barrier() +#include #include #include -- cgit v1.2.3 From 603228bcb8da90f8f8a5cdd8de74178f6c3e7e13 Mon Sep 17 00:00:00 2001 From: Peter Zijlstra Date: Thu, 13 Mar 2014 19:00:35 +0100 Subject: arch,sh: Convert smp_mb__*() SH can use the asm-generic/barrier.h implementation since that uses smp_mb(). Signed-off-by: Peter Zijlstra Acked-by: Paul E. McKenney Link: http://lkml.kernel.org/n/tip-2z962by2ppzcd984ybw2mwdw@git.kernel.org Cc: Linus Torvalds Cc: linux-kernel@vger.kernel.org Cc: linux-sh@vger.kernel.org Signed-off-by: Ingo Molnar --- arch/sh/include/asm/atomic.h | 6 +----- arch/sh/include/asm/bitops.h | 7 +------ 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/arch/sh/include/asm/atomic.h b/arch/sh/include/asm/atomic.h index f4c1c20bcdf6..f57b8a6743b3 100644 --- a/arch/sh/include/asm/atomic.h +++ b/arch/sh/include/asm/atomic.h @@ -10,6 +10,7 @@ #include #include #include +#include #define ATOMIC_INIT(i) { (i) } @@ -62,9 +63,4 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u) return c; } -#define smp_mb__before_atomic_dec() smp_mb() -#define smp_mb__after_atomic_dec() smp_mb() -#define smp_mb__before_atomic_inc() smp_mb() -#define smp_mb__after_atomic_inc() smp_mb() - #endif /* __ASM_SH_ATOMIC_H */ diff --git a/arch/sh/include/asm/bitops.h b/arch/sh/include/asm/bitops.h index ea8706d94f08..fc8e652cf173 100644 --- a/arch/sh/include/asm/bitops.h +++ b/arch/sh/include/asm/bitops.h @@ -9,6 +9,7 @@ /* For __swab32 */ #include +#include #ifdef CONFIG_GUSA_RB #include @@ -22,12 +23,6 @@ #include #endif -/* - * clear_bit() doesn't provide any barrier for the compiler. - */ -#define smp_mb__before_clear_bit() smp_mb() -#define smp_mb__after_clear_bit() smp_mb() - #ifdef CONFIG_SUPERH32 static inline unsigned long ffz(unsigned long word) { -- cgit v1.2.3 From 56d3648948c202e8b89cd786a004c451a3eb264f Mon Sep 17 00:00:00 2001 From: Peter Zijlstra Date: Thu, 13 Mar 2014 19:00:35 +0100 Subject: arch,sparc: Convert smp_mb__*() sparc32: fully relies on asm-generic/barrier.h and thus can use its implementation. sparc64: is strongly ordered and its atomic ops imply a full barrier, implement the new primitives using barrier(). Signed-off-by: Peter Zijlstra Acked-by: Paul E. McKenney Acked-by: David S. Miller Link: http://lkml.kernel.org/n/tip-2cla9ubpd8chrntnm7e4zdt4@git.kernel.org Cc: Linus Torvalds Cc: Will Deacon Cc: linux-kernel@vger.kernel.org Cc: sparclinux@vger.kernel.org Signed-off-by: Ingo Molnar --- arch/sparc/include/asm/atomic_32.h | 7 +------ arch/sparc/include/asm/atomic_64.h | 7 +------ arch/sparc/include/asm/barrier_64.h | 3 +++ arch/sparc/include/asm/bitops_32.h | 3 --- arch/sparc/include/asm/bitops_64.h | 4 +--- 5 files changed, 6 insertions(+), 18 deletions(-) diff --git a/arch/sparc/include/asm/atomic_32.h b/arch/sparc/include/asm/atomic_32.h index 905832aa9e9e..f08fe51b264d 100644 --- a/arch/sparc/include/asm/atomic_32.h +++ b/arch/sparc/include/asm/atomic_32.h @@ -14,6 +14,7 @@ #include #include +#include #include @@ -52,10 +53,4 @@ extern void atomic_set(atomic_t *, int); #define atomic_dec_and_test(v) (atomic_dec_return(v) == 0) #define atomic_sub_and_test(i, v) (atomic_sub_return(i, v) == 0) -/* Atomic operations are already serializing */ -#define smp_mb__before_atomic_dec() barrier() -#define smp_mb__after_atomic_dec() barrier() -#define smp_mb__before_atomic_inc() barrier() -#define smp_mb__after_atomic_inc() barrier() - #endif /* !(__ARCH_SPARC_ATOMIC__) */ diff --git a/arch/sparc/include/asm/atomic_64.h b/arch/sparc/include/asm/atomic_64.h index be56a244c9cf..8b2f1bde2889 100644 --- a/arch/sparc/include/asm/atomic_64.h +++ b/arch/sparc/include/asm/atomic_64.h @@ -9,6 +9,7 @@ #include #include +#include #define ATOMIC_INIT(i) { (i) } #define ATOMIC64_INIT(i) { (i) } @@ -108,10 +109,4 @@ static inline long atomic64_add_unless(atomic64_t *v, long a, long u) extern long atomic64_dec_if_positive(atomic64_t *v); -/* Atomic operations are already serializing */ -#define smp_mb__before_atomic_dec() barrier() -#define smp_mb__after_atomic_dec() barrier() -#define smp_mb__before_atomic_inc() barrier() -#define smp_mb__after_atomic_inc() barrier() - #endif /* !(__ARCH_SPARC64_ATOMIC__) */ diff --git a/arch/sparc/include/asm/barrier_64.h b/arch/sparc/include/asm/barrier_64.h index b5aad964558e..305dcc3dc721 100644 --- a/arch/sparc/include/asm/barrier_64.h +++ b/arch/sparc/include/asm/barrier_64.h @@ -68,4 +68,7 @@ do { \ ___p1; \ }) +#define smp_mb__before_atomic() barrier() +#define smp_mb__after_atomic() barrier() + #endif /* !(__SPARC64_BARRIER_H) */ diff --git a/arch/sparc/include/asm/bitops_32.h b/arch/sparc/include/asm/bitops_32.h index 25a676653d45..88c9a962502c 100644 --- a/arch/sparc/include/asm/bitops_32.h +++ b/arch/sparc/include/asm/bitops_32.h @@ -90,9 +90,6 @@ static inline void change_bit(unsigned long nr, volatile unsigned long *addr) #include -#define smp_mb__before_clear_bit() do { } while(0) -#define smp_mb__after_clear_bit() do { } while(0) - #include #include #include diff --git a/arch/sparc/include/asm/bitops_64.h b/arch/sparc/include/asm/bitops_64.h index 29011cc0e4be..f1a051ca301a 100644 --- a/arch/sparc/include/asm/bitops_64.h +++ b/arch/sparc/include/asm/bitops_64.h @@ -13,6 +13,7 @@ #include #include +#include extern int test_and_set_bit(unsigned long nr, volatile unsigned long *addr); extern int test_and_clear_bit(unsigned long nr, volatile unsigned long *addr); @@ -23,9 +24,6 @@ extern void change_bit(unsigned long nr, volatile unsigned long *addr); #include -#define smp_mb__before_clear_bit() barrier() -#define smp_mb__after_clear_bit() barrier() - #include #include #include -- cgit v1.2.3 From ce3609f93445846f7b5a5b4bacb236a9bdc35216 Mon Sep 17 00:00:00 2001 From: Peter Zijlstra Date: Thu, 13 Mar 2014 19:00:35 +0100 Subject: arch,tile: Convert smp_mb__*() Implement the new smp_mb__* ops as per the old ones. Signed-off-by: Peter Zijlstra Acked-by: Paul E. McKenney Acked-by: Chris Metcalf Link: http://lkml.kernel.org/n/tip-euuabnf5a3u23fy4fq8m3jcg@git.kernel.org Cc: Akinobu Mita Cc: Chen Gang Cc: Geert Uytterhoeven Cc: Linus Torvalds Cc: Mathieu Desnoyers Cc: linux-kernel@vger.kernel.org Signed-off-by: Ingo Molnar --- arch/tile/include/asm/atomic_32.h | 10 ---------- arch/tile/include/asm/atomic_64.h | 6 ------ arch/tile/include/asm/barrier.h | 14 ++++++++++++++ arch/tile/include/asm/bitops.h | 1 + arch/tile/include/asm/bitops_32.h | 8 ++------ arch/tile/include/asm/bitops_64.h | 4 ---- 6 files changed, 17 insertions(+), 26 deletions(-) diff --git a/arch/tile/include/asm/atomic_32.h b/arch/tile/include/asm/atomic_32.h index 1ad4a1f7d42b..1b109fad9fff 100644 --- a/arch/tile/include/asm/atomic_32.h +++ b/arch/tile/include/asm/atomic_32.h @@ -169,16 +169,6 @@ static inline void atomic64_set(atomic64_t *v, long long n) #define atomic64_dec_and_test(v) (atomic64_dec_return((v)) == 0) #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1LL, 0LL) -/* - * We need to barrier before modifying the word, since the _atomic_xxx() - * routines just tns the lock and then read/modify/write of the word. - * But after the word is updated, the routine issues an "mf" before returning, - * and since it's a function call, we don't even need a compiler barrier. - */ -#define smp_mb__before_atomic_dec() smp_mb() -#define smp_mb__before_atomic_inc() smp_mb() -#define smp_mb__after_atomic_dec() do { } while (0) -#define smp_mb__after_atomic_inc() do { } while (0) #endif /* !__ASSEMBLY__ */ diff --git a/arch/tile/include/asm/atomic_64.h b/arch/tile/include/asm/atomic_64.h index ad220eed05fc..7b11c5fadd42 100644 --- a/arch/tile/include/asm/atomic_64.h +++ b/arch/tile/include/asm/atomic_64.h @@ -105,12 +105,6 @@ static inline long atomic64_add_unless(atomic64_t *v, long a, long u) #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0) -/* Atomic dec and inc don't implement barrier, so provide them if needed. */ -#define smp_mb__before_atomic_dec() smp_mb() -#define smp_mb__after_atomic_dec() smp_mb() -#define smp_mb__before_atomic_inc() smp_mb() -#define smp_mb__after_atomic_inc() smp_mb() - /* Define this to indicate that cmpxchg is an efficient operation. */ #define __HAVE_ARCH_CMPXCHG diff --git a/arch/tile/include/asm/barrier.h b/arch/tile/include/asm/barrier.h index b5a05d050a8f..96a42ae79f4d 100644 --- a/arch/tile/include/asm/barrier.h +++ b/arch/tile/include/asm/barrier.h @@ -72,6 +72,20 @@ mb_incoherent(void) #define mb() fast_mb() #define iob() fast_iob() +#ifndef __tilegx__ /* 32 bit */ +/* + * We need to barrier before modifying the word, since the _atomic_xxx() + * routines just tns the lock and then read/modify/write of the word. + * But after the word is updated, the routine issues an "mf" before returning, + * and since it's a function call, we don't even need a compiler barrier. + */ +#define smp_mb__before_atomic() smp_mb() +#define smp_mb__after_atomic() do { } while (0) +#else /* 64 bit */ +#define smp_mb__before_atomic() smp_mb() +#define smp_mb__after_atomic() smp_mb() +#endif + #include #endif /* !__ASSEMBLY__ */ diff --git a/arch/tile/include/asm/bitops.h b/arch/tile/include/asm/bitops.h index d5a206865036..20caa346ac06 100644 --- a/arch/tile/include/asm/bitops.h +++ b/arch/tile/include/asm/bitops.h @@ -17,6 +17,7 @@ #define _ASM_TILE_BITOPS_H #include +#include #ifndef _LINUX_BITOPS_H #error only can be included directly diff --git a/arch/tile/include/asm/bitops_32.h b/arch/tile/include/asm/bitops_32.h index 386865ad2f55..bbf7b666f21d 100644 --- a/arch/tile/include/asm/bitops_32.h +++ b/arch/tile/include/asm/bitops_32.h @@ -49,8 +49,8 @@ static inline void set_bit(unsigned nr, volatile unsigned long *addr) * restricted to acting on a single-word quantity. * * clear_bit() may not contain a memory barrier, so if it is used for - * locking purposes, you should call smp_mb__before_clear_bit() and/or - * smp_mb__after_clear_bit() to ensure changes are visible on other cpus. + * locking purposes, you should call smp_mb__before_atomic() and/or + * smp_mb__after_atomic() to ensure changes are visible on other cpus. */ static inline void clear_bit(unsigned nr, volatile unsigned long *addr) { @@ -121,10 +121,6 @@ static inline int test_and_change_bit(unsigned nr, return (_atomic_xor(addr, mask) & mask) != 0; } -/* See discussion at smp_mb__before_atomic_dec() in . */ -#define smp_mb__before_clear_bit() smp_mb() -#define smp_mb__after_clear_bit() do {} while (0) - #include #endif /* _ASM_TILE_BITOPS_32_H */ diff --git a/arch/tile/include/asm/bitops_64.h b/arch/tile/include/asm/bitops_64.h index ad34cd056085..bb1a29221fcd 100644 --- a/arch/tile/include/asm/bitops_64.h +++ b/arch/tile/include/asm/bitops_64.h @@ -32,10 +32,6 @@ static inline void clear_bit(unsigned nr, volatile unsigned long *addr) __insn_fetchand((void *)(addr + nr / BITS_PER_LONG), ~mask); } -#define smp_mb__before_clear_bit() smp_mb() -#define smp_mb__after_clear_bit() smp_mb() - - static inline void change_bit(unsigned nr, volatile unsigned long *addr) { unsigned long mask = (1UL << (nr % BITS_PER_LONG)); -- cgit v1.2.3 From d00a569284b1340c16fe2c148099e077ea09ebc9 Mon Sep 17 00:00:00 2001 From: Peter Zijlstra Date: Thu, 13 Mar 2014 19:00:35 +0100 Subject: arch,x86: Convert smp_mb__*() x86 is strongly ordered and all its atomic ops imply a full barrier. Implement the two new primitives as the old ones were. Signed-off-by: Peter Zijlstra Acked-by: Paul E. McKenney Link: http://lkml.kernel.org/n/tip-knswsr5mldkr0w1lrdxvc81w@git.kernel.org Cc: Dave Jones Cc: Jesse Brandeburg Cc: Linus Torvalds Cc: Michel Lespinasse Cc: Will Deacon Cc: linux-kernel@vger.kernel.org Signed-off-by: Ingo Molnar --- arch/x86/include/asm/atomic.h | 7 +------ arch/x86/include/asm/barrier.h | 4 ++++ arch/x86/include/asm/bitops.h | 6 ++---- arch/x86/include/asm/sync_bitops.h | 2 +- arch/x86/kernel/apic/hw_nmi.c | 2 +- 5 files changed, 9 insertions(+), 12 deletions(-) diff --git a/arch/x86/include/asm/atomic.h b/arch/x86/include/asm/atomic.h index b17f4f48ecd7..6dd1c7dd0473 100644 --- a/arch/x86/include/asm/atomic.h +++ b/arch/x86/include/asm/atomic.h @@ -7,6 +7,7 @@ #include #include #include +#include /* * Atomic operations that C can't guarantee us. Useful for @@ -243,12 +244,6 @@ static inline void atomic_or_long(unsigned long *v1, unsigned long v2) : : "r" ((unsigned)(mask)), "m" (*(addr)) \ : "memory") -/* Atomic operations are already serializing on x86 */ -#define smp_mb__before_atomic_dec() barrier() -#define smp_mb__after_atomic_dec() barrier() -#define smp_mb__before_atomic_inc() barrier() -#define smp_mb__after_atomic_inc() barrier() - #ifdef CONFIG_X86_32 # include #else diff --git a/arch/x86/include/asm/barrier.h b/arch/x86/include/asm/barrier.h index 69bbb4845020..5c7198cca5ed 100644 --- a/arch/x86/include/asm/barrier.h +++ b/arch/x86/include/asm/barrier.h @@ -137,6 +137,10 @@ do { \ #endif +/* Atomic operations are already serializing on x86 */ +#define smp_mb__before_atomic() barrier() +#define smp_mb__after_atomic() barrier() + /* * Stop RDTSC speculation. This is needed when you need to use RDTSC * (or get_cycles or vread that possibly accesses the TSC) in a defined diff --git a/arch/x86/include/asm/bitops.h b/arch/x86/include/asm/bitops.h index 9fc1af74dc83..afcd35d331de 100644 --- a/arch/x86/include/asm/bitops.h +++ b/arch/x86/include/asm/bitops.h @@ -15,6 +15,7 @@ #include #include #include +#include #if BITS_PER_LONG == 32 # define _BITOPS_LONG_SHIFT 5 @@ -102,7 +103,7 @@ static inline void __set_bit(long nr, volatile unsigned long *addr) * * clear_bit() is atomic and may not be reordered. However, it does * not contain a memory barrier, so if it is used for locking purposes, - * you should call smp_mb__before_clear_bit() and/or smp_mb__after_clear_bit() + * you should call smp_mb__before_atomic() and/or smp_mb__after_atomic() * in order to ensure changes are visible on other processors. */ static __always_inline void @@ -156,9 +157,6 @@ static inline void __clear_bit_unlock(long nr, volatile unsigned long *addr) __clear_bit(nr, addr); } -#define smp_mb__before_clear_bit() barrier() -#define smp_mb__after_clear_bit() barrier() - /** * __change_bit - Toggle a bit in memory * @nr: the bit to change diff --git a/arch/x86/include/asm/sync_bitops.h b/arch/x86/include/asm/sync_bitops.h index 05af3b31d522..f28a24b51dc7 100644 --- a/arch/x86/include/asm/sync_bitops.h +++ b/arch/x86/include/asm/sync_bitops.h @@ -41,7 +41,7 @@ static inline void sync_set_bit(long nr, volatile unsigned long *addr) * * sync_clear_bit() is atomic and may not be reordered. However, it does * not contain a memory barrier, so if it is used for locking purposes, - * you should call smp_mb__before_clear_bit() and/or smp_mb__after_clear_bit() + * you should call smp_mb__before_atomic() and/or smp_mb__after_atomic() * in order to ensure changes are visible on other processors. */ static inline void sync_clear_bit(long nr, volatile unsigned long *addr) diff --git a/arch/x86/kernel/apic/hw_nmi.c b/arch/x86/kernel/apic/hw_nmi.c index a698d7165c96..eab67047dec3 100644 --- a/arch/x86/kernel/apic/hw_nmi.c +++ b/arch/x86/kernel/apic/hw_nmi.c @@ -57,7 +57,7 @@ void arch_trigger_all_cpu_backtrace(void) } clear_bit(0, &backtrace_flag); - smp_mb__after_clear_bit(); + smp_mb__after_atomic(); } static int __kprobes -- cgit v1.2.3 From 09a01c0ccb1837abb28afcfdd668fa0dfabed928 Mon Sep 17 00:00:00 2001 From: Peter Zijlstra Date: Thu, 13 Mar 2014 19:00:35 +0100 Subject: arch,xtensa: Convert smp_mb__*() Xtensa SMP has compare-and-swap which is fully serializing, therefore its exising smp_mb__{before,after}_clear_bit() appear unduly heavy. Implement the new barriers as barrier(). Signed-off-by: Peter Zijlstra Acked-by: Paul E. McKenney Link: http://lkml.kernel.org/n/tip-e9rqjxr1m1ejsob9p433kmji@git.kernel.org Cc: Chris Zankel Cc: Geert Uytterhoeven Cc: Linus Torvalds Cc: Mathieu Desnoyers Cc: Max Filippov Cc: linux-kernel@vger.kernel.org Cc: linux-xtensa@linux-xtensa.org Signed-off-by: Ingo Molnar --- arch/xtensa/include/asm/atomic.h | 7 +------ arch/xtensa/include/asm/barrier.h | 3 +++ arch/xtensa/include/asm/bitops.h | 4 +--- 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/arch/xtensa/include/asm/atomic.h b/arch/xtensa/include/asm/atomic.h index e7fb447bce8e..e5103b47a8ce 100644 --- a/arch/xtensa/include/asm/atomic.h +++ b/arch/xtensa/include/asm/atomic.h @@ -19,6 +19,7 @@ #ifdef __KERNEL__ #include #include +#include #define ATOMIC_INIT(i) { (i) } @@ -387,12 +388,6 @@ static inline void atomic_set_mask(unsigned int mask, atomic_t *v) #endif } -/* Atomic operations are already serializing */ -#define smp_mb__before_atomic_dec() barrier() -#define smp_mb__after_atomic_dec() barrier() -#define smp_mb__before_atomic_inc() barrier() -#define smp_mb__after_atomic_inc() barrier() - #endif /* __KERNEL__ */ #endif /* _XTENSA_ATOMIC_H */ diff --git a/arch/xtensa/include/asm/barrier.h b/arch/xtensa/include/asm/barrier.h index 0a24b04d6b21..5b88774c75ab 100644 --- a/arch/xtensa/include/asm/barrier.h +++ b/arch/xtensa/include/asm/barrier.h @@ -13,6 +13,9 @@ #define rmb() barrier() #define wmb() mb() +#define smp_mb__before_atomic() barrier() +#define smp_mb__after_atomic() barrier() + #include #endif /* _XTENSA_SYSTEM_H */ diff --git a/arch/xtensa/include/asm/bitops.h b/arch/xtensa/include/asm/bitops.h index 7b6873ae84c2..3f44fa2a53e9 100644 --- a/arch/xtensa/include/asm/bitops.h +++ b/arch/xtensa/include/asm/bitops.h @@ -21,9 +21,7 @@ #include #include - -#define smp_mb__before_clear_bit() smp_mb() -#define smp_mb__after_clear_bit() smp_mb() +#include #include -- cgit v1.2.3 From 1b15611e1c30b37abe393d411c316cd659920bf5 Mon Sep 17 00:00:00 2001 From: Peter Zijlstra Date: Thu, 13 Mar 2014 19:00:35 +0100 Subject: arch,doc: Convert smp_mb__*() Update the documentation to reflect the change of barrier primitives. Signed-off-by: Peter Zijlstra Reviewed-by: Paul E. McKenney Acked-by: David Howells Link: http://lkml.kernel.org/n/tip-xslfehiga1twbk5uk94rij1e@git.kernel.org Cc: Linus Torvalds Cc: Randy Dunlap Cc: linux-doc@vger.kernel.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Ingo Molnar --- Documentation/atomic_ops.txt | 31 +++++++++++------------------ Documentation/memory-barriers.txt | 42 ++++++++++----------------------------- 2 files changed, 23 insertions(+), 50 deletions(-) diff --git a/Documentation/atomic_ops.txt b/Documentation/atomic_ops.txt index d9ca5be9b471..68542fe13b85 100644 --- a/Documentation/atomic_ops.txt +++ b/Documentation/atomic_ops.txt @@ -285,15 +285,13 @@ If a caller requires memory barrier semantics around an atomic_t operation which does not return a value, a set of interfaces are defined which accomplish this: - void smp_mb__before_atomic_dec(void); - void smp_mb__after_atomic_dec(void); - void smp_mb__before_atomic_inc(void); - void smp_mb__after_atomic_inc(void); + void smp_mb__before_atomic(void); + void smp_mb__after_atomic(void); -For example, smp_mb__before_atomic_dec() can be used like so: +For example, smp_mb__before_atomic() can be used like so: obj->dead = 1; - smp_mb__before_atomic_dec(); + smp_mb__before_atomic(); atomic_dec(&obj->ref_count); It makes sure that all memory operations preceding the atomic_dec() @@ -302,15 +300,10 @@ operation. In the above example, it guarantees that the assignment of "1" to obj->dead will be globally visible to other cpus before the atomic counter decrement. -Without the explicit smp_mb__before_atomic_dec() call, the +Without the explicit smp_mb__before_atomic() call, the implementation could legally allow the atomic counter update visible to other cpus before the "obj->dead = 1;" assignment. -The other three interfaces listed are used to provide explicit -ordering with respect to memory operations after an atomic_dec() call -(smp_mb__after_atomic_dec()) and around atomic_inc() calls -(smp_mb__{before,after}_atomic_inc()). - A missing memory barrier in the cases where they are required by the atomic_t implementation above can have disastrous results. Here is an example, which follows a pattern occurring frequently in the Linux @@ -487,12 +480,12 @@ Finally there is the basic operation: Which returns a boolean indicating if bit "nr" is set in the bitmask pointed to by "addr". -If explicit memory barriers are required around clear_bit() (which -does not return a value, and thus does not need to provide memory -barrier semantics), two interfaces are provided: +If explicit memory barriers are required around {set,clear}_bit() (which do +not return a value, and thus does not need to provide memory barrier +semantics), two interfaces are provided: - void smp_mb__before_clear_bit(void); - void smp_mb__after_clear_bit(void); + void smp_mb__before_atomic(void); + void smp_mb__after_atomic(void); They are used as follows, and are akin to their atomic_t operation brothers: @@ -500,13 +493,13 @@ brothers: /* All memory operations before this call will * be globally visible before the clear_bit(). */ - smp_mb__before_clear_bit(); + smp_mb__before_atomic(); clear_bit( ... ); /* The clear_bit() will be visible before all * subsequent memory operations. */ - smp_mb__after_clear_bit(); + smp_mb__after_atomic(); There are two special bitops with lock barrier semantics (acquire/release, same as spinlocks). These operate in the same way as their non-_lock/unlock diff --git a/Documentation/memory-barriers.txt b/Documentation/memory-barriers.txt index 556f951f8626..46412bded104 100644 --- a/Documentation/memory-barriers.txt +++ b/Documentation/memory-barriers.txt @@ -1583,20 +1583,21 @@ There are some more advanced barrier functions: insert anything more than a compiler barrier in a UP compilation. - (*) smp_mb__before_atomic_dec(); - (*) smp_mb__after_atomic_dec(); - (*) smp_mb__before_atomic_inc(); - (*) smp_mb__after_atomic_inc(); + (*) smp_mb__before_atomic(); + (*) smp_mb__after_atomic(); - These are for use with atomic add, subtract, increment and decrement - functions that don't return a value, especially when used for reference - counting. These functions do not imply memory barriers. + These are for use with atomic (such as add, subtract, increment and + decrement) functions that don't return a value, especially when used for + reference counting. These functions do not imply memory barriers. + + These are also used for atomic bitop functions that do not return a + value (such as set_bit and clear_bit). As an example, consider a piece of code that marks an object as being dead and then decrements the object's reference count: obj->dead = 1; - smp_mb__before_atomic_dec(); + smp_mb__before_atomic(); atomic_dec(&obj->ref_count); This makes sure that the death mark on the object is perceived to be set @@ -1606,27 +1607,6 @@ There are some more advanced barrier functions: operations" subsection for information on where to use these. - (*) smp_mb__before_clear_bit(void); - (*) smp_mb__after_clear_bit(void); - - These are for use similar to the atomic inc/dec barriers. These are - typically used for bitwise unlocking operations, so care must be taken as - there are no implicit memory barriers here either. - - Consider implementing an unlock operation of some nature by clearing a - locking bit. The clear_bit() would then need to be barriered like this: - - smp_mb__before_clear_bit(); - clear_bit( ... ); - - This prevents memory operations before the clear leaking to after it. See - the subsection on "Locking Functions" with reference to RELEASE operation - implications. - - See Documentation/atomic_ops.txt for more information. See the "Atomic - operations" subsection for information on where to use these. - - MMIO WRITE BARRIER ------------------ @@ -2283,11 +2263,11 @@ operations: change_bit(); With these the appropriate explicit memory barrier should be used if necessary -(smp_mb__before_clear_bit() for instance). +(smp_mb__before_atomic() for instance). The following also do _not_ imply memory barriers, and so may require explicit -memory barriers under some circumstances (smp_mb__before_atomic_dec() for +memory barriers under some circumstances (smp_mb__before_atomic() for instance): atomic_add(); -- cgit v1.2.3 From 4e857c58efeb99393cba5a5d0d8ec7117183137c Mon Sep 17 00:00:00 2001 From: Peter Zijlstra Date: Mon, 17 Mar 2014 18:06:10 +0100 Subject: arch: Mass conversion of smp_mb__*() Mostly scripted conversion of the smp_mb__* barriers. Signed-off-by: Peter Zijlstra Acked-by: Paul E. McKenney Link: http://lkml.kernel.org/n/tip-55dhyhocezdw1dg7u19hmh1u@git.kernel.org Cc: Linus Torvalds Cc: linux-arch@vger.kernel.org Signed-off-by: Ingo Molnar --- block/blk-iopoll.c | 4 +- crypto/chainiv.c | 2 +- drivers/base/power/domain.c | 2 +- drivers/block/mtip32xx/mtip32xx.c | 4 +- drivers/cpuidle/coupled.c | 2 +- drivers/firewire/ohci.c | 2 +- drivers/gpu/drm/drm_irq.c | 10 ++-- drivers/gpu/drm/i915/i915_irq.c | 2 +- drivers/md/bcache/bcache.h | 2 +- drivers/md/bcache/closure.h | 2 +- drivers/md/dm-bufio.c | 8 ++-- drivers/md/dm-snap.c | 4 +- drivers/md/dm.c | 2 +- drivers/md/raid5.c | 2 +- drivers/media/usb/dvb-usb-v2/dvb_usb_core.c | 6 +-- drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c | 6 +-- drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c | 18 ++++---- drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c | 26 +++++------ drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c | 8 ++-- drivers/net/ethernet/broadcom/cnic.c | 8 ++-- drivers/net/ethernet/brocade/bna/bnad.c | 6 +-- drivers/net/ethernet/chelsio/cxgb/cxgb2.c | 2 +- drivers/net/ethernet/chelsio/cxgb3/sge.c | 6 +-- drivers/net/ethernet/chelsio/cxgb4/sge.c | 2 +- drivers/net/ethernet/chelsio/cxgb4vf/sge.c | 2 +- drivers/net/ethernet/freescale/gianfar.c | 8 ++-- drivers/net/ethernet/intel/i40e/i40e_main.c | 2 +- drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 8 ++-- drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c | 6 +-- drivers/net/wireless/ti/wlcore/main.c | 2 +- drivers/pci/xen-pcifront.c | 4 +- drivers/scsi/isci/remote_device.c | 2 +- drivers/target/loopback/tcm_loop.c | 4 +- drivers/target/target_core_alua.c | 26 +++++------ drivers/target/target_core_device.c | 6 +-- drivers/target/target_core_iblock.c | 2 +- drivers/target/target_core_pr.c | 56 +++++++++++------------ drivers/target/target_core_transport.c | 16 +++---- drivers/target/target_core_ua.c | 10 ++-- drivers/tty/n_tty.c | 2 +- drivers/tty/serial/mxs-auart.c | 4 +- drivers/usb/gadget/tcm_usb_gadget.c | 4 +- drivers/usb/serial/usb_wwan.c | 2 +- drivers/vhost/scsi.c | 2 +- drivers/w1/w1_family.c | 4 +- drivers/xen/xen-pciback/pciback_ops.c | 4 +- fs/btrfs/btrfs_inode.h | 2 +- fs/btrfs/extent_io.c | 2 +- fs/btrfs/inode.c | 6 +-- fs/btrfs/ioctl.c | 2 +- fs/buffer.c | 2 +- fs/ext4/resize.c | 2 +- fs/gfs2/glock.c | 8 ++-- fs/gfs2/glops.c | 2 +- fs/gfs2/lock_dlm.c | 4 +- fs/gfs2/recovery.c | 2 +- fs/gfs2/sys.c | 4 +- fs/jbd2/commit.c | 6 +-- fs/nfs/dir.c | 12 ++--- fs/nfs/inode.c | 2 +- fs/nfs/nfs4filelayoutdev.c | 4 +- fs/nfs/nfs4state.c | 4 +- fs/nfs/pagelist.c | 6 +-- fs/nfs/pnfs.c | 2 +- fs/nfs/pnfs.h | 2 +- fs/nfs/write.c | 4 +- fs/ubifs/lpt_commit.c | 4 +- fs/ubifs/tnc_commit.c | 4 +- include/asm-generic/bitops/atomic.h | 2 +- include/asm-generic/bitops/lock.h | 2 +- include/linux/buffer_head.h | 2 +- include/linux/genhd.h | 2 +- include/linux/interrupt.h | 8 ++-- include/linux/netdevice.h | 2 +- include/linux/sched.h | 6 +-- include/linux/sunrpc/sched.h | 8 ++-- include/linux/sunrpc/xprt.h | 8 ++-- include/linux/tracehook.h | 2 +- include/net/ip_vs.h | 4 +- kernel/debug/debug_core.c | 4 +- kernel/futex.c | 4 +- kernel/kmod.c | 2 +- kernel/rcu/tree.c | 22 ++++----- kernel/rcu/tree_plugin.h | 8 ++-- kernel/sched/cpupri.c | 6 +-- kernel/sched/wait.c | 2 +- mm/backing-dev.c | 2 +- mm/filemap.c | 4 +- net/atm/pppoatm.c | 2 +- net/bluetooth/hci_event.c | 4 +- net/core/dev.c | 8 ++-- net/core/link_watch.c | 2 +- net/ipv4/inetpeer.c | 2 +- net/ipv4/tcp_output.c | 4 +- net/netfilter/nf_conntrack_core.c | 2 +- net/rds/ib_recv.c | 4 +- net/rds/iw_recv.c | 4 +- net/rds/send.c | 6 +-- net/rds/tcp_send.c | 2 +- net/sunrpc/auth.c | 2 +- net/sunrpc/auth_gss/auth_gss.c | 2 +- net/sunrpc/backchannel_rqst.c | 4 +- net/sunrpc/xprt.c | 4 +- net/sunrpc/xprtsock.c | 16 +++---- net/unix/af_unix.c | 2 +- sound/pci/bt87x.c | 4 +- 106 files changed, 284 insertions(+), 288 deletions(-) diff --git a/block/blk-iopoll.c b/block/blk-iopoll.c index c11d24e379e2..f8c6a11b13f0 100644 --- a/block/blk-iopoll.c +++ b/block/blk-iopoll.c @@ -49,7 +49,7 @@ EXPORT_SYMBOL(blk_iopoll_sched); void __blk_iopoll_complete(struct blk_iopoll *iop) { list_del(&iop->list); - smp_mb__before_clear_bit(); + smp_mb__before_atomic(); clear_bit_unlock(IOPOLL_F_SCHED, &iop->state); } EXPORT_SYMBOL(__blk_iopoll_complete); @@ -161,7 +161,7 @@ EXPORT_SYMBOL(blk_iopoll_disable); void blk_iopoll_enable(struct blk_iopoll *iop) { BUG_ON(!test_bit(IOPOLL_F_SCHED, &iop->state)); - smp_mb__before_clear_bit(); + smp_mb__before_atomic(); clear_bit_unlock(IOPOLL_F_SCHED, &iop->state); } EXPORT_SYMBOL(blk_iopoll_enable); diff --git a/crypto/chainiv.c b/crypto/chainiv.c index 834d8dd3d4fc..9c294c8f9a07 100644 --- a/crypto/chainiv.c +++ b/crypto/chainiv.c @@ -126,7 +126,7 @@ static int async_chainiv_schedule_work(struct async_chainiv_ctx *ctx) int err = ctx->err; if (!ctx->queue.qlen) { - smp_mb__before_clear_bit(); + smp_mb__before_atomic(); clear_bit(CHAINIV_STATE_INUSE, &ctx->state); if (!ctx->queue.qlen || diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index ae098a261fcd..eee55c1e5fde 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -105,7 +105,7 @@ static bool genpd_sd_counter_dec(struct generic_pm_domain *genpd) static void genpd_sd_counter_inc(struct generic_pm_domain *genpd) { atomic_inc(&genpd->sd_count); - smp_mb__after_atomic_inc(); + smp_mb__after_atomic(); } static void genpd_acquire_lock(struct generic_pm_domain *genpd) diff --git a/drivers/block/mtip32xx/mtip32xx.c b/drivers/block/mtip32xx/mtip32xx.c index 59c5abe32f06..4fd8d6c1c3d2 100644 --- a/drivers/block/mtip32xx/mtip32xx.c +++ b/drivers/block/mtip32xx/mtip32xx.c @@ -224,9 +224,9 @@ static int get_slot(struct mtip_port *port) */ static inline void release_slot(struct mtip_port *port, int tag) { - smp_mb__before_clear_bit(); + smp_mb__before_atomic(); clear_bit(tag, port->allocated); - smp_mb__after_clear_bit(); + smp_mb__after_atomic(); } /* diff --git a/drivers/cpuidle/coupled.c b/drivers/cpuidle/coupled.c index cb6654bfad77..73fe2f8d7f96 100644 --- a/drivers/cpuidle/coupled.c +++ b/drivers/cpuidle/coupled.c @@ -159,7 +159,7 @@ void cpuidle_coupled_parallel_barrier(struct cpuidle_device *dev, atomic_t *a) { int n = dev->coupled->online_count; - smp_mb__before_atomic_inc(); + smp_mb__before_atomic(); atomic_inc(a); while (atomic_read(a) < n) diff --git a/drivers/firewire/ohci.c b/drivers/firewire/ohci.c index 8db663219560..995dd42a2627 100644 --- a/drivers/firewire/ohci.c +++ b/drivers/firewire/ohci.c @@ -3498,7 +3498,7 @@ static int ohci_flush_iso_completions(struct fw_iso_context *base) } clear_bit_unlock(0, &ctx->flushing_completions); - smp_mb__after_clear_bit(); + smp_mb__after_atomic(); } tasklet_enable(&ctx->context.tasklet); diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c index c2676b5908d9..ec5c3f4cdd01 100644 --- a/drivers/gpu/drm/drm_irq.c +++ b/drivers/gpu/drm/drm_irq.c @@ -156,7 +156,7 @@ static void vblank_disable_and_save(struct drm_device *dev, int crtc) */ if ((vblrc > 0) && (abs64(diff_ns) > 1000000)) { atomic_inc(&dev->vblank[crtc].count); - smp_mb__after_atomic_inc(); + smp_mb__after_atomic(); } /* Invalidate all timestamps while vblank irq's are off. */ @@ -864,9 +864,9 @@ static void drm_update_vblank_count(struct drm_device *dev, int crtc) vblanktimestamp(dev, crtc, tslot) = t_vblank; } - smp_mb__before_atomic_inc(); + smp_mb__before_atomic(); atomic_add(diff, &dev->vblank[crtc].count); - smp_mb__after_atomic_inc(); + smp_mb__after_atomic(); } /** @@ -1330,9 +1330,9 @@ bool drm_handle_vblank(struct drm_device *dev, int crtc) /* Increment cooked vblank count. This also atomically commits * the timestamp computed above. */ - smp_mb__before_atomic_inc(); + smp_mb__before_atomic(); atomic_inc(&dev->vblank[crtc].count); - smp_mb__after_atomic_inc(); + smp_mb__after_atomic(); } else { DRM_DEBUG("crtc %d: Redundant vblirq ignored. diff_ns = %d\n", crtc, (int) diff_ns); diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c index 7753249b3a95..5409bfafff63 100644 --- a/drivers/gpu/drm/i915/i915_irq.c +++ b/drivers/gpu/drm/i915/i915_irq.c @@ -2147,7 +2147,7 @@ static void i915_error_work_func(struct work_struct *work) * updates before * the counter increment. */ - smp_mb__before_atomic_inc(); + smp_mb__before_atomic(); atomic_inc(&dev_priv->gpu_error.reset_counter); kobject_uevent_env(&dev->primary->kdev->kobj, diff --git a/drivers/md/bcache/bcache.h b/drivers/md/bcache/bcache.h index 82c9c5d35251..d2ebcf323094 100644 --- a/drivers/md/bcache/bcache.h +++ b/drivers/md/bcache/bcache.h @@ -828,7 +828,7 @@ static inline bool cached_dev_get(struct cached_dev *dc) return false; /* Paired with the mb in cached_dev_attach */ - smp_mb__after_atomic_inc(); + smp_mb__after_atomic(); return true; } diff --git a/drivers/md/bcache/closure.h b/drivers/md/bcache/closure.h index 7ef7461912be..a08e3eeac3c5 100644 --- a/drivers/md/bcache/closure.h +++ b/drivers/md/bcache/closure.h @@ -243,7 +243,7 @@ static inline void set_closure_fn(struct closure *cl, closure_fn *fn, cl->fn = fn; cl->wq = wq; /* between atomic_dec() in closure_put() */ - smp_mb__before_atomic_dec(); + smp_mb__before_atomic(); } static inline void closure_queue(struct closure *cl) diff --git a/drivers/md/dm-bufio.c b/drivers/md/dm-bufio.c index 66c5d130c8c2..4e84095833db 100644 --- a/drivers/md/dm-bufio.c +++ b/drivers/md/dm-bufio.c @@ -607,9 +607,9 @@ static void write_endio(struct bio *bio, int error) BUG_ON(!test_bit(B_WRITING, &b->state)); - smp_mb__before_clear_bit(); + smp_mb__before_atomic(); clear_bit(B_WRITING, &b->state); - smp_mb__after_clear_bit(); + smp_mb__after_atomic(); wake_up_bit(&b->state, B_WRITING); } @@ -997,9 +997,9 @@ static void read_endio(struct bio *bio, int error) BUG_ON(!test_bit(B_READING, &b->state)); - smp_mb__before_clear_bit(); + smp_mb__before_atomic(); clear_bit(B_READING, &b->state); - smp_mb__after_clear_bit(); + smp_mb__after_atomic(); wake_up_bit(&b->state, B_READING); } diff --git a/drivers/md/dm-snap.c b/drivers/md/dm-snap.c index ebddef5237e4..8e0caed0bf74 100644 --- a/drivers/md/dm-snap.c +++ b/drivers/md/dm-snap.c @@ -642,7 +642,7 @@ static void free_pending_exception(struct dm_snap_pending_exception *pe) struct dm_snapshot *s = pe->snap; mempool_free(pe, s->pending_pool); - smp_mb__before_atomic_dec(); + smp_mb__before_atomic(); atomic_dec(&s->pending_exceptions_count); } @@ -783,7 +783,7 @@ static int init_hash_tables(struct dm_snapshot *s) static void merge_shutdown(struct dm_snapshot *s) { clear_bit_unlock(RUNNING_MERGE, &s->state_bits); - smp_mb__after_clear_bit(); + smp_mb__after_atomic(); wake_up_bit(&s->state_bits, RUNNING_MERGE); } diff --git a/drivers/md/dm.c b/drivers/md/dm.c index 455e64916498..2db768e4553f 100644 --- a/drivers/md/dm.c +++ b/drivers/md/dm.c @@ -2447,7 +2447,7 @@ static void dm_wq_work(struct work_struct *work) static void dm_queue_flush(struct mapped_device *md) { clear_bit(DMF_BLOCK_IO_FOR_SUSPEND, &md->flags); - smp_mb__after_clear_bit(); + smp_mb__after_atomic(); queue_work(md->wq, &md->work); } diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c index ad1b9bea446e..2afef4ec9312 100644 --- a/drivers/md/raid5.c +++ b/drivers/md/raid5.c @@ -4400,7 +4400,7 @@ static void raid5_unplug(struct blk_plug_cb *blk_cb, bool from_schedule) * STRIPE_ON_UNPLUG_LIST clear but the stripe * is still in our list */ - smp_mb__before_clear_bit(); + smp_mb__before_atomic(); clear_bit(STRIPE_ON_UNPLUG_LIST, &sh->state); /* * STRIPE_ON_RELEASE_LIST could be set here. In that diff --git a/drivers/media/usb/dvb-usb-v2/dvb_usb_core.c b/drivers/media/usb/dvb-usb-v2/dvb_usb_core.c index de02db802ace..e35580618936 100644 --- a/drivers/media/usb/dvb-usb-v2/dvb_usb_core.c +++ b/drivers/media/usb/dvb-usb-v2/dvb_usb_core.c @@ -399,7 +399,7 @@ static int dvb_usb_stop_feed(struct dvb_demux_feed *dvbdmxfeed) /* clear 'streaming' status bit */ clear_bit(ADAP_STREAMING, &adap->state_bits); - smp_mb__after_clear_bit(); + smp_mb__after_atomic(); wake_up_bit(&adap->state_bits, ADAP_STREAMING); skip_feed_stop: @@ -550,7 +550,7 @@ static int dvb_usb_fe_init(struct dvb_frontend *fe) err: if (!adap->suspend_resume_active) { clear_bit(ADAP_INIT, &adap->state_bits); - smp_mb__after_clear_bit(); + smp_mb__after_atomic(); wake_up_bit(&adap->state_bits, ADAP_INIT); } @@ -591,7 +591,7 @@ err: if (!adap->suspend_resume_active) { adap->active_fe = -1; clear_bit(ADAP_SLEEP, &adap->state_bits); - smp_mb__after_clear_bit(); + smp_mb__after_atomic(); wake_up_bit(&adap->state_bits, ADAP_SLEEP); } diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c index 9261d5313b5b..dd57c7c5a3da 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c @@ -2781,7 +2781,7 @@ int bnx2x_nic_load(struct bnx2x *bp, int load_mode) case LOAD_OPEN: netif_tx_start_all_queues(bp->dev); - smp_mb__after_clear_bit(); + smp_mb__after_atomic(); break; case LOAD_DIAG: @@ -4939,9 +4939,9 @@ void bnx2x_update_coalesce_sb_index(struct bnx2x *bp, u8 fw_sb_id, void bnx2x_schedule_sp_rtnl(struct bnx2x *bp, enum sp_rtnl_flag flag, u32 verbose) { - smp_mb__before_clear_bit(); + smp_mb__before_atomic(); set_bit(flag, &bp->sp_rtnl_state); - smp_mb__after_clear_bit(); + smp_mb__after_atomic(); DP((BNX2X_MSG_SP | verbose), "Scheduling sp_rtnl task [Flag: %d]\n", flag); schedule_delayed_work(&bp->sp_rtnl_task, 0); diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c index a78edaccceee..16391db2e8c9 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c @@ -1858,10 +1858,10 @@ void bnx2x_sp_event(struct bnx2x_fastpath *fp, union eth_rx_cqe *rr_cqe) return; #endif - smp_mb__before_atomic_inc(); + smp_mb__before_atomic(); atomic_inc(&bp->cq_spq_left); /* push the change in bp->spq_left and towards the memory */ - smp_mb__after_atomic_inc(); + smp_mb__after_atomic(); DP(BNX2X_MSG_SP, "bp->cq_spq_left %x\n", atomic_read(&bp->cq_spq_left)); @@ -1876,11 +1876,11 @@ void bnx2x_sp_event(struct bnx2x_fastpath *fp, union eth_rx_cqe *rr_cqe) * sp_state is cleared, and this order prevents * races */ - smp_mb__before_clear_bit(); + smp_mb__before_atomic(); set_bit(BNX2X_AFEX_PENDING_VIFSET_MCP_ACK, &bp->sp_state); wmb(); clear_bit(BNX2X_AFEX_FCOE_Q_UPDATE_PENDING, &bp->sp_state); - smp_mb__after_clear_bit(); + smp_mb__after_atomic(); /* schedule the sp task as mcp ack is required */ bnx2x_schedule_sp_task(bp); @@ -5272,9 +5272,9 @@ static void bnx2x_after_function_update(struct bnx2x *bp) __clear_bit(RAMROD_COMP_WAIT, &queue_params.ramrod_flags); /* mark latest Q bit */ - smp_mb__before_clear_bit(); + smp_mb__before_atomic(); set_bit(BNX2X_AFEX_FCOE_Q_UPDATE_PENDING, &bp->sp_state); - smp_mb__after_clear_bit(); + smp_mb__after_atomic(); /* send Q update ramrod for FCoE Q */ rc = bnx2x_queue_state_change(bp, &queue_params); @@ -5500,7 +5500,7 @@ next_spqe: spqe_cnt++; } /* for */ - smp_mb__before_atomic_inc(); + smp_mb__before_atomic(); atomic_add(spqe_cnt, &bp->eq_spq_left); bp->eq_cons = sw_cons; @@ -13869,9 +13869,9 @@ static int bnx2x_drv_ctl(struct net_device *dev, struct drv_ctl_info *ctl) case DRV_CTL_RET_L2_SPQ_CREDIT_CMD: { int count = ctl->data.credit.credit_count; - smp_mb__before_atomic_inc(); + smp_mb__before_atomic(); atomic_add(count, &bp->cq_spq_left); - smp_mb__after_atomic_inc(); + smp_mb__after_atomic(); break; } case DRV_CTL_ULP_REGISTER_CMD: { diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c index 31297266b743..d725317c4277 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c @@ -258,16 +258,16 @@ static bool bnx2x_raw_check_pending(struct bnx2x_raw_obj *o) static void bnx2x_raw_clear_pending(struct bnx2x_raw_obj *o) { - smp_mb__before_clear_bit(); + smp_mb__before_atomic(); clear_bit(o->state, o->pstate); - smp_mb__after_clear_bit(); + smp_mb__after_atomic(); } static void bnx2x_raw_set_pending(struct bnx2x_raw_obj *o) { - smp_mb__before_clear_bit(); + smp_mb__before_atomic(); set_bit(o->state, o->pstate); - smp_mb__after_clear_bit(); + smp_mb__after_atomic(); } /** @@ -2131,7 +2131,7 @@ static int bnx2x_set_rx_mode_e1x(struct bnx2x *bp, /* The operation is completed */ clear_bit(p->state, p->pstate); - smp_mb__after_clear_bit(); + smp_mb__after_atomic(); return 0; } @@ -3576,16 +3576,16 @@ error_exit1: static void bnx2x_mcast_clear_sched(struct bnx2x_mcast_obj *o) { - smp_mb__before_clear_bit(); + smp_mb__before_atomic(); clear_bit(o->sched_state, o->raw.pstate); - smp_mb__after_clear_bit(); + smp_mb__after_atomic(); } static void bnx2x_mcast_set_sched(struct bnx2x_mcast_obj *o) { - smp_mb__before_clear_bit(); + smp_mb__before_atomic(); set_bit(o->sched_state, o->raw.pstate); - smp_mb__after_clear_bit(); + smp_mb__after_atomic(); } static bool bnx2x_mcast_check_sched(struct bnx2x_mcast_obj *o) @@ -4200,7 +4200,7 @@ int bnx2x_queue_state_change(struct bnx2x *bp, if (rc) { o->next_state = BNX2X_Q_STATE_MAX; clear_bit(pending_bit, pending); - smp_mb__after_clear_bit(); + smp_mb__after_atomic(); return rc; } @@ -4288,7 +4288,7 @@ static int bnx2x_queue_comp_cmd(struct bnx2x *bp, wmb(); clear_bit(cmd, &o->pending); - smp_mb__after_clear_bit(); + smp_mb__after_atomic(); return 0; } @@ -5279,7 +5279,7 @@ static inline int bnx2x_func_state_change_comp(struct bnx2x *bp, wmb(); clear_bit(cmd, &o->pending); - smp_mb__after_clear_bit(); + smp_mb__after_atomic(); return 0; } @@ -5926,7 +5926,7 @@ int bnx2x_func_state_change(struct bnx2x *bp, if (rc) { o->next_state = BNX2X_F_STATE_MAX; clear_bit(cmd, pending); - smp_mb__after_clear_bit(); + smp_mb__after_atomic(); return rc; } diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c index 5c523b32db70..f82ac5ac2336 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c @@ -1626,9 +1626,9 @@ static void bnx2x_vf_handle_filters_eqe(struct bnx2x *bp, struct bnx2x_virtf *vf) { - smp_mb__before_clear_bit(); + smp_mb__before_atomic(); clear_bit(BNX2X_FILTER_RX_MODE_PENDING, &vf->filter_state); - smp_mb__after_clear_bit(); + smp_mb__after_atomic(); } static void bnx2x_vf_handle_rss_update_eqe(struct bnx2x *bp, @@ -2960,9 +2960,9 @@ void bnx2x_iov_task(struct work_struct *work) void bnx2x_schedule_iov_task(struct bnx2x *bp, enum bnx2x_iov_flag flag) { - smp_mb__before_clear_bit(); + smp_mb__before_atomic(); set_bit(flag, &bp->iov_task_state); - smp_mb__after_clear_bit(); + smp_mb__after_atomic(); DP(BNX2X_MSG_IOV, "Scheduling iov task [Flag: %d]\n", flag); queue_delayed_work(bnx2x_iov_wq, &bp->iov_task, 0); } diff --git a/drivers/net/ethernet/broadcom/cnic.c b/drivers/net/ethernet/broadcom/cnic.c index 09f3fefcbf9c..4dd48d2fa804 100644 --- a/drivers/net/ethernet/broadcom/cnic.c +++ b/drivers/net/ethernet/broadcom/cnic.c @@ -436,7 +436,7 @@ static int cnic_offld_prep(struct cnic_sock *csk) static int cnic_close_prep(struct cnic_sock *csk) { clear_bit(SK_F_CONNECT_START, &csk->flags); - smp_mb__after_clear_bit(); + smp_mb__after_atomic(); if (test_and_clear_bit(SK_F_OFFLD_COMPLETE, &csk->flags)) { while (test_and_set_bit(SK_F_OFFLD_SCHED, &csk->flags)) @@ -450,7 +450,7 @@ static int cnic_close_prep(struct cnic_sock *csk) static int cnic_abort_prep(struct cnic_sock *csk) { clear_bit(SK_F_CONNECT_START, &csk->flags); - smp_mb__after_clear_bit(); + smp_mb__after_atomic(); while (test_and_set_bit(SK_F_OFFLD_SCHED, &csk->flags)) msleep(1); @@ -3646,7 +3646,7 @@ static int cnic_cm_destroy(struct cnic_sock *csk) csk_hold(csk); clear_bit(SK_F_INUSE, &csk->flags); - smp_mb__after_clear_bit(); + smp_mb__after_atomic(); while (atomic_read(&csk->ref_count) != 1) msleep(1); cnic_cm_cleanup(csk); @@ -4026,7 +4026,7 @@ static void cnic_cm_process_kcqe(struct cnic_dev *dev, struct kcqe *kcqe) L4_KCQE_COMPLETION_STATUS_PARITY_ERROR) set_bit(SK_F_HW_ERR, &csk->flags); - smp_mb__before_clear_bit(); + smp_mb__before_atomic(); clear_bit(SK_F_OFFLD_SCHED, &csk->flags); cnic_cm_upcall(cp, csk, opcode); break; diff --git a/drivers/net/ethernet/brocade/bna/bnad.c b/drivers/net/ethernet/brocade/bna/bnad.c index 675550fe8ee9..3a77f9ead004 100644 --- a/drivers/net/ethernet/brocade/bna/bnad.c +++ b/drivers/net/ethernet/brocade/bna/bnad.c @@ -249,7 +249,7 @@ bnad_tx_complete(struct bnad *bnad, struct bna_tcb *tcb) if (likely(test_bit(BNAD_TXQ_TX_STARTED, &tcb->flags))) bna_ib_ack(tcb->i_dbell, sent); - smp_mb__before_clear_bit(); + smp_mb__before_atomic(); clear_bit(BNAD_TXQ_FREE_SENT, &tcb->flags); return sent; @@ -1126,7 +1126,7 @@ bnad_tx_cleanup(struct delayed_work *work) bnad_txq_cleanup(bnad, tcb); - smp_mb__before_clear_bit(); + smp_mb__before_atomic(); clear_bit(BNAD_TXQ_FREE_SENT, &tcb->flags); } @@ -2992,7 +2992,7 @@ bnad_start_xmit(struct sk_buff *skb, struct net_device *netdev) sent = bnad_txcmpl_process(bnad, tcb); if (likely(test_bit(BNAD_TXQ_TX_STARTED, &tcb->flags))) bna_ib_ack(tcb->i_dbell, sent); - smp_mb__before_clear_bit(); + smp_mb__before_atomic(); clear_bit(BNAD_TXQ_FREE_SENT, &tcb->flags); } else { netif_stop_queue(netdev); diff --git a/drivers/net/ethernet/chelsio/cxgb/cxgb2.c b/drivers/net/ethernet/chelsio/cxgb/cxgb2.c index 0fe7ff750d77..05613a85ce61 100644 --- a/drivers/net/ethernet/chelsio/cxgb/cxgb2.c +++ b/drivers/net/ethernet/chelsio/cxgb/cxgb2.c @@ -281,7 +281,7 @@ static int cxgb_close(struct net_device *dev) if (adapter->params.stats_update_period && !(adapter->open_device_map & PORT_MASK)) { /* Stop statistics accumulation. */ - smp_mb__after_clear_bit(); + smp_mb__after_atomic(); spin_lock(&adapter->work_lock); /* sync with update task */ spin_unlock(&adapter->work_lock); cancel_mac_stats_update(adapter); diff --git a/drivers/net/ethernet/chelsio/cxgb3/sge.c b/drivers/net/ethernet/chelsio/cxgb3/sge.c index 8b069f96e920..3dfcf600fcc6 100644 --- a/drivers/net/ethernet/chelsio/cxgb3/sge.c +++ b/drivers/net/ethernet/chelsio/cxgb3/sge.c @@ -1379,7 +1379,7 @@ static inline int check_desc_avail(struct adapter *adap, struct sge_txq *q, struct sge_qset *qs = txq_to_qset(q, qid); set_bit(qid, &qs->txq_stopped); - smp_mb__after_clear_bit(); + smp_mb__after_atomic(); if (should_restart_tx(q) && test_and_clear_bit(qid, &qs->txq_stopped)) @@ -1492,7 +1492,7 @@ static void restart_ctrlq(unsigned long data) if (!skb_queue_empty(&q->sendq)) { set_bit(TXQ_CTRL, &qs->txq_stopped); - smp_mb__after_clear_bit(); + smp_mb__after_atomic(); if (should_restart_tx(q) && test_and_clear_bit(TXQ_CTRL, &qs->txq_stopped)) @@ -1697,7 +1697,7 @@ again: reclaim_completed_tx(adap, q, TX_RECLAIM_CHUNK); if (unlikely(q->size - q->in_use < ndesc)) { set_bit(TXQ_OFLD, &qs->txq_stopped); - smp_mb__after_clear_bit(); + smp_mb__after_atomic(); if (should_restart_tx(q) && test_and_clear_bit(TXQ_OFLD, &qs->txq_stopped)) diff --git a/drivers/net/ethernet/chelsio/cxgb4/sge.c b/drivers/net/ethernet/chelsio/cxgb4/sge.c index ca95cf2954eb..e249528c8e60 100644 --- a/drivers/net/ethernet/chelsio/cxgb4/sge.c +++ b/drivers/net/ethernet/chelsio/cxgb4/sge.c @@ -2031,7 +2031,7 @@ static void sge_rx_timer_cb(unsigned long data) struct sge_fl *fl = s->egr_map[id]; clear_bit(id, s->starving_fl); - smp_mb__after_clear_bit(); + smp_mb__after_atomic(); if (fl_starving(fl)) { rxq = container_of(fl, struct sge_eth_rxq, fl); diff --git a/drivers/net/ethernet/chelsio/cxgb4vf/sge.c b/drivers/net/ethernet/chelsio/cxgb4vf/sge.c index 9cfa4b4bb089..9d88c1d50b49 100644 --- a/drivers/net/ethernet/chelsio/cxgb4vf/sge.c +++ b/drivers/net/ethernet/chelsio/cxgb4vf/sge.c @@ -1951,7 +1951,7 @@ static void sge_rx_timer_cb(unsigned long data) struct sge_fl *fl = s->egr_map[id]; clear_bit(id, s->starving_fl); - smp_mb__after_clear_bit(); + smp_mb__after_atomic(); /* * Since we are accessing fl without a lock there's a diff --git a/drivers/net/ethernet/freescale/gianfar.c b/drivers/net/ethernet/freescale/gianfar.c index 9125d9abf099..d82f092cae90 100644 --- a/drivers/net/ethernet/freescale/gianfar.c +++ b/drivers/net/ethernet/freescale/gianfar.c @@ -1797,9 +1797,9 @@ void stop_gfar(struct net_device *dev) netif_tx_stop_all_queues(dev); - smp_mb__before_clear_bit(); + smp_mb__before_atomic(); set_bit(GFAR_DOWN, &priv->state); - smp_mb__after_clear_bit(); + smp_mb__after_atomic(); disable_napi(priv); @@ -2042,9 +2042,9 @@ int startup_gfar(struct net_device *ndev) gfar_init_tx_rx_base(priv); - smp_mb__before_clear_bit(); + smp_mb__before_atomic(); clear_bit(GFAR_DOWN, &priv->state); - smp_mb__after_clear_bit(); + smp_mb__after_atomic(); /* Start Rx/Tx DMA and enable the interrupts */ gfar_start(priv); diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c b/drivers/net/ethernet/intel/i40e/i40e_main.c index 861b722c2672..1e526c072a44 100644 --- a/drivers/net/ethernet/intel/i40e/i40e_main.c +++ b/drivers/net/ethernet/intel/i40e/i40e_main.c @@ -4671,7 +4671,7 @@ static void i40e_service_event_complete(struct i40e_pf *pf) BUG_ON(!test_bit(__I40E_SERVICE_SCHED, &pf->state)); /* flush memory to make sure state is correct before next watchog */ - smp_mb__before_clear_bit(); + smp_mb__before_atomic(); clear_bit(__I40E_SERVICE_SCHED, &pf->state); } diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c index c4c526b7f99f..2fecc2626de5 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c @@ -376,7 +376,7 @@ static void ixgbe_service_event_complete(struct ixgbe_adapter *adapter) BUG_ON(!test_bit(__IXGBE_SERVICE_SCHED, &adapter->state)); /* flush memory to make sure state is correct before next watchdog */ - smp_mb__before_clear_bit(); + smp_mb__before_atomic(); clear_bit(__IXGBE_SERVICE_SCHED, &adapter->state); } @@ -4671,7 +4671,7 @@ static void ixgbe_up_complete(struct ixgbe_adapter *adapter) if (hw->mac.ops.enable_tx_laser) hw->mac.ops.enable_tx_laser(hw); - smp_mb__before_clear_bit(); + smp_mb__before_atomic(); clear_bit(__IXGBE_DOWN, &adapter->state); ixgbe_napi_enable_all(adapter); @@ -5567,7 +5567,7 @@ static int ixgbe_resume(struct pci_dev *pdev) e_dev_err("Cannot enable PCI device from suspend\n"); return err; } - smp_mb__before_clear_bit(); + smp_mb__before_atomic(); clear_bit(__IXGBE_DISABLED, &adapter->state); pci_set_master(pdev); @@ -8541,7 +8541,7 @@ static pci_ers_result_t ixgbe_io_slot_reset(struct pci_dev *pdev) e_err(probe, "Cannot re-enable PCI device after reset.\n"); result = PCI_ERS_RESULT_DISCONNECT; } else { - smp_mb__before_clear_bit(); + smp_mb__before_atomic(); clear_bit(__IXGBE_DISABLED, &adapter->state); adapter->hw.hw_addr = adapter->io_addr; pci_set_master(pdev); diff --git a/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c b/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c index d0799e8e31e4..de2793b06305 100644 --- a/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c +++ b/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c @@ -1668,7 +1668,7 @@ static void ixgbevf_up_complete(struct ixgbevf_adapter *adapter) spin_unlock_bh(&adapter->mbx_lock); - smp_mb__before_clear_bit(); + smp_mb__before_atomic(); clear_bit(__IXGBEVF_DOWN, &adapter->state); ixgbevf_napi_enable_all(adapter); @@ -3354,7 +3354,7 @@ static int ixgbevf_resume(struct pci_dev *pdev) dev_err(&pdev->dev, "Cannot enable PCI device from suspend\n"); return err; } - smp_mb__before_clear_bit(); + smp_mb__before_atomic(); clear_bit(__IXGBEVF_DISABLED, &adapter->state); pci_set_master(pdev); @@ -3712,7 +3712,7 @@ static pci_ers_result_t ixgbevf_io_slot_reset(struct pci_dev *pdev) return PCI_ERS_RESULT_DISCONNECT; } - smp_mb__before_clear_bit(); + smp_mb__before_atomic(); clear_bit(__IXGBEVF_DISABLED, &adapter->state); pci_set_master(pdev); diff --git a/drivers/net/wireless/ti/wlcore/main.c b/drivers/net/wireless/ti/wlcore/main.c index ed88d3913483..e71eae353368 100644 --- a/drivers/net/wireless/ti/wlcore/main.c +++ b/drivers/net/wireless/ti/wlcore/main.c @@ -543,7 +543,7 @@ static int wlcore_irq_locked(struct wl1271 *wl) * wl1271_ps_elp_wakeup cannot be called concurrently. */ clear_bit(WL1271_FLAG_IRQ_RUNNING, &wl->flags); - smp_mb__after_clear_bit(); + smp_mb__after_atomic(); ret = wlcore_fw_status(wl, wl->fw_status); if (ret < 0) diff --git a/drivers/pci/xen-pcifront.c b/drivers/pci/xen-pcifront.c index 179b8edc2262..53df39a22c8a 100644 --- a/drivers/pci/xen-pcifront.c +++ b/drivers/pci/xen-pcifront.c @@ -662,9 +662,9 @@ static void pcifront_do_aer(struct work_struct *data) notify_remote_via_evtchn(pdev->evtchn); /*in case of we lost an aer request in four lines time_window*/ - smp_mb__before_clear_bit(); + smp_mb__before_atomic(); clear_bit(_PDEVB_op_active, &pdev->flags); - smp_mb__after_clear_bit(); + smp_mb__after_atomic(); schedule_pcifront_aer_op(pdev); diff --git a/drivers/scsi/isci/remote_device.c b/drivers/scsi/isci/remote_device.c index 96a26f454673..cc51f38b116d 100644 --- a/drivers/scsi/isci/remote_device.c +++ b/drivers/scsi/isci/remote_device.c @@ -1541,7 +1541,7 @@ void isci_remote_device_release(struct kref *kref) clear_bit(IDEV_STOP_PENDING, &idev->flags); clear_bit(IDEV_IO_READY, &idev->flags); clear_bit(IDEV_GONE, &idev->flags); - smp_mb__before_clear_bit(); + smp_mb__before_atomic(); clear_bit(IDEV_ALLOCATED, &idev->flags); wake_up(&ihost->eventq); } diff --git a/drivers/target/loopback/tcm_loop.c b/drivers/target/loopback/tcm_loop.c index c886ad1c39fb..73ab75ddaf42 100644 --- a/drivers/target/loopback/tcm_loop.c +++ b/drivers/target/loopback/tcm_loop.c @@ -951,7 +951,7 @@ static int tcm_loop_port_link( struct tcm_loop_hba *tl_hba = tl_tpg->tl_hba; atomic_inc(&tl_tpg->tl_tpg_port_count); - smp_mb__after_atomic_inc(); + smp_mb__after_atomic(); /* * Add Linux/SCSI struct scsi_device by HCTL */ @@ -986,7 +986,7 @@ static void tcm_loop_port_unlink( scsi_device_put(sd); atomic_dec(&tl_tpg->tl_tpg_port_count); - smp_mb__after_atomic_dec(); + smp_mb__after_atomic(); pr_debug("TCM_Loop_ConfigFS: Port Unlink Successful\n"); } diff --git a/drivers/target/target_core_alua.c b/drivers/target/target_core_alua.c index fcbe6125b73e..0b79b852f4b2 100644 --- a/drivers/target/target_core_alua.c +++ b/drivers/target/target_core_alua.c @@ -393,7 +393,7 @@ target_emulate_set_target_port_groups(struct se_cmd *cmd) continue; atomic_inc(&tg_pt_gp->tg_pt_gp_ref_cnt); - smp_mb__after_atomic_inc(); + smp_mb__after_atomic(); spin_unlock(&dev->t10_alua.tg_pt_gps_lock); @@ -404,7 +404,7 @@ target_emulate_set_target_port_groups(struct se_cmd *cmd) spin_lock(&dev->t10_alua.tg_pt_gps_lock); atomic_dec(&tg_pt_gp->tg_pt_gp_ref_cnt); - smp_mb__after_atomic_dec(); + smp_mb__after_atomic(); break; } spin_unlock(&dev->t10_alua.tg_pt_gps_lock); @@ -990,7 +990,7 @@ static void core_alua_do_transition_tg_pt_work(struct work_struct *work) * TARGET PORT GROUPS command */ atomic_inc(&mem->tg_pt_gp_mem_ref_cnt); - smp_mb__after_atomic_inc(); + smp_mb__after_atomic(); spin_unlock(&tg_pt_gp->tg_pt_gp_lock); spin_lock_bh(&port->sep_alua_lock); @@ -1020,7 +1020,7 @@ static void core_alua_do_transition_tg_pt_work(struct work_struct *work) spin_lock(&tg_pt_gp->tg_pt_gp_lock); atomic_dec(&mem->tg_pt_gp_mem_ref_cnt); - smp_mb__after_atomic_dec(); + smp_mb__after_atomic(); } spin_unlock(&tg_pt_gp->tg_pt_gp_lock); /* @@ -1054,7 +1054,7 @@ static void core_alua_do_transition_tg_pt_work(struct work_struct *work) core_alua_dump_state(tg_pt_gp->tg_pt_gp_alua_pending_state)); spin_lock(&dev->t10_alua.tg_pt_gps_lock); atomic_dec(&tg_pt_gp->tg_pt_gp_ref_cnt); - smp_mb__after_atomic_dec(); + smp_mb__after_atomic(); spin_unlock(&dev->t10_alua.tg_pt_gps_lock); if (tg_pt_gp->tg_pt_gp_transition_complete) @@ -1116,7 +1116,7 @@ static int core_alua_do_transition_tg_pt( */ spin_lock(&dev->t10_alua.tg_pt_gps_lock); atomic_inc(&tg_pt_gp->tg_pt_gp_ref_cnt); - smp_mb__after_atomic_inc(); + smp_mb__after_atomic(); spin_unlock(&dev->t10_alua.tg_pt_gps_lock); if (!explicit && tg_pt_gp->tg_pt_gp_implicit_trans_secs) { @@ -1159,7 +1159,7 @@ int core_alua_do_port_transition( spin_lock(&local_lu_gp_mem->lu_gp_mem_lock); lu_gp = local_lu_gp_mem->lu_gp; atomic_inc(&lu_gp->lu_gp_ref_cnt); - smp_mb__after_atomic_inc(); + smp_mb__after_atomic(); spin_unlock(&local_lu_gp_mem->lu_gp_mem_lock); /* * For storage objects that are members of the 'default_lu_gp', @@ -1176,7 +1176,7 @@ int core_alua_do_port_transition( rc = core_alua_do_transition_tg_pt(l_tg_pt_gp, new_state, explicit); atomic_dec(&lu_gp->lu_gp_ref_cnt); - smp_mb__after_atomic_dec(); + smp_mb__after_atomic(); return rc; } /* @@ -1190,7 +1190,7 @@ int core_alua_do_port_transition( dev = lu_gp_mem->lu_gp_mem_dev; atomic_inc(&lu_gp_mem->lu_gp_mem_ref_cnt); - smp_mb__after_atomic_inc(); + smp_mb__after_atomic(); spin_unlock(&lu_gp->lu_gp_lock); spin_lock(&dev->t10_alua.tg_pt_gps_lock); @@ -1219,7 +1219,7 @@ int core_alua_do_port_transition( tg_pt_gp->tg_pt_gp_alua_nacl = NULL; } atomic_inc(&tg_pt_gp->tg_pt_gp_ref_cnt); - smp_mb__after_atomic_inc(); + smp_mb__after_atomic(); spin_unlock(&dev->t10_alua.tg_pt_gps_lock); /* * core_alua_do_transition_tg_pt() will always return @@ -1230,7 +1230,7 @@ int core_alua_do_port_transition( spin_lock(&dev->t10_alua.tg_pt_gps_lock); atomic_dec(&tg_pt_gp->tg_pt_gp_ref_cnt); - smp_mb__after_atomic_dec(); + smp_mb__after_atomic(); if (rc) break; } @@ -1238,7 +1238,7 @@ int core_alua_do_port_transition( spin_lock(&lu_gp->lu_gp_lock); atomic_dec(&lu_gp_mem->lu_gp_mem_ref_cnt); - smp_mb__after_atomic_dec(); + smp_mb__after_atomic(); } spin_unlock(&lu_gp->lu_gp_lock); @@ -1252,7 +1252,7 @@ int core_alua_do_port_transition( } atomic_dec(&lu_gp->lu_gp_ref_cnt); - smp_mb__after_atomic_dec(); + smp_mb__after_atomic(); return rc; } diff --git a/drivers/target/target_core_device.c b/drivers/target/target_core_device.c index 65001e133670..72618776ede4 100644 --- a/drivers/target/target_core_device.c +++ b/drivers/target/target_core_device.c @@ -225,7 +225,7 @@ struct se_dev_entry *core_get_se_deve_from_rtpi( continue; atomic_inc(&deve->pr_ref_count); - smp_mb__after_atomic_inc(); + smp_mb__after_atomic(); spin_unlock_irq(&nacl->device_list_lock); return deve; @@ -1392,7 +1392,7 @@ int core_dev_add_initiator_node_lun_acl( spin_lock(&lun->lun_acl_lock); list_add_tail(&lacl->lacl_list, &lun->lun_acl_list); atomic_inc(&lun->lun_acl_count); - smp_mb__after_atomic_inc(); + smp_mb__after_atomic(); spin_unlock(&lun->lun_acl_lock); pr_debug("%s_TPG[%hu]_LUN[%u->%u] - Added %s ACL for " @@ -1426,7 +1426,7 @@ int core_dev_del_initiator_node_lun_acl( spin_lock(&lun->lun_acl_lock); list_del(&lacl->lacl_list); atomic_dec(&lun->lun_acl_count); - smp_mb__after_atomic_dec(); + smp_mb__after_atomic(); spin_unlock(&lun->lun_acl_lock); core_disable_device_list_for_node(lun, NULL, lacl->mapped_lun, diff --git a/drivers/target/target_core_iblock.c b/drivers/target/target_core_iblock.c index 9e0232cca92e..7e6b857c6b3f 100644 --- a/drivers/target/target_core_iblock.c +++ b/drivers/target/target_core_iblock.c @@ -323,7 +323,7 @@ static void iblock_bio_done(struct bio *bio, int err) * Bump the ib_bio_err_cnt and release bio. */ atomic_inc(&ibr->ib_bio_err_cnt); - smp_mb__after_atomic_inc(); + smp_mb__after_atomic(); } bio_put(bio); diff --git a/drivers/target/target_core_pr.c b/drivers/target/target_core_pr.c index 3013287a2aaa..df357862286e 100644 --- a/drivers/target/target_core_pr.c +++ b/drivers/target/target_core_pr.c @@ -675,7 +675,7 @@ static struct t10_pr_registration *__core_scsi3_alloc_registration( spin_lock(&dev->se_port_lock); list_for_each_entry_safe(port, port_tmp, &dev->dev_sep_list, sep_list) { atomic_inc(&port->sep_tg_pt_ref_cnt); - smp_mb__after_atomic_inc(); + smp_mb__after_atomic(); spin_unlock(&dev->se_port_lock); spin_lock_bh(&port->sep_alua_lock); @@ -710,7 +710,7 @@ static struct t10_pr_registration *__core_scsi3_alloc_registration( continue; atomic_inc(&deve_tmp->pr_ref_count); - smp_mb__after_atomic_inc(); + smp_mb__after_atomic(); spin_unlock_bh(&port->sep_alua_lock); /* * Grab a configfs group dependency that is released @@ -723,9 +723,9 @@ static struct t10_pr_registration *__core_scsi3_alloc_registration( pr_err("core_scsi3_lunacl_depend" "_item() failed\n"); atomic_dec(&port->sep_tg_pt_ref_cnt); - smp_mb__after_atomic_dec(); + smp_mb__after_atomic(); atomic_dec(&deve_tmp->pr_ref_count); - smp_mb__after_atomic_dec(); + smp_mb__after_atomic(); goto out; } /* @@ -740,9 +740,9 @@ static struct t10_pr_registration *__core_scsi3_alloc_registration( sa_res_key, all_tg_pt, aptpl); if (!pr_reg_atp) { atomic_dec(&port->sep_tg_pt_ref_cnt); - smp_mb__after_atomic_dec(); + smp_mb__after_atomic(); atomic_dec(&deve_tmp->pr_ref_count); - smp_mb__after_atomic_dec(); + smp_mb__after_atomic(); core_scsi3_lunacl_undepend_item(deve_tmp); goto out; } @@ -755,7 +755,7 @@ static struct t10_pr_registration *__core_scsi3_alloc_registration( spin_lock(&dev->se_port_lock); atomic_dec(&port->sep_tg_pt_ref_cnt); - smp_mb__after_atomic_dec(); + smp_mb__after_atomic(); } spin_unlock(&dev->se_port_lock); @@ -1110,7 +1110,7 @@ static struct t10_pr_registration *__core_scsi3_locate_pr_reg( continue; } atomic_inc(&pr_reg->pr_res_holders); - smp_mb__after_atomic_inc(); + smp_mb__after_atomic(); spin_unlock(&pr_tmpl->registration_lock); return pr_reg; } @@ -1125,7 +1125,7 @@ static struct t10_pr_registration *__core_scsi3_locate_pr_reg( continue; atomic_inc(&pr_reg->pr_res_holders); - smp_mb__after_atomic_inc(); + smp_mb__after_atomic(); spin_unlock(&pr_tmpl->registration_lock); return pr_reg; } @@ -1155,7 +1155,7 @@ static struct t10_pr_registration *core_scsi3_locate_pr_reg( static void core_scsi3_put_pr_reg(struct t10_pr_registration *pr_reg) { atomic_dec(&pr_reg->pr_res_holders); - smp_mb__after_atomic_dec(); + smp_mb__after_atomic(); } static int core_scsi3_check_implicit_release( @@ -1349,7 +1349,7 @@ static void core_scsi3_tpg_undepend_item(struct se_portal_group *tpg) &tpg->tpg_group.cg_item); atomic_dec(&tpg->tpg_pr_ref_count); - smp_mb__after_atomic_dec(); + smp_mb__after_atomic(); } static int core_scsi3_nodeacl_depend_item(struct se_node_acl *nacl) @@ -1369,7 +1369,7 @@ static void core_scsi3_nodeacl_undepend_item(struct se_node_acl *nacl) if (nacl->dynamic_node_acl) { atomic_dec(&nacl->acl_pr_ref_count); - smp_mb__after_atomic_dec(); + smp_mb__after_atomic(); return; } @@ -1377,7 +1377,7 @@ static void core_scsi3_nodeacl_undepend_item(struct se_node_acl *nacl) &nacl->acl_group.cg_item); atomic_dec(&nacl->acl_pr_ref_count); - smp_mb__after_atomic_dec(); + smp_mb__after_atomic(); } static int core_scsi3_lunacl_depend_item(struct se_dev_entry *se_deve) @@ -1408,7 +1408,7 @@ static void core_scsi3_lunacl_undepend_item(struct se_dev_entry *se_deve) */ if (!lun_acl) { atomic_dec(&se_deve->pr_ref_count); - smp_mb__after_atomic_dec(); + smp_mb__after_atomic(); return; } nacl = lun_acl->se_lun_nacl; @@ -1418,7 +1418,7 @@ static void core_scsi3_lunacl_undepend_item(struct se_dev_entry *se_deve) &lun_acl->se_lun_group.cg_item); atomic_dec(&se_deve->pr_ref_count); - smp_mb__after_atomic_dec(); + smp_mb__after_atomic(); } static sense_reason_t @@ -1552,14 +1552,14 @@ core_scsi3_decode_spec_i_port( continue; atomic_inc(&tmp_tpg->tpg_pr_ref_count); - smp_mb__after_atomic_inc(); + smp_mb__after_atomic(); spin_unlock(&dev->se_port_lock); if (core_scsi3_tpg_depend_item(tmp_tpg)) { pr_err(" core_scsi3_tpg_depend_item()" " for tmp_tpg\n"); atomic_dec(&tmp_tpg->tpg_pr_ref_count); - smp_mb__after_atomic_dec(); + smp_mb__after_atomic(); ret = TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE; goto out_unmap; } @@ -1573,7 +1573,7 @@ core_scsi3_decode_spec_i_port( tmp_tpg, i_str); if (dest_node_acl) { atomic_inc(&dest_node_acl->acl_pr_ref_count); - smp_mb__after_atomic_inc(); + smp_mb__after_atomic(); } spin_unlock_irq(&tmp_tpg->acl_node_lock); @@ -1587,7 +1587,7 @@ core_scsi3_decode_spec_i_port( pr_err("configfs_depend_item() failed" " for dest_node_acl->acl_group\n"); atomic_dec(&dest_node_acl->acl_pr_ref_count); - smp_mb__after_atomic_dec(); + smp_mb__after_atomic(); core_scsi3_tpg_undepend_item(tmp_tpg); ret = TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE; goto out_unmap; @@ -1647,7 +1647,7 @@ core_scsi3_decode_spec_i_port( pr_err("core_scsi3_lunacl_depend_item()" " failed\n"); atomic_dec(&dest_se_deve->pr_ref_count); - smp_mb__after_atomic_dec(); + smp_mb__after_atomic(); core_scsi3_nodeacl_undepend_item(dest_node_acl); core_scsi3_tpg_undepend_item(dest_tpg); ret = TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE; @@ -3168,14 +3168,14 @@ core_scsi3_emulate_pro_register_and_move(struct se_cmd *cmd, u64 res_key, continue; atomic_inc(&dest_se_tpg->tpg_pr_ref_count); - smp_mb__after_atomic_inc(); + smp_mb__after_atomic(); spin_unlock(&dev->se_port_lock); if (core_scsi3_tpg_depend_item(dest_se_tpg)) { pr_err("core_scsi3_tpg_depend_item() failed" " for dest_se_tpg\n"); atomic_dec(&dest_se_tpg->tpg_pr_ref_count); - smp_mb__after_atomic_dec(); + smp_mb__after_atomic(); ret = TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE; goto out_put_pr_reg; } @@ -3273,7 +3273,7 @@ after_iport_check: initiator_str); if (dest_node_acl) { atomic_inc(&dest_node_acl->acl_pr_ref_count); - smp_mb__after_atomic_inc(); + smp_mb__after_atomic(); } spin_unlock_irq(&dest_se_tpg->acl_node_lock); @@ -3289,7 +3289,7 @@ after_iport_check: pr_err("core_scsi3_nodeacl_depend_item() for" " dest_node_acl\n"); atomic_dec(&dest_node_acl->acl_pr_ref_count); - smp_mb__after_atomic_dec(); + smp_mb__after_atomic(); dest_node_acl = NULL; ret = TCM_INVALID_PARAMETER_LIST; goto out; @@ -3314,7 +3314,7 @@ after_iport_check: if (core_scsi3_lunacl_depend_item(dest_se_deve)) { pr_err("core_scsi3_lunacl_depend_item() failed\n"); atomic_dec(&dest_se_deve->pr_ref_count); - smp_mb__after_atomic_dec(); + smp_mb__after_atomic(); dest_se_deve = NULL; ret = TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE; goto out; @@ -3880,7 +3880,7 @@ core_scsi3_pri_read_full_status(struct se_cmd *cmd) add_desc_len = 0; atomic_inc(&pr_reg->pr_res_holders); - smp_mb__after_atomic_inc(); + smp_mb__after_atomic(); spin_unlock(&pr_tmpl->registration_lock); /* * Determine expected length of $FABRIC_MOD specific @@ -3894,7 +3894,7 @@ core_scsi3_pri_read_full_status(struct se_cmd *cmd) " out of buffer: %d\n", cmd->data_length); spin_lock(&pr_tmpl->registration_lock); atomic_dec(&pr_reg->pr_res_holders); - smp_mb__after_atomic_dec(); + smp_mb__after_atomic(); break; } /* @@ -3956,7 +3956,7 @@ core_scsi3_pri_read_full_status(struct se_cmd *cmd) spin_lock(&pr_tmpl->registration_lock); atomic_dec(&pr_reg->pr_res_holders); - smp_mb__after_atomic_dec(); + smp_mb__after_atomic(); /* * Set the ADDITIONAL DESCRIPTOR LENGTH */ diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c index d4b98690a736..4badca1cd625 100644 --- a/drivers/target/target_core_transport.c +++ b/drivers/target/target_core_transport.c @@ -736,7 +736,7 @@ void target_qf_do_work(struct work_struct *work) list_for_each_entry_safe(cmd, cmd_tmp, &qf_cmd_list, se_qf_node) { list_del(&cmd->se_qf_node); atomic_dec(&dev->dev_qf_count); - smp_mb__after_atomic_dec(); + smp_mb__after_atomic(); pr_debug("Processing %s cmd: %p QUEUE_FULL in work queue" " context: %s\n", cmd->se_tfo->get_fabric_name(), cmd, @@ -1148,7 +1148,7 @@ transport_check_alloc_task_attr(struct se_cmd *cmd) * Dormant to Active status. */ cmd->se_ordered_id = atomic_inc_return(&dev->dev_ordered_id); - smp_mb__after_atomic_inc(); + smp_mb__after_atomic(); pr_debug("Allocated se_ordered_id: %u for Task Attr: 0x%02x on %s\n", cmd->se_ordered_id, cmd->sam_task_attr, dev->transport->name); @@ -1705,7 +1705,7 @@ static bool target_handle_task_attr(struct se_cmd *cmd) return false; case MSG_ORDERED_TAG: atomic_inc(&dev->dev_ordered_sync); - smp_mb__after_atomic_inc(); + smp_mb__after_atomic(); pr_debug("Added ORDERED for CDB: 0x%02x to ordered list, " " se_ordered_id: %u\n", @@ -1723,7 +1723,7 @@ static bool target_handle_task_attr(struct se_cmd *cmd) * For SIMPLE and UNTAGGED Task Attribute commands */ atomic_inc(&dev->simple_cmds); - smp_mb__after_atomic_inc(); + smp_mb__after_atomic(); break; } @@ -1828,7 +1828,7 @@ static void transport_complete_task_attr(struct se_cmd *cmd) if (cmd->sam_task_attr == MSG_SIMPLE_TAG) { atomic_dec(&dev->simple_cmds); - smp_mb__after_atomic_dec(); + smp_mb__after_atomic(); dev->dev_cur_ordered_id++; pr_debug("Incremented dev->dev_cur_ordered_id: %u for" " SIMPLE: %u\n", dev->dev_cur_ordered_id, @@ -1840,7 +1840,7 @@ static void transport_complete_task_attr(struct se_cmd *cmd) cmd->se_ordered_id); } else if (cmd->sam_task_attr == MSG_ORDERED_TAG) { atomic_dec(&dev->dev_ordered_sync); - smp_mb__after_atomic_dec(); + smp_mb__after_atomic(); dev->dev_cur_ordered_id++; pr_debug("Incremented dev_cur_ordered_id: %u for ORDERED:" @@ -1899,7 +1899,7 @@ static void transport_handle_queue_full( spin_lock_irq(&dev->qf_cmd_lock); list_add_tail(&cmd->se_qf_node, &cmd->se_dev->qf_cmd_list); atomic_inc(&dev->dev_qf_count); - smp_mb__after_atomic_inc(); + smp_mb__after_atomic(); spin_unlock_irq(&cmd->se_dev->qf_cmd_lock); schedule_work(&cmd->se_dev->qf_work_queue); @@ -2875,7 +2875,7 @@ void transport_send_task_abort(struct se_cmd *cmd) if (cmd->se_tfo->write_pending_status(cmd) != 0) { cmd->transport_state |= CMD_T_ABORTED; cmd->se_cmd_flags |= SCF_SEND_DELAYED_TAS; - smp_mb__after_atomic_inc(); + smp_mb__after_atomic(); return; } } diff --git a/drivers/target/target_core_ua.c b/drivers/target/target_core_ua.c index 505519b10cb7..101858e245b3 100644 --- a/drivers/target/target_core_ua.c +++ b/drivers/target/target_core_ua.c @@ -162,7 +162,7 @@ int core_scsi3_ua_allocate( spin_unlock_irq(&nacl->device_list_lock); atomic_inc(&deve->ua_count); - smp_mb__after_atomic_inc(); + smp_mb__after_atomic(); return 0; } list_add_tail(&ua->ua_nacl_list, &deve->ua_list); @@ -175,7 +175,7 @@ int core_scsi3_ua_allocate( asc, ascq); atomic_inc(&deve->ua_count); - smp_mb__after_atomic_inc(); + smp_mb__after_atomic(); return 0; } @@ -190,7 +190,7 @@ void core_scsi3_ua_release_all( kmem_cache_free(se_ua_cache, ua); atomic_dec(&deve->ua_count); - smp_mb__after_atomic_dec(); + smp_mb__after_atomic(); } spin_unlock(&deve->ua_lock); } @@ -251,7 +251,7 @@ void core_scsi3_ua_for_check_condition( kmem_cache_free(se_ua_cache, ua); atomic_dec(&deve->ua_count); - smp_mb__after_atomic_dec(); + smp_mb__after_atomic(); } spin_unlock(&deve->ua_lock); spin_unlock_irq(&nacl->device_list_lock); @@ -310,7 +310,7 @@ int core_scsi3_ua_clear_for_request_sense( kmem_cache_free(se_ua_cache, ua); atomic_dec(&deve->ua_count); - smp_mb__after_atomic_dec(); + smp_mb__after_atomic(); } spin_unlock(&deve->ua_lock); spin_unlock_irq(&nacl->device_list_lock); diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c index 41fe8a047d37..746ae80b972f 100644 --- a/drivers/tty/n_tty.c +++ b/drivers/tty/n_tty.c @@ -2041,7 +2041,7 @@ static int canon_copy_from_read_buf(struct tty_struct *tty, if (found) clear_bit(eol, ldata->read_flags); - smp_mb__after_clear_bit(); + smp_mb__after_atomic(); ldata->read_tail += c; if (found) { diff --git a/drivers/tty/serial/mxs-auart.c b/drivers/tty/serial/mxs-auart.c index aa97fd845b4d..4b5b3c2fe328 100644 --- a/drivers/tty/serial/mxs-auart.c +++ b/drivers/tty/serial/mxs-auart.c @@ -200,7 +200,7 @@ static void dma_tx_callback(void *param) /* clear the bit used to serialize the DMA tx. */ clear_bit(MXS_AUART_DMA_TX_SYNC, &s->flags); - smp_mb__after_clear_bit(); + smp_mb__after_atomic(); /* wake up the possible processes. */ if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS) @@ -275,7 +275,7 @@ static void mxs_auart_tx_chars(struct mxs_auart_port *s) mxs_auart_dma_tx(s, i); } else { clear_bit(MXS_AUART_DMA_TX_SYNC, &s->flags); - smp_mb__after_clear_bit(); + smp_mb__after_atomic(); } return; } diff --git a/drivers/usb/gadget/tcm_usb_gadget.c b/drivers/usb/gadget/tcm_usb_gadget.c index f058c0368d61..819875c7e394 100644 --- a/drivers/usb/gadget/tcm_usb_gadget.c +++ b/drivers/usb/gadget/tcm_usb_gadget.c @@ -1851,7 +1851,7 @@ static int usbg_port_link(struct se_portal_group *se_tpg, struct se_lun *lun) struct usbg_tpg *tpg = container_of(se_tpg, struct usbg_tpg, se_tpg); atomic_inc(&tpg->tpg_port_count); - smp_mb__after_atomic_inc(); + smp_mb__after_atomic(); return 0; } @@ -1861,7 +1861,7 @@ static void usbg_port_unlink(struct se_portal_group *se_tpg, struct usbg_tpg *tpg = container_of(se_tpg, struct usbg_tpg, se_tpg); atomic_dec(&tpg->tpg_port_count); - smp_mb__after_atomic_dec(); + smp_mb__after_atomic(); } static int usbg_check_stop_free(struct se_cmd *se_cmd) diff --git a/drivers/usb/serial/usb_wwan.c b/drivers/usb/serial/usb_wwan.c index 640fe0173236..f1ec1680e822 100644 --- a/drivers/usb/serial/usb_wwan.c +++ b/drivers/usb/serial/usb_wwan.c @@ -325,7 +325,7 @@ static void usb_wwan_outdat_callback(struct urb *urb) for (i = 0; i < N_OUT_URB; ++i) { if (portdata->out_urbs[i] == urb) { - smp_mb__before_clear_bit(); + smp_mb__before_atomic(); clear_bit(i, &portdata->out_busy); break; } diff --git a/drivers/vhost/scsi.c b/drivers/vhost/scsi.c index cf50ce93975b..aeb513108448 100644 --- a/drivers/vhost/scsi.c +++ b/drivers/vhost/scsi.c @@ -1255,7 +1255,7 @@ vhost_scsi_set_endpoint(struct vhost_scsi *vs, tpg->tv_tpg_vhost_count++; tpg->vhost_scsi = vs; vs_tpg[tpg->tport_tpgt] = tpg; - smp_mb__after_atomic_inc(); + smp_mb__after_atomic(); match = true; } mutex_unlock(&tpg->tv_tpg_mutex); diff --git a/drivers/w1/w1_family.c b/drivers/w1/w1_family.c index 3bff6b37b472..3651ec801f45 100644 --- a/drivers/w1/w1_family.c +++ b/drivers/w1/w1_family.c @@ -139,9 +139,9 @@ void w1_family_get(struct w1_family *f) void __w1_family_get(struct w1_family *f) { - smp_mb__before_atomic_inc(); + smp_mb__before_atomic(); atomic_inc(&f->refcnt); - smp_mb__after_atomic_inc(); + smp_mb__after_atomic(); } EXPORT_SYMBOL(w1_unregister_family); diff --git a/drivers/xen/xen-pciback/pciback_ops.c b/drivers/xen/xen-pciback/pciback_ops.c index 607e41460c0d..c4a0666de6f5 100644 --- a/drivers/xen/xen-pciback/pciback_ops.c +++ b/drivers/xen/xen-pciback/pciback_ops.c @@ -348,9 +348,9 @@ void xen_pcibk_do_op(struct work_struct *data) notify_remote_via_irq(pdev->evtchn_irq); /* Mark that we're done. */ - smp_mb__before_clear_bit(); /* /after/ clearing PCIF_active */ + smp_mb__before_atomic(); /* /after/ clearing PCIF_active */ clear_bit(_PDEVF_op_active, &pdev->flags); - smp_mb__after_clear_bit(); /* /before/ final check for work */ + smp_mb__after_atomic(); /* /before/ final check for work */ /* Check to see if the driver domain tried to start another request in * between clearing _XEN_PCIF_active and clearing _PDEVF_op_active. diff --git a/fs/btrfs/btrfs_inode.h b/fs/btrfs/btrfs_inode.h index c9a24444ec9a..2256e9cceec5 100644 --- a/fs/btrfs/btrfs_inode.h +++ b/fs/btrfs/btrfs_inode.h @@ -279,7 +279,7 @@ static inline void btrfs_inode_block_unlocked_dio(struct inode *inode) static inline void btrfs_inode_resume_unlocked_dio(struct inode *inode) { - smp_mb__before_clear_bit(); + smp_mb__before_atomic(); clear_bit(BTRFS_INODE_READDIO_NEED_LOCK, &BTRFS_I(inode)->runtime_flags); } diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index 3955e475ceec..f29a54e454d4 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -3458,7 +3458,7 @@ static int lock_extent_buffer_for_io(struct extent_buffer *eb, static void end_extent_buffer_writeback(struct extent_buffer *eb) { clear_bit(EXTENT_BUFFER_WRITEBACK, &eb->bflags); - smp_mb__after_clear_bit(); + smp_mb__after_atomic(); wake_up_bit(&eb->bflags, EXTENT_BUFFER_WRITEBACK); } diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 5f805bc944fa..5a3b8371772e 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -7126,7 +7126,7 @@ static void btrfs_end_dio_bio(struct bio *bio, int err) * before atomic variable goto zero, we must make sure * dip->errors is perceived to be set. */ - smp_mb__before_atomic_dec(); + smp_mb__before_atomic(); } /* if there are more bios still pending for this dio, just exit */ @@ -7306,7 +7306,7 @@ out_err: * before atomic variable goto zero, we must * make sure dip->errors is perceived to be set. */ - smp_mb__before_atomic_dec(); + smp_mb__before_atomic(); if (atomic_dec_and_test(&dip->pending_bios)) bio_io_error(dip->orig_bio); @@ -7449,7 +7449,7 @@ static ssize_t btrfs_direct_IO(int rw, struct kiocb *iocb, return 0; atomic_inc(&inode->i_dio_count); - smp_mb__after_atomic_inc(); + smp_mb__after_atomic(); /* * The generic stuff only does filemap_write_and_wait_range, which diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c index e79ff6b90cb7..f45040a4bb76 100644 --- a/fs/btrfs/ioctl.c +++ b/fs/btrfs/ioctl.c @@ -642,7 +642,7 @@ static int create_snapshot(struct btrfs_root *root, struct inode *dir, return -EINVAL; atomic_inc(&root->will_be_snapshoted); - smp_mb__after_atomic_inc(); + smp_mb__after_atomic(); btrfs_wait_nocow_write(root); ret = btrfs_start_delalloc_inodes(root, 0); diff --git a/fs/buffer.c b/fs/buffer.c index 9ddb9fc7d923..6a8110c03a47 100644 --- a/fs/buffer.c +++ b/fs/buffer.c @@ -77,7 +77,7 @@ EXPORT_SYMBOL(__lock_buffer); void unlock_buffer(struct buffer_head *bh) { clear_bit_unlock(BH_Lock, &bh->b_state); - smp_mb__after_clear_bit(); + smp_mb__after_atomic(); wake_up_bit(&bh->b_state, BH_Lock); } EXPORT_SYMBOL(unlock_buffer); diff --git a/fs/ext4/resize.c b/fs/ext4/resize.c index f3b84cd9de56..08b3c116915b 100644 --- a/fs/ext4/resize.c +++ b/fs/ext4/resize.c @@ -42,7 +42,7 @@ int ext4_resize_begin(struct super_block *sb) void ext4_resize_end(struct super_block *sb) { clear_bit_unlock(EXT4_RESIZING, &EXT4_SB(sb)->s_resize_flags); - smp_mb__after_clear_bit(); + smp_mb__after_atomic(); } static ext4_group_t ext4_meta_bg_first_group(struct super_block *sb, diff --git a/fs/gfs2/glock.c b/fs/gfs2/glock.c index aec7f73832f0..c355f7320e44 100644 --- a/fs/gfs2/glock.c +++ b/fs/gfs2/glock.c @@ -277,7 +277,7 @@ static inline int may_grant(const struct gfs2_glock *gl, const struct gfs2_holde static void gfs2_holder_wake(struct gfs2_holder *gh) { clear_bit(HIF_WAIT, &gh->gh_iflags); - smp_mb__after_clear_bit(); + smp_mb__after_atomic(); wake_up_bit(&gh->gh_iflags, HIF_WAIT); } @@ -411,7 +411,7 @@ static void gfs2_demote_wake(struct gfs2_glock *gl) { gl->gl_demote_state = LM_ST_EXCLUSIVE; clear_bit(GLF_DEMOTE, &gl->gl_flags); - smp_mb__after_clear_bit(); + smp_mb__after_atomic(); wake_up_bit(&gl->gl_flags, GLF_DEMOTE); } @@ -620,7 +620,7 @@ out: out_sched: clear_bit(GLF_LOCK, &gl->gl_flags); - smp_mb__after_clear_bit(); + smp_mb__after_atomic(); gl->gl_lockref.count++; if (queue_delayed_work(glock_workqueue, &gl->gl_work, 0) == 0) gl->gl_lockref.count--; @@ -628,7 +628,7 @@ out_sched: out_unlock: clear_bit(GLF_LOCK, &gl->gl_flags); - smp_mb__after_clear_bit(); + smp_mb__after_atomic(); return; } diff --git a/fs/gfs2/glops.c b/fs/gfs2/glops.c index 54b66809e818..74d9a3dbf16f 100644 --- a/fs/gfs2/glops.c +++ b/fs/gfs2/glops.c @@ -221,7 +221,7 @@ static void inode_go_sync(struct gfs2_glock *gl) * Writeback of the data mapping may cause the dirty flag to be set * so we have to clear it again here. */ - smp_mb__before_clear_bit(); + smp_mb__before_atomic(); clear_bit(GLF_DIRTY, &gl->gl_flags); } diff --git a/fs/gfs2/lock_dlm.c b/fs/gfs2/lock_dlm.c index c1eb555dc588..91f274de1246 100644 --- a/fs/gfs2/lock_dlm.c +++ b/fs/gfs2/lock_dlm.c @@ -1134,7 +1134,7 @@ static void gdlm_recover_done(void *arg, struct dlm_slot *slots, int num_slots, queue_delayed_work(gfs2_control_wq, &sdp->sd_control_work, 0); clear_bit(DFL_DLM_RECOVERY, &ls->ls_recover_flags); - smp_mb__after_clear_bit(); + smp_mb__after_atomic(); wake_up_bit(&ls->ls_recover_flags, DFL_DLM_RECOVERY); spin_unlock(&ls->ls_recover_spin); } @@ -1271,7 +1271,7 @@ static int gdlm_mount(struct gfs2_sbd *sdp, const char *table) ls->ls_first = !!test_bit(DFL_FIRST_MOUNT, &ls->ls_recover_flags); clear_bit(SDF_NOJOURNALID, &sdp->sd_flags); - smp_mb__after_clear_bit(); + smp_mb__after_atomic(); wake_up_bit(&sdp->sd_flags, SDF_NOJOURNALID); return 0; diff --git a/fs/gfs2/recovery.c b/fs/gfs2/recovery.c index 7ad4094d68c0..fe7a56fb6084 100644 --- a/fs/gfs2/recovery.c +++ b/fs/gfs2/recovery.c @@ -587,7 +587,7 @@ fail: gfs2_recovery_done(sdp, jd->jd_jid, LM_RD_GAVEUP); done: clear_bit(JDF_RECOVERY, &jd->jd_flags); - smp_mb__after_clear_bit(); + smp_mb__after_atomic(); wake_up_bit(&jd->jd_flags, JDF_RECOVERY); } diff --git a/fs/gfs2/sys.c b/fs/gfs2/sys.c index de25d5577e5d..529d9a9eb897 100644 --- a/fs/gfs2/sys.c +++ b/fs/gfs2/sys.c @@ -333,7 +333,7 @@ static ssize_t block_store(struct gfs2_sbd *sdp, const char *buf, size_t len) set_bit(DFL_BLOCK_LOCKS, &ls->ls_recover_flags); else if (val == 0) { clear_bit(DFL_BLOCK_LOCKS, &ls->ls_recover_flags); - smp_mb__after_clear_bit(); + smp_mb__after_atomic(); gfs2_glock_thaw(sdp); } else { ret = -EINVAL; @@ -482,7 +482,7 @@ static ssize_t jid_store(struct gfs2_sbd *sdp, const char *buf, size_t len) rv = jid = -EINVAL; sdp->sd_lockstruct.ls_jid = jid; clear_bit(SDF_NOJOURNALID, &sdp->sd_flags); - smp_mb__after_clear_bit(); + smp_mb__after_atomic(); wake_up_bit(&sdp->sd_flags, SDF_NOJOURNALID); out: spin_unlock(&sdp->sd_jindex_spin); diff --git a/fs/jbd2/commit.c b/fs/jbd2/commit.c index 5f26139a165a..6fac74349856 100644 --- a/fs/jbd2/commit.c +++ b/fs/jbd2/commit.c @@ -43,7 +43,7 @@ static void journal_end_buffer_io_sync(struct buffer_head *bh, int uptodate) clear_buffer_uptodate(bh); if (orig_bh) { clear_bit_unlock(BH_Shadow, &orig_bh->b_state); - smp_mb__after_clear_bit(); + smp_mb__after_atomic(); wake_up_bit(&orig_bh->b_state, BH_Shadow); } unlock_buffer(bh); @@ -239,7 +239,7 @@ static int journal_submit_data_buffers(journal_t *journal, spin_lock(&journal->j_list_lock); J_ASSERT(jinode->i_transaction == commit_transaction); clear_bit(__JI_COMMIT_RUNNING, &jinode->i_flags); - smp_mb__after_clear_bit(); + smp_mb__after_atomic(); wake_up_bit(&jinode->i_flags, __JI_COMMIT_RUNNING); } spin_unlock(&journal->j_list_lock); @@ -277,7 +277,7 @@ static int journal_finish_inode_data_buffers(journal_t *journal, } spin_lock(&journal->j_list_lock); clear_bit(__JI_COMMIT_RUNNING, &jinode->i_flags); - smp_mb__after_clear_bit(); + smp_mb__after_atomic(); wake_up_bit(&jinode->i_flags, __JI_COMMIT_RUNNING); } diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c index d9f3d067cd15..4a3d4ef76127 100644 --- a/fs/nfs/dir.c +++ b/fs/nfs/dir.c @@ -2032,9 +2032,9 @@ static void nfs_access_free_entry(struct nfs_access_entry *entry) { put_rpccred(entry->cred); kfree(entry); - smp_mb__before_atomic_dec(); + smp_mb__before_atomic(); atomic_long_dec(&nfs_access_nr_entries); - smp_mb__after_atomic_dec(); + smp_mb__after_atomic(); } static void nfs_access_free_list(struct list_head *head) @@ -2082,9 +2082,9 @@ nfs_access_cache_scan(struct shrinker *shrink, struct shrink_control *sc) else { remove_lru_entry: list_del_init(&nfsi->access_cache_inode_lru); - smp_mb__before_clear_bit(); + smp_mb__before_atomic(); clear_bit(NFS_INO_ACL_LRU_SET, &nfsi->flags); - smp_mb__after_clear_bit(); + smp_mb__after_atomic(); } spin_unlock(&inode->i_lock); } @@ -2232,9 +2232,9 @@ void nfs_access_add_cache(struct inode *inode, struct nfs_access_entry *set) nfs_access_add_rbtree(inode, cache); /* Update accounting */ - smp_mb__before_atomic_inc(); + smp_mb__before_atomic(); atomic_long_inc(&nfs_access_nr_entries); - smp_mb__after_atomic_inc(); + smp_mb__after_atomic(); /* Add inode to global LRU list */ if (!test_bit(NFS_INO_ACL_LRU_SET, &NFS_I(inode)->flags)) { diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c index 0c438973f3c8..e6f7398d2b3c 100644 --- a/fs/nfs/inode.c +++ b/fs/nfs/inode.c @@ -1085,7 +1085,7 @@ int nfs_revalidate_mapping(struct inode *inode, struct address_space *mapping) trace_nfs_invalidate_mapping_exit(inode, ret); clear_bit_unlock(NFS_INO_INVALIDATING, bitlock); - smp_mb__after_clear_bit(); + smp_mb__after_atomic(); wake_up_bit(bitlock, NFS_INO_INVALIDATING); out: return ret; diff --git a/fs/nfs/nfs4filelayoutdev.c b/fs/nfs/nfs4filelayoutdev.c index efac602edb37..b9c61efe9660 100644 --- a/fs/nfs/nfs4filelayoutdev.c +++ b/fs/nfs/nfs4filelayoutdev.c @@ -789,9 +789,9 @@ static void nfs4_wait_ds_connect(struct nfs4_pnfs_ds *ds) static void nfs4_clear_ds_conn_bit(struct nfs4_pnfs_ds *ds) { - smp_mb__before_clear_bit(); + smp_mb__before_atomic(); clear_bit(NFS4DS_CONNECTING, &ds->ds_state); - smp_mb__after_clear_bit(); + smp_mb__after_atomic(); wake_up_bit(&ds->ds_state, NFS4DS_CONNECTING); } diff --git a/fs/nfs/nfs4state.c b/fs/nfs/nfs4state.c index 2349518eef2c..c0583b9bef71 100644 --- a/fs/nfs/nfs4state.c +++ b/fs/nfs/nfs4state.c @@ -1140,9 +1140,9 @@ static int nfs4_run_state_manager(void *); static void nfs4_clear_state_manager_bit(struct nfs_client *clp) { - smp_mb__before_clear_bit(); + smp_mb__before_atomic(); clear_bit(NFS4CLNT_MANAGER_RUNNING, &clp->cl_state); - smp_mb__after_clear_bit(); + smp_mb__after_atomic(); wake_up_bit(&clp->cl_state, NFS4CLNT_MANAGER_RUNNING); rpc_wake_up(&clp->cl_rpcwaitq); } diff --git a/fs/nfs/pagelist.c b/fs/nfs/pagelist.c index 2ffebf2081ce..03ed984ab4d8 100644 --- a/fs/nfs/pagelist.c +++ b/fs/nfs/pagelist.c @@ -95,7 +95,7 @@ nfs_iocounter_dec(struct nfs_io_counter *c) { if (atomic_dec_and_test(&c->io_count)) { clear_bit(NFS_IO_INPROGRESS, &c->flags); - smp_mb__after_clear_bit(); + smp_mb__after_atomic(); wake_up_bit(&c->flags, NFS_IO_INPROGRESS); } } @@ -193,9 +193,9 @@ void nfs_unlock_request(struct nfs_page *req) printk(KERN_ERR "NFS: Invalid unlock attempted\n"); BUG(); } - smp_mb__before_clear_bit(); + smp_mb__before_atomic(); clear_bit(PG_BUSY, &req->wb_flags); - smp_mb__after_clear_bit(); + smp_mb__after_atomic(); wake_up_bit(&req->wb_flags, PG_BUSY); } diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c index cb53d450ae32..fd9536e494bc 100644 --- a/fs/nfs/pnfs.c +++ b/fs/nfs/pnfs.c @@ -1810,7 +1810,7 @@ static void pnfs_clear_layoutcommitting(struct inode *inode) unsigned long *bitlock = &NFS_I(inode)->flags; clear_bit_unlock(NFS_INO_LAYOUTCOMMITTING, bitlock); - smp_mb__after_clear_bit(); + smp_mb__after_atomic(); wake_up_bit(bitlock, NFS_INO_LAYOUTCOMMITTING); } diff --git a/fs/nfs/pnfs.h b/fs/nfs/pnfs.h index 023793909778..c3058a076596 100644 --- a/fs/nfs/pnfs.h +++ b/fs/nfs/pnfs.h @@ -275,7 +275,7 @@ pnfs_get_lseg(struct pnfs_layout_segment *lseg) { if (lseg) { atomic_inc(&lseg->pls_refcount); - smp_mb__after_atomic_inc(); + smp_mb__after_atomic(); } return lseg; } diff --git a/fs/nfs/write.c b/fs/nfs/write.c index 9a3b6a4cd6b9..ffb9459f180b 100644 --- a/fs/nfs/write.c +++ b/fs/nfs/write.c @@ -405,7 +405,7 @@ int nfs_writepages(struct address_space *mapping, struct writeback_control *wbc) nfs_pageio_complete(&pgio); clear_bit_unlock(NFS_INO_FLUSHING, bitlock); - smp_mb__after_clear_bit(); + smp_mb__after_atomic(); wake_up_bit(bitlock, NFS_INO_FLUSHING); if (err < 0) @@ -1458,7 +1458,7 @@ static int nfs_commit_set_lock(struct nfs_inode *nfsi, int may_wait) static void nfs_commit_clear_lock(struct nfs_inode *nfsi) { clear_bit(NFS_INO_COMMIT, &nfsi->flags); - smp_mb__after_clear_bit(); + smp_mb__after_atomic(); wake_up_bit(&nfsi->flags, NFS_INO_COMMIT); } diff --git a/fs/ubifs/lpt_commit.c b/fs/ubifs/lpt_commit.c index 4b826abb1528..45d4e96a6bac 100644 --- a/fs/ubifs/lpt_commit.c +++ b/fs/ubifs/lpt_commit.c @@ -460,9 +460,9 @@ static int write_cnodes(struct ubifs_info *c) * important. */ clear_bit(DIRTY_CNODE, &cnode->flags); - smp_mb__before_clear_bit(); + smp_mb__before_atomic(); clear_bit(COW_CNODE, &cnode->flags); - smp_mb__after_clear_bit(); + smp_mb__after_atomic(); offs += len; dbg_chk_lpt_sz(c, 1, len); cnode = cnode->cnext; diff --git a/fs/ubifs/tnc_commit.c b/fs/ubifs/tnc_commit.c index 52a6559275c4..3600994f8411 100644 --- a/fs/ubifs/tnc_commit.c +++ b/fs/ubifs/tnc_commit.c @@ -895,9 +895,9 @@ static int write_index(struct ubifs_info *c) * the reason for the second barrier. */ clear_bit(DIRTY_ZNODE, &znode->flags); - smp_mb__before_clear_bit(); + smp_mb__before_atomic(); clear_bit(COW_ZNODE, &znode->flags); - smp_mb__after_clear_bit(); + smp_mb__after_atomic(); /* * We have marked the znode as clean but have not updated the diff --git a/include/asm-generic/bitops/atomic.h b/include/asm-generic/bitops/atomic.h index 9ae6c34dc191..49673510b484 100644 --- a/include/asm-generic/bitops/atomic.h +++ b/include/asm-generic/bitops/atomic.h @@ -80,7 +80,7 @@ static inline void set_bit(int nr, volatile unsigned long *addr) * * clear_bit() is atomic and may not be reordered. However, it does * not contain a memory barrier, so if it is used for locking purposes, - * you should call smp_mb__before_clear_bit() and/or smp_mb__after_clear_bit() + * you should call smp_mb__before_atomic() and/or smp_mb__after_atomic() * in order to ensure changes are visible on other processors. */ static inline void clear_bit(int nr, volatile unsigned long *addr) diff --git a/include/asm-generic/bitops/lock.h b/include/asm-generic/bitops/lock.h index 308a9e22c802..c30266e94806 100644 --- a/include/asm-generic/bitops/lock.h +++ b/include/asm-generic/bitops/lock.h @@ -20,7 +20,7 @@ */ #define clear_bit_unlock(nr, addr) \ do { \ - smp_mb__before_clear_bit(); \ + smp_mb__before_atomic(); \ clear_bit(nr, addr); \ } while (0) diff --git a/include/linux/buffer_head.h b/include/linux/buffer_head.h index c40302f909ce..7cbf837a279c 100644 --- a/include/linux/buffer_head.h +++ b/include/linux/buffer_head.h @@ -278,7 +278,7 @@ static inline void get_bh(struct buffer_head *bh) static inline void put_bh(struct buffer_head *bh) { - smp_mb__before_atomic_dec(); + smp_mb__before_atomic(); atomic_dec(&bh->b_count); } diff --git a/include/linux/genhd.h b/include/linux/genhd.h index 9f3c275e053e..ec274e0f4ed2 100644 --- a/include/linux/genhd.h +++ b/include/linux/genhd.h @@ -649,7 +649,7 @@ static inline void hd_ref_init(struct hd_struct *part) static inline void hd_struct_get(struct hd_struct *part) { atomic_inc(&part->ref); - smp_mb__after_atomic_inc(); + smp_mb__after_atomic(); } static inline int hd_struct_try_get(struct hd_struct *part) diff --git a/include/linux/interrupt.h b/include/linux/interrupt.h index c7bfac1c4a7b..157111043281 100644 --- a/include/linux/interrupt.h +++ b/include/linux/interrupt.h @@ -453,7 +453,7 @@ static inline int tasklet_trylock(struct tasklet_struct *t) static inline void tasklet_unlock(struct tasklet_struct *t) { - smp_mb__before_clear_bit(); + smp_mb__before_atomic(); clear_bit(TASKLET_STATE_RUN, &(t)->state); } @@ -501,7 +501,7 @@ static inline void tasklet_hi_schedule_first(struct tasklet_struct *t) static inline void tasklet_disable_nosync(struct tasklet_struct *t) { atomic_inc(&t->count); - smp_mb__after_atomic_inc(); + smp_mb__after_atomic(); } static inline void tasklet_disable(struct tasklet_struct *t) @@ -513,13 +513,13 @@ static inline void tasklet_disable(struct tasklet_struct *t) static inline void tasklet_enable(struct tasklet_struct *t) { - smp_mb__before_atomic_dec(); + smp_mb__before_atomic(); atomic_dec(&t->count); } static inline void tasklet_hi_enable(struct tasklet_struct *t) { - smp_mb__before_atomic_dec(); + smp_mb__before_atomic(); atomic_dec(&t->count); } diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index 7ed3a3aa6604..616415a4fee4 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -493,7 +493,7 @@ static inline void napi_disable(struct napi_struct *n) static inline void napi_enable(struct napi_struct *n) { BUG_ON(!test_bit(NAPI_STATE_SCHED, &n->state)); - smp_mb__before_clear_bit(); + smp_mb__before_atomic(); clear_bit(NAPI_STATE_SCHED, &n->state); } diff --git a/include/linux/sched.h b/include/linux/sched.h index 25f54c79f757..010cde3b44cb 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -2782,10 +2782,8 @@ static inline bool __must_check current_set_polling_and_test(void) /* * Polling state must be visible before we test NEED_RESCHED, * paired by resched_task() - * - * XXX: assumes set/clear bit are identical barrier wise. */ - smp_mb__after_clear_bit(); + smp_mb__after_atomic(); return unlikely(tif_need_resched()); } @@ -2803,7 +2801,7 @@ static inline bool __must_check current_clr_polling_and_test(void) * Polling state must be visible before we test NEED_RESCHED, * paired by resched_task() */ - smp_mb__after_clear_bit(); + smp_mb__after_atomic(); return unlikely(tif_need_resched()); } diff --git a/include/linux/sunrpc/sched.h b/include/linux/sunrpc/sched.h index 3a847de83fab..ad7dbe2cfecd 100644 --- a/include/linux/sunrpc/sched.h +++ b/include/linux/sunrpc/sched.h @@ -142,18 +142,18 @@ struct rpc_task_setup { test_and_set_bit(RPC_TASK_RUNNING, &(t)->tk_runstate) #define rpc_clear_running(t) \ do { \ - smp_mb__before_clear_bit(); \ + smp_mb__before_atomic(); \ clear_bit(RPC_TASK_RUNNING, &(t)->tk_runstate); \ - smp_mb__after_clear_bit(); \ + smp_mb__after_atomic(); \ } while (0) #define RPC_IS_QUEUED(t) test_bit(RPC_TASK_QUEUED, &(t)->tk_runstate) #define rpc_set_queued(t) set_bit(RPC_TASK_QUEUED, &(t)->tk_runstate) #define rpc_clear_queued(t) \ do { \ - smp_mb__before_clear_bit(); \ + smp_mb__before_atomic(); \ clear_bit(RPC_TASK_QUEUED, &(t)->tk_runstate); \ - smp_mb__after_clear_bit(); \ + smp_mb__after_atomic(); \ } while (0) #define RPC_IS_ACTIVATED(t) test_bit(RPC_TASK_ACTIVE, &(t)->tk_runstate) diff --git a/include/linux/sunrpc/xprt.h b/include/linux/sunrpc/xprt.h index 3e5efb2b236e..3876f0f1dfd3 100644 --- a/include/linux/sunrpc/xprt.h +++ b/include/linux/sunrpc/xprt.h @@ -379,9 +379,9 @@ static inline int xprt_test_and_clear_connected(struct rpc_xprt *xprt) static inline void xprt_clear_connecting(struct rpc_xprt *xprt) { - smp_mb__before_clear_bit(); + smp_mb__before_atomic(); clear_bit(XPRT_CONNECTING, &xprt->state); - smp_mb__after_clear_bit(); + smp_mb__after_atomic(); } static inline int xprt_connecting(struct rpc_xprt *xprt) @@ -411,9 +411,9 @@ static inline void xprt_clear_bound(struct rpc_xprt *xprt) static inline void xprt_clear_binding(struct rpc_xprt *xprt) { - smp_mb__before_clear_bit(); + smp_mb__before_atomic(); clear_bit(XPRT_BINDING, &xprt->state); - smp_mb__after_clear_bit(); + smp_mb__after_atomic(); } static inline int xprt_test_and_set_binding(struct rpc_xprt *xprt) diff --git a/include/linux/tracehook.h b/include/linux/tracehook.h index 1e98b5530425..6f8ab7da27c4 100644 --- a/include/linux/tracehook.h +++ b/include/linux/tracehook.h @@ -191,7 +191,7 @@ static inline void tracehook_notify_resume(struct pt_regs *regs) * pairs with task_work_add()->set_notify_resume() after * hlist_add_head(task->task_works); */ - smp_mb__after_clear_bit(); + smp_mb__after_atomic(); if (unlikely(current->task_works)) task_work_run(); } diff --git a/include/net/ip_vs.h b/include/net/ip_vs.h index 5679d927562b..624a8a54806d 100644 --- a/include/net/ip_vs.h +++ b/include/net/ip_vs.h @@ -1204,7 +1204,7 @@ static inline bool __ip_vs_conn_get(struct ip_vs_conn *cp) /* put back the conn without restarting its timer */ static inline void __ip_vs_conn_put(struct ip_vs_conn *cp) { - smp_mb__before_atomic_dec(); + smp_mb__before_atomic(); atomic_dec(&cp->refcnt); } void ip_vs_conn_put(struct ip_vs_conn *cp); @@ -1408,7 +1408,7 @@ static inline void ip_vs_dest_hold(struct ip_vs_dest *dest) static inline void ip_vs_dest_put(struct ip_vs_dest *dest) { - smp_mb__before_atomic_dec(); + smp_mb__before_atomic(); atomic_dec(&dest->refcnt); } diff --git a/kernel/debug/debug_core.c b/kernel/debug/debug_core.c index 2956c8da1605..1adf62b39b96 100644 --- a/kernel/debug/debug_core.c +++ b/kernel/debug/debug_core.c @@ -534,7 +534,7 @@ return_normal: kgdb_info[cpu].exception_state &= ~(DCPU_WANT_MASTER | DCPU_IS_SLAVE); kgdb_info[cpu].enter_kgdb--; - smp_mb__before_atomic_dec(); + smp_mb__before_atomic(); atomic_dec(&slaves_in_kgdb); dbg_touch_watchdogs(); local_irq_restore(flags); @@ -662,7 +662,7 @@ kgdb_restore: kgdb_info[cpu].exception_state &= ~(DCPU_WANT_MASTER | DCPU_IS_SLAVE); kgdb_info[cpu].enter_kgdb--; - smp_mb__before_atomic_dec(); + smp_mb__before_atomic(); atomic_dec(&masters_in_kgdb); /* Free kgdb_active */ atomic_set(&kgdb_active, -1); diff --git a/kernel/futex.c b/kernel/futex.c index 5f589279e462..b991ec05b8f9 100644 --- a/kernel/futex.c +++ b/kernel/futex.c @@ -267,7 +267,7 @@ static inline void futex_get_mm(union futex_key *key) * get_futex_key() implies a full barrier. This is relied upon * as full barrier (B), see the ordering comment above. */ - smp_mb__after_atomic_inc(); + smp_mb__after_atomic(); } /* @@ -280,7 +280,7 @@ static inline void hb_waiters_inc(struct futex_hash_bucket *hb) /* * Full barrier (A), see the ordering comment above. */ - smp_mb__after_atomic_inc(); + smp_mb__after_atomic(); #endif } diff --git a/kernel/kmod.c b/kernel/kmod.c index 6b375af4958d..0ac67a5861c5 100644 --- a/kernel/kmod.c +++ b/kernel/kmod.c @@ -498,7 +498,7 @@ int __usermodehelper_disable(enum umh_disable_depth depth) static void helper_lock(void) { atomic_inc(&running_helpers); - smp_mb__after_atomic_inc(); + smp_mb__after_atomic(); } static void helper_unlock(void) diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c index 0c47e300210a..88b4a1dcb58c 100644 --- a/kernel/rcu/tree.c +++ b/kernel/rcu/tree.c @@ -387,9 +387,9 @@ static void rcu_eqs_enter_common(struct rcu_dynticks *rdtp, long long oldval, } rcu_prepare_for_idle(smp_processor_id()); /* CPUs seeing atomic_inc() must see prior RCU read-side crit sects */ - smp_mb__before_atomic_inc(); /* See above. */ + smp_mb__before_atomic(); /* See above. */ atomic_inc(&rdtp->dynticks); - smp_mb__after_atomic_inc(); /* Force ordering with next sojourn. */ + smp_mb__after_atomic(); /* Force ordering with next sojourn. */ WARN_ON_ONCE(atomic_read(&rdtp->dynticks) & 0x1); /* @@ -507,10 +507,10 @@ void rcu_irq_exit(void) static void rcu_eqs_exit_common(struct rcu_dynticks *rdtp, long long oldval, int user) { - smp_mb__before_atomic_inc(); /* Force ordering w/previous sojourn. */ + smp_mb__before_atomic(); /* Force ordering w/previous sojourn. */ atomic_inc(&rdtp->dynticks); /* CPUs seeing atomic_inc() must see later RCU read-side crit sects */ - smp_mb__after_atomic_inc(); /* See above. */ + smp_mb__after_atomic(); /* See above. */ WARN_ON_ONCE(!(atomic_read(&rdtp->dynticks) & 0x1)); rcu_cleanup_after_idle(smp_processor_id()); trace_rcu_dyntick(TPS("End"), oldval, rdtp->dynticks_nesting); @@ -635,10 +635,10 @@ void rcu_nmi_enter(void) (atomic_read(&rdtp->dynticks) & 0x1)) return; rdtp->dynticks_nmi_nesting++; - smp_mb__before_atomic_inc(); /* Force delay from prior write. */ + smp_mb__before_atomic(); /* Force delay from prior write. */ atomic_inc(&rdtp->dynticks); /* CPUs seeing atomic_inc() must see later RCU read-side crit sects */ - smp_mb__after_atomic_inc(); /* See above. */ + smp_mb__after_atomic(); /* See above. */ WARN_ON_ONCE(!(atomic_read(&rdtp->dynticks) & 0x1)); } @@ -657,9 +657,9 @@ void rcu_nmi_exit(void) --rdtp->dynticks_nmi_nesting != 0) return; /* CPUs seeing atomic_inc() must see prior RCU read-side crit sects */ - smp_mb__before_atomic_inc(); /* See above. */ + smp_mb__before_atomic(); /* See above. */ atomic_inc(&rdtp->dynticks); - smp_mb__after_atomic_inc(); /* Force delay to next write. */ + smp_mb__after_atomic(); /* Force delay to next write. */ WARN_ON_ONCE(atomic_read(&rdtp->dynticks) & 0x1); } @@ -2790,7 +2790,7 @@ void synchronize_sched_expedited(void) s = atomic_long_read(&rsp->expedited_done); if (ULONG_CMP_GE((ulong)s, (ulong)firstsnap)) { /* ensure test happens before caller kfree */ - smp_mb__before_atomic_inc(); /* ^^^ */ + smp_mb__before_atomic(); /* ^^^ */ atomic_long_inc(&rsp->expedited_workdone1); return; } @@ -2808,7 +2808,7 @@ void synchronize_sched_expedited(void) s = atomic_long_read(&rsp->expedited_done); if (ULONG_CMP_GE((ulong)s, (ulong)firstsnap)) { /* ensure test happens before caller kfree */ - smp_mb__before_atomic_inc(); /* ^^^ */ + smp_mb__before_atomic(); /* ^^^ */ atomic_long_inc(&rsp->expedited_workdone2); return; } @@ -2837,7 +2837,7 @@ void synchronize_sched_expedited(void) s = atomic_long_read(&rsp->expedited_done); if (ULONG_CMP_GE((ulong)s, (ulong)snap)) { /* ensure test happens before caller kfree */ - smp_mb__before_atomic_inc(); /* ^^^ */ + smp_mb__before_atomic(); /* ^^^ */ atomic_long_inc(&rsp->expedited_done_lost); break; } diff --git a/kernel/rcu/tree_plugin.h b/kernel/rcu/tree_plugin.h index 962d1d589929..56db2f853e43 100644 --- a/kernel/rcu/tree_plugin.h +++ b/kernel/rcu/tree_plugin.h @@ -2523,9 +2523,9 @@ static void rcu_sysidle_enter(struct rcu_dynticks *rdtp, int irq) /* Record start of fully idle period. */ j = jiffies; ACCESS_ONCE(rdtp->dynticks_idle_jiffies) = j; - smp_mb__before_atomic_inc(); + smp_mb__before_atomic(); atomic_inc(&rdtp->dynticks_idle); - smp_mb__after_atomic_inc(); + smp_mb__after_atomic(); WARN_ON_ONCE(atomic_read(&rdtp->dynticks_idle) & 0x1); } @@ -2590,9 +2590,9 @@ static void rcu_sysidle_exit(struct rcu_dynticks *rdtp, int irq) } /* Record end of idle period. */ - smp_mb__before_atomic_inc(); + smp_mb__before_atomic(); atomic_inc(&rdtp->dynticks_idle); - smp_mb__after_atomic_inc(); + smp_mb__after_atomic(); WARN_ON_ONCE(!(atomic_read(&rdtp->dynticks_idle) & 0x1)); /* diff --git a/kernel/sched/cpupri.c b/kernel/sched/cpupri.c index 8b836b376d91..746bc9344969 100644 --- a/kernel/sched/cpupri.c +++ b/kernel/sched/cpupri.c @@ -165,7 +165,7 @@ void cpupri_set(struct cpupri *cp, int cpu, int newpri) * do a write memory barrier, and then update the count, to * make sure the vector is visible when count is set. */ - smp_mb__before_atomic_inc(); + smp_mb__before_atomic(); atomic_inc(&(vec)->count); do_mb = 1; } @@ -185,14 +185,14 @@ void cpupri_set(struct cpupri *cp, int cpu, int newpri) * the new priority vec. */ if (do_mb) - smp_mb__after_atomic_inc(); + smp_mb__after_atomic(); /* * When removing from the vector, we decrement the counter first * do a memory barrier and then clear the mask. */ atomic_dec(&(vec)->count); - smp_mb__after_atomic_inc(); + smp_mb__after_atomic(); cpumask_clear_cpu(cpu, vec->mask); } diff --git a/kernel/sched/wait.c b/kernel/sched/wait.c index 7d50f794e248..0ffa20ae657b 100644 --- a/kernel/sched/wait.c +++ b/kernel/sched/wait.c @@ -394,7 +394,7 @@ EXPORT_SYMBOL(__wake_up_bit); * * In order for this to function properly, as it uses waitqueue_active() * internally, some kind of memory barrier must be done prior to calling - * this. Typically, this will be smp_mb__after_clear_bit(), but in some + * this. Typically, this will be smp_mb__after_atomic(), but in some * cases where bitflags are manipulated non-atomically under a lock, one * may need to use a less regular barrier, such fs/inode.c's smp_mb(), * because spin_unlock() does not guarantee a memory barrier. diff --git a/mm/backing-dev.c b/mm/backing-dev.c index 09d9591b7708..1706cbbdf5f0 100644 --- a/mm/backing-dev.c +++ b/mm/backing-dev.c @@ -557,7 +557,7 @@ void clear_bdi_congested(struct backing_dev_info *bdi, int sync) bit = sync ? BDI_sync_congested : BDI_async_congested; if (test_and_clear_bit(bit, &bdi->state)) atomic_dec(&nr_bdi_congested[sync]); - smp_mb__after_clear_bit(); + smp_mb__after_atomic(); if (waitqueue_active(wqh)) wake_up(wqh); } diff --git a/mm/filemap.c b/mm/filemap.c index a82fbe4c9e8e..c73535c914cc 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -740,7 +740,7 @@ void unlock_page(struct page *page) { VM_BUG_ON_PAGE(!PageLocked(page), page); clear_bit_unlock(PG_locked, &page->flags); - smp_mb__after_clear_bit(); + smp_mb__after_atomic(); wake_up_page(page, PG_locked); } EXPORT_SYMBOL(unlock_page); @@ -757,7 +757,7 @@ void end_page_writeback(struct page *page) if (!test_clear_page_writeback(page)) BUG(); - smp_mb__after_clear_bit(); + smp_mb__after_atomic(); wake_up_page(page, PG_writeback); } EXPORT_SYMBOL(end_page_writeback); diff --git a/net/atm/pppoatm.c b/net/atm/pppoatm.c index 8c93267ce969..c4e09846d1de 100644 --- a/net/atm/pppoatm.c +++ b/net/atm/pppoatm.c @@ -252,7 +252,7 @@ static int pppoatm_may_send(struct pppoatm_vcc *pvcc, int size) * we need to ensure there's a memory barrier after it. The bit * *must* be set before we do the atomic_inc() on pvcc->inflight. * There's no smp_mb__after_set_bit(), so it's this or abuse - * smp_mb__after_clear_bit(). + * smp_mb__after_atomic(). */ test_and_set_bit(BLOCKED, &pvcc->blocked); diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index 49774912cb01..74014420b3c7 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -45,7 +45,7 @@ static void hci_cc_inquiry_cancel(struct hci_dev *hdev, struct sk_buff *skb) return; clear_bit(HCI_INQUIRY, &hdev->flags); - smp_mb__after_clear_bit(); /* wake_up_bit advises about this barrier */ + smp_mb__after_atomic(); /* wake_up_bit advises about this barrier */ wake_up_bit(&hdev->flags, HCI_INQUIRY); hci_conn_check_pending(hdev); @@ -1768,7 +1768,7 @@ static void hci_inquiry_complete_evt(struct hci_dev *hdev, struct sk_buff *skb) if (!test_and_clear_bit(HCI_INQUIRY, &hdev->flags)) return; - smp_mb__after_clear_bit(); /* wake_up_bit advises about this barrier */ + smp_mb__after_atomic(); /* wake_up_bit advises about this barrier */ wake_up_bit(&hdev->flags, HCI_INQUIRY); if (!test_bit(HCI_MGMT, &hdev->dev_flags)) diff --git a/net/core/dev.c b/net/core/dev.c index 5b3042e69f85..e14f1cba591a 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -1326,7 +1326,7 @@ static int __dev_close_many(struct list_head *head) * dev->stop() will invoke napi_disable() on all of it's * napi_struct instances on this device. */ - smp_mb__after_clear_bit(); /* Commit netif_running(). */ + smp_mb__after_atomic(); /* Commit netif_running(). */ } dev_deactivate_many(head); @@ -3343,7 +3343,7 @@ static void net_tx_action(struct softirq_action *h) root_lock = qdisc_lock(q); if (spin_trylock(root_lock)) { - smp_mb__before_clear_bit(); + smp_mb__before_atomic(); clear_bit(__QDISC_STATE_SCHED, &q->state); qdisc_run(q); @@ -3353,7 +3353,7 @@ static void net_tx_action(struct softirq_action *h) &q->state)) { __netif_reschedule(q); } else { - smp_mb__before_clear_bit(); + smp_mb__before_atomic(); clear_bit(__QDISC_STATE_SCHED, &q->state); } @@ -4244,7 +4244,7 @@ void __napi_complete(struct napi_struct *n) BUG_ON(n->gro_list); list_del(&n->poll_list); - smp_mb__before_clear_bit(); + smp_mb__before_atomic(); clear_bit(NAPI_STATE_SCHED, &n->state); } EXPORT_SYMBOL(__napi_complete); diff --git a/net/core/link_watch.c b/net/core/link_watch.c index 9c3a839322ba..bd0767e6b2b3 100644 --- a/net/core/link_watch.c +++ b/net/core/link_watch.c @@ -147,7 +147,7 @@ static void linkwatch_do_dev(struct net_device *dev) * Make sure the above read is complete since it can be * rewritten as soon as we clear the bit below. */ - smp_mb__before_clear_bit(); + smp_mb__before_atomic(); /* We are about to handle this device, * so new events can be accepted diff --git a/net/ipv4/inetpeer.c b/net/ipv4/inetpeer.c index 48f424465112..56cd458a1b8c 100644 --- a/net/ipv4/inetpeer.c +++ b/net/ipv4/inetpeer.c @@ -522,7 +522,7 @@ EXPORT_SYMBOL_GPL(inet_getpeer); void inet_putpeer(struct inet_peer *p) { p->dtime = (__u32)jiffies; - smp_mb__before_atomic_dec(); + smp_mb__before_atomic(); atomic_dec(&p->refcnt); } EXPORT_SYMBOL_GPL(inet_putpeer); diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c index 025e25093984..366cf06587b8 100644 --- a/net/ipv4/tcp_output.c +++ b/net/ipv4/tcp_output.c @@ -1930,10 +1930,8 @@ static bool tcp_write_xmit(struct sock *sk, unsigned int mss_now, int nonagle, /* It is possible TX completion already happened * before we set TSQ_THROTTLED, so we must * test again the condition. - * We abuse smp_mb__after_clear_bit() because - * there is no smp_mb__after_set_bit() yet */ - smp_mb__after_clear_bit(); + smp_mb__after_atomic(); if (atomic_read(&sk->sk_wmem_alloc) > limit) break; } diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c index 75421f2ba8be..1f4f954c4b47 100644 --- a/net/netfilter/nf_conntrack_core.c +++ b/net/netfilter/nf_conntrack_core.c @@ -914,7 +914,7 @@ void nf_conntrack_free(struct nf_conn *ct) nf_ct_ext_destroy(ct); nf_ct_ext_free(ct); kmem_cache_free(net->ct.nf_conntrack_cachep, ct); - smp_mb__before_atomic_dec(); + smp_mb__before_atomic(); atomic_dec(&net->ct.count); } EXPORT_SYMBOL_GPL(nf_conntrack_free); diff --git a/net/rds/ib_recv.c b/net/rds/ib_recv.c index b7ebe23cdedf..d67de453c35a 100644 --- a/net/rds/ib_recv.c +++ b/net/rds/ib_recv.c @@ -598,7 +598,7 @@ static void rds_ib_set_ack(struct rds_ib_connection *ic, u64 seq, { atomic64_set(&ic->i_ack_next, seq); if (ack_required) { - smp_mb__before_clear_bit(); + smp_mb__before_atomic(); set_bit(IB_ACK_REQUESTED, &ic->i_ack_flags); } } @@ -606,7 +606,7 @@ static void rds_ib_set_ack(struct rds_ib_connection *ic, u64 seq, static u64 rds_ib_get_ack(struct rds_ib_connection *ic) { clear_bit(IB_ACK_REQUESTED, &ic->i_ack_flags); - smp_mb__after_clear_bit(); + smp_mb__after_atomic(); return atomic64_read(&ic->i_ack_next); } diff --git a/net/rds/iw_recv.c b/net/rds/iw_recv.c index 45033358358e..aa8bf6786008 100644 --- a/net/rds/iw_recv.c +++ b/net/rds/iw_recv.c @@ -429,7 +429,7 @@ static void rds_iw_set_ack(struct rds_iw_connection *ic, u64 seq, { atomic64_set(&ic->i_ack_next, seq); if (ack_required) { - smp_mb__before_clear_bit(); + smp_mb__before_atomic(); set_bit(IB_ACK_REQUESTED, &ic->i_ack_flags); } } @@ -437,7 +437,7 @@ static void rds_iw_set_ack(struct rds_iw_connection *ic, u64 seq, static u64 rds_iw_get_ack(struct rds_iw_connection *ic) { clear_bit(IB_ACK_REQUESTED, &ic->i_ack_flags); - smp_mb__after_clear_bit(); + smp_mb__after_atomic(); return atomic64_read(&ic->i_ack_next); } diff --git a/net/rds/send.c b/net/rds/send.c index a82fb660ec00..23718160d71e 100644 --- a/net/rds/send.c +++ b/net/rds/send.c @@ -107,7 +107,7 @@ static int acquire_in_xmit(struct rds_connection *conn) static void release_in_xmit(struct rds_connection *conn) { clear_bit(RDS_IN_XMIT, &conn->c_flags); - smp_mb__after_clear_bit(); + smp_mb__after_atomic(); /* * We don't use wait_on_bit()/wake_up_bit() because our waking is in a * hot path and finding waiters is very rare. We don't want to walk @@ -661,7 +661,7 @@ void rds_send_drop_acked(struct rds_connection *conn, u64 ack, /* order flag updates with spin locks */ if (!list_empty(&list)) - smp_mb__after_clear_bit(); + smp_mb__after_atomic(); spin_unlock_irqrestore(&conn->c_lock, flags); @@ -691,7 +691,7 @@ void rds_send_drop_to(struct rds_sock *rs, struct sockaddr_in *dest) } /* order flag updates with the rs lock */ - smp_mb__after_clear_bit(); + smp_mb__after_atomic(); spin_unlock_irqrestore(&rs->rs_lock, flags); diff --git a/net/rds/tcp_send.c b/net/rds/tcp_send.c index 81cf5a4c5e40..53b17ca0dff5 100644 --- a/net/rds/tcp_send.c +++ b/net/rds/tcp_send.c @@ -93,7 +93,7 @@ int rds_tcp_xmit(struct rds_connection *conn, struct rds_message *rm, rm->m_ack_seq = tc->t_last_sent_nxt + sizeof(struct rds_header) + be32_to_cpu(rm->m_inc.i_hdr.h_len) - 1; - smp_mb__before_clear_bit(); + smp_mb__before_atomic(); set_bit(RDS_MSG_HAS_ACK_SEQ, &rm->m_flags); tc->t_last_expected_una = rm->m_ack_seq + 1; diff --git a/net/sunrpc/auth.c b/net/sunrpc/auth.c index 5285ead196c0..247e973544bf 100644 --- a/net/sunrpc/auth.c +++ b/net/sunrpc/auth.c @@ -296,7 +296,7 @@ static void rpcauth_unhash_cred_locked(struct rpc_cred *cred) { hlist_del_rcu(&cred->cr_hash); - smp_mb__before_clear_bit(); + smp_mb__before_atomic(); clear_bit(RPCAUTH_CRED_HASHED, &cred->cr_flags); } diff --git a/net/sunrpc/auth_gss/auth_gss.c b/net/sunrpc/auth_gss/auth_gss.c index 36e431ee1c90..b6e440baccc3 100644 --- a/net/sunrpc/auth_gss/auth_gss.c +++ b/net/sunrpc/auth_gss/auth_gss.c @@ -143,7 +143,7 @@ gss_cred_set_ctx(struct rpc_cred *cred, struct gss_cl_ctx *ctx) gss_get_ctx(ctx); rcu_assign_pointer(gss_cred->gc_ctx, ctx); set_bit(RPCAUTH_CRED_UPTODATE, &cred->cr_flags); - smp_mb__before_clear_bit(); + smp_mb__before_atomic(); clear_bit(RPCAUTH_CRED_NEW, &cred->cr_flags); } diff --git a/net/sunrpc/backchannel_rqst.c b/net/sunrpc/backchannel_rqst.c index 3513d559bc45..9761a0da964d 100644 --- a/net/sunrpc/backchannel_rqst.c +++ b/net/sunrpc/backchannel_rqst.c @@ -244,10 +244,10 @@ void xprt_free_bc_request(struct rpc_rqst *req) dprintk("RPC: free backchannel req=%p\n", req); req->rq_connect_cookie = xprt->connect_cookie - 1; - smp_mb__before_clear_bit(); + smp_mb__before_atomic(); WARN_ON_ONCE(!test_bit(RPC_BC_PA_IN_USE, &req->rq_bc_pa_state)); clear_bit(RPC_BC_PA_IN_USE, &req->rq_bc_pa_state); - smp_mb__after_clear_bit(); + smp_mb__after_atomic(); if (!xprt_need_to_requeue(xprt)) { /* diff --git a/net/sunrpc/xprt.c b/net/sunrpc/xprt.c index d173f79947c6..89d051de6b3e 100644 --- a/net/sunrpc/xprt.c +++ b/net/sunrpc/xprt.c @@ -230,9 +230,9 @@ static void xprt_clear_locked(struct rpc_xprt *xprt) { xprt->snd_task = NULL; if (!test_bit(XPRT_CLOSE_WAIT, &xprt->state)) { - smp_mb__before_clear_bit(); + smp_mb__before_atomic(); clear_bit(XPRT_LOCKED, &xprt->state); - smp_mb__after_clear_bit(); + smp_mb__after_atomic(); } else queue_work(rpciod_workqueue, &xprt->task_cleanup); } diff --git a/net/sunrpc/xprtsock.c b/net/sunrpc/xprtsock.c index 25a3dcf15cae..402a7e9a16b7 100644 --- a/net/sunrpc/xprtsock.c +++ b/net/sunrpc/xprtsock.c @@ -893,11 +893,11 @@ static void xs_close(struct rpc_xprt *xprt) xs_reset_transport(transport); xprt->reestablish_timeout = 0; - smp_mb__before_clear_bit(); + smp_mb__before_atomic(); clear_bit(XPRT_CONNECTION_ABORT, &xprt->state); clear_bit(XPRT_CLOSE_WAIT, &xprt->state); clear_bit(XPRT_CLOSING, &xprt->state); - smp_mb__after_clear_bit(); + smp_mb__after_atomic(); xprt_disconnect_done(xprt); } @@ -1497,12 +1497,12 @@ static void xs_tcp_cancel_linger_timeout(struct rpc_xprt *xprt) static void xs_sock_reset_connection_flags(struct rpc_xprt *xprt) { - smp_mb__before_clear_bit(); + smp_mb__before_atomic(); clear_bit(XPRT_CONNECTION_ABORT, &xprt->state); clear_bit(XPRT_CONNECTION_CLOSE, &xprt->state); clear_bit(XPRT_CLOSE_WAIT, &xprt->state); clear_bit(XPRT_CLOSING, &xprt->state); - smp_mb__after_clear_bit(); + smp_mb__after_atomic(); } static void xs_sock_mark_closed(struct rpc_xprt *xprt) @@ -1556,10 +1556,10 @@ static void xs_tcp_state_change(struct sock *sk) xprt->connect_cookie++; xprt->reestablish_timeout = 0; set_bit(XPRT_CLOSING, &xprt->state); - smp_mb__before_clear_bit(); + smp_mb__before_atomic(); clear_bit(XPRT_CONNECTED, &xprt->state); clear_bit(XPRT_CLOSE_WAIT, &xprt->state); - smp_mb__after_clear_bit(); + smp_mb__after_atomic(); xs_tcp_schedule_linger_timeout(xprt, xs_tcp_fin_timeout); break; case TCP_CLOSE_WAIT: @@ -1578,9 +1578,9 @@ static void xs_tcp_state_change(struct sock *sk) case TCP_LAST_ACK: set_bit(XPRT_CLOSING, &xprt->state); xs_tcp_schedule_linger_timeout(xprt, xs_tcp_fin_timeout); - smp_mb__before_clear_bit(); + smp_mb__before_atomic(); clear_bit(XPRT_CONNECTED, &xprt->state); - smp_mb__after_clear_bit(); + smp_mb__after_atomic(); break; case TCP_CLOSE: xs_tcp_cancel_linger_timeout(xprt); diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c index bb7e8ba821f4..749f80c21e22 100644 --- a/net/unix/af_unix.c +++ b/net/unix/af_unix.c @@ -1207,7 +1207,7 @@ restart: sk->sk_state = TCP_ESTABLISHED; sock_hold(newsk); - smp_mb__after_atomic_inc(); /* sock_hold() does an atomic_inc() */ + smp_mb__after_atomic(); /* sock_hold() does an atomic_inc() */ unix_peer(sk) = newsk; unix_state_unlock(sk); diff --git a/sound/pci/bt87x.c b/sound/pci/bt87x.c index 8546711d12f9..70951fd9b354 100644 --- a/sound/pci/bt87x.c +++ b/sound/pci/bt87x.c @@ -443,7 +443,7 @@ static int snd_bt87x_pcm_open(struct snd_pcm_substream *substream) _error: clear_bit(0, &chip->opened); - smp_mb__after_clear_bit(); + smp_mb__after_atomic(); return err; } @@ -458,7 +458,7 @@ static int snd_bt87x_close(struct snd_pcm_substream *substream) chip->substream = NULL; clear_bit(0, &chip->opened); - smp_mb__after_clear_bit(); + smp_mb__after_atomic(); return 0; } -- cgit v1.2.3 From 1413c03893332366e5b4d1e26f942ada25f3e82a Mon Sep 17 00:00:00 2001 From: Sasha Levin Date: Wed, 8 Jan 2014 14:21:46 -0500 Subject: lockdep: Increase static allocations Fuzzing a recent kernel with a large configuration hits the static allocation limits and disables lockdep. This patch doubles the limits. Signed-off-by: Sasha Levin Signed-off-by: Peter Zijlstra Link: http://lkml.kernel.org/r/1389208906-24338-1-git-send-email-sasha.levin@oracle.com Cc: linux-kernel@vger.kernel.org Signed-off-by: Ingo Molnar --- kernel/locking/lockdep_internals.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/kernel/locking/lockdep_internals.h b/kernel/locking/lockdep_internals.h index 4f560cfedc8f..51c4b24b6328 100644 --- a/kernel/locking/lockdep_internals.h +++ b/kernel/locking/lockdep_internals.h @@ -54,9 +54,9 @@ enum { * table (if it's not there yet), and we check it for lock order * conflicts and deadlocks. */ -#define MAX_LOCKDEP_ENTRIES 16384UL +#define MAX_LOCKDEP_ENTRIES 32768UL -#define MAX_LOCKDEP_CHAINS_BITS 15 +#define MAX_LOCKDEP_CHAINS_BITS 16 #define MAX_LOCKDEP_CHAINS (1UL << MAX_LOCKDEP_CHAINS_BITS) #define MAX_LOCKDEP_CHAIN_HLOCKS (MAX_LOCKDEP_CHAINS*5) @@ -65,7 +65,7 @@ enum { * Stack-trace: tightly packed array of stack backtrace * addresses. Protected by the hash_lock. */ -#define MAX_STACK_TRACE_ENTRIES 262144UL +#define MAX_STACK_TRACE_ENTRIES 524288UL extern struct list_head all_lock_classes; extern struct lock_chain lock_chains[]; -- cgit v1.2.3 From cab27258b1fdaad6380c971917b22d8d54abb7f5 Mon Sep 17 00:00:00 2001 From: Charles Keepax Date: Thu, 17 Apr 2014 13:42:54 +0100 Subject: ASoC: wm_adsp: Remove uneeded semicolon Reported-by: kbuild test robot Signed-off-by: Charles Keepax Signed-off-by: Mark Brown --- sound/soc/codecs/wm_adsp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/soc/codecs/wm_adsp.c b/sound/soc/codecs/wm_adsp.c index bb5f7b4e3ebb..53e3ab5fa0de 100644 --- a/sound/soc/codecs/wm_adsp.c +++ b/sound/soc/codecs/wm_adsp.c @@ -1625,7 +1625,7 @@ int wm_adsp2_early_event(struct snd_soc_dapm_widget *w, break; default: break; - }; + } return 0; } -- cgit v1.2.3 From a4c1d6c75822eb76b818cbffda2cf26a3e3ba5ac Mon Sep 17 00:00:00 2001 From: Alexandre Belloni Date: Tue, 15 Apr 2014 13:07:42 +0200 Subject: ARM: at91/dt: sam9rl: add lcd, adc, usb gadget and pwm support This patch adds support for the ADC, LCD, USB gadget and PWM controllers to the at91sam9rl. It also reorders the pinctrl_spi0 as it was not correctly sorted. Signed-off-by: Alexandre Belloni Signed-off-by: Nicolas Ferre --- arch/arm/boot/dts/at91sam9rl.dtsi | 265 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 256 insertions(+), 9 deletions(-) diff --git a/arch/arm/boot/dts/at91sam9rl.dtsi b/arch/arm/boot/dts/at91sam9rl.dtsi index 63e1784d272c..6202e161314a 100644 --- a/arch/arm/boot/dts/at91sam9rl.dtsi +++ b/arch/arm/boot/dts/at91sam9rl.dtsi @@ -11,6 +11,7 @@ #include #include #include +#include / { model = "Atmel AT91SAM9RL family SoC"; @@ -32,6 +33,7 @@ i2c1 = &i2c1; ssc0 = &ssc0; ssc1 = &ssc1; + pwm0 = &pwm0; }; cpus { @@ -48,12 +50,31 @@ reg = <0x20000000 0x04000000>; }; + clocks { + adc_op_clk: adc_op_clk{ + compatible = "fixed-clock"; + #clock-cells = <0>; + clock-frequency = <1000000>; + }; + }; + ahb { compatible = "simple-bus"; #address-cells = <1>; #size-cells = <1>; ranges; + fb0: fb@00500000 { + compatible = "atmel,at91sam9rl-lcdc"; + reg = <0x00500000 0x1000>; + interrupts = <23 IRQ_TYPE_LEVEL_HIGH 3>; + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_fb>; + clocks = <&lcd_clk>, <&lcd_clk>; + clock-names = "hclk", "lcdc_clk"; + status = "disabled"; + }; + nand0: nand@40000000 { compatible = "atmel,at91rm9200-nand"; #address-cells = <1>; @@ -187,6 +208,16 @@ status = "disabled"; }; + pwm0: pwm@fffc8000 { + compatible = "atmel,at91sam9rl-pwm"; + reg = <0xfffc8000 0x300>; + interrupts = <19 IRQ_TYPE_LEVEL_HIGH 4>; + #pwm-cells = <3>; + clocks = <&pwm_clk>; + clock-names = "pwm_clk"; + status = "disabled"; + }; + spi0: spi@fffcc000 { #address-cells = <1>; #size-cells = <0>; @@ -200,6 +231,111 @@ status = "disabled"; }; + adc0: adc@fffd0000 { + #address-cells = <1>; + #size-cells = <0>; + compatible = "atmel,at91sam9rl-adc"; + reg = <0xfffd0000 0x100>; + interrupts = <20 IRQ_TYPE_LEVEL_HIGH 0>; + clocks = <&adc_clk>, <&adc_op_clk>; + clock-names = "adc_clk", "adc_op_clk"; + atmel,adc-use-external-triggers; + atmel,adc-channels-used = <0x3f>; + atmel,adc-vref = <3300>; + atmel,adc-startup-time = <40>; + atmel,adc-res = <8 10>; + atmel,adc-res-names = "lowres", "highres"; + atmel,adc-use-res = "highres"; + + trigger@0 { + reg = <0>; + trigger-name = "timer-counter-0"; + trigger-value = <0x1>; + }; + trigger@1 { + reg = <1>; + trigger-name = "timer-counter-1"; + trigger-value = <0x3>; + }; + + trigger@2 { + reg = <2>; + trigger-name = "timer-counter-2"; + trigger-value = <0x5>; + }; + + trigger@3 { + reg = <3>; + trigger-name = "external"; + trigger-value = <0x13>; + trigger-external; + }; + }; + + usb0: gadget@fffd4000 { + #address-cells = <1>; + #size-cells = <0>; + compatible = "atmel,at91sam9rl-udc"; + reg = <0x00600000 0x100000>, + <0xfffd4000 0x4000>; + interrupts = <22 IRQ_TYPE_LEVEL_HIGH 2>; + clocks = <&udphs_clk>, <&utmi>; + clock-names = "pclk", "hclk"; + status = "disabled"; + + ep0 { + reg = <0>; + atmel,fifo-size = <64>; + atmel,nb-banks = <1>; + }; + + ep1 { + reg = <1>; + atmel,fifo-size = <1024>; + atmel,nb-banks = <2>; + atmel,can-dma; + atmel,can-isoc; + }; + + ep2 { + reg = <2>; + atmel,fifo-size = <1024>; + atmel,nb-banks = <2>; + atmel,can-dma; + atmel,can-isoc; + }; + + ep3 { + reg = <3>; + atmel,fifo-size = <1024>; + atmel,nb-banks = <3>; + atmel,can-dma; + }; + + ep4 { + reg = <4>; + atmel,fifo-size = <1024>; + atmel,nb-banks = <3>; + atmel,can-dma; + }; + + ep5 { + reg = <5>; + atmel,fifo-size = <1024>; + atmel,nb-banks = <3>; + atmel,can-dma; + atmel,can-isoc; + }; + + ep6 { + reg = <6>; + atmel,fifo-size = <1024>; + atmel,nb-banks = <3>; + atmel,can-dma; + atmel,can-isoc; + }; + }; + ramc0: ramc@ffffea00 { compatible = "atmel,at91sam9260-sdramc"; reg = <0xffffea00 0x200>; @@ -238,6 +374,44 @@ <0x003fffff 0x0001ff3c>; /* pioD */ /* shared pinctrl settings */ + adc0 { + pinctrl_adc0_ts: adc0_ts-0 { + atmel,pins = + , + , + , + ; + }; + + pinctrl_adc0_ad0: adc0_ad0-0 { + atmel,pins = ; + }; + + pinctrl_adc0_ad1: adc0_ad1-0 { + atmel,pins = ; + }; + + pinctrl_adc0_ad2: adc0_ad2-0 { + atmel,pins = ; + }; + + pinctrl_adc0_ad3: adc0_ad3-0 { + atmel,pins = ; + }; + + pinctrl_adc0_ad4: adc0_ad4-0 { + atmel,pins = ; + }; + + pinctrl_adc0_ad5: adc0_ad5-0 { + atmel,pins = ; + }; + + pinctrl_adc0_adtrg: adc0_adtrg-0 { + atmel,pins = ; + }; + }; + dbgu { pinctrl_dbgu: dbgu-0 { atmel,pins = @@ -246,6 +420,33 @@ }; }; + fb { + pinctrl_fb: fb-0 { + atmel,pins = + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + ; + }; + }; + i2c_gpio0 { pinctrl_i2c_gpio0: i2c_gpio0-0 { atmel,pins = @@ -307,6 +508,61 @@ }; }; + pwm0 { + pinctrl_pwm0_pwm0_0: pwm0_pwm0-0 { + atmel,pins = ; + }; + + pinctrl_pwm0_pwm0_1: pwm0_pwm0-1 { + atmel,pins = ; + }; + + pinctrl_pwm0_pwm0_2: pwm0_pwm0-2 { + atmel,pins = ; + }; + + pinctrl_pwm0_pwm1_0: pwm0_pwm1-0 { + atmel,pins = ; + }; + + pinctrl_pwm0_pwm1_1: pwm0_pwm1-1 { + atmel,pins = ; + }; + + pinctrl_pwm0_pwm1_2: pwm0_pwm1-2 { + atmel,pins = ; + }; + + pinctrl_pwm0_pwm2_0: pwm0_pwm2-0 { + atmel,pins = ; + }; + + pinctrl_pwm0_pwm2_1: pwm0_pwm2-1 { + atmel,pins = ; + }; + + pinctrl_pwm0_pwm2_2: pwm0_pwm2-2 { + atmel,pins = ; + }; + + pinctrl_pwm0_pwm3_0: pwm0_pwm3-0 { + atmel,pins = ; + }; + + pinctrl_pwm0_pwm3_1: pwm0_pwm3-1 { + atmel,pins = ; + }; + }; + + spi0 { + pinctrl_spi0: spi0-0 { + atmel,pins = + , + , + ; + }; + }; + ssc0 { pinctrl_ssc0_tx: ssc0_tx-0 { atmel,pins = @@ -339,15 +595,6 @@ }; }; - spi0 { - pinctrl_spi0: spi0-0 { - atmel,pins = - , - , - ; - }; - }; - tcb0 { pinctrl_tcb0_tclk0: tcb0_tclk0-0 { atmel,pins = ; -- cgit v1.2.3 From 3d293138f6793a87594be2d74191b6645421bc65 Mon Sep 17 00:00:00 2001 From: Alexandre Belloni Date: Tue, 15 Apr 2014 13:07:43 +0200 Subject: ARM: at91/dt: add peripherals to the at91sam9rlek board This adds support for: - SPI - Dataflash - LCD - i2c - ADC - Touchscreen - USB gadget - PWM Also it switches the ds1 and ds2 leds to PWM control. Signed-off-by: Alexandre Belloni Signed-off-by: Nicolas Ferre --- arch/arm/boot/dts/at91sam9rlek.dts | 90 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 86 insertions(+), 4 deletions(-) diff --git a/arch/arm/boot/dts/at91sam9rlek.dts b/arch/arm/boot/dts/at91sam9rlek.dts index cddb37825fad..f148fa4b3ab9 100644 --- a/arch/arm/boot/dts/at91sam9rlek.dts +++ b/arch/arm/boot/dts/at91sam9rlek.dts @@ -32,6 +32,37 @@ }; ahb { + fb0: fb@00500000 { + display = <&display0>; + status = "okay"; + + display0: display { + bits-per-pixel = <16>; + atmel,lcdcon-backlight; + atmel,dmacon = <0x1>; + atmel,lcdcon2 = <0x80008002>; + atmel,guard-time = <1>; + atmel,lcd-wiring-mode = "RGB"; + + display-timings { + native-mode = <&timing0>; + timing0: timing0 { + clock-frequency = <4965000>; + hactive = <240>; + vactive = <320>; + hback-porch = <1>; + hfront-porch = <33>; + vback-porch = <1>; + vfront-porch = <0>; + hsync-len = <5>; + vsync-len = <1>; + hsync-active = <1>; + vsync-active = <1>; + }; + }; + }; + }; + nand0: nand@40000000 { nand-bus-width = <8>; nand-ecc-mode = "soft"; @@ -92,6 +123,43 @@ status = "okay"; }; + adc0: adc@fffd0000 { + pinctrl-names = "default"; + pinctrl-0 = < + &pinctrl_adc0_ad0 + &pinctrl_adc0_ad1 + &pinctrl_adc0_ad2 + &pinctrl_adc0_ad3 + &pinctrl_adc0_ad4 + &pinctrl_adc0_ad5 + &pinctrl_adc0_adtrg>; + atmel,adc-ts-wires = <4>; + status = "okay"; + }; + + usb0: gadget@fffd4000 { + atmel,vbus-gpio = <&pioA 8 GPIO_ACTIVE_HIGH>; + status = "okay"; + }; + + spi0: spi@fffcc000 { + status = "okay"; + cs-gpios = <&pioA 28 0>, <0>, <0>, <0>; + mtd_dataflash@0 { + compatible = "atmel,at45", "atmel,dataflash"; + spi-max-frequency = <15000000>; + reg = <0>; + }; + }; + + pwm0: pwm@fffc8000 { + status = "okay"; + + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_pwm0_pwm1_2>, + <&pinctrl_pwm0_pwm2_2>; + }; + dbgu: serial@fffff200 { status = "okay"; }; @@ -117,18 +185,24 @@ }; }; - leds { - compatible = "gpio-leds"; + pwmleds { + compatible = "pwm-leds"; ds1 { label = "ds1"; - gpios = <&pioD 15 GPIO_ACTIVE_LOW>; + pwms = <&pwm0 1 5000 PWM_POLARITY_INVERTED>; + max-brightness = <255>; }; ds2 { label = "ds2"; - gpios = <&pioD 16 GPIO_ACTIVE_LOW>; + pwms = <&pwm0 2 5000 PWM_POLARITY_INVERTED>; + max-brightness = <255>; }; + }; + + leds { + compatible = "gpio-leds"; ds3 { label = "ds3"; @@ -154,4 +228,12 @@ gpio-key,wakeup; }; }; + + i2c@0 { + status = "okay"; + }; + + i2c@1 { + status = "okay"; + }; }; -- cgit v1.2.3 From 073a77d03ee88ae3a5504b3f73632841a55d60a1 Mon Sep 17 00:00:00 2001 From: Axel Lin Date: Tue, 15 Apr 2014 19:47:38 +0800 Subject: regulator: tps65217: Remove *rdev[] from struct tps65217 Now this driver uses devm_regulator_register() so we don't need to save rdev pointer to tps->rdev[i] for cleanup. Signed-off-by: Axel Lin Acked-by: Lee Jones Signed-off-by: Mark Brown --- drivers/regulator/tps65217-regulator.c | 3 --- include/linux/mfd/tps65217.h | 1 - 2 files changed, 4 deletions(-) diff --git a/drivers/regulator/tps65217-regulator.c b/drivers/regulator/tps65217-regulator.c index 10b78d2b766a..8482f6ba08a1 100644 --- a/drivers/regulator/tps65217-regulator.c +++ b/drivers/regulator/tps65217-regulator.c @@ -257,9 +257,6 @@ static int tps65217_regulator_probe(struct platform_device *pdev) pdev->name); return PTR_ERR(rdev); } - - /* Save regulator for cleanup */ - tps->rdev[i] = rdev; } return 0; } diff --git a/include/linux/mfd/tps65217.h b/include/linux/mfd/tps65217.h index 54b5458ec084..95d6938737fd 100644 --- a/include/linux/mfd/tps65217.h +++ b/include/linux/mfd/tps65217.h @@ -254,7 +254,6 @@ struct tps65217 { struct tps65217_board *pdata; unsigned long id; struct regulator_desc desc[TPS65217_NUM_REGULATOR]; - struct regulator_dev *rdev[TPS65217_NUM_REGULATOR]; struct regmap *regmap; }; -- cgit v1.2.3 From 3477501274b79a904a4195b675bb74caa57d2e14 Mon Sep 17 00:00:00 2001 From: Bard Liao Date: Thu, 17 Apr 2014 20:12:56 +0800 Subject: ASoC: dapm: Allow update_bits use 32 bits reg This patch change reg's type from unsigned short to int. Signed-off-by: Bard Liao Signed-off-by: Mark Brown --- sound/soc/soc-dapm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c index c8a780d0d057..f4ba7b40a6ab 100644 --- a/sound/soc/soc-dapm.c +++ b/sound/soc/soc-dapm.c @@ -426,7 +426,7 @@ static void soc_dapm_async_complete(struct snd_soc_dapm_context *dapm) } static int soc_widget_update_bits_locked(struct snd_soc_dapm_widget *w, - unsigned short reg, unsigned int mask, unsigned int value) + int reg, unsigned int mask, unsigned int value) { bool change; unsigned int old, new; -- cgit v1.2.3 From 1025c05f727be33e065bb502a223637681c7991d Mon Sep 17 00:00:00 2001 From: Axel Lin Date: Thu, 17 Apr 2014 16:35:43 +0800 Subject: ASoC: cs42l51: Fix mask for REVID The REVID mask was changed by commit a1253ef6d3fa "ASoC: cs42l51: split i2c from codec driver". Fix it. Signed-off-by: Axel Lin Acked-by: Brian Austin Signed-off-by: Mark Brown --- sound/soc/codecs/cs42l51.c | 3 ++- sound/soc/codecs/cs42l51.h | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/sound/soc/codecs/cs42l51.c b/sound/soc/codecs/cs42l51.c index 46abd3e02f14..6aa69e5aaa3f 100644 --- a/sound/soc/codecs/cs42l51.c +++ b/sound/soc/codecs/cs42l51.c @@ -548,7 +548,8 @@ int cs42l51_probe(struct device *dev, struct regmap *regmap) ret = -ENODEV; goto error; } - dev_info(dev, "Cirrus Logic CS42L51, Revision: %02X\n", val & 0xFF); + dev_info(dev, "Cirrus Logic CS42L51, Revision: %02X\n", + val & CS42L51_CHIP_REV_MASK); ret = snd_soc_register_codec(dev, &soc_codec_device_cs42l51, &cs42l51_dai, 1); diff --git a/sound/soc/codecs/cs42l51.h b/sound/soc/codecs/cs42l51.h index 641ef18435b3..8c55bf384bc6 100644 --- a/sound/soc/codecs/cs42l51.h +++ b/sound/soc/codecs/cs42l51.h @@ -26,6 +26,7 @@ int cs42l51_probe(struct device *dev, struct regmap *regmap); #define CS42L51_CHIP_ID 0x1B #define CS42L51_CHIP_REV_A 0x00 #define CS42L51_CHIP_REV_B 0x01 +#define CS42L51_CHIP_REV_MASK 0x07 #define CS42L51_CHIP_REV_ID 0x01 #define CS42L51_MK_CHIP_REV(a, b) ((a)<<3|(b)) -- cgit v1.2.3 From 290414499cf94284a97cc3c33214d13ccfcd896a Mon Sep 17 00:00:00 2001 From: Doug Anderson Date: Wed, 16 Apr 2014 16:12:28 -0700 Subject: regulator: tps65090: Allow setting the overcurrent wait time The tps65090 regulator allows you to specify how long you want it to wait before detecting an overcurrent condition. Allow specifying that through the device tree (or through platform data). Signed-off-by: Doug Anderson Signed-off-by: Simon Glass Signed-off-by: Michael Spang Signed-off-by: Sean Paul Signed-off-by: Mark Brown --- .../devicetree/bindings/regulator/tps65090.txt | 4 ++ drivers/regulator/tps65090-regulator.c | 56 ++++++++++++++++++++++ include/linux/mfd/tps65090.h | 5 ++ 3 files changed, 65 insertions(+) diff --git a/Documentation/devicetree/bindings/regulator/tps65090.txt b/Documentation/devicetree/bindings/regulator/tps65090.txt index 313a60ba61d8..340980239ea9 100644 --- a/Documentation/devicetree/bindings/regulator/tps65090.txt +++ b/Documentation/devicetree/bindings/regulator/tps65090.txt @@ -21,6 +21,10 @@ Optional properties: number should be provided. If it is externally controlled and no GPIO entry then driver will just configure this rails as external control and will not provide any enable/disable APIs. +- ti,overcurrent-wait: This is applicable to FET registers, which have a + poorly defined "overcurrent wait" field. If this property is present it + should be between 0 - 3. If this property isn't present we won't touch the + "overcurrent wait" field and we'll leave it to the BIOS/EC to deal with. Each regulator is defined using the standard binding for regulators. diff --git a/drivers/regulator/tps65090-regulator.c b/drivers/regulator/tps65090-regulator.c index 2e92ef68574d..ca04e9f010e1 100644 --- a/drivers/regulator/tps65090-regulator.c +++ b/drivers/regulator/tps65090-regulator.c @@ -28,15 +28,58 @@ #include #include +#define CTRL_WT_BIT 2 /* Regulator wait time 0 bit */ + +#define MAX_OVERCURRENT_WAIT 3 /* Overcurrent wait must be <= this */ + +/** + * struct tps65090_regulator - Per-regulator data for a tps65090 regulator + * + * @dev: Pointer to our device. + * @desc: The struct regulator_desc for the regulator. + * @rdev: The struct regulator_dev for the regulator. + * @overcurrent_wait_valid: True if overcurrent_wait is valid. + * @overcurrent_wait: For FETs, the value to put in the WTFET bitfield. + */ + struct tps65090_regulator { struct device *dev; struct regulator_desc *desc; struct regulator_dev *rdev; + bool overcurrent_wait_valid; + int overcurrent_wait; }; static struct regulator_ops tps65090_ext_control_ops = { }; +/** + * tps65090_reg_set_overcurrent_wait - Setup overcurrent wait + * + * This will set the overcurrent wait time based on what's in the regulator + * info. + * + * @ri: Overall regulator data + * @rdev: Regulator device + * + * Return: 0 if no error, non-zero if there was an error writing the register. + */ +static int tps65090_reg_set_overcurrent_wait(struct tps65090_regulator *ri, + struct regulator_dev *rdev) +{ + int ret; + + ret = regmap_update_bits(rdev->regmap, rdev->desc->enable_reg, + MAX_OVERCURRENT_WAIT << CTRL_WT_BIT, + ri->overcurrent_wait << CTRL_WT_BIT); + if (ret) { + dev_err(&rdev->dev, "Error updating overcurrent wait %#x\n", + rdev->desc->enable_reg); + } + + return ret; +} + static struct regulator_ops tps65090_reg_contol_ops = { .enable = regulator_enable_regmap, .disable = regulator_disable_regmap, @@ -209,6 +252,11 @@ static struct tps65090_platform_data *tps65090_parse_dt_reg_data( rpdata->gpio = of_get_named_gpio(np, "dcdc-ext-control-gpios", 0); + if (of_property_read_u32(tps65090_matches[idx].of_node, + "ti,overcurrent-wait", + &rpdata->overcurrent_wait) == 0) + rpdata->overcurrent_wait_valid = true; + tps65090_pdata->reg_pdata[idx] = rpdata; } return tps65090_pdata; @@ -258,6 +306,8 @@ static int tps65090_regulator_probe(struct platform_device *pdev) ri = &pmic[num]; ri->dev = &pdev->dev; ri->desc = &tps65090_regulator_desc[num]; + ri->overcurrent_wait_valid = tps_pdata->overcurrent_wait_valid; + ri->overcurrent_wait = tps_pdata->overcurrent_wait; /* * TPS5090 DCDC support the control from external digital input. @@ -299,6 +349,12 @@ static int tps65090_regulator_probe(struct platform_device *pdev) } ri->rdev = rdev; + if (ri->overcurrent_wait_valid) { + ret = tps65090_reg_set_overcurrent_wait(ri, rdev); + if (ret < 0) + return ret; + } + /* Enable external control if it is require */ if (tps_pdata && is_dcdc(num) && tps_pdata->reg_init_data && tps_pdata->enable_ext_control) { diff --git a/include/linux/mfd/tps65090.h b/include/linux/mfd/tps65090.h index 3f43069413e7..f25adfa97c73 100644 --- a/include/linux/mfd/tps65090.h +++ b/include/linux/mfd/tps65090.h @@ -78,11 +78,16 @@ struct tps65090 { * DCDC1, DCDC2 and DCDC3. * @gpio: Gpio number if external control is enabled and controlled through * gpio. + * @overcurrent_wait_valid: True if the overcurrent_wait should be applied. + * @overcurrent_wait: Value to set as the overcurrent wait time. This is the + * actual bitfield value, not a time in ms (valid value are 0 - 3). */ struct tps65090_regulator_plat_data { struct regulator_init_data *reg_init_data; bool enable_ext_control; int gpio; + bool overcurrent_wait_valid; + int overcurrent_wait; }; struct tps65090_platform_data { -- cgit v1.2.3 From 3ac170376f2c5123414e0267aa0f9cf218965e24 Mon Sep 17 00:00:00 2001 From: Boris BREZILLON Date: Thu, 17 Apr 2014 11:40:11 +0200 Subject: regmap: add reg_read/reg_write callbacks to regmap_bus struct Some busses do not support sending/receiving multiple registers in one go. Such kind of busses just unpack the registers that have been previously packed by the regmap core or pack registers that will be later unpacked by the core code. Add reg_write and reg_read callbacks in order to optimize access through this kind of busses. Signed-off-by: Boris BREZILLON Signed-off-by: Mark Brown --- drivers/base/regmap/regmap.c | 26 ++++++++++++++++++++++++++ include/linux/regmap.h | 6 ++++++ 2 files changed, 32 insertions(+) diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c index 63e30ef096e2..2209de0ceabc 100644 --- a/drivers/base/regmap/regmap.c +++ b/drivers/base/regmap/regmap.c @@ -35,10 +35,14 @@ static int _regmap_update_bits(struct regmap *map, unsigned int reg, unsigned int mask, unsigned int val, bool *change); +static int _regmap_bus_reg_read(void *context, unsigned int reg, + unsigned int *val); static int _regmap_bus_read(void *context, unsigned int reg, unsigned int *val); static int _regmap_bus_formatted_write(void *context, unsigned int reg, unsigned int val); +static int _regmap_bus_reg_write(void *context, unsigned int reg, + unsigned int val); static int _regmap_bus_raw_write(void *context, unsigned int reg, unsigned int val); @@ -493,6 +497,12 @@ struct regmap *regmap_init(struct device *dev, map->reg_read = config->reg_read; map->reg_write = config->reg_write; + map->defer_caching = false; + goto skip_format_initialization; + } else if (!bus->read || !bus->write) { + map->reg_read = _regmap_bus_reg_read; + map->reg_write = _regmap_bus_reg_write; + map->defer_caching = false; goto skip_format_initialization; } else { @@ -1284,6 +1294,14 @@ static int _regmap_bus_formatted_write(void *context, unsigned int reg, return ret; } +static int _regmap_bus_reg_write(void *context, unsigned int reg, + unsigned int val) +{ + struct regmap *map = context; + + return map->bus->reg_write(map->bus_context, reg, val); +} + static int _regmap_bus_raw_write(void *context, unsigned int reg, unsigned int val) { @@ -1925,6 +1943,14 @@ static int _regmap_raw_read(struct regmap *map, unsigned int reg, void *val, return ret; } +static int _regmap_bus_reg_read(void *context, unsigned int reg, + unsigned int *val) +{ + struct regmap *map = context; + + return map->bus->reg_read(map->bus_context, reg, val); +} + static int _regmap_bus_read(void *context, unsigned int reg, unsigned int *val) { diff --git a/include/linux/regmap.h b/include/linux/regmap.h index 85691b9b4fa7..7b0e4b425cdf 100644 --- a/include/linux/regmap.h +++ b/include/linux/regmap.h @@ -276,6 +276,10 @@ typedef int (*regmap_hw_async_write)(void *context, typedef int (*regmap_hw_read)(void *context, const void *reg_buf, size_t reg_size, void *val_buf, size_t val_size); +typedef int (*regmap_hw_reg_read)(void *context, unsigned int reg, + unsigned int *val); +typedef int (*regmap_hw_reg_write)(void *context, unsigned int reg, + unsigned int val); typedef struct regmap_async *(*regmap_hw_async_alloc)(void); typedef void (*regmap_hw_free_context)(void *context); @@ -309,7 +313,9 @@ struct regmap_bus { regmap_hw_write write; regmap_hw_gather_write gather_write; regmap_hw_async_write async_write; + regmap_hw_reg_write reg_write; regmap_hw_read read; + regmap_hw_reg_read reg_read; regmap_hw_free_context free_context; regmap_hw_async_alloc async_alloc; u8 read_flag_mask; -- cgit v1.2.3 From 72e6caca6389713c6c37c230b58657b28bcd6a00 Mon Sep 17 00:00:00 2001 From: Alexandre Belloni Date: Wed, 19 Mar 2014 00:15:39 +0100 Subject: ARM: at91/dt: sam9g45: improve ADC/touchscreen support Fixes the compatible string, adds the pinmuxing for the ADC pins. Also, removes atmel,adc-use-external-triggers as it is not possible to remove it unless redefining the whole adc node Signed-off-by: Alexandre Belloni Signed-off-by: Nicolas Ferre --- arch/arm/boot/dts/at91sam9g45.dtsi | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/arch/arm/boot/dts/at91sam9g45.dtsi b/arch/arm/boot/dts/at91sam9g45.dtsi index 9cdaecff13b3..ace6bf197b70 100644 --- a/arch/arm/boot/dts/at91sam9g45.dtsi +++ b/arch/arm/boot/dts/at91sam9g45.dtsi @@ -136,6 +136,36 @@ >; /* shared pinctrl settings */ + adc0 { + pinctrl_adc0_adtrg: adc0_adtrg { + atmel,pins = ; + }; + pinctrl_adc0_ad0: adc0_ad0 { + atmel,pins = ; + }; + pinctrl_adc0_ad1: adc0_ad1 { + atmel,pins = ; + }; + pinctrl_adc0_ad2: adc0_ad2 { + atmel,pins = ; + }; + pinctrl_adc0_ad3: adc0_ad3 { + atmel,pins = ; + }; + pinctrl_adc0_ad4: adc0_ad4 { + atmel,pins = ; + }; + pinctrl_adc0_ad5: adc0_ad5 { + atmel,pins = ; + }; + pinctrl_adc0_ad6: adc0_ad6 { + atmel,pins = ; + }; + pinctrl_adc0_ad7: adc0_ad7 { + atmel,pins = ; + }; + }; + dbgu { pinctrl_dbgu: dbgu-0 { atmel,pins = @@ -634,10 +664,9 @@ adc0: adc@fffb0000 { #address-cells = <1>; #size-cells = <0>; - compatible = "atmel,at91sam9260-adc"; + compatible = "atmel,at91sam9g45-adc"; reg = <0xfffb0000 0x100>; interrupts = <20 IRQ_TYPE_LEVEL_HIGH 0>; - atmel,adc-use-external-triggers; atmel,adc-channels-used = <0xff>; atmel,adc-vref = <3300>; atmel,adc-startup-time = <40>; -- cgit v1.2.3 From e10a57e341a6799db7e1414f38940ba800d4f297 Mon Sep 17 00:00:00 2001 From: Alexandre Belloni Date: Wed, 19 Mar 2014 00:15:40 +0100 Subject: ARM: at91/dt: at91sam9m10g45ek: add ADC and touchscreen support Signed-off-by: Alexandre Belloni Signed-off-by: Nicolas Ferre --- arch/arm/boot/dts/at91sam9m10g45ek.dts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/arch/arm/boot/dts/at91sam9m10g45ek.dts b/arch/arm/boot/dts/at91sam9m10g45ek.dts index 7ff665a8c708..7800931a4b16 100644 --- a/arch/arm/boot/dts/at91sam9m10g45ek.dts +++ b/arch/arm/boot/dts/at91sam9m10g45ek.dts @@ -130,6 +130,21 @@ status = "okay"; }; + adc0: adc@fffb0000 { + pinctrl-names = "default"; + pinctrl-0 = < + &pinctrl_adc0_ad0 + &pinctrl_adc0_ad1 + &pinctrl_adc0_ad2 + &pinctrl_adc0_ad3 + &pinctrl_adc0_ad4 + &pinctrl_adc0_ad5 + &pinctrl_adc0_ad6 + &pinctrl_adc0_ad7>; + atmel,adc-ts-wires = <4>; + status = "okay"; + }; + pwm0: pwm@fffb8000 { status = "okay"; -- cgit v1.2.3 From 66844c749c3520f99aa2e0f29601db6b571a284e Mon Sep 17 00:00:00 2001 From: Alexandre Belloni Date: Wed, 19 Mar 2014 00:15:41 +0100 Subject: ARM: at91/dt: at91sam9m10g45ek PWM leds polarity is inversed The real polarity of the LEDs is inversed. The led is between 3.3v and the PWM. It was working before because the driver was getting the duty cycle calculation wrong. Signed-off-by: Alexandre Belloni Signed-off-by: Nicolas Ferre --- arch/arm/boot/dts/at91sam9m10g45ek.dts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/arch/arm/boot/dts/at91sam9m10g45ek.dts b/arch/arm/boot/dts/at91sam9m10g45ek.dts index 7800931a4b16..9f5b0a674995 100644 --- a/arch/arm/boot/dts/at91sam9m10g45ek.dts +++ b/arch/arm/boot/dts/at91sam9m10g45ek.dts @@ -8,6 +8,7 @@ */ /dts-v1/; #include "at91sam9g45.dtsi" +#include / { model = "Atmel AT91SAM9M10G45-EK"; @@ -231,14 +232,14 @@ d6 { label = "d6"; - pwms = <&pwm0 3 5000 0>; + pwms = <&pwm0 3 5000 PWM_POLARITY_INVERTED>; max-brightness = <255>; linux,default-trigger = "nand-disk"; }; d7 { label = "d7"; - pwms = <&pwm0 1 5000 0>; + pwms = <&pwm0 1 5000 PWM_POLARITY_INVERTED>; max-brightness = <255>; linux,default-trigger = "mmc0"; }; -- cgit v1.2.3 From b7580cde704920da69e50d133cea16eca77ff3bd Mon Sep 17 00:00:00 2001 From: Christoph Jaeger Date: Tue, 15 Apr 2014 22:39:01 +0200 Subject: ASoC: core: use PTR_ERR instead of PTR_RET PTR_RET is deprecated. PTR_ERR_OR_ZERO should be used instead. However, we already know that IS_ERR is true, and thus PTR_ERR_OR_ZERO would never yield zero, so we can use PTR_ERR here. Signed-off-by: Christoph Jaeger Signed-off-by: Mark Brown --- sound/soc/soc-core.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 78f0c51c6c83..7f8efea5c5b1 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -2075,28 +2075,28 @@ static int snd_soc_ac97_parse_pinctl(struct device *dev, p = devm_pinctrl_get(dev); if (IS_ERR(p)) { dev_err(dev, "Failed to get pinctrl\n"); - return PTR_RET(p); + return PTR_ERR(p); } cfg->pctl = p; state = pinctrl_lookup_state(p, "ac97-reset"); if (IS_ERR(state)) { dev_err(dev, "Can't find pinctrl state ac97-reset\n"); - return PTR_RET(state); + return PTR_ERR(state); } cfg->pstate_reset = state; state = pinctrl_lookup_state(p, "ac97-warm-reset"); if (IS_ERR(state)) { dev_err(dev, "Can't find pinctrl state ac97-warm-reset\n"); - return PTR_RET(state); + return PTR_ERR(state); } cfg->pstate_warm_reset = state; state = pinctrl_lookup_state(p, "ac97-running"); if (IS_ERR(state)) { dev_err(dev, "Can't find pinctrl state ac97-running\n"); - return PTR_RET(state); + return PTR_ERR(state); } cfg->pstate_run = state; -- cgit v1.2.3 From 5957ae1fdc50de61d08735d7132ae4f70ae357f7 Mon Sep 17 00:00:00 2001 From: Axel Lin Date: Tue, 15 Apr 2014 19:55:35 +0800 Subject: regulator: tps65217: Use regulator_map_voltage_ascend for LDO1 The voltages in LDO1_VSEL_table are in ascendant order, so use regulator_map_voltage_ascend. Signed-off-by: Axel Lin Signed-off-by: Mark Brown --- drivers/regulator/tps65217-regulator.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/regulator/tps65217-regulator.c b/drivers/regulator/tps65217-regulator.c index 8482f6ba08a1..f7ed20a5a8b9 100644 --- a/drivers/regulator/tps65217-regulator.c +++ b/drivers/regulator/tps65217-regulator.c @@ -134,6 +134,7 @@ static struct regulator_ops tps65217_pmic_ldo1_ops = { .get_voltage_sel = regulator_get_voltage_sel_regmap, .set_voltage_sel = tps65217_pmic_set_voltage_sel, .list_voltage = regulator_list_voltage_table, + .map_voltage = regulator_map_voltage_ascend, }; static const struct regulator_desc regulators[] = { -- cgit v1.2.3 From 8931bf6208776292b1b888dd8534229f63e2eaa2 Mon Sep 17 00:00:00 2001 From: Peter Ujfalusi Date: Wed, 16 Apr 2014 15:46:11 +0300 Subject: ASoC: Add resource managed snd_soc_register_platform() Simplify error handling and remove repetitive (and rarely executed) code for unregistration by providing a devm_snd_soc_register_platform() platform. Signed-off-by: Peter Ujfalusi Signed-off-by: Mark Brown --- include/sound/soc.h | 2 ++ sound/soc/soc-devres.c | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/include/sound/soc.h b/include/sound/soc.h index 0b83168d8ff4..34c34d6e095c 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h @@ -377,6 +377,8 @@ int snd_soc_resume(struct device *dev); int snd_soc_poweroff(struct device *dev); int snd_soc_register_platform(struct device *dev, const struct snd_soc_platform_driver *platform_drv); +int devm_snd_soc_register_platform(struct device *dev, + const struct snd_soc_platform_driver *platform_drv); void snd_soc_unregister_platform(struct device *dev); int snd_soc_add_platform(struct device *dev, struct snd_soc_platform *platform, const struct snd_soc_platform_driver *platform_drv); diff --git a/sound/soc/soc-devres.c b/sound/soc/soc-devres.c index 7ac745df1412..e94aa0277250 100644 --- a/sound/soc/soc-devres.c +++ b/sound/soc/soc-devres.c @@ -52,6 +52,40 @@ int devm_snd_soc_register_component(struct device *dev, } EXPORT_SYMBOL_GPL(devm_snd_soc_register_component); +static void devm_platform_release(struct device *dev, void *res) +{ + snd_soc_unregister_platform(*(struct device **)res); +} + +/** + * devm_snd_soc_register_platform - resource managed platform registration + * @dev: Device used to manage platform + * @platform: platform to register + * + * Register a platform driver with automatic unregistration when the device is + * unregistered. + */ +int devm_snd_soc_register_platform(struct device *dev, + const struct snd_soc_platform_driver *platform_drv) +{ + struct device **ptr; + int ret; + + ptr = devres_alloc(devm_platform_release, sizeof(*ptr), GFP_KERNEL); + if (!ptr) + return -ENOMEM; + + ret = snd_soc_register_platform(dev, platform_drv); + if (ret == 0) { + *ptr = dev; + devres_add(dev, ptr); + } else { + devres_free(ptr); + } + + return ret; +} + static void devm_card_release(struct device *dev, void *res) { snd_soc_unregister_card(*(struct snd_soc_card **)res); -- cgit v1.2.3 From f6563b31fb4878fddc846d2012bcee9c5f260d11 Mon Sep 17 00:00:00 2001 From: Peter Ujfalusi Date: Wed, 16 Apr 2014 15:46:13 +0300 Subject: ASoC: omap-mcpdm: Assign the dai DMA data at earlier time Assign the dai dma data at dai driver probe time, not in startup. Signed-off-by: Peter Ujfalusi Signed-off-by: Mark Brown --- sound/soc/omap/omap-mcpdm.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/sound/soc/omap/omap-mcpdm.c b/sound/soc/omap/omap-mcpdm.c index 2f5b1536477e..e984b0485e92 100644 --- a/sound/soc/omap/omap-mcpdm.c +++ b/sound/soc/omap/omap-mcpdm.c @@ -265,9 +265,6 @@ static int omap_mcpdm_dai_startup(struct snd_pcm_substream *substream, } mutex_unlock(&mcpdm->mutex); - snd_soc_dai_set_dma_data(dai, substream, - &mcpdm->dma_data[substream->stream]); - return 0; } @@ -406,6 +403,11 @@ static int omap_mcpdm_probe(struct snd_soc_dai *dai) mcpdm->config[SNDRV_PCM_STREAM_PLAYBACK].threshold = 2; mcpdm->config[SNDRV_PCM_STREAM_CAPTURE].threshold = MCPDM_UP_THRES_MAX - 3; + + snd_soc_dai_init_dma_data(dai, + &mcpdm->dma_data[SNDRV_PCM_STREAM_PLAYBACK], + &mcpdm->dma_data[SNDRV_PCM_STREAM_CAPTURE]); + return ret; } -- cgit v1.2.3 From 335b06515eda252b36aa9063596f740a903c1e35 Mon Sep 17 00:00:00 2001 From: Peter Ujfalusi Date: Wed, 16 Apr 2014 15:46:14 +0300 Subject: ASoC: omap-mcpdm: Bind the platform driver to the dai driver when loading Use the same device for the platform driver when registering as the dai driver. This will enable us to clean up some DT booted cases. Signed-off-by: Peter Ujfalusi Signed-off-by: Mark Brown --- sound/soc/omap/omap-mcpdm.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/sound/soc/omap/omap-mcpdm.c b/sound/soc/omap/omap-mcpdm.c index e984b0485e92..d8ebb52645a9 100644 --- a/sound/soc/omap/omap-mcpdm.c +++ b/sound/soc/omap/omap-mcpdm.c @@ -42,6 +42,7 @@ #include #include "omap-mcpdm.h" +#include "omap-pcm.h" struct mcpdm_link_config { u32 link_mask; /* channel mask for the direction */ @@ -462,6 +463,7 @@ static int asoc_mcpdm_probe(struct platform_device *pdev) { struct omap_mcpdm *mcpdm; struct resource *res; + int ret; mcpdm = devm_kzalloc(&pdev->dev, sizeof(struct omap_mcpdm), GFP_KERNEL); if (!mcpdm) @@ -492,9 +494,13 @@ static int asoc_mcpdm_probe(struct platform_device *pdev) mcpdm->dev = &pdev->dev; - return devm_snd_soc_register_component(&pdev->dev, + ret = devm_snd_soc_register_component(&pdev->dev, &omap_mcpdm_component, &omap_mcpdm_dai, 1); + if (ret) + return ret; + + return omap_pcm_platform_register(&pdev->dev); } static const struct of_device_id omap_mcpdm_of_match[] = { -- cgit v1.2.3 From 3fe856b3127744ce30d4369ba760459b6ac9f820 Mon Sep 17 00:00:00 2001 From: Peter Ujfalusi Date: Wed, 16 Apr 2014 15:46:15 +0300 Subject: ASoC: omap-mcbsp: Assign the dai DMA data at earlier time Assign the dai dma data at dai driver probe time, not in startup. Signed-off-by: Peter Ujfalusi Signed-off-by: Mark Brown --- sound/soc/omap/omap-mcbsp.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/sound/soc/omap/omap-mcbsp.c b/sound/soc/omap/omap-mcbsp.c index 6c19bba23570..4525190d5599 100644 --- a/sound/soc/omap/omap-mcbsp.c +++ b/sound/soc/omap/omap-mcbsp.c @@ -149,9 +149,6 @@ static int omap_mcbsp_dai_startup(struct snd_pcm_substream *substream, SNDRV_PCM_HW_PARAM_PERIOD_SIZE, 2); } - snd_soc_dai_set_dma_data(cpu_dai, substream, - &mcbsp->dma_data[substream->stream]); - return err; } @@ -559,6 +556,10 @@ static int omap_mcbsp_probe(struct snd_soc_dai *dai) pm_runtime_enable(mcbsp->dev); + snd_soc_dai_init_dma_data(dai, + &mcbsp->dma_data[SNDRV_PCM_STREAM_PLAYBACK], + &mcbsp->dma_data[SNDRV_PCM_STREAM_CAPTURE]); + return 0; } -- cgit v1.2.3 From 64241425b8eaf46c971b6ba400c21f71979e6782 Mon Sep 17 00:00:00 2001 From: Peter Ujfalusi Date: Wed, 16 Apr 2014 15:46:16 +0300 Subject: ASoC: omap-mcbsp: Bind the platform driver to the dai driver when loading Use the same device for the platform driver when registering as the dai driver. This will enable us to clean up some DT booted cases. Signed-off-by: Peter Ujfalusi Signed-off-by: Mark Brown --- sound/soc/omap/omap-mcbsp.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/sound/soc/omap/omap-mcbsp.c b/sound/soc/omap/omap-mcbsp.c index 4525190d5599..af2764adf252 100644 --- a/sound/soc/omap/omap-mcbsp.c +++ b/sound/soc/omap/omap-mcbsp.c @@ -38,6 +38,7 @@ #include #include "mcbsp.h" #include "omap-mcbsp.h" +#include "omap-pcm.h" #define OMAP_MCBSP_RATES (SNDRV_PCM_RATE_8000_96000) @@ -800,11 +801,15 @@ static int asoc_mcbsp_probe(struct platform_device *pdev) platform_set_drvdata(pdev, mcbsp); ret = omap_mcbsp_init(pdev); - if (!ret) - return snd_soc_register_component(&pdev->dev, &omap_mcbsp_component, - &omap_mcbsp_dai, 1); + if (ret) + return ret; - return ret; + ret = snd_soc_register_component(&pdev->dev, &omap_mcbsp_component, + &omap_mcbsp_dai, 1); + if (ret) + return ret; + + return omap_pcm_platform_register(&pdev->dev); } static int asoc_mcbsp_remove(struct platform_device *pdev) -- cgit v1.2.3 From fe7b5868809a89a7316eef064f0bb7796aa8c225 Mon Sep 17 00:00:00 2001 From: Peter Ujfalusi Date: Wed, 16 Apr 2014 15:46:12 +0300 Subject: ASoC: omap-pcm: Support for binding the platform driver to dai devices With the new calls it is going to be possible to bind the platform driver to a dai device which makes it easier for us in a long run to handle DT boots, and opens the possibility to move machine driver to generic simple card. Signed-off-by: Peter Ujfalusi Signed-off-by: Mark Brown --- sound/soc/omap/omap-pcm.c | 6 ++++++ sound/soc/omap/omap-pcm.h | 30 ++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 sound/soc/omap/omap-pcm.h diff --git a/sound/soc/omap/omap-pcm.c b/sound/soc/omap/omap-pcm.c index 07b8b7bc9d20..c3711b582d5f 100644 --- a/sound/soc/omap/omap-pcm.c +++ b/sound/soc/omap/omap-pcm.c @@ -232,6 +232,12 @@ static struct snd_soc_platform_driver omap_soc_platform = { .pcm_free = omap_pcm_free_dma_buffers, }; +int omap_pcm_platform_register(struct device *dev) +{ + return devm_snd_soc_register_platform(dev, &omap_soc_platform); +} +EXPORT_SYMBOL_GPL(omap_pcm_platform_register); + static int omap_pcm_probe(struct platform_device *pdev) { return snd_soc_register_platform(&pdev->dev, diff --git a/sound/soc/omap/omap-pcm.h b/sound/soc/omap/omap-pcm.h new file mode 100644 index 000000000000..c1d2f31d71e9 --- /dev/null +++ b/sound/soc/omap/omap-pcm.h @@ -0,0 +1,30 @@ +/* + * omap-pcm.h - OMAP PCM driver + * + * Copyright (C) 2014 Texas Instruments, Inc. + * + * Author: Peter Ujfalusi + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + */ + +#ifndef __OMAP_PCM_H__ +#define __OMAP_PCM_H__ + +#if IS_ENABLED(CONFIG_SND_OMAP_SOC) +int omap_pcm_platform_register(struct device *dev); +#else +static inline int omap_pcm_platform_register(struct device *dev) +{ + return 0; +} +#endif /* CONFIG_SND_OMAP_SOC */ + +#endif /* __OMAP_PCM_H__ */ -- cgit v1.2.3 From 3802a259272e48870b8d7e02c4fc28f938a699cb Mon Sep 17 00:00:00 2001 From: Peter Ujfalusi Date: Wed, 16 Apr 2014 15:46:17 +0300 Subject: ASoC: omap-dmic: Assign the dai DMA data at earlier time Assign the dai dma data at dai driver probe time, not in startup. Signed-off-by: Peter Ujfalusi Signed-off-by: Mark Brown --- sound/soc/omap/omap-dmic.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sound/soc/omap/omap-dmic.c b/sound/soc/omap/omap-dmic.c index 1bd531d718f9..7fb7703264fa 100644 --- a/sound/soc/omap/omap-dmic.c +++ b/sound/soc/omap/omap-dmic.c @@ -113,7 +113,6 @@ static int omap_dmic_dai_startup(struct snd_pcm_substream *substream, mutex_unlock(&dmic->mutex); - snd_soc_dai_set_dma_data(dai, substream, &dmic->dma_data); return ret; } @@ -417,6 +416,9 @@ static int omap_dmic_probe(struct snd_soc_dai *dai) /* Configure DMIC threshold value */ dmic->threshold = OMAP_DMIC_THRES_MAX - 3; + + snd_soc_dai_init_dma_data(dai, NULL, &dmic->dma_data); + return 0; } -- cgit v1.2.3 From 18d7cfea28fe7e06047abef40a18db2643a427be Mon Sep 17 00:00:00 2001 From: Peter Ujfalusi Date: Wed, 16 Apr 2014 15:46:18 +0300 Subject: ASoC: omap-dmic: Bind the platform driver to the dai driver when loading Use the same device for the platform driver when registering as the dai driver. This will enable us to clean up some DT booted cases. Signed-off-by: Peter Ujfalusi Signed-off-by: Mark Brown --- sound/soc/omap/omap-dmic.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/sound/soc/omap/omap-dmic.c b/sound/soc/omap/omap-dmic.c index 7fb7703264fa..53da041896c4 100644 --- a/sound/soc/omap/omap-dmic.c +++ b/sound/soc/omap/omap-dmic.c @@ -42,6 +42,7 @@ #include #include "omap-dmic.h" +#include "omap-pcm.h" struct omap_dmic { struct device *dev; @@ -494,6 +495,10 @@ static int asoc_dmic_probe(struct platform_device *pdev) if (ret) goto err_put_clk; + ret = omap_pcm_platform_register(&pdev->dev); + if (ret) + goto err_put_clk; + return 0; err_put_clk: -- cgit v1.2.3 From 9769824cf9ca4bb877146dbec2695bdbf577c499 Mon Sep 17 00:00:00 2001 From: Peter Ujfalusi Date: Wed, 16 Apr 2014 15:46:19 +0300 Subject: ASoC: omap-hdmi: Bind the platform driver to the dai driver when loading Use the same device for the platform driver when registering as the dai driver. This will enable us to clean up some DT booted cases. Signed-off-by: Peter Ujfalusi Signed-off-by: Mark Brown --- sound/soc/omap/omap-hdmi.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/sound/soc/omap/omap-hdmi.c b/sound/soc/omap/omap-hdmi.c index ced3b88b44d4..32614b49653c 100644 --- a/sound/soc/omap/omap-hdmi.c +++ b/sound/soc/omap/omap-hdmi.c @@ -36,6 +36,7 @@ #include